- scriptified the no-spawn flag check for armor and health items.

This commit is contained in:
Christoph Oelckers 2018-12-02 18:04:44 +01:00
parent 319f8743db
commit a5fc26b37c
3 changed files with 30 additions and 23 deletions

View File

@ -5621,32 +5621,17 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
{ {
return NULL; return NULL;
} }
auto it = GetDefaultByType(i);
// [RH] Other things that shouldn't be spawned depending on dmflags
if (deathmatch || alwaysapplydmflags) IFVIRTUALPTR(it, AActor, ShouldSpawn)
{ {
if (i->IsDescendantOf(RUNTIME_CLASS(AInventory))) int ret;
{ VMValue param = it;
auto it = static_cast<AInventory*>(GetDefaultByType(i)); VMReturn rett(&ret);
VMCall(func, &param, 1, &rett, 1);
if (dmflags & DF_NO_HEALTH) if (!ret) return nullptr;
{
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;
}
}
} }
// spawn it // spawn it
double sz; double sz;

View File

@ -960,6 +960,11 @@ class Actor : Thinker native
RenderStyle = default.RenderStyle; RenderStyle = default.RenderStyle;
Alpha = default.Alpha; 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); 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);

View File

@ -113,6 +113,23 @@ class Inventory : Actor native
Super.OnDestroy(); 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 // PROC A_RestoreSpecialThing1