From de142f3ae1a67fd4987c8ef68500b849b34dd79e Mon Sep 17 00:00:00 2001 From: "Hello=)" Date: Tue, 19 Nov 2024 21:08:22 +0300 Subject: This adds script logic to spawn mob on other mob's death. Useful to sub-split slimes and do similar extra tricks. Relies on https://git.themanaworld.org/legacy/tmwa/-/merge_requests/292 Mentioned server change provides X/Y of mob kill so e.g. slime "split" can look reasonable - spawning new slimes where killed mob been. This is preliminary version, so far it introduces following spawns: Mob Killed -> What appears 1) Sea Slime Mother -> angry sea slimes on kill. 2) Green Slime Mother -> angry green slimes on kill. 3) Blue Slime -> few SlimeBlast (same as it spawns) 4) Tormenta -> Void Bats + Demonic Spirits + undead witch. 5) Luvia -> Void Bats + Demonic Spirits (slightly fewer so Illia players arent instakilled hopefully) TODO: Add few BIG slimes decaying into existent "normal" ones. E.g. BIG green slime -> bunch of angry green slimes. or BIG Sea Slime -> bunch of angry sea slimes. (this needs GFX of big slime and turning it into mob) --- world/map/npc/functions/global_event_handler.txt | 1 + world/map/npc/functions/spawns_on_mobkill.txt | 71 ++++++++++++++++++++++++ world/map/npc/scripts.conf | 1 + 3 files changed, 73 insertions(+) create mode 100644 world/map/npc/functions/spawns_on_mobkill.txt diff --git a/world/map/npc/functions/global_event_handler.txt b/world/map/npc/functions/global_event_handler.txt index dfc7966f..ed95b442 100644 --- a/world/map/npc/functions/global_event_handler.txt +++ b/world/map/npc/functions/global_event_handler.txt @@ -35,6 +35,7 @@ OnMobKillEvent: callfunc "MobPoints"; callfunc "MobKillHandler"; callfunc "SweetTooth"; + callfunc "spawns_on_mobkill"; end; OnPCDieEvent: diff --git a/world/map/npc/functions/spawns_on_mobkill.txt b/world/map/npc/functions/spawns_on_mobkill.txt new file mode 100644 index 00000000..991f2567 --- /dev/null +++ b/world/map/npc/functions/spawns_on_mobkill.txt @@ -0,0 +1,71 @@ +// Spawns some mobs on death of some other mob. Say split slime -> few smaller ones +// This function meant to be called with player RID attached (usually in OnMobKillEvent) +// Inputs: nothing, but expects @mobID, @mob_X and @mob_Y set (usually by server) +// Return: nothing, but spawns few things. +// TODO: Add few big slime mobs and "split" these (this needs big slime GFX and making mob). +function|script|spawns_on_mobkill +{ + debugmes "spawns_on_death ->"; + debugmes "spawns_on_death mobID=" + @mobID + " @mob_X=" + @mob_X + " @mob_Y=" + @mob_Y; + if (@mobID == SeaSlimeMother) goto L_SplitSea; + if (@mobID == GreenSlimeMother) goto L_SplitGreen; + if (@mobID == BlueSlime) goto L_SplitBlue; + if (@mobID == Tormenta) goto L_TorWitchDead; + if (@mobID == Luvia) goto L_LuvWitchDead; + debugmes "spawns_on_death <-"; + return; + +L_SplitSea: + debugmes "slime_split - Sea Mother"; + void call("spawn_mobs_around", getmap(), @mob_X, @mob_Y, AngrySeaSlime, rand(8, 20)); + return; + +L_SplitGreen: + debugmes "slime_split - Greens Mother"; + void call("spawn_mobs_around", getmap(), @mob_X, @mob_Y, AngryGreenSlime, rand(8, 20)); + return; + +L_SplitBlue: + debugmes "slime_split - BigBlue"; + void call("spawn_mobs_around", getmap(), @mob_X, @mob_Y, SlimeBlast, rand(1, 6)); + return; + +L_TorWitchDead: + void call("spawn_mobs_around", getmap(), @mob_X, @mob_Y, VoidBat, rand(7, 12)); + void call("spawn_mobs_around", getmap(), @mob_X, @mob_Y, DemonicSpirit, rand(5, 10)); + void call("spawn_mobs_around", getmap(), @mob_X, @mob_Y, UndeadWitch, 1); + return; + +L_LuvWitchDead: + void call("spawn_mobs_around", getmap(), @mob_X, @mob_Y, "", VoidBat, rand(6, 10)); + void call("spawn_mobs_around", getmap(), @mob_X, @mob_Y, "", DemonicSpirit, rand(4, 8)); + return; +} + +// Spawns mobs around spot, if it can - or stacks mobs on spot if no room for 3x3 area +// This function can be called from any context. +// Inputs: arg0: map (string), arg1: X, arg2: Y, arg3: mob ID, ard4: amount +// Return: nothing, but spawns few things. +function|script|spawn_mobs_around +{ + set .@map$, getarg(0, ""); + set .@mobX, getarg(1, -1); + set .@mobY, getarg(2, -1); + set .@mobID, getarg(3, -1); + set .@mobQTY, getarg(4, -1); + debugmes "spawn_mob_around ->"; + debugmes "spawn_mob_around: map$=" + .@map$ + " x=" + .@mobX + " y=" + .@mobY + " mobID=" + .@mobID + " mobQTY=" + .@mobQTY; + if ((.@map$ == "") || (.@mobX < 1) || (.@mobY < 1) || (.@mobID < 1002) || + (.@mobX > getmapmaxx(.@map$)) || (.@mobX > getmapmaxy(.@map$)) || + (.@mobQTY < 1)) goto L_Abort; + debugmes "spawn_mob_arounc: map$=" + .@map$ + " x=" + .@mobX + " y=" + .@mobY + " mobID=" + .@mobID + " mobQTY=" + .@mobQTY; + if ((.@mobX > 1) && (.@mobY > 1) && (.@mobX < getmapmaxx(.@map$)) && (.@mobY < getmapmaxy(.@map$))) + areamonster .@map$, (.@mobX-1), (.@mobY-1), (.@mobX+1), (.@mobY+1), "", .@mobID, .@mobQTY; // Enough room for 3x3 + else + monster .@map$, .@mobX, .@mobY, "", .@mobID, .@mobQTY; // 3x3 wouldnt fit -> use spot. + return; + +L_Abort: + debugmes "spawn_mob_around: invalid args! Map=" + .@map$ + " x=" + .@mobX + " y=" + .@mobY + " mobID=" + .@mobID + " mobQTY=" + .@mobQTY; + return; +} diff --git a/world/map/npc/scripts.conf b/world/map/npc/scripts.conf index 7fbe10b4..b2565af8 100644 --- a/world/map/npc/scripts.conf +++ b/world/map/npc/scripts.conf @@ -37,6 +37,7 @@ npc: npc/functions/ghost.txt npc: npc/functions/vault.txt npc: npc/functions/global_event_handler.txt npc: npc/functions/teleport_manager.txt +npc: npc/functions/spawns_on_mobkill.txt // Item Functions npc: npc/items/purification_potion.txt -- cgit v1.2.3-70-g09d2