From c7fd672bd4bab84f940f0b356ebc6a94115905b0 Mon Sep 17 00:00:00 2001 From: "Hello=)" Date: Wed, 19 Jun 2024 07:47:06 +0300 Subject: 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. --- world/map/npc/functions/global_event_handler.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'world/map/npc/functions/global_event_handler.txt') 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 -- cgit v1.2.3-70-g09d2 From 9bf6516e56f3c54cc10ccc6d7f051a81329e62dd Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Sat, 22 Jun 2024 17:16:43 +0200 Subject: upmarmu v6 full --- world/map/npc/functions/global_event_handler.txt | 2 +- world/map/npc/magic/level2-magic-knuckles.txt | 42 +++++++++++++----------- 2 files changed, 23 insertions(+), 21 deletions(-) (limited to 'world/map/npc/functions/global_event_handler.txt') diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt index d169f3c7..ef93435c 100644 --- a/world/map/npc/functions/global_event_handler.txt +++ b/world/map/npc/functions/global_event_handler.txt @@ -45,7 +45,7 @@ OnPCDieEvent: end; OnPCLogoutEvent: -// if (getnpcid("#Upmarmu#" + getcharid(3)) >= 1) addnpctimer 0, "#Upmarmu#" + getcharid(3) + "::OnDestroy"; // @upmarmu_spell_npc_name$ is already lost at this point so it must be done like this + if (getnpcid("#Upmarmu#" + getcharid(0)) >= 1) addnpctimer 0, "#Upmarmu#" + getcharid(0) + "::OnDestroy"; // @upmarmu_spell_npc_name$ is already lost at this point so it must be done like this callfunc "VaultLogout"; end; diff --git a/world/map/npc/magic/level2-magic-knuckles.txt b/world/map/npc/magic/level2-magic-knuckles.txt index a67941cf..d752aa11 100644 --- a/world/map/npc/magic/level2-magic-knuckles.txt +++ b/world/map/npc/magic/level2-magic-knuckles.txt @@ -1,18 +1,17 @@ -|script|magic-knuckles|32767 { if @_U_BLOCK >= 1 goto L_Still_Exhausted; -/* - set @upmarmu_spell_npc_name$, "#Upmarmu#" + getcharid(3); // make a unique puppet name for every player + + set @upmarmu_spell_npc_name$, "#Upmarmu#" + getcharid(0); // make a unique puppet name for every player set .upmarmu_spell_npc, getnpcid(@upmarmu_spell_npc_name$); if ( .upmarmu_spell_npc >= 1 ) goto L_NPC_Exists; // if this npc already exist reuse it so that idle recovery timer does not get destroyed set .upmarmu_spell_npc, puppet(getmap(), 0, 0, @upmarmu_spell_npc_name$, 127); // clone npc => get puppet id (npc 127 is invisible and can't be targeted) if (.upmarmu_spell_npc < 1) end; - set .caster, getcharid(3), .upmarmu_spell_npc; // tell the puppet who controls it + set .caster, getcharid(0), .upmarmu_spell_npc; // tell the puppet who controls it goto L_NPC_Exists; L_NPC_Exists: -*/ if (call("magic_checks")) end; if (Sp < 20) end; if (getskilllv(SKILL_MAGIC) < .level) end; @@ -49,35 +48,29 @@ OnAttack: if (target(BL_ID, @target_id, 22) != 22) goto L_FreeRecast; // 0x10 | 0x02 | 0x04 void call("elt_damage", @upmarmuspell[0], (@upmarmuspell[3] + @upmarmuspell[4]), ELT_WATER, ELT_FIRE, FX_NONE); -// addtimer 0, @upmarmu_spell_npc_name$ + "::OnResetTimer"; + addtimer 0, @upmarmu_spell_npc_name$ + "::OnResetTimer"; set @upmarmuspell[1], @upmarmuspell[1] - 1; + + if @num_upmarmu_hits >= UPMARMU_HITS_TILL_EXHAUST goto L_FreeRecast; set @num_upmarmu_hits, @num_upmarmu_hits + 1; + if @num_upmarmu_hits >= UPMARMU_HITS_TILL_EXHAUST set .exhausted, 1, .upmarmu_spell_npc; - if @num_upmarmu_hits >= UPMARMU_HITS_TILL_EXHAUST goto L_Exhausted; goto L_FreeRecast; L_FreeRecast: if (@upmarmuspell[1] > 0) addtimer 0, strnpcinfo(0) + "::OnSetRecast"; + else + addtimer 0, @upmarmu_spell_npc_name$ + "::OnExhausted"; end; -L_Exhausted: - set @_U_BLOCK, 1; - set @upmarmuspell[1], 0; - misceffect FX_MAGIC_DISCHARGE, strcharinfo(0); - overrideattack; - addtimer UPMARMU_EXHAUST_DURATION, "Upmarmu Exhaust Timer::OnClear"; // set the exhaustion time - sc_start SC_COOLDOWN_UPMARMU, UPMARMU_EXHAUST_DURATION, 0, BL_ID; - smsg SMSG_FAILURE, "Magic: You are too exhausted to use this spell for a while!"; - goto L_StopTimer; - L_Still_Exhausted: smsg SMSG_FAILURE, "Magic: You are still too exhausted to use this spell for a while!"; end; L_StopTimer: -// addtimer 0, @upmarmu_spell_npc_name$ + "::OnStopTimer"; + addtimer 0, @upmarmu_spell_npc_name$ + "::OnStopTimer"; end; OnDischarge: @@ -91,7 +84,6 @@ OnSetRecast: overrideattack (@upmarmuspell[2] * @upmarmuspell[2]), 1, ATTACK_ICON_GENERIC, OVERRIDE_KNUCKLES, strnpcinfo(0)+"::OnAttack", @upmarmuspell[1]; // delay needs to be squared end; -/* OnResetTimer: // This timer is if you stopped somewhere below max hits then after 25sec you recover fully and start at 0 hits again stopnpctimer; @@ -117,9 +109,20 @@ OnTimer25000: setnpctimer 0; end; +OnExhausted: + if (.exhausted < 1) end; + + set @_U_BLOCK, 1; + set @upmarmuspell[1], 0; + set @num_upmarmu_hits, 0; + set .exhausted, 0; + addtimer UPMARMU_EXHAUST_DURATION, "Upmarmu Exhaust Timer::OnClear"; // set the exhaustion time + sc_start SC_COOLDOWN_UPMARMU, UPMARMU_EXHAUST_DURATION, 0, BL_ID; + smsg SMSG_FAILURE, "Magic: You are too exhausted to use this spell for a while!"; + goto L_StopTimer; + OnDestroy: destroy; -*/ OnInit: set .school, SKILL_MAGIC_WAR; @@ -136,6 +139,5 @@ OnInit: OnClear: set @_U_BLOCK, 0; - set @num_upmarmu_hits, 0; end; } -- cgit v1.2.3-70-g09d2 From a5a76a68000fa0cce711c9a1502f0ac57aecc58b Mon Sep 17 00:00:00 2001 From: HoraK-FDF Date: Mon, 24 Jun 2024 16:14:20 +0200 Subject: attachrid only supports acc id (getcharid(3)) --- world/map/npc/functions/global_event_handler.txt | 2 +- world/map/npc/magic/level2-magic-knuckles.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'world/map/npc/functions/global_event_handler.txt') diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt index ef93435c..5274fa05 100644 --- a/world/map/npc/functions/global_event_handler.txt +++ b/world/map/npc/functions/global_event_handler.txt @@ -45,7 +45,7 @@ OnPCDieEvent: end; OnPCLogoutEvent: - if (getnpcid("#Upmarmu#" + getcharid(0)) >= 1) addnpctimer 0, "#Upmarmu#" + getcharid(0) + "::OnDestroy"; // @upmarmu_spell_npc_name$ is already lost at this point so it must be done like this + if (getnpcid("#Upmarmu#" + getcharid(3)) >= 1) addnpctimer 0, "#Upmarmu#" + getcharid(3) + "::OnDestroy"; // @upmarmu_spell_npc_name$ is already lost at this point so it must be done like this callfunc "VaultLogout"; end; diff --git a/world/map/npc/magic/level2-magic-knuckles.txt b/world/map/npc/magic/level2-magic-knuckles.txt index d752aa11..92ee07a5 100644 --- a/world/map/npc/magic/level2-magic-knuckles.txt +++ b/world/map/npc/magic/level2-magic-knuckles.txt @@ -2,13 +2,13 @@ { if @_U_BLOCK >= 1 goto L_Still_Exhausted; - set @upmarmu_spell_npc_name$, "#Upmarmu#" + getcharid(0); // make a unique puppet name for every player + set @upmarmu_spell_npc_name$, "#Upmarmu#" + getcharid(3); // make a unique puppet name for every player set .upmarmu_spell_npc, getnpcid(@upmarmu_spell_npc_name$); if ( .upmarmu_spell_npc >= 1 ) goto L_NPC_Exists; // if this npc already exist reuse it so that idle recovery timer does not get destroyed set .upmarmu_spell_npc, puppet(getmap(), 0, 0, @upmarmu_spell_npc_name$, 127); // clone npc => get puppet id (npc 127 is invisible and can't be targeted) if (.upmarmu_spell_npc < 1) end; - set .caster, getcharid(0), .upmarmu_spell_npc; // tell the puppet who controls it + set .caster, getcharid(3), .upmarmu_spell_npc; // tell the puppet who controls it goto L_NPC_Exists; L_NPC_Exists: -- cgit v1.2.3-70-g09d2 From 43bf4d6d3b9252017a34e197ceea6f647a30c3de Mon Sep 17 00:00:00 2001 From: "Hello=)" Date: Sun, 14 Jul 2024 14:49:39 +0300 Subject: This commit lands workaround on MM weight problem. Naive approach using stats failed. But even more direct way works. This sets MaxWeight on MM login to 10 000 000 aka 10 000 kg aka 10 tons. I think 10 tons "should be enough for everyone". I've actually tested it works by heavily loading ManaMarket replica on local server with itens. --- world/map/npc/functions/global_event_handler.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'world/map/npc/functions/global_event_handler.txt') diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt index 5274fa05..6664da36 100644 --- a/world/map/npc/functions/global_event_handler.txt +++ b/world/map/npc/functions/global_event_handler.txt @@ -20,6 +20,7 @@ OnPCLoginEvent: callfunc "VaultLogin"; // Mirror Lake Protocol biddings callfunc "VaultLogout"; // Clean some stuff, to be safe // add more here + if (strcharinfo(0, BL_ID) == "ManaMarket") set MaxWeight, 10000000; // Let ManaMarket bot to carry 10 tons set @login_event, 2; end; -- cgit v1.2.3-70-g09d2 From 577d79a5f115636ee71bce69523229c04dd669a3 Mon Sep 17 00:00:00 2001 From: "Hello=)" Date: Tue, 16 Jul 2024 12:00:54 +0300 Subject: V2 of ManaMarket weight solution idea. Differences vs previous version: * Allows to set "arbitrary" weight limits (within i32). * Does NOT makes hardcoded assumptions on nick or weight. * Reusable for >1 trade bot if desired. * Acts a bit like ACL, most of it done by server itself. * Still oneliner :) Usage: @setvar WEIGHT_LIMIT 0 10000000 ManaMarket Since its per-character variable, user must be online. --- world/map/npc/functions/global_event_handler.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'world/map/npc/functions/global_event_handler.txt') diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt index 6664da36..b9e81e37 100644 --- a/world/map/npc/functions/global_event_handler.txt +++ b/world/map/npc/functions/global_event_handler.txt @@ -19,8 +19,8 @@ OnPCLoginEvent: callfunc "ConvertChristmas21"; // Christmas 2021 callfunc "VaultLogin"; // Mirror Lake Protocol biddings callfunc "VaultLogout"; // Clean some stuff, to be safe + if (WEIGHT_LIMIT) set MaxWeight, WEIGHT_LIMIT; // If this char var set, override max weight (tradebots, etc) // add more here - if (strcharinfo(0, BL_ID) == "ManaMarket") set MaxWeight, 10000000; // Let ManaMarket bot to carry 10 tons set @login_event, 2; end; -- cgit v1.2.3-70-g09d2 From 7e19113c28332724effcb3a93e0452129b639a9c Mon Sep 17 00:00:00 2001 From: "Hello=)" Date: Thu, 18 Jul 2024 19:08:03 +0300 Subject: v3 of idea: rewired to use some server-side assistance by HoraK --- world/map/npc/functions/global_event_handler.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'world/map/npc/functions/global_event_handler.txt') diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt index b9e81e37..b1c5917e 100644 --- a/world/map/npc/functions/global_event_handler.txt +++ b/world/map/npc/functions/global_event_handler.txt @@ -19,7 +19,7 @@ OnPCLoginEvent: callfunc "ConvertChristmas21"; // Christmas 2021 callfunc "VaultLogin"; // Mirror Lake Protocol biddings callfunc "VaultLogout"; // Clean some stuff, to be safe - if (WEIGHT_LIMIT) set MaxWeight, WEIGHT_LIMIT; // If this char var set, override max weight (tradebots, etc) + if (WEIGHT_LIMIT) set MaxWeightOverride, WEIGHT_LIMIT; // If this char var set, override max weight (tradebots, etc) // add more here set @login_event, 2; end; -- cgit v1.2.3-70-g09d2 From bab8a25d6d3a2a5f5173654c95d057c65a3fa4f6 Mon Sep 17 00:00:00 2001 From: "Hello=)" Date: Fri, 19 Jul 2024 04:03:41 +0300 Subject: V4 - rename weight override char var to HoraK's suggestion --- world/map/npc/functions/global_event_handler.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'world/map/npc/functions/global_event_handler.txt') diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt index b1c5917e..9db9dd8f 100644 --- a/world/map/npc/functions/global_event_handler.txt +++ b/world/map/npc/functions/global_event_handler.txt @@ -19,7 +19,7 @@ OnPCLoginEvent: callfunc "ConvertChristmas21"; // Christmas 2021 callfunc "VaultLogin"; // Mirror Lake Protocol biddings callfunc "VaultLogout"; // Clean some stuff, to be safe - if (WEIGHT_LIMIT) set MaxWeightOverride, WEIGHT_LIMIT; // If this char var set, override max weight (tradebots, etc) + if (MAXWEIGHT_OVERRIDE) set MaxWeightOverride, MAXWEIGHT_OVERRIDE; // If MAXWEIGHT_OVERRIDE char var set, override max weight (tradebots, etc) // add more here set @login_event, 2; end; -- cgit v1.2.3-70-g09d2 From 870b2cc2199c0556d44a62b92760a3e584b9a270 Mon Sep 17 00:00:00 2001 From: "Hello=)" Date: Sat, 20 Jul 2024 07:21:37 +0300 Subject: Revert "V4 - rename weight override char var to HoraK's suggestion" This reverts commit bab8a25d6d3a2a5f5173654c95d057c65a3fa4f6. Reason: its confusing if PC variable name looks same like server's param name. --- world/map/npc/functions/global_event_handler.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'world/map/npc/functions/global_event_handler.txt') diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt index 9db9dd8f..b1c5917e 100644 --- a/world/map/npc/functions/global_event_handler.txt +++ b/world/map/npc/functions/global_event_handler.txt @@ -19,7 +19,7 @@ OnPCLoginEvent: callfunc "ConvertChristmas21"; // Christmas 2021 callfunc "VaultLogin"; // Mirror Lake Protocol biddings callfunc "VaultLogout"; // Clean some stuff, to be safe - if (MAXWEIGHT_OVERRIDE) set MaxWeightOverride, MAXWEIGHT_OVERRIDE; // If MAXWEIGHT_OVERRIDE char var set, override max weight (tradebots, etc) + if (WEIGHT_LIMIT) set MaxWeightOverride, WEIGHT_LIMIT; // If this char var set, override max weight (tradebots, etc) // add more here set @login_event, 2; end; -- cgit v1.2.3-70-g09d2