From 797f3aec0a7c931563cc32413a4a14ec05ad5e03 Mon Sep 17 00:00:00 2001 From: Leonard2 Date: Fri, 1 Jul 2016 23:43:30 +0200 Subject: [PATCH] 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 --- src/g_shared/a_pickups.h | 1 + src/p_pspr.cpp | 25 ++++++++++++++----------- src/thingdef/thingdef_data.cpp | 1 + 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index d432fdda0..af0135bc2 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -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. // 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_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) // Flags used only by bot AI: diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index 73a8054f0..70355a0f9 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -1396,20 +1396,23 @@ void player_t::TickPSprites() 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) - P_BringUpWeapon(this); - } - else - { - P_CheckWeaponSwitch(this); - if (WeaponState & (WF_WEAPONREADY | WF_WEAPONREADYALT)) + if (ReadyWeapon == nullptr) { - 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); } } diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index fca7f2ddb..dc4587cfb 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -363,6 +363,7 @@ static FFlagDef WeaponFlagDefs[] = DEFINE_FLAG(WIF, AMMO_CHECKBOTH, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, NOAUTOAIM, AWeapon, WeaponFlags), DEFINE_FLAG(WIF, NODEATHJUMP, AWeapon, WeaponFlags), + DEFINE_FLAG(WIF, NODEATHINPUT, AWeapon, WeaponFlags), DEFINE_DUMMY_FLAG(NOLMS), DEFINE_FLAG(WIF, ALT_USES_BOTH, AWeapon, WeaponFlags),