From 271b53b153c3a05b9604b365c7f4ba076fdbc8c4 Mon Sep 17 00:00:00 2001
From: "Hello=)" <hello@themanaworld.org>
Date: Sat, 16 Nov 2024 18:46:07 +0300
Subject: Expose X and Y of killed mob to OnMobKillEvent script event (for
 slime split, etc)

Rationale:
    OnMobKillEvent invoked under PLAYER's RID - so using e.g. POS_X and
    POS_Y returns PLAYER's coordinates when kill occured. The only extra data
    available been @mobID - giving killed mob's type (class).

    However, to "split" slimes I need to spawn few new mobs right on location
    where kill occured - or some area around this spot, not player's X/Y.

This commit exposes 2 new variables set by server, @mob_X and @mob_Y
containing mob's X and Y coordinates when kill happened.

This is server-code change needed by relevant scripts.
Scripts itself would be landed a bit later to serverdata.
---
 src/map/mob.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index 996e2bb..065a517 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -2796,9 +2796,11 @@ int mob_damage(dumb_ptr<block_list> src, dumb_ptr<mob_data> md, int damage,
                 npc_event(sd, md->npc_event, 0);
 
             // TODO: in the future, OnPCKillEvent, OnMobKillEvent and OnPCDieEvent should be combined
-            argrec_t arg[1] =
+            argrec_t arg[3] =
             {
                 {"@mobID"_s, static_cast<int32_t>(unwrap<Species>(md->mob_class))},
+                {"@mob_X"_s, static_cast<int32_t>(md->bl_x)},
+                {"@mob_Y"_s, static_cast<int32_t>(md->bl_y)},
             };
             npc_event_doall_l(stringish<ScriptLabel>("OnMobKillEvent"_s), sd->bl_id, arg);
         }
-- 
cgit v1.2.3-70-g09d2