From 4d0c83b84594763e1f14cc5814bd147e36f249fd Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 8 Sep 2015 10:47:22 +0200 Subject: Fixed a failed assertion in skill_get_ele. Fixes #708 - Thanks to AnisotropicDefixation Signed-off-by: Haru --- src/map/battle.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'src/map/battle.c') diff --git a/src/map/battle.c b/src/map/battle.c index 671d63200..6536e54c4 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3251,24 +3251,27 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if (skill_id) mob->skill_event((TBL_MOB*)bl,src,timer->gettick(),MSC_SKILLUSED|(skill_id<<16)); } - if( sd ) { - if( pc_ismadogear(sd) && rnd()%100 < 50 ) { - short element = skill->get_ele(skill_id, skill_lv); - if( !skill_id || element == -1 ) { //Take weapon's element - struct status_data *sstatus = NULL; - if( src->type == BL_PC && ((TBL_PC*)src)->bonus.arrow_ele ) - element = ((TBL_PC*)src)->bonus.arrow_ele; - else if( (sstatus = status->get_status_data(src)) ) { - element = sstatus->rhw.ele; - } + if (sd && pc_ismadogear(sd) && rnd()%100 < 50) { + int element = -1; + if (!skill_id || (element = skill->get_ele(skill_id, skill_lv)) == -1) { + // Take weapon's element + struct status_data *sstatus = NULL; + if (src->type == BL_PC && ((TBL_PC*)src)->bonus.arrow_ele) { + element = ((TBL_PC*)src)->bonus.arrow_ele; + } else if ((sstatus = status->get_status_data(src)) != NULL) { + element = sstatus->rhw.ele; } - else if( element == -2 ) //Use enchantment's element - element = status_get_attack_sc_element(src,status->get_sc(src)); - else if( element == -3 ) //Use random element - element = rnd()%ELE_MAX; - if( element == ELE_FIRE || element == ELE_WATER ) - pc->overheat(sd,element == ELE_FIRE ? 1 : -1); - } + } else if (element == -2) { + // Use enchantment's element + element = status_get_attack_sc_element(src,status->get_sc(src)); + } else if (element == -3) { + // Use random element + element = rnd()%ELE_MAX; + } + if (element == ELE_FIRE) + pc->overheat(sd, 1); + else if (element == ELE_WATER) + pc->overheat(sd, -1); } return damage; -- cgit v1.2.3-70-g09d2