Added a weapon flag to ignore a player's input when dead

The reason this is not set by default is because before that anyone could call A_WeaponReady within their Deselect state which would have allowed players to fire even when dead
This commit is contained in:
Leonard2 2016-07-01 23:43:30 +02:00 committed by Christoph Oelckers
parent bcb18cf7d8
commit 797f3aec0a
3 changed files with 16 additions and 11 deletions

View file

@ -379,6 +379,7 @@ enum
WIF_DEHAMMO = 0x00010000, // Uses Doom's original amount of ammo for the respective attack functions so that old DEHACKED patches work as intended. WIF_DEHAMMO = 0x00010000, // Uses Doom's original amount of ammo for the respective attack functions so that old DEHACKED patches work as intended.
// AmmoUse1 will be set to the first attack's ammo use so that checking for empty weapons still works // AmmoUse1 will be set to the first attack's ammo use so that checking for empty weapons still works
WIF_NODEATHJUMP = 0x00020000, // Don't jump to the Deselect state when the player dies WIF_NODEATHJUMP = 0x00020000, // Don't jump to the Deselect state when the player dies
WIF_NODEATHINPUT = 0x00040000, // The weapon cannot be fired/reloaded/whatever when the player is dead
WIF_CHEATNOTWEAPON = 0x08000000, // Give cheat considers this not a weapon (used by Sigil) WIF_CHEATNOTWEAPON = 0x08000000, // Give cheat considers this not a weapon (used by Sigil)
// Flags used only by bot AI: // Flags used only by bot AI:

View file

@ -1396,20 +1396,23 @@ void player_t::TickPSprites()
pspr = pspr->Next; pspr = pspr->Next;
} }
if (ReadyWeapon == nullptr && (health > 0 || mo->DamageType != NAME_Fire)) if ((health > 0) || (ReadyWeapon != nullptr && !(ReadyWeapon->WeaponFlags & WIF_NODEATHINPUT)))
{ {
if (PendingWeapon != WP_NOCHANGE) if (ReadyWeapon == nullptr)
P_BringUpWeapon(this);
}
else
{
P_CheckWeaponSwitch(this);
if (WeaponState & (WF_WEAPONREADY | WF_WEAPONREADYALT))
{ {
P_CheckWeaponFire(this); if (PendingWeapon != WP_NOCHANGE)
P_BringUpWeapon(this);
}
else
{
P_CheckWeaponSwitch(this);
if (WeaponState & (WF_WEAPONREADY | WF_WEAPONREADYALT))
{
P_CheckWeaponFire(this);
}
// Check custom buttons
P_CheckWeaponButtons(this);
} }
// Check custom buttons
P_CheckWeaponButtons(this);
} }
} }

View file

@ -363,6 +363,7 @@ static FFlagDef WeaponFlagDefs[] =
DEFINE_FLAG(WIF, AMMO_CHECKBOTH, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, AMMO_CHECKBOTH, AWeapon, WeaponFlags),
DEFINE_FLAG(WIF, NOAUTOAIM, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, NOAUTOAIM, AWeapon, WeaponFlags),
DEFINE_FLAG(WIF, NODEATHJUMP, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, NODEATHJUMP, AWeapon, WeaponFlags),
DEFINE_FLAG(WIF, NODEATHINPUT, AWeapon, WeaponFlags),
DEFINE_DUMMY_FLAG(NOLMS), DEFINE_DUMMY_FLAG(NOLMS),
DEFINE_FLAG(WIF, ALT_USES_BOTH, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, ALT_USES_BOTH, AWeapon, WeaponFlags),