#ifdef ENABLE_SHIP_DEFENSE
auto CHARACTER::IsInShipDefenseDungeon() const -> bool
{
return m_Dungeon && m_Dungeon->GetIndex() == ConstMap::DungShipDefense;
}
#endif
I checked for the dungeon ptr on the mobs, bcs this is a very reliable identification if they are in that dungeon.
When they spawn, they immediately get the ptr.
auto CDungeon::SpawnMob(const ConstDungeon::MobSpawn* spawn, bool tryRarity) -> LPCHARACTER
{
auto* map = CSectreeManager::instance().GetMap(m_MapIndex);
if (!map) return nullptr;
auto rotation = spawn->dir;
if (!spawn->degrees)
{
rotation ? rotation = (spawn->dir - 1) * 45 : rotation = -1;
}
auto* mob = CCharacterManager::instance().SpawnMob(
spawn->vnum, m_MapIndex, map->m_setting.baseX + spawn->x * 100, map->m_setting.baseY + spawn->y * 100, 0, spawn->motion, rotation, true, false, nullptr, "", tryRarity
);
if (!mob)
return nullptr;
mob->SetDungeon(this);
ProcessSpawnEvent(mob);
if (!spawn->key.empty())
m_UniqueMobs.emplace(spawn->key, mob);
return mob;
}
And when they die (get destroyed) it is being set to nullptr.
So you have a very solid identification method over the lifespan of the mobs if they need the state machine skip or not.
If you would check for the Mast and in a few months you dont think about it anymore and spawn one maybe on a non dungeon map, it would lead to unnecessary server load.
I guess there are also other ways you can do the check e.g. with the private map index of the mob, I think you can check which function Owsap has written for the identification of the dungeon mobs and use his one.