summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHello=) <hello@themanaworld.org>2025-03-12 16:48:38 +0300
committerHello TMW <hello@themanaworld.org>2025-04-09 23:08:23 +0000
commitf241d62af0dca01cbe437a0d297a76039ae8b478 (patch)
treeeb0cb05176bae8c8e3192c91b2c9d0970ef2a920
parent079edb5967bae22a486f2cc9ff6258bf8512858a (diff)
downloadserverdata-return-summon-gid-spells-refactor.tar.gz
serverdata-return-summon-gid-spells-refactor.tar.bz2
serverdata-return-summon-gid-spells-refactor.tar.xz
serverdata-return-summon-gid-spells-refactor.zip
Summon spells refactor by Hello=)return-summon-gid-spells-refactor
Rationale behind refactor: * Reduces spells LoC and "spaghetti" by factoring out duplicate code to summon N beings within radius to function to reusable function. * Single summon() wrapper used in most spells would allow to do summon() builtin refactor much easier, changing 1 place in scripts. * Trying to spread mobs within given radius if possible. * If not possible (collision), falls back to given X,Y (usually player position at cast time so collision free). * This fixes bugs where summons failed to appear being placed on collisions. * Full version would try to mimic monster() of Herc, likelty most logic thing around (no idea why Herc's summon() dumbed down vs TMWA or monster()) * Part of puzzle to enable more intelligent "big" summons, etc. This version of refactor is non-intrusive and atomic: uses existing TMWA summon() builtin and can coexist with non-refactored spells.
-rw-r--r--world/map/npc/magic/_procedures.txt62
-rw-r--r--world/map/npc/magic/event-summon-managuardian.txt12
-rw-r--r--world/map/npc/magic/event-summon-manatyrant.txt12
-rw-r--r--world/map/npc/magic/event-summon-stonegolem.txt12
-rw-r--r--world/map/npc/magic/event-summon-sunshroom.txt15
-rw-r--r--world/map/npc/magic/level1-grow-alizarin.txt10
-rw-r--r--world/map/npc/magic/level1-grow-cobalt.txt10
-rw-r--r--world/map/npc/magic/level1-grow-gamboge.txt10
-rw-r--r--world/map/npc/magic/level1-grow-mauve.txt10
-rw-r--r--world/map/npc/magic/level1-grow-shadow.txt10
-rw-r--r--world/map/npc/magic/level1-summon-maggots.txt15
-rw-r--r--world/map/npc/magic/level2-summon-fluffies.txt15
-rw-r--r--world/map/npc/magic/level2-summon-mouboo.txt15
-rw-r--r--world/map/npc/magic/level2-summon-pinkie.txt15
-rw-r--r--world/map/npc/magic/level2-summon-snakes.txt26
-rw-r--r--world/map/npc/magic/level2-summon-spiky-mushroom.txt15
-rw-r--r--world/map/npc/magic/level2-summon-wickedmushroom.txt27
17 files changed, 121 insertions, 170 deletions
diff --git a/world/map/npc/magic/_procedures.txt b/world/map/npc/magic/_procedures.txt
index 517373e2..504539a8 100644
--- a/world/map/npc/magic/_procedures.txt
+++ b/world/map/npc/magic/_procedures.txt
@@ -339,6 +339,7 @@ L_LvCkFail:
// This function used to lock out spell.
// Input: arg0 - length of cooldown.
// Input: arg1 - optional: custom SC_COOLDOWN ID to use.
+// Return: nothing, but configures spell lockout mechanics going.
function|script|magic_block
{
if (getarg(0) <= 0) goto L_Block_Fail;
@@ -356,3 +357,64 @@ L_Block_Fail:
debugmes "bug: magic_block needs arg(0) > 0";
return; // Called wrong way -> spell bug.
}
+
+// magic_summon_all function can be called in any context with or without player
+// This function SUMMONS all requested creatures arouns given spot
+// Its effectively wrapper to summon builtin to summon >= 1 beings, in area
+// input: arg(0) -> MAP
+// input: arg(1) -> X
+// input: arg(2) -> Y
+// input: arg(3) -> Radius (tiles)
+// input: arg(4) -> Mob Qty
+// input: arg(5) -> Owner
+// input: arg(6) -> Disp Name
+// input: arg(7) -> Mob type
+// input: arg(8) -> Mob Mode (AI)
+// input: arg(9) -> LifeTime
+// input: arg(10) -> Event label (optional)
+// Return: GID of last summoned mob, 0 on failure.
+function|script|magic_summon_all
+{
+ set .@map$, getarg(0, ""); // Map where to spawn
+ set .@x, getarg(1, -1); // X
+ set .@y, getarg(2, -1); // Y
+ set .@r, getarg(3, -1); // Mob spread radius (X-R),(Y-R):(X+R),(Y+R)
+ set .@qty, getarg(4, -1); // # of mobs to summon
+ set .@owner, getarg(5, -1); // owner of mob to set
+ set .@name$, getarg(6, ""); // mob display name
+ set .@mobID, getarg(7, -1); // ID of mob to summon
+ set .@mobAI, getarg(8, -1); // AI (mode) of mob to use
+ set .@lifetime, getarg(9, -1); // Mob's lifetime.
+ set .@event$, getarg(10, ""); // Custom event on mob death
+
+ if ((.@map$ == "") || (.@r < 0) || // FIXME: better map validity check?
+ (.@x <= .@r) || (.@y <= .@r) || // No spawns outside of map
+ (.@x > (getmapmaxx(.@map$) + .@r)) || // No spawns outside of map
+ (.@y > (getmapmaxy(.@map$) + .@r)) || // No spawns outside of map
+ (.@qty < 1) || (.@owner < 1) || (.@lifetime < 0) ||
+ (.@event$ == "10")) // no event been given, not even ""
+ goto L_Fail;
+ goto L_Summon;
+
+L_Summon:
+ set .@qty, .@qty - 1;
+ set .@realx, rand(.@x-.@r, .@x+.@r); // Pick spot around (x,y)
+ set .@realy, rand(.@y-.@r, .@y+.@r);
+ if !(iscollision(.@map$, .@realx, .@realy)) goto L_SummonHere; // Spot ok?
+ set .@realx, .@x; // Fallback to (x, y) on collision (typically player x,y)
+ set .@realy, .@y;
+ goto L_SummonHere;
+
+L_SummonHere:
+ set .@mobGID, 1; // TODO: now its just placeholder for future summon() call prototype change
+ summon .@map$, .@realx, .@realy, .@owner, .@name$, .@mobID, .@mobAI, .@lifetime, .@event$;
+ if (.@qty > 0) goto L_Summon;
+ return .@mobGID;
+
+L_Fail:
+ debugmes "magic_summon_all: call failed, .@map$="+.@map$+" .@x="+.@x+" .@y="+.@y+
+ " .@r="+.@r+" .@qty="+.@qty+" .@owner="+.@owner+" .@name$="+.@name$+
+ " .@mobID="+.@mobID+" .@mobAI="+.@mobAI+" .@lifetime="+.@lifetime+
+ " .@event$="+.@event$+"getarg(10)=" + getarg(10);
+ return 0;
+}
diff --git a/world/map/npc/magic/event-summon-managuardian.txt b/world/map/npc/magic/event-summon-managuardian.txt
index 1aa172ad..18bb79c3 100644
--- a/world/map/npc/magic/event-summon-managuardian.txt
+++ b/world/map/npc/magic/event-summon-managuardian.txt
@@ -41,17 +41,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_MAGGOT_SPAWN;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, 1, .master, "Mana Guardian Summon", ManaGuard, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Mana Guardian Summon", ManaGuard, 2, .lifetime;
+OnDestroy:
destroy;
L_Cooldown:
diff --git a/world/map/npc/magic/event-summon-manatyrant.txt b/world/map/npc/magic/event-summon-manatyrant.txt
index ff082930..0a9f97cb 100644
--- a/world/map/npc/magic/event-summon-manatyrant.txt
+++ b/world/map/npc/magic/event-summon-manatyrant.txt
@@ -42,17 +42,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_MAGGOT_SPAWN;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, 1, .master, "Mana Tyrant Summon", ManaTyrant, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Mana Tyrant Summon", ManaTyrant, 2, .lifetime;
+OnDestroy:
destroy;
L_Cooldown:
diff --git a/world/map/npc/magic/event-summon-stonegolem.txt b/world/map/npc/magic/event-summon-stonegolem.txt
index dd8e8c53..ba3c24f6 100644
--- a/world/map/npc/magic/event-summon-stonegolem.txt
+++ b/world/map/npc/magic/event-summon-stonegolem.txt
@@ -42,17 +42,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_MAGGOT_SPAWN;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, 1, .master, "Stone Golem Summon", StoneGolem, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Stone Golem Summon", StoneGolem, 2, .lifetime;
+OnDestroy:
destroy;
L_Cooldown:
diff --git a/world/map/npc/magic/event-summon-sunshroom.txt b/world/map/npc/magic/event-summon-sunshroom.txt
index 6c01c1c8..52f7619e 100644
--- a/world/map/npc/magic/event-summon-sunshroom.txt
+++ b/world/map/npc/magic/event-summon-sunshroom.txt
@@ -39,20 +39,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_SPIKY_SPAWN;
- set .@i, 0;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, .count, .master, "Sunshroom Summon", Sunshroom, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Sunshroom Summon", Sunshroom, 2, .lifetime;
- set .@i, .@i + 1;
- if (.@i < .count) goto S_SummonAll;
+OnDestroy:
destroy;
L_SpecialRules6:
diff --git a/world/map/npc/magic/level1-grow-alizarin.txt b/world/map/npc/magic/level1-grow-alizarin.txt
index d82288cd..d07e9448 100644
--- a/world/map/npc/magic/level1-grow-alizarin.txt
+++ b/world/map/npc/magic/level1-grow-alizarin.txt
@@ -14,22 +14,16 @@
set CASTS, CASTS + 1;
if (CASTS < 0) set CASTS, 1; // overflow
misceffect FX_MAGIC_GROW_CAST, strcharinfo(0);
- setarray @summon[0], 0, (getskilllv(.school)/2)+1;
callfunc "magic_exp";
addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon";
end;
OnSummon:
misceffect FX_MAGIC_GROW_SPAWN, strcharinfo(0);
- callsub S_SummonAll;
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", getmap(), POS_X, POS_Y, 2, (getskilllv(.school)/2)+1, BL_ID, "Alizarin Plant Summon2", AlizarinPlant, 1, (@spellpower*50)+10000, "");
end;
-S_SummonAll:
- summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, "Alizarin Plant Summon", AlizarinPlant, 1, (@spellpower*50)+10000;
- set @summon[0], @summon[0] + 1;
- if (@summon[0] < @summon[1]) goto S_SummonAll;
- return;
-
OnInit:
set .school, SKILL_MAGIC_NATURE;
set .invocation$, chr(MAGIC_SYMBOL) + "modriphoo"; // used in npcs that refer to this spell
diff --git a/world/map/npc/magic/level1-grow-cobalt.txt b/world/map/npc/magic/level1-grow-cobalt.txt
index 58028e8c..bed01002 100644
--- a/world/map/npc/magic/level1-grow-cobalt.txt
+++ b/world/map/npc/magic/level1-grow-cobalt.txt
@@ -14,22 +14,16 @@
set CASTS, CASTS + 1;
if (CASTS < 0) set CASTS, 1; // overflow
misceffect FX_MAGIC_GROW_CAST, strcharinfo(0);
- setarray @summon[0], 0, (getskilllv(.school)/2)+1;
callfunc "magic_exp";
addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon";
end;
OnSummon:
misceffect FX_MAGIC_GROW_SPAWN, strcharinfo(0);
- callsub S_SummonAll;
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", getmap(), POS_X, POS_Y, 2, (getskilllv(.school)/2)+1, BL_ID, "Cobalt Plant Summon", CobaltPlant, 1, (@spellpower*50)+10000, "");
end;
-S_SummonAll:
- summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, "Cobalt Plant Summon", CobaltPlant, 1, (@spellpower*50)+10000;
- set @summon[0], @summon[0] + 1;
- if (@summon[0] < @summon[1]) goto S_SummonAll;
- return;
-
OnInit:
set .school, SKILL_MAGIC_NATURE;
set .invocation$, chr(MAGIC_SYMBOL) + "modrisump"; // used in npcs that refer to this spell
diff --git a/world/map/npc/magic/level1-grow-gamboge.txt b/world/map/npc/magic/level1-grow-gamboge.txt
index fae2cf7d..674da14f 100644
--- a/world/map/npc/magic/level1-grow-gamboge.txt
+++ b/world/map/npc/magic/level1-grow-gamboge.txt
@@ -14,22 +14,16 @@
set CASTS, CASTS + 1;
if (CASTS < 0) set CASTS, 1; // overflow
misceffect FX_MAGIC_GROW_CAST, strcharinfo(0);
- setarray @summon[0], 0, (getskilllv(.school)/2)+1;
callfunc "magic_exp";
addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon";
end;
OnSummon:
misceffect FX_MAGIC_GROW_SPAWN, strcharinfo(0);
- callsub S_SummonAll;
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", getmap(), POS_X, POS_Y, 2, (getskilllv(.school)/2)+1, BL_ID, "Gamboge Plant Summon", GambogePlant, 1, (@spellpower*50)+10000, "");
end;
-S_SummonAll:
- summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, "Gamboge Plant Summon", GambogePlant, 1, (@spellpower*50)+10000;
- set @summon[0], @summon[0] + 1;
- if (@summon[0] < @summon[1]) goto S_SummonAll;
- return;
-
OnInit:
set .school, SKILL_MAGIC_NATURE;
set .invocation$, chr(MAGIC_SYMBOL) + "modriyikam"; // used in npcs that refer to this spell
diff --git a/world/map/npc/magic/level1-grow-mauve.txt b/world/map/npc/magic/level1-grow-mauve.txt
index af8f54d8..dbc64e59 100644
--- a/world/map/npc/magic/level1-grow-mauve.txt
+++ b/world/map/npc/magic/level1-grow-mauve.txt
@@ -14,22 +14,16 @@
set CASTS, CASTS + 1;
if (CASTS < 0) set CASTS, 1; // overflow
misceffect FX_MAGIC_GROW_CAST, strcharinfo(0);
- setarray @summon[0], 0, (getskilllv(.school)/2)+1;
callfunc "magic_exp";
addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon";
end;
OnSummon:
misceffect FX_MAGIC_GROW_SPAWN, strcharinfo(0);
- callsub S_SummonAll;
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", getmap(), POS_X, POS_Y, 2, (getskilllv(.school)/2)+1, BL_ID, "Mauve Plant Summon", MauvePlant, 1, (@spellpower*50)+10000, "");
end;
-S_SummonAll:
- summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, "Mauve Plant Summon", MauvePlant, 1, (@spellpower*50)+10000;
- set @summon[0], @summon[0] + 1;
- if (@summon[0] < @summon[1]) goto S_SummonAll;
- return;
-
OnInit:
set .school, SKILL_MAGIC_NATURE;
set .invocation$, chr(MAGIC_SYMBOL) + "modrilax"; // used in npcs that refer to this spell
diff --git a/world/map/npc/magic/level1-grow-shadow.txt b/world/map/npc/magic/level1-grow-shadow.txt
index fff821db..945e0577 100644
--- a/world/map/npc/magic/level1-grow-shadow.txt
+++ b/world/map/npc/magic/level1-grow-shadow.txt
@@ -14,22 +14,16 @@
set CASTS, CASTS + 1;
if (CASTS < 0) set CASTS, 1; // overflow
misceffect FX_MAGIC_GROW_CAST, strcharinfo(0);
- setarray @summon[0], 0, (getskilllv(.school)/2)+1;
callfunc "magic_exp";
addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon";
end;
OnSummon:
misceffect FX_MAGIC_GROW_SPAWN, strcharinfo(0);
- callsub S_SummonAll;
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", getmap(), POS_X, POS_Y, 2, (getskilllv(.school)/2)+1, BL_ID, "Shadow Plant Summon", ShadowPlant, 1, (@spellpower*50)+10000, "");
end;
-S_SummonAll:
- summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, "Shadow Plant Summon", ShadowPlant, 1, (@spellpower*50)+10000;
- set @summon[0], @summon[0] + 1;
- if (@summon[0] < @summon[1]) goto S_SummonAll;
- return;
-
OnInit:
set .school, SKILL_MAGIC_NATURE;
set .invocation$, chr(MAGIC_SYMBOL) + "modrisha"; // used in npcs that refer to this spell
diff --git a/world/map/npc/magic/level1-summon-maggots.txt b/world/map/npc/magic/level1-summon-maggots.txt
index ce95422c..c87193da 100644
--- a/world/map/npc/magic/level1-summon-maggots.txt
+++ b/world/map/npc/magic/level1-summon-maggots.txt
@@ -37,20 +37,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_MAGGOT_SPAWN;
- set .@i, 0;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, .count, .master, "Maggot Summon", Maggot, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Maggot Summon", Maggot, 2, .lifetime;
- set .@i, .@i + 1;
- if (.@i < .count) goto S_SummonAll;
+OnDestroy:
destroy;
L_SpecialRules6:
diff --git a/world/map/npc/magic/level2-summon-fluffies.txt b/world/map/npc/magic/level2-summon-fluffies.txt
index fef40a17..b94fd3ba 100644
--- a/world/map/npc/magic/level2-summon-fluffies.txt
+++ b/world/map/npc/magic/level2-summon-fluffies.txt
@@ -38,20 +38,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_FLUFFY_SPAWN;
- set .@i, 0;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, .count, .master, "Fluffy Summon", Fluffy, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Fluffy Summon", Fluffy, 2, .lifetime;
- set .@i, .@i + 1;
- if (.@i < .count) goto S_SummonAll;
+OnDestroy:
destroy;
L_SpecialRules6:
diff --git a/world/map/npc/magic/level2-summon-mouboo.txt b/world/map/npc/magic/level2-summon-mouboo.txt
index 8a8603c6..bb45f96f 100644
--- a/world/map/npc/magic/level2-summon-mouboo.txt
+++ b/world/map/npc/magic/level2-summon-mouboo.txt
@@ -38,20 +38,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_MOUBOO_SPAWN;
- set .@i, 0;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, .count, .master, "Mouboo Summon", Mouboo, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Mouboo Summon", Mouboo, 2, .lifetime;
- set .@i, .@i + 1;
- if (.@i < .count) goto S_SummonAll;
+OnDestroy:
destroy;
L_SpecialRules6:
diff --git a/world/map/npc/magic/level2-summon-pinkie.txt b/world/map/npc/magic/level2-summon-pinkie.txt
index b4774584..08d03dca 100644
--- a/world/map/npc/magic/level2-summon-pinkie.txt
+++ b/world/map/npc/magic/level2-summon-pinkie.txt
@@ -38,20 +38,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_PINKY_SPAWN;
- set .@i, 0;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, .count, .master, "Pinkie Summon", Pinkie, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Pinkie Summon", Pinkie, 2, .lifetime;
- set .@i, .@i + 1;
- if (.@i < .count) goto S_SummonAll;
+OnDestroy:
destroy;
L_SpecialRules6:
diff --git a/world/map/npc/magic/level2-summon-snakes.txt b/world/map/npc/magic/level2-summon-snakes.txt
index 5815cef5..6549b7e7 100644
--- a/world/map/npc/magic/level2-summon-snakes.txt
+++ b/world/map/npc/magic/level2-summon-snakes.txt
@@ -39,25 +39,19 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_SNAKE_SPAWN;
- set .@i, 0;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
+ setarray .@mobs[0], CaveSnake, Snake, MountainSnake, GrassSnake; // Which snake to summon?
+ goto L_SummonRandom; // Spawn one by one to randomize
-OnDestroy:
+L_SummonRandom:
+ set .count, .count - 1;
+ set .mob, .@mobs[rand(getarraysize(.@mobs))]; // Pick random mob
+ set .nm$, mobinfo(.mob, MOB_ENG_NAME) + " Summon"; // Get mob's name + add Summon
+ // map X Y Rad QTY OWNER Disp MobID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, 1, .master, .nm$, .mob, 2, .lifetime, "");
+ if (.count > 0) goto L_SummonRandom;
destroy;
-S_SummonAll:
- set .@sn, rand(0, 3);
-
- if (.@sn == 0) summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Cave Snake Summon", CaveSnake, 2, .lifetime;
- elif (.@sn == 1) summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Snake Summon", Snake, 2, .lifetime;
- elif (.@sn == 2) summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Mountain Snake Summon", MountainSnake, 2, .lifetime;
- elif (.@sn == 3) summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Grass Snake Summon", GrassSnake, 2, .lifetime;
- set .@i, .@i + 1;
- if (.@i < .count) goto S_SummonAll;
+OnDestroy:
destroy;
L_SpecialRules6:
diff --git a/world/map/npc/magic/level2-summon-spiky-mushroom.txt b/world/map/npc/magic/level2-summon-spiky-mushroom.txt
index 0f884185..9e305313 100644
--- a/world/map/npc/magic/level2-summon-spiky-mushroom.txt
+++ b/world/map/npc/magic/level2-summon-spiky-mushroom.txt
@@ -38,20 +38,11 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_SPIKY_SPAWN;
- set .@i, 0;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
-
-OnDestroy:
+ // map X Y Rad QTY OWNER DisplayName Mob ID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, .count, .master, "Spiky Mushroom Summon", SpikyMushroom, 2, .lifetime, "");
destroy;
-S_SummonAll:
- summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Spiky Mushroom Summon", SpikyMushroom, 2, .lifetime;
- set .@i, .@i + 1;
- if (.@i < .count) goto S_SummonAll;
+OnDestroy:
destroy;
L_SpecialRules6:
diff --git a/world/map/npc/magic/level2-summon-wickedmushroom.txt b/world/map/npc/magic/level2-summon-wickedmushroom.txt
index 7d0e93c1..9ee4406a 100644
--- a/world/map/npc/magic/level2-summon-wickedmushroom.txt
+++ b/world/map/npc/magic/level2-summon-wickedmushroom.txt
@@ -39,24 +39,21 @@ OnSummon:
if(get(Hp, .master) < 1) destroy; // destroy if master is missing
if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_MAGIC_WICKED_SPAWN;
- set .@i, 0;
- set .@x, getnpcx();
- set .@y, getnpcy();
- set .@map$, strnpcinfo(3);
- callsub S_SummonAll;
- end;
+ goto L_SummonRandom; // Spawn one by one to randomize
-OnDestroy:
+L_SummonRandom:
+ set .count, .count - 1;
+ set .rnd, rand(0, 9);
+ if (.rnd < 6) set .mob, WickedMushroom;
+ elif (.rnd < 9) set .mob, Moonshroom;
+ else set .mob, EvilMushroom;
+ set .nm$, mobinfo(.mob, MOB_ENG_NAME) + " Summon"; // Get mob's name + add Summon
+ // map X Y Rad QTY OWNER Disp MobID AI Lifetime (no custom event)
+ void call("magic_summon_all", strnpcinfo(3), getnpcx(), getnpcy(), 2, 1, .master, .nm$, .mob, 2, .lifetime, "");
+ if (.count > 0) goto L_SummonRandom;
destroy;
-S_SummonAll:
- set .@rnd, rand(0, 9);
-
- if (.@rnd < 6) summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Wicked Mushroom Summon", WickedMushroom, 2, .lifetime;
- elif (.@rnd < 9) summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Moonshroom Summon", Moonshroom, 2, .lifetime;
- elif (.@rnd == 9) summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, "Evil Mushroom Summon", EvilMushroom, 2, .lifetime;
- set .@i, .@i + 1;
- if (.@i < .count) goto S_SummonAll;
+OnDestroy:
destroy;
L_SpecialRules6: