Skip to content

Commit

Permalink
Fixed WALKDELAY_SYNC not applying walkdelay in some circumstances
Browse files Browse the repository at this point in the history
  • Loading branch information
csnv committed Jun 1, 2024
1 parent 0a870fa commit 8da935b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
30 changes: 20 additions & 10 deletions src/map/battle.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ static int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data)
&& (target->m == src->m && check_distance_bl(src, target, dat->distance)))
)) {
map->freeblock_lock();
#ifdef WALKDELAY_SYNC
status_fix_damage(src, target, dat->damage, 0);
#else
status_fix_damage(src, target, dat->damage, dat->delay);
#endif
if (dat->attack_type && !status->isdead(target) && dat->additional_effects)
skill->additional_effect(src,target,dat->skill_id,dat->skill_lv,dat->attack_type,dat->dmg_lv,tick);
if (dat->dmg_lv > ATK_BLOCK && dat->attack_type)
Expand All @@ -284,7 +288,11 @@ static int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data)
} else if (src == NULL && dat->skill_id == CR_REFLECTSHIELD) {
// it was monster reflected damage, and the monster died, we pass the damage to the character as expected
map->freeblock_lock();
#ifdef WALKDELAY_SYNC
status_fix_damage(target, target, dat->damage, 0);
#else
status_fix_damage(target, target, dat->damage, dat->delay);
#endif
map->freeblock_unlock();
}
}
Expand Down Expand Up @@ -321,16 +329,6 @@ static int battle_delay_damage(int64 tick, int amotion, struct block_list *src,
if (((d_tbl && sc && check_distance_bl(target, d_tbl, sc->data[SC_DEVOTION]->val3)) || e_tbl) && damage > 0 && skill_id != PA_PRESSURE && skill_id != CR_REFLECTSHIELD)
damage = 0;

#ifdef WALKDELAY_SYNC
int delay = amotion;
int mob_delay;

if (src->type == BL_MOB && (mob_delay = BL_UCCAST(BL_MOB, src)->status.ddelay) > 0)
delay = skill_id == 0 ? mob_delay : 0; // Skills have 0 delay?

if (damage > 0)
timer->add(timer->gettick() + delay, unit->set_walkdelay_timer, target->id, MakeDWord(ddelay, skill_id != 0));
#endif

if ( !battle_config.delay_battle_damage || amotion <= 1 ) {
map->freeblock_lock();
Expand Down Expand Up @@ -360,6 +358,18 @@ static int battle_delay_damage(int64 tick, int amotion, struct block_list *src,
if (src->type == BL_PC) {
BL_UCAST(BL_PC, src)->delayed_damage++;
}

#ifdef WALKDELAY_SYNC
int walkdelay_latency = amotion;
int mob_delay;

if (src->type == BL_MOB && (mob_delay = BL_UCCAST(BL_MOB, src)->status.ddelay) > 0)
walkdelay_latency = skill_id == 0 ? mob_delay : 0; // Skills have 0 delay?

if (damage > 0)
timer->add(timer->gettick() + walkdelay_latency, unit->set_walkdelay_timer, target->id, MakeDWord(ddelay, skill_id != 0));
#endif

timer->add(tick + amotion, battle->delay_damage_sub, 0, (intptr_t)dat);

return 0;
Expand Down
2 changes: 0 additions & 2 deletions src/map/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,8 @@ static int status_damage(struct block_list *src, struct block_list *target, int6

if (st->hp || (flag&8)) {
//Still lives or has been dead before this damage.
#ifndef WALKDELAY_SYNC
if (walkdelay)
unit->set_walkdelay(target, timer->gettick(), walkdelay, 0);
#endif
return (int)(hp+sp);
}

Expand Down

0 comments on commit 8da935b

Please sign in to comment.