mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- use an inventory flag to decide what items are slipped by DF_NO_HEALTH and DF_NO_ARMOR. With all the changes over the last 10 years this had become too spotty.
- use an enum type for ItemFlags, just like it was done for actor flags. Since the flag word is almost full it may soon be necessary to add a second one and then this kind of security check may become necessary.
This commit is contained in:
parent
dc6c91042b
commit
12915b5f6e
7 changed files with 34 additions and 24 deletions
|
@ -17,7 +17,7 @@ struct visstyle_t;
|
||||||
|
|
||||||
// A pickup is anything the player can pickup (i.e. weapons, ammo, powerups, etc)
|
// A pickup is anything the player can pickup (i.e. weapons, ammo, powerups, etc)
|
||||||
|
|
||||||
enum
|
enum ItemFlag
|
||||||
{
|
{
|
||||||
IF_ACTIVATABLE = 1<<0, // can be activated
|
IF_ACTIVATABLE = 1<<0, // can be activated
|
||||||
IF_ACTIVATED = 1<<1, // is currently activated
|
IF_ACTIVATED = 1<<1, // is currently activated
|
||||||
|
@ -46,8 +46,14 @@ enum
|
||||||
IF_TRANSFER = 1<<24, // All inventory items that the inventory item contains is also transfered to the pickuper
|
IF_TRANSFER = 1<<24, // All inventory items that the inventory item contains is also transfered to the pickuper
|
||||||
IF_NOTELEPORTFREEZE = 1<<25, // does not 'freeze' the player right after teleporting.
|
IF_NOTELEPORTFREEZE = 1<<25, // does not 'freeze' the player right after teleporting.
|
||||||
IF_NOSCREENBLINK = 1<<26, // Does not blink the screen overlay when expiring.
|
IF_NOSCREENBLINK = 1<<26, // Does not blink the screen overlay when expiring.
|
||||||
|
IF_ISHEALTH = 1<<27, // for the DM flag so that it can recognize items that are not obviously health givers.
|
||||||
|
IF_ISARMOR = 1<<28, // for the DM flag so that it can recognize items that are not obviously armor givers.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef TFlags<ItemFlag> InvFlags;
|
||||||
|
//typedef TFlags<ItemFlag2> ItemFlags2;
|
||||||
|
DEFINE_TFLAGS_OPERATORS(InvFlags)
|
||||||
|
//DEFINE_TFLAGS_OPERATORS(ItemFlags2)
|
||||||
|
|
||||||
class AInventory : public AActor
|
class AInventory : public AActor
|
||||||
{
|
{
|
||||||
|
@ -89,7 +95,7 @@ public:
|
||||||
PClassActor *SpawnPointClass; // For respawning like Heretic's mace
|
PClassActor *SpawnPointClass; // For respawning like Heretic's mace
|
||||||
FTextureID AltHUDIcon;
|
FTextureID AltHUDIcon;
|
||||||
|
|
||||||
DWORD ItemFlags;
|
InvFlags ItemFlags;
|
||||||
PClassActor *PickupFlash; // actor to spawn as pickup flash
|
PClassActor *PickupFlash; // actor to spawn as pickup flash
|
||||||
|
|
||||||
FSoundIDNoInit PickupSound;
|
FSoundIDNoInit PickupSound;
|
||||||
|
|
|
@ -3217,13 +3217,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_ActiveSound)
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void ModifyDropAmount(AInventory *inv, int dropamount)
|
void ModifyDropAmount(AInventory *inv, int dropamount)
|
||||||
{
|
{
|
||||||
int flagmask = IF_IGNORESKILL;
|
auto flagmask = IF_IGNORESKILL;
|
||||||
double dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor);
|
double dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor);
|
||||||
// Default drop amount is half of regular amount * regular ammo multiplication
|
// Default drop amount is half of regular amount * regular ammo multiplication
|
||||||
if (dropammofactor == -1)
|
if (dropammofactor == -1)
|
||||||
{
|
{
|
||||||
dropammofactor = 0.5;
|
dropammofactor = 0.5;
|
||||||
flagmask = 0;
|
flagmask = ItemFlag(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropamount > 0)
|
if (dropamount > 0)
|
||||||
|
|
|
@ -5821,27 +5821,23 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position)
|
||||||
// [RH] Other things that shouldn't be spawned depending on dmflags
|
// [RH] Other things that shouldn't be spawned depending on dmflags
|
||||||
if (deathmatch || alwaysapplydmflags)
|
if (deathmatch || alwaysapplydmflags)
|
||||||
{
|
{
|
||||||
// Fixme: This needs to be done differently, it's quite broken.
|
if (i->IsDescendantOf(RUNTIME_CLASS(AInventory)))
|
||||||
if (dmflags & DF_NO_HEALTH)
|
|
||||||
{
|
{
|
||||||
if (i->IsDescendantOf (PClass::FindActor(NAME_Health)))
|
auto it = static_cast<AInventory*>(GetDefaultByType(i));
|
||||||
return NULL;
|
|
||||||
if (i->TypeName == NAME_Berserk)
|
if (dmflags & DF_NO_HEALTH)
|
||||||
return NULL;
|
{
|
||||||
if (i->TypeName == NAME_Megasphere)
|
if (it->ItemFlags & IF_ISHEALTH) return nullptr;
|
||||||
return NULL;
|
}
|
||||||
}
|
if (dmflags & DF_NO_ITEMS)
|
||||||
if (dmflags & DF_NO_ITEMS)
|
{
|
||||||
{
|
// if (i->IsDescendantOf (RUNTIME_CLASS(AArtifact)))
|
||||||
// if (i->IsDescendantOf (RUNTIME_CLASS(AArtifact)))
|
// return;
|
||||||
// return;
|
}
|
||||||
}
|
if (dmflags & DF_NO_ARMOR)
|
||||||
if (dmflags & DF_NO_ARMOR)
|
{
|
||||||
{
|
if (it->ItemFlags & IF_ISARMOR) return nullptr;
|
||||||
if (i->IsDescendantOf (PClass::FindActor(NAME_Armor)))
|
}
|
||||||
return NULL;
|
|
||||||
if (i->TypeName == NAME_Megasphere)
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -430,6 +430,8 @@ static FFlagDef InventoryFlagDefs[] =
|
||||||
DEFINE_FLAG(IF, TRANSFER, AInventory, ItemFlags),
|
DEFINE_FLAG(IF, TRANSFER, AInventory, ItemFlags),
|
||||||
DEFINE_FLAG(IF, NOTELEPORTFREEZE, AInventory, ItemFlags),
|
DEFINE_FLAG(IF, NOTELEPORTFREEZE, AInventory, ItemFlags),
|
||||||
DEFINE_FLAG(IF, NOSCREENBLINK, AInventory, ItemFlags),
|
DEFINE_FLAG(IF, NOSCREENBLINK, AInventory, ItemFlags),
|
||||||
|
DEFINE_FLAG(IF, ISARMOR, AInventory, ItemFlags),
|
||||||
|
DEFINE_FLAG(IF, ISHEALTH, AInventory, ItemFlags),
|
||||||
|
|
||||||
DEFINE_DUMMY_FLAG(FORCERESPAWNINSURVIVAL, false),
|
DEFINE_DUMMY_FLAG(FORCERESPAWNINSURVIVAL, false),
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@ class Megasphere : CustomInventory
|
||||||
{
|
{
|
||||||
+COUNTITEM
|
+COUNTITEM
|
||||||
+INVENTORY.ALWAYSPICKUP
|
+INVENTORY.ALWAYSPICKUP
|
||||||
|
+INVENTORY.ISHEALTH
|
||||||
|
+INVENTORY.ISARMOR
|
||||||
Inventory.PickupMessage "$GOTMSPHERE";
|
Inventory.PickupMessage "$GOTMSPHERE";
|
||||||
Inventory.PickupSound "misc/p_pkup";
|
Inventory.PickupSound "misc/p_pkup";
|
||||||
}
|
}
|
||||||
|
@ -183,6 +185,7 @@ class Berserk : CustomInventory
|
||||||
{
|
{
|
||||||
+COUNTITEM
|
+COUNTITEM
|
||||||
+INVENTORY.ALWAYSPICKUP
|
+INVENTORY.ALWAYSPICKUP
|
||||||
|
+INVENTORY.ISHEALTH
|
||||||
Inventory.PickupMessage "$GOTBERSERK";
|
Inventory.PickupMessage "$GOTBERSERK";
|
||||||
Inventory.PickupSound "misc/p_pkup";
|
Inventory.PickupSound "misc/p_pkup";
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ class Armor : Inventory
|
||||||
Default
|
Default
|
||||||
{
|
{
|
||||||
Inventory.PickupSound "misc/armor_pkup";
|
Inventory.PickupSound "misc/armor_pkup";
|
||||||
|
+INVENTORY.ISARMOR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ class Health : Inventory
|
||||||
|
|
||||||
Default
|
Default
|
||||||
{
|
{
|
||||||
|
+INVENTORY.ISHEALTH
|
||||||
Inventory.Amount 1;
|
Inventory.Amount 1;
|
||||||
Inventory.MaxAmount 0;
|
Inventory.MaxAmount 0;
|
||||||
Inventory.PickupSound "misc/health_pkup";
|
Inventory.PickupSound "misc/health_pkup";
|
||||||
|
@ -99,6 +100,7 @@ class HealthPickup : Inventory
|
||||||
{
|
{
|
||||||
Inventory.DefMaxAmount;
|
Inventory.DefMaxAmount;
|
||||||
+INVENTORY.INVBAR
|
+INVENTORY.INVBAR
|
||||||
|
+INVENTORY.ISHEALTH
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
Loading…
Reference in a new issue