Issue information

Issue ID
#5303
Status
Fixed
Severity
Fair
Started
Hercules Elf Bot
Feb 7, 2012 20:56
Last Post
Mysterious
Jan 27, 2013 17:02
Confirmation
N/A

Hercules Elf Bot - Feb 7, 2012 20:56

Originally posted by [b]Wildcard[/b]
[b][u]Synopsis[/u][/b]

The wizard skill WZ_WATERBALL, when used in conjuncture with SC_MAGICPOWER (better known as Amplify Magic), will not consume the status effect if it kills the target before the last hit, and can be cast additional times with the benefits of SC_MAGICPOWER until the status timer expires.

[b][u]Reconstruction[/u][/b]

The breakage results from a now false assumption in skill_timerskill. The code assumes that the killing blow to the target will take place within the call to skill_attack. However, skill_attack will in turn evoke battle_delay_damage on any non-aoe skill, thus resulting in [i]no actual damage[/i] at the time. The code will thus continue by queueing the next timerskill call. Between the two calls of skill_timerskill, battle_delay_damage_sub will deal the killing blow to the target. The subsequent waterball timer will thus look up a target ID that has already been killed, and exit at the target == NULL check before ever ending the status as originally intended.

[u][b]History[/b][/u]

The issue affects both eAthena and rAthena.

A fix for the exact same issue was introduced by Skotlex in [url="http://sourceforge.net/apps/trac/rathena/changeset/5601"]r5601[/url]. It is crucial to understand that back then magic damage was *not delayed by amotion*, but instead dealt instantly.

[code]
in skill_attack(...)

if (attack_type&BF_WEAPON)
battle_delay_damage(tick+dmg.amotion,bl,src,0,0,0,rdamage,ATK_DEF,0);
else
battle_damage(bl,src,rdamage,0);
[/code]

In [url="http://sourceforge.net/apps/trac/rathena/changeset/6346"]r6346[/url], Skotlex introducing amotion delay for skills, thus breaking his own assumption about waterball damage. This persists up until today.

[code]
if (dmg.amotion)
battle_delay_damage(tick, dmg.amotion,src,bl,dmg.flag,skillid,skilllv,damage,dmg.dmg_lv,dmg.dmotion);
[/code]

[u][b]Proposed Solution[/b][/u]

The original fix remains valid for the scenario of waterball not killing the target. It needs to be replicated, however, should the target indeed die of it. The function most suitable for this cleanup appears to be skill_counter_additional_effect. I have provided a patch with my suggested solution as an attachment.
[attachment=829:wb+mp.patch]

[b][u]Additional Concerns[/u][/b]

With the recent introduction of magic reflect, and associated problems with the waterball skill, it stands to reason that special scenarios involving reflect might exist wherein the status would also not be canceled. Since the scenario covered in a [url="http://sourceforge.net/apps/trac/rathena/changeset/15526"]recent revision[/url] however specifically addresses the damage source (in this case the caster) dying, however, I suspect that status cleanup on death should already handle this particular happenstance. I did not, however, investigate the issue of reflection at all.

Another interesting observation is that the reflection issue only ever presented itself due to the fact that reflect damage is applied directly via battle_calc_attack rather than queueing it via amotion, which is how the crash fixed in [url="http://sourceforge.net/apps/trac/rathena/changeset/15526"]r15526[/url] even got past the initial check against a dead source at the very top of skill_timerskill. Heh.

I hope I could be of help! Regards,

Wildcard

Hercules Elf Bot - Feb 8, 2012 6:48

Originally posted by [b]Xantara[/b]
I like how organized and detailed this report is xD

Dev note: More info (and somewhat a duplicate of) [bug=1249]

This post has been edited by Xantara on Feb 8, 2012 6:50

Hercules Elf Bot - Feb 8, 2012 9:13

Originally posted by [b]Wildcard[/b]
Apologies for the duplicate, I completely missed that bug when searching for related issues. My bad!

Hercules Elf Bot - Feb 8, 2012 22:31

Originally posted by [b]Ind[/b]
I've made the other the duplicate being yours is much more detailed (thank you).

Hercules Elf Bot - Feb 8, 2012 23:17

Originally posted by [b]Ind[/b]
fixed in [rev=15548]. thank you for your fix