- 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;
}
// [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<AInventory*>(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, &param, 1, &rett, 1);
if (!ret) return nullptr;
}
// spawn it
double sz;

View File

@ -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);

View File

@ -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