From a5fc26b37c63c6b5d7918dae80d9807188de123d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 2 Dec 2018 18:04:44 +0100 Subject: [PATCH] - scriptified the no-spawn flag check for armor and health items. --- src/p_mobj.cpp | 31 +++++-------------- wadsrc/static/zscript/actor.txt | 5 +++ wadsrc/static/zscript/inventory/inventory.txt | 17 ++++++++++ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 669935405..40c416bc7 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 8f421dd55..41e603729 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 fed1ab972..2166c8630 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