Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/game/client/tf/c_tf_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,14 +1597,17 @@ void C_TFRagdoll::DissolveEntity( CBaseEntity* pEnt )
pDissolve->SetRenderColor( 255, 255, 255, 255 );

Vector vColor;
C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
bool bIsFriendlyFireOrSuicide = pLocalPlayer ? pLocalPlayer->IsDeathFriendlyFireOrSuicide() : NULL;
// If a player kills themselves or a teammate with a weapon that dissolves ragdolls, set dissolving color to their own team
if ( m_iTeam == TF_TEAM_BLUE )
{
vColor = TF_PARTICLE_WEAPON_RED_1 * 255;
vColor = ( bIsFriendlyFireOrSuicide ) ? TF_PARTICLE_WEAPON_BLUE_1 * 255 : TF_PARTICLE_WEAPON_RED_1 * 255;
pDissolve->SetEffectColor( vColor );
}
else
{
vColor = TF_PARTICLE_WEAPON_BLUE_1 * 255;
vColor = ( bIsFriendlyFireOrSuicide ) ? TF_PARTICLE_WEAPON_RED_1 * 255 : TF_PARTICLE_WEAPON_BLUE_1 * 255;
pDissolve->SetEffectColor( vColor );
}

Expand Down Expand Up @@ -3977,6 +3980,8 @@ C_TFPlayer::C_TFPlayer() :

m_iPlayerSkinOverride = 0;

m_bIsFriendlyFireOrSuicide = false;

ListenForGameEvent( "player_hurt" );
ListenForGameEvent( "hltv_changed_mode" );
ListenForGameEvent( "hltv_changed_target" );
Expand All @@ -3993,6 +3998,7 @@ C_TFPlayer::C_TFPlayer() :
ListenForGameEvent( "player_abandoned_match" );
ListenForGameEvent( "rocketpack_launch" );
ListenForGameEvent( "rocketpack_landed" );
ListenForGameEvent( "player_death" );

//AddPhonemeFile
engine->AddPhonemeFile( "scripts/game_sounds_vo_phonemes.txt" );
Expand Down Expand Up @@ -11182,6 +11188,23 @@ void C_TFPlayer::FireGameEvent( IGameEvent *event )
}
}
}
else if (FStrEq(event->GetName(), "player_death" ) )
{
m_bIsFriendlyFireOrSuicide = false;
const int iAttacker = engine->GetPlayerForUserID( event->GetInt( "attacker" ) );
C_TFPlayer* pAttacker = ToTFPlayer( UTIL_PlayerByIndex( iAttacker ) );

const int iVictim = engine->GetPlayerForUserID( event->GetInt( "userid" ) );
C_TFPlayer* pVictim = ToTFPlayer( UTIL_PlayerByIndex( iVictim ) );

if ( !pVictim )
return;
// If attacker can't be found lets treat it as a suicide
if ( !pAttacker || pAttacker->GetTeamNumber() == pVictim->GetTeamNumber() )
{
m_bIsFriendlyFireOrSuicide = true;
}
}
BaseClass::FireGameEvent( event );
}

Expand Down
2 changes: 2 additions & 0 deletions src/game/client/tf/c_tf_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ class C_TFPlayer : public C_BasePlayer, public IHasAttributes, public IInventory
// Called by shared code.
public:
float GetClassChangeTime() const { return m_flChangeClassTime; }
bool IsDeathFriendlyFireOrSuicide() const { return m_bIsFriendlyFireOrSuicide; }
void SetFootStamps( int nFootStamps ) { m_nFootStamps = nFootStamps; }

void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
Expand Down Expand Up @@ -675,6 +676,7 @@ class C_TFPlayer : public C_BasePlayer, public IHasAttributes, public IInventory
bool m_bSaveMeParity;
bool m_bOldSaveMeParity;
bool m_bIsCoaching;
bool m_bIsFriendlyFireOrSuicide;

private:
void UpdateTauntItem();
Expand Down