From d74ced6650797a84651ef7e9481f02c1933ad405 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Thu, 2 Nov 2023 18:59:42 -0500 Subject: [PATCH] fix worm medal being awarded to everyone in the lobby rather than just the worm-toucher --- src/game/shared/swarm/rd_inventory_shared.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/game/shared/swarm/rd_inventory_shared.cpp b/src/game/shared/swarm/rd_inventory_shared.cpp index fb0fa0fbe..2265a3663 100644 --- a/src/game/shared/swarm/rd_inventory_shared.cpp +++ b/src/game/shared/swarm/rd_inventory_shared.cpp @@ -1194,6 +1194,12 @@ static class CRD_Inventory_Manager final : public CAutoGameSystem, public CGameE { int64_t iCounterBefore = instance.m_nCounter[iCombinedIndex]; #ifdef CLIENT_DLL + if ( engine->IsPlayingDemo() ) + { + // watching a recording + return; + } + PendingDynamicPropertyUpdate_t *pUpdate = NULL; FOR_EACH_VEC( m_PendingDynamicPropertyUpdates, j ) { @@ -3437,6 +3443,13 @@ namespace ReactiveDropInventory void OnHitConfirm( CBaseEntity *pAttacker, CBaseEntity *pTarget, Vector vecDamagePosition, bool bKilled, bool bDamageOverTime, bool bBlastDamage, int iDisposition, float flDamage, CBaseEntity *pWeapon ) { +#ifdef CLIENT_DLL + if ( engine->IsPlayingDemo() ) + { + return; + } +#endif + CASW_Game_Resource *pGameResource = ASWGameResource(); if ( !pGameResource ) return; @@ -3452,16 +3465,18 @@ namespace ReactiveDropInventory { if ( pAttacker && pTarget && pTarget->IsInhabitableNPC() && !V_stricmp( IGameSystem::MapName(), "rd-reduction2" ) && !V_strcmp( pAttacker->GetClassname(), "trigger_hurt" ) && !V_strcmp( STRING( pAttacker->GetEntityName() ), "trigger_pitworm_hitbox" ) ) { + CASW_Inhabitable_NPC *pTargetNPC = assert_cast< CASW_Inhabitable_NPC * >( pTarget ); + #ifdef CLIENT_DLL static bool s_bRequestedWormToucherMedal = false; - if ( !s_bRequestedWormToucherMedal ) + if ( !s_bRequestedWormToucherMedal && pTargetNPC->IsInhabited() && pTargetNPC->GetCommander() && pTargetNPC->GetCommander()->IsLocalPlayer() ) { AddPromoItem( 42 ); s_bRequestedWormToucherMedal = true; } #endif - s_RD_Inventory_Manager.IncrementStrangePropertyOnEquippedItems( assert_cast< CASW_Inhabitable_NPC * >( pTarget ), 42, 1 ); + s_RD_Inventory_Manager.IncrementStrangePropertyOnEquippedItems( pTargetNPC, 42, 1 ); } return;