diff options
author | Hello=) <hello@themanaworld.org> | 2025-03-11 21:17:05 +0300 |
---|---|---|
committer | Hello TMW <hello@themanaworld.org> | 2025-03-12 12:42:10 +0000 |
commit | aac4589d15d0da9252297847c979d4a6723b545b (patch) | |
tree | 926a19b94dd0f52c215de2c5036e05d382435e76 | |
parent | e23b028861e92d025d1bf851783c1059e22fbb6c (diff) | |
download | tmwa-return-summon-gid.tar.gz tmwa-return-summon-gid.tar.bz2 tmwa-return-summon-gid.tar.xz tmwa-return-summon-gid.zip |
Return 0 as mob GID if mob not really usable for script.return-summon-gid
Testing shown it can happen if e.g. mob placed on collision on spawn.
Somehow internal function would return some block ID anyway. However e.g.
(mob->hp == 0) gives this case away.
-rw-r--r-- | src/map/script-fun.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 5982624..1a292b9 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -3111,8 +3111,6 @@ 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) { case MonsterAttitude::SERVANT: @@ -3150,8 +3148,17 @@ void builtin_summon(ScriptState *st) mob->master_id = owner->bl_id; mob->master_dist = 6; } + + if (mob->hp > 0) // Is mob REALLY spawned && usable? + { + push_int<ScriptDataInt>(st->stack, unwrap<BlockId>(mob->bl_id)); // Return mob GID to caller + } + else // Server can fail to place mob (e.g. collision) but ->bl_id still valid? + { // (md->hp == 0) gives this case away. + push_int<ScriptDataInt>(st->stack, 0); + } } - else // got no (mob), default + else // got no (mob), report failure to caller { push_int<ScriptDataInt>(st->stack, 0); } |