summaryrefslogtreecommitdiff
path: root/world
diff options
context:
space:
mode:
authorHello=) <hello@themanaworld.org>2024-06-19 07:47:06 +0300
committerHello TMW <hello@themanaworld.org>2024-06-19 04:58:18 +0000
commitc7fd672bd4bab84f940f0b356ebc6a94115905b0 (patch)
tree50c6288a465e646f6737ac9709a4019c7fccd12c /world
parent4b5d0f318e5a9f29326866b8d6d41d212c0e8fe7 (diff)
downloadserverdata-c7fd672bd4bab84f940f0b356ebc6a94115905b0.tar.gz
serverdata-c7fd672bd4bab84f940f0b356ebc6a94115905b0.tar.bz2
serverdata-c7fd672bd4bab84f940f0b356ebc6a94115905b0.tar.xz
serverdata-c7fd672bd4bab84f940f0b356ebc6a94115905b0.zip
Fix for repeated suicides of caster when they try to attack target after they
killed in rain by own lightning. Problem technically can be described like this: 1) Caster retains all spell charges upon death for lightnings. 2) It wouldn't be problem itself, but it would invoke OnAttack handler! 3) If caster dies in rain by own lightning, nothing clears "in rain" flag. 4) When they respawn and try to attack, OnAttack kicks in. 5) Since nothing has cleaned "in rain" flag, its still set. 6) At this point caster dies by own lightning again. 7) Worse, on respawn sequence would repeat itself. This happens regardless of rain and is very unexpected edge case. Workaround: caster can use #dicharge spell after respawn but its unobvious.
Diffstat (limited to 'world')
-rw-r--r--world/map/npc/functions/global_event_handler.txt1
-rw-r--r--world/map/npc/magic/level2-lightning-strike.txt4
2 files changed, 3 insertions, 2 deletions
diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt
index 915423e8..d169f3c7 100644
--- a/world/map/npc/functions/global_event_handler.txt
+++ b/world/map/npc/functions/global_event_handler.txt
@@ -37,6 +37,7 @@ OnMobKillEvent:
OnPCDieEvent:
set @necromancer, 0;
addtimer 0, "Magic Timer::OnClear"; // reset magic block on death
+ addtimer 0, "::OnDischarge"; // seeks OnDischarge in ALL npcs (discharge chargeable spells on PC death)
callfunc "SpawnGhost";
callfunc "MiriamExpire"; // force the speed skill quest to expire
set @killerrid, 0; // reset killer rid
diff --git a/world/map/npc/magic/level2-lightning-strike.txt b/world/map/npc/magic/level2-lightning-strike.txt
index bdd311a6..0a97dc63 100644
--- a/world/map/npc/magic/level2-lightning-strike.txt
+++ b/world/map/npc/magic/level2-lightning-strike.txt
@@ -30,12 +30,11 @@
OnAttack:
if (target(BL_ID, @target_id, 0x36) != 0x36) goto L_FreeRecast; // 0x10 | 0x02 | 0x04 | 0x20
-
set .@p, get(.max_radius, "rain") + 1;
set @ingravspell[5], @target_id; // store it because foreach overwrites it
foreach 1, getmap(), POS_X-.@p, POS_Y-.@p, POS_X+.@p, POS_Y+.@p, strnpcinfo(0)+"::OnNpc";
set @target_id, @ingravspell[5]; // now restore it
-
+ if (@ingravspell[2] <= 0) overrideattack; // workaround for caster in rain death case
set @ingravspell[2], @ingravspell[2] - 1;
if (@ingravspell[4] & 1) goto L_InRain;
void call("elt_damage", @ingravspell[0], (@ingravspell[0]/2)+1, ELT_EARTH, ELT_WIND, FX_LIGHTNING1 + rand(3));
@@ -49,6 +48,7 @@ L_FreeRecast:
OnDischarge:
if (@ingravspell[2] < 1) end;
set @ingravspell[2], 0;
+ set @ingravspell[4], 0; // Clean up "in rain" flag, it caused funny bugs.
misceffect FX_MAGIC_DISCHARGE, strcharinfo(0);
overrideattack;
end;