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
9 changes: 9 additions & 0 deletions src/game/client/tf/c_tf_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7002,6 +7002,15 @@ void C_TFPlayer::UpdateIDTarget()

if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )
{
trace_t trShot;
// use the shot mask to replicate the medigun's trace
UTIL_TraceLine( vecStart, vecEnd, MASK_SHOT, this, COLLISION_GROUP_NONE, &trShot );

if ( trShot.fraction != 1.0 && trShot.m_pEnt && trShot.m_pEnt->IsPlayer() && ( !tr.startsolid || tr.m_pEnt != trShot.m_pEnt ) )
{
tr = trShot;
}

// It's okay to start solid against enemies because we sometimes press right against them
bIsEnemyPlayer = GetTeamNumber() != tr.m_pEnt->GetTeamNumber();
}
Expand Down
29 changes: 22 additions & 7 deletions src/game/shared/tf/tf_weapon_medigun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ void CWeaponMedigun::MaintainTargetInSlot()
pOwner->EyeVectors( &vecAiming );

Vector vecEnd = vecSrc + vecAiming * GetTargetRange();
UTIL_TraceLine( vecSrc, vecEnd, (MASK_SHOT & ~CONTENTS_HITBOX), pOwner, DMG_GENERIC, &tr );
UTIL_TraceLine( vecSrc, vecEnd, (MASK_SHOT & ~CONTENTS_HITBOX), pOwner, COLLISION_GROUP_NONE, &tr );

// Still visible?
if ( tr.m_pEnt == pTarget )
Expand Down Expand Up @@ -729,24 +729,39 @@ void CWeaponMedigun::FindNewTargetForSlot()
// Find a player in range of this player, and make sure they're healable.
Vector vecEnd = vecSrc + vecAiming * GetTargetRange();
trace_t tr;
// for leniency, trace for hull instead of hitboxes first
UTIL_TraceLine( vecSrc, vecEnd, (MASK_SHOT & ~CONTENTS_HITBOX), pOwner, COLLISION_GROUP_NONE, &tr );

UTIL_TraceLine( vecSrc, vecEnd, (MASK_SHOT & ~CONTENTS_HITBOX), pOwner, DMG_GENERIC, &tr );
if ( tr.fraction != 1.0 && tr.m_pEnt )
{
if ( !HealingTarget( tr.m_pEnt ) && AllowedToHealTarget( tr.m_pEnt ) )
CBaseEntity *pTarget = tr.m_pEnt;

// trace again but for hitboxes to help with selecting targets that are clumped together
UTIL_TraceLine( vecSrc, vecEnd, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr );

if ( tr.fraction != 1.0 && tr.m_pEnt && tr.m_pEnt != pTarget && !HealingTarget( tr.m_pEnt ) && AllowedToHealTarget( tr.m_pEnt ) )
{
pTarget = tr.m_pEnt;
}
else if ( HealingTarget( pTarget ) || !AllowedToHealTarget( pTarget ) )
{
pTarget = NULL;
}

if ( pTarget )
{
#ifdef GAME_DLL
pOwner->SpeakConceptIfAllowed( MP_CONCEPT_MEDIC_STARTEDHEALING );
if ( tr.m_pEnt->IsPlayer() )
if ( pTarget->IsPlayer() )
{
CTFPlayer *pTarget = ToTFPlayer( tr.m_pEnt );
pTarget->SpeakConceptIfAllowed( MP_CONCEPT_HEALTARGET_STARTEDHEALING );
CTFPlayer *pTFPlayer = ToTFPlayer( pTarget );
pTFPlayer->SpeakConceptIfAllowed( MP_CONCEPT_HEALTARGET_STARTEDHEALING );
}

// Start the heal target thinking.
SetContextThink( &CWeaponMedigun::HealTargetThink, gpGlobals->curtime, s_pszMedigunHealTargetThink );
#endif
m_hHealingTarget.Set( tr.m_pEnt );
m_hHealingTarget.Set( pTarget );
m_flNextTargetCheckTime = gpGlobals->curtime + 1.0f;
}
}
Expand Down