diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 6699354052..40c416bc74 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5621,32 +5621,17 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) { return NULL; } - - // [RH] Other things that shouldn't be spawned depending on dmflags - if (deathmatch || alwaysapplydmflags) + auto it = GetDefaultByType(i); + + IFVIRTUALPTR(it, AActor, ShouldSpawn) { - if (i->IsDescendantOf(RUNTIME_CLASS(AInventory))) - { - auto it = static_cast(GetDefaultByType(i)); - - if (dmflags & DF_NO_HEALTH) - { - if (it->ItemFlags & IF_ISHEALTH) return nullptr; - } - if (dmflags & DF_NO_ITEMS) - { - // if (i->IsDescendantOf (RUNTIME_CLASS(AArtifact))) - // return; - } - if (dmflags & DF_NO_ARMOR) - { - if (it->ItemFlags & IF_ISARMOR) return nullptr; - } - } + int ret; + VMValue param = it; + VMReturn rett(&ret); + VMCall(func, ¶m, 1, &rett, 1); + if (!ret) return nullptr; } - - // spawn it double sz; diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 8f421dd559..41e6037299 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -960,6 +960,11 @@ class Actor : Thinker native RenderStyle = default.RenderStyle; Alpha = default.Alpha; } + + virtual bool ShouldSpawn() + { + return true; + } native void A_Face(Actor faceto, double max_turn = 0, double max_pitch = 270, double ang_offset = 0, double pitch_offset = 0, int flags = 0, double z_ofs = 0); diff --git a/wadsrc/static/zscript/inventory/inventory.txt b/wadsrc/static/zscript/inventory/inventory.txt index fed1ab9724..2166c8630f 100644 --- a/wadsrc/static/zscript/inventory/inventory.txt +++ b/wadsrc/static/zscript/inventory/inventory.txt @@ -113,6 +113,23 @@ class Inventory : Actor native Super.OnDestroy(); } + //=========================================================================== + // + // AInventory :: ShouldSpawn + // + //=========================================================================== + + override bool ShouldSpawn() + { + // [RH] Other things that shouldn't be spawned depending on dmflags + if (deathmatch || alwaysapplydmflags) + { + if (sv_nohealth && bIsHealth) return false; + if (sv_noarmor && bIsArmor) return false; + } + return true; + } + //--------------------------------------------------------------------------- // // PROC A_RestoreSpecialThing1