Skip to content

Commit

Permalink
When ConVar sk_tripmine_use_owner_relations is 1, tripmines will use …
Browse files Browse the repository at this point in the history
…owner entity's relationships instead of default relationships
  • Loading branch information
1upD committed Jan 22, 2024
1 parent 0c05054 commit 5263e57
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
28 changes: 23 additions & 5 deletions sp/src/game/server/hl2mp/grenade_tripmine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

extern const char* g_pModelNameLaser;

ConVar sk_plr_dmg_tripmine ( "sk_plr_dmg_tripmine","0");
ConVar sk_npc_dmg_tripmine ( "sk_npc_dmg_tripmine","0");
ConVar sk_tripmine_radius ( "sk_tripmine_radius","0");
ConVar sk_plr_dmg_tripmine ( "sk_plr_dmg_tripmine","0" );
ConVar sk_npc_dmg_tripmine ( "sk_npc_dmg_tripmine","0" );
ConVar sk_tripmine_radius ( "sk_tripmine_radius","0" );
ConVar sk_tripmine_use_owner_relations ( "sk_tripmine_use_owner_relations", "0" );

LINK_ENTITY_TO_CLASS( npc_tripmine, CTripmineGrenade );

Expand Down Expand Up @@ -357,8 +358,7 @@ void CTripmineGrenade::BeamBreakThink( void )
CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity );

#ifdef EZ2
// Tripmines do not detonate when tripped by entities that treat their class as friendly or by the owner
if ( ( pBCC && pBCC->GetDefaultRelationshipDisposition( m_nTripmineClass ) == D_LI ) || ( GetOwnerEntity() && GetOwnerEntity() == pBCC ) )
if ( pBCC && !TargetShouldDetonate(pBCC) )
{
SetNextThink( gpGlobals->curtime + 0.05f );
return;
Expand Down Expand Up @@ -495,3 +495,21 @@ void CTripmineGrenade::InputDeactivate( inputdata_t &inputdata )
}
#endif

#ifdef EZ2
bool CTripmineGrenade::TargetShouldDetonate(CBaseCombatCharacter* pTarget)
{
if ( pTarget && sk_tripmine_use_owner_relations.GetBool() && GetOwnerEntity() && GetOwnerEntity()->IsCombatCharacter() )
{
return GetOwnerEntity()->MyCombatCharacterPointer()->IRelationType(pTarget) < D_LI;
}

// Tripmines do not detonate when tripped by entities that treat their class as friendly or by the owner
if ((pTarget && pTarget->GetDefaultRelationshipDisposition(m_nTripmineClass) == D_LI) || (GetOwnerEntity() && GetOwnerEntity() == pTarget))
{
return false;
}


return true;
}
#endif
5 changes: 5 additions & 0 deletions sp/src/game/server/hl2mp/grenade_tripmine.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class CTripmineGrenade : public CBaseGrenade
COutputEvent m_OnExplode;
#endif

#ifdef EZ2
virtual bool TargetShouldDetonate(CBaseCombatCharacter* pTarget);
#endif


public:
EHANDLE m_hOwner;

Expand Down

0 comments on commit 5263e57

Please sign in to comment.