diff options
-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); } |