diff --git a/game/game/gamescript.cpp b/game/game/gamescript.cpp index 87feab0b7..594c098b3 100644 --- a/game/game/gamescript.cpp +++ b/game/game/gamescript.cpp @@ -1138,6 +1138,13 @@ void GameScript::invokeRefreshAtInsert(Npc& npc) { } CollideMask GameScript::canNpcCollideWithSpell(Npc& npc, Npc* shooter, int32_t spellId) { + if(owner.version().game==1) { + auto& spl = spellDesc(spellId); + if(npc.isTargetableBySpell(TargetType(spl.target_collect_type))) + return COLL_DOEVERYTHING; else + return COLL_DONOTHING; + } + auto fn = vm.find_symbol_by_name("C_CanNpcCollideWithSpell"); if(fn==nullptr) return COLL_DOEVERYTHING; diff --git a/game/world/objects/npc.cpp b/game/world/objects/npc.cpp index 7ce546b92..dad7a6928 100644 --- a/game/world/objects/npc.cpp +++ b/game/world/objects/npc.cpp @@ -2815,6 +2815,24 @@ void Npc::runEffect(Effect&& e) { visual.startEffect(owner, std::move(e), 0, true); } +bool Npc::isTargetableBySpell(TargetType t) const { + if(bool(t&(TARGET_TYPE_ALL|TARGET_TYPE_NPCS))) + return true; + Guild gil = Guild(trueGuild()); + if(bool(t&TARGET_TYPE_HUMANS) && gilGIL_SEPERATOR_ORC) + return true; + if(bool(t&TARGET_TYPE_UNDEAD)) { + if(gil == GIL_GOBBO_SKELETON || gil == GIL_SUMMONED_GOBBO_SKELETON || + gil == GIL_SKELETON || gil == GIL_SUMMONED_SKELETON || + gil == GIL_SKELETON_MAGE || gil == GIL_SHADOWBEAST_SKELETON || + gil == GIL_ZOMBIE) + return true; + } + return false; + } + void Npc::commitSpell() { auto active = invent.getItem(currentSpellCast); if(active==nullptr || !active->isSpellOrRune()) diff --git a/game/world/objects/npc.h b/game/world/objects/npc.h index 4b5e88141..822dfcd49 100644 --- a/game/world/objects/npc.h +++ b/game/world/objects/npc.h @@ -398,6 +398,7 @@ class Npc final { void commitSpell(); void takeDamage(Npc& other, const Bullet* b); void takeDamage(Npc& other, const Bullet* b, const VisualFx* vfx, int32_t splId); + bool isTargetableBySpell(TargetType t) const; void emitSoundEffect(std::string_view sound, float range, bool freeSlot); void emitSoundGround(std::string_view sound, float range, bool freeSlot); diff --git a/game/world/worldobjects.cpp b/game/world/worldobjects.cpp index acaaed320..42a4b4358 100644 --- a/game/world/worldobjects.cpp +++ b/game/world/worldobjects.cpp @@ -1003,21 +1003,7 @@ template static bool checkTargetType(T&, TargetType) { return true; } static bool checkTargetType(Npc& n, TargetType t) { - if(bool(t&(TARGET_TYPE_ALL|TARGET_TYPE_NPCS))) - return true; - Guild gil = Guild(n.trueGuild()); - if(bool(t&TARGET_TYPE_HUMANS) && gilGIL_SEPERATOR_ORC) - return true; - if(bool(t&TARGET_TYPE_UNDEAD)) { - if(gil == GIL_GOBBO_SKELETON || gil == GIL_SUMMONED_GOBBO_SKELETON || - gil == GIL_SKELETON || gil == GIL_SUMMONED_SKELETON || - gil == GIL_SKELETON_MAGE || gil == GIL_SHADOWBEAST_SKELETON || - gil == GIL_ZOMBIE) - return true; - } - return false; + return n.isTargetableBySpell(t); } template