From e5f7900e2ced97384d3a1833dff016e22e69857c Mon Sep 17 00:00:00 2001 From: jhh8 Date: Thu, 20 Feb 2025 20:26:32 +0200 Subject: [PATCH] medrifle and deagle pickup pdw and pistol ammo --- src/game/client/swarm/c_asw_ammo.cpp | 2 ++ src/game/server/swarm/asw_ammo.cpp | 30 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/game/client/swarm/c_asw_ammo.cpp b/src/game/client/swarm/c_asw_ammo.cpp index ef97fd8a9..f905028fd 100644 --- a/src/game/client/swarm/c_asw_ammo.cpp +++ b/src/game/client/swarm/c_asw_ammo.cpp @@ -106,6 +106,7 @@ C_ASW_Ammo_Pistol::C_ASW_Ammo_Pistol() Q_snprintf( m_szNoGunText, sizeof( m_szNoGunText ), "#asw_ammo_pistol" ); Q_snprintf( m_szAmmoFullText, sizeof( m_szAmmoFullText ), "#asw_ammo_pistol_full" ); m_iAmmoIndex = GetAmmoDef()->Index( "ASW_P" ); + m_iAmmoIndex2 = GetAmmoDef()->Index( "ASW_DEAGLE" ); } //------------ @@ -166,6 +167,7 @@ C_ASW_Ammo_PDW::C_ASW_Ammo_PDW() Q_snprintf( m_szNoGunText, sizeof( m_szNoGunText ), "#asw_ammo_pdw" ); Q_snprintf( m_szAmmoFullText, sizeof( m_szAmmoFullText ), "#asw_ammo_pdw_full" ); m_iAmmoIndex = GetAmmoDef()->Index( "ASW_PDW" ); + m_iAmmoIndex2 = GetAmmoDef()->Index( "ASW_MEDRIFLE" ); } //------------ diff --git a/src/game/server/swarm/asw_ammo.cpp b/src/game/server/swarm/asw_ammo.cpp index 4bbeab00f..1b8e7e322 100644 --- a/src/game/server/swarm/asw_ammo.cpp +++ b/src/game/server/swarm/asw_ammo.cpp @@ -31,6 +31,8 @@ extern ConVar asw_ammo_count_rifle_burst; extern ConVar asw_ammo_count_shotgun; extern ConVar asw_ammo_count_sniper_rifle; extern ConVar asw_ammo_count_vindicator; +extern ConVar asw_ammo_count_deagle; +extern ConVar asw_ammo_count_medrifle; //------------- // Generic give ammo function @@ -455,6 +457,7 @@ void CASW_Ammo_Pistol::Spawn( void ) SetModel( "models/swarm/Ammo/ammopistol.mdl" ); BaseClass::Spawn(); m_iAmmoIndex = GetAmmoDef()->Index( "ASW_P" ); + m_iAmmoIndex2 = GetAmmoDef()->Index( "ASW_DEAGLE" ); } @@ -468,11 +471,24 @@ void CASW_Ammo_Pistol::ActivateUseIcon( CASW_Inhabitable_NPC *pNPC, int nHoldTyp if ( nHoldType == ASW_USE_HOLD_START ) return; + bool bDeagleActive = pNPC->GetActiveWeapon() && pNPC->GetActiveWeapon()->GetPrimaryAmmoType() == GetAmmoDef()->Index( "ASW_DEAGLE" ); + if ( bDeagleActive && ASW_GiveAmmo( pNPC, asw_ammo_count_deagle.GetInt(), "ASW_DEAGLE", this ) ) + { + UTIL_Remove( this ); + return; + } + if ( ASW_GiveAmmo( pNPC, asw_ammo_count_pistol.GetInt(), "ASW_P", this ) ) { UTIL_Remove( this ); return; } + + if ( !bDeagleActive && ASW_GiveAmmo( pNPC, asw_ammo_count_deagle.GetInt(), "ASW_DEAGLE", this ) ) + { + UTIL_Remove( this ); + return; + } } //------------- @@ -607,6 +623,7 @@ void CASW_Ammo_PDW::Spawn( void ) SetModel( "models/swarm/Ammo/ammopdw.mdl" ); BaseClass::Spawn(); m_iAmmoIndex = GetAmmoDef()->Index( "ASW_PDW" ); + m_iAmmoIndex2 = GetAmmoDef()->Index( "ASW_MEDRIFLE" ); } @@ -620,11 +637,24 @@ void CASW_Ammo_PDW::ActivateUseIcon( CASW_Inhabitable_NPC *pNPC, int nHoldType ) if ( nHoldType == ASW_USE_HOLD_START ) return; + bool bMedRifleActive = pNPC->GetActiveWeapon() && pNPC->GetActiveWeapon()->GetPrimaryAmmoType() == GetAmmoDef()->Index( "ASW_MEDRIFLE" ); + if ( bMedRifleActive && ASW_GiveAmmo( pNPC, asw_ammo_count_medrifle.GetInt(), "ASW_MEDRIFLE", this ) ) + { + UTIL_Remove( this ); + return; + } + if ( ASW_GiveAmmo( pNPC, asw_ammo_count_pdw.GetInt(), "ASW_PDW", this) ) { UTIL_Remove( this ); return; } + + if ( !bMedRifleActive && ASW_GiveAmmo( pNPC, asw_ammo_count_medrifle.GetInt(), "ASW_MEDRIFLE", this ) ) + { + UTIL_Remove( this ); + return; + } } //-------------