summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHello=) <hello@themanaworld.org>2025-03-01 06:41:16 +0300
committerHello TMW <hello@themanaworld.org>2025-03-12 12:42:10 +0000
commite23b028861e92d025d1bf851783c1059e22fbb6c (patch)
treeff1b457df141f4478a3322ca8d20f49d7f4543ab
parent88dfbd91ed22ab4ad98b2b9f0243f9d9faa9b49d (diff)
downloadtmwa-e23b028861e92d025d1bf851783c1059e22fbb6c.tar.gz
tmwa-e23b028861e92d025d1bf851783c1059e22fbb6c.tar.bz2
tmwa-e23b028861e92d025d1bf851783c1059e22fbb6c.tar.xz
tmwa-e23b028861e92d025d1bf851783c1059e22fbb6c.zip
This changes summon() to return summoned being bl_id
Technically it makes TMWA summon() builtin a bit more like Herc summon(). It now would return summon's being bl_id if summon successful. Rationale behind this change: 1) Makes call behaving a bit more like it does now in Herc, why not? 2) Having being ID allows to do something with just spawned summon in scripts. (now finding just summoned being is hard/weird code-wise) 3) Having ID of mob allows to check if summon succeeded. Summon can fail if e.g. position randomized and chosen position is a collision. This would allow me to implement "antibug" summon refactor in content. Caveat: Content (spells) needs refactor to swallow fact its now returns "int" instead. If this given go, it MUST only be merged with matching content change.
-rw-r--r--src/map/script-fun.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index c471da1..5982624 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -3111,6 +3111,7 @@ void builtin_summon(ScriptState *st)
if (mob)
{
mob->mode = get_mob_db(monster_id).mode;
+ push_int<ScriptDataInt>(st->stack, unwrap<BlockId>(mob->bl_id)); // Return mob GID to caller
switch (monster_attitude)
{
@@ -3150,6 +3151,10 @@ void builtin_summon(ScriptState *st)
mob->master_dist = 6;
}
}
+ else // got no (mob), default
+ {
+ push_int<ScriptDataInt>(st->stack, 0);
+ }
}
/*==========================================
@@ -5687,7 +5692,7 @@ BuiltinFunction builtin_functions[] =
BUILTIN(mobinfo, "ii"_s, 'v'),
BUILTIN(mobinfo_droparrays, "iiN"_s, 'i'),
BUILTIN(getmobdrops, "i"_s, 'i'),
- BUILTIN(summon, "Mxyssmii?"_s, '\0'),
+ BUILTIN(summon, "Mxyssmii?"_s, 'i'),
BUILTIN(monster, "Mxysmi?"_s, '\0'),
BUILTIN(areamonster, "Mxyxysmi?"_s, '\0'),
BUILTIN(killmonster, "ME"_s, '\0'),