diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 82f9ad5..24ff608 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -21,6 +21,10 @@ #include "player.h" #include "gamerules.h" +// If you want the "legacy" controls where primary attack is "throw first charge / detonate" and secondary attack is +// "throw extra" charge, simply comment this define. +#define MODERN_SATCHEL_CONTROLS + class CSatchelCharge : public CGrenade { void Spawn() override; @@ -333,6 +337,13 @@ void CSatchel::Holster() void CSatchel::PrimaryAttack() { +#ifdef MODERN_SATCHEL_CONTROLS + // we're reloading, don't allow fire + if (m_chargeReady != 2) + { + Throw(); + } +#else switch (m_chargeReady) { case 0: @@ -342,28 +353,7 @@ void CSatchel::PrimaryAttack() break; case 1: { - SendWeaponAnim(SATCHEL_RADIO_FIRE); - - edict_t* pPlayer = m_pPlayer->edict(); - - CBaseEntity* pSatchel = NULL; - - while ((pSatchel = UTIL_FindEntityInSphere(pSatchel, m_pPlayer->pev->origin, 4096)) != NULL) - { - if (FClassnameIs(pSatchel->pev, "monster_satchel")) - { - if (pSatchel->pev->owner == pPlayer) - { - pSatchel->Use(m_pPlayer, m_pPlayer, USE_ON, 0); - m_chargeReady = 2; - } - } - } - - m_chargeReady = 2; - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + Detonate(); break; } @@ -373,15 +363,23 @@ void CSatchel::PrimaryAttack() } break; } +#endif } void CSatchel::SecondaryAttack() { +#ifdef MODERN_SATCHEL_CONTROLS + if (m_chargeReady == 1) + { + Detonate(); + } +#else if (m_chargeReady != 2) { Throw(); } +#endif } @@ -419,6 +417,33 @@ void CSatchel::Throw() } +void CSatchel::Detonate() +{ + SendWeaponAnim(SATCHEL_RADIO_FIRE); + + edict_t* pPlayer = m_pPlayer->edict(); + + CBaseEntity* pSatchel = NULL; + + while ((pSatchel = UTIL_FindEntityInSphere(pSatchel, m_pPlayer->pev->origin, 4096)) != NULL) + { + if (FClassnameIs(pSatchel->pev, "monster_satchel")) + { + if (pSatchel->pev->owner == pPlayer) + { + pSatchel->Use(m_pPlayer, m_pPlayer, USE_ON, 0); + m_chargeReady = 2; + } + } + } + + m_chargeReady = 2; + m_flNextPrimaryAttack = GetNextAttackDelay(0.5); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; +} + + void CSatchel::WeaponIdle() { if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) diff --git a/dlls/weapons.h b/dlls/weapons.h index cd34c5b..65c02d4 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -1129,6 +1129,7 @@ public: void Holster() override; void WeaponIdle() override; void Throw(); + void Detonate(); bool UseDecrement() override {