Thanks to visit codestin.com
Credit goes to github.com

Skip to content
1 change: 1 addition & 0 deletions src/game/client/c_baseviewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ bool C_BaseViewModel::ShouldFlipViewModel()
{
return pWeapon->m_bFlipViewModel != cl_flipviewmodels.GetBool();
}
return cl_flipviewmodels.GetBool(); // hack for scout ball projeciles to have properly flipped viewmodels
#endif

return false;
Expand Down
1 change: 1 addition & 0 deletions src/game/client/tf/tf_hud_itemeffectmeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ void CHudItemEffectMeter::CreateHudElementsForClass( C_TFPlayer* pPlayer, CUtlVe
}
case TF_CLASS_DEMOMAN:
DECLARE_ITEM_EFFECT_METER( CTFSword, TF_WEAPON_SWORD, false, "resource/UI/HudItemEffectMeter_Demoman.res" );
lambdaAddItemEffectMeter("tf_weapon_stickbomb", true);
break;

case TF_CLASS_SOLDIER:
Expand Down
29 changes: 18 additions & 11 deletions src/game/client/tf/tf_hud_target_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void DisableFloatingHealthCallback( IConVar *var, const char *oldString, float o
pTargetID->InvalidateLayout();
}
}
ConVar tf_hud_target_id_disable_floating_health( "tf_hud_target_id_disable_floating_health", "0", FCVAR_ARCHIVE, "Set to disable floating health bar", DisableFloatingHealthCallback );
ConVar tf_hud_target_id_disable_floating_health( "tf_hud_target_id_disable_floating_health", "0", FCVAR_ARCHIVE, "Set to disable floating health bar. 1 = everyone, 2 = normal players only.", DisableFloatingHealthCallback );
ConVar tf_hud_target_id_alpha( "tf_hud_target_id_alpha", "100", FCVAR_ARCHIVE, "Alpha value of target id background, default 100" );
ConVar tf_hud_target_id_offset( "tf_hud_target_id_offset", "0", FCVAR_ARCHIVE, "RES file Y offset for target id" );
ConVar tf_hud_target_id_show_avatars( "tf_hud_target_id_show_avatars", "1", FCVAR_ARCHIVE, "Display Steam avatars on TargetID when using floating health icons. 1 = everyone, 2 = friends only." );
Expand All @@ -80,15 +80,17 @@ bool ShouldHealthBarBeVisible( CBaseEntity *pTarget, CTFPlayer *pLocalPlayer )
if ( !pTarget || !pLocalPlayer )
return false;

if ( tf_hud_target_id_disable_floating_health.GetBool() )
return false;

if ( pTarget->IsHealthBarVisible() )
// now second in priority to force floating health bars on for giant robots in MvM, robot destruction NPCs, and any custom game logic that forces the mini boss flag on players
// regardless of setting due to entities that return this check as true typically not having a visible target ID to fall back to when tf_hud_target_id_disable_floating_health is 1.
if ( pTarget->IsHealthBarVisible() && tf_hud_target_id_disable_floating_health.GetInt() != 1 )
return true;

if ( tf_hud_target_id_disable_floating_health.GetBool() )
return false;

if ( !pTarget->IsPlayer() )
return false;

int iHideEnemyHealth = 0;
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( pLocalPlayer, iHideEnemyHealth, hide_enemy_health );
if ( ( iHideEnemyHealth > 0 ) && !pLocalPlayer->InSameTeam( pTarget ) )
Expand Down Expand Up @@ -475,7 +477,8 @@ bool CTargetID::IsValidIDTarget( int nEntIndex, float flOldTargetRetainFOV, floa

//Recreate the floating health icon if there isn't one, we're not a spectator, and
// we're not a spy or this was a robot from Robot Destruction-Mode
if ( !m_pFloatingHealthIcon && !bSpectator && ( !bSpy || bHealthBarVisible ) && !DrawHealthIcon() )
// force render floating health icon if it's a player miniboss or RD robot.
if ( !m_pFloatingHealthIcon && !bSpectator && ( !bSpy || bHealthBarVisible ) && ( !DrawHealthIcon() || pEnt->IsHealthBarVisible() && tf_hud_target_id_disable_floating_health.GetInt() != 1 ) )
{
m_pFloatingHealthIcon = CFloatingHealthIcon::AddFloatingHealthIcon( pEnt );
}
Expand Down Expand Up @@ -794,21 +797,25 @@ void CTargetID::UpdateID( void )
}
}

// Remove redundant class checks in favor for the attribute itself,
// and remove second enemy disguised spy check
// This allows for better support ith the see_enemy_health attribute on
// all classes.
bool bInSameTeam = pLocalTFPlayer->InSameDisguisedTeam( pEnt );
bool bSpy = pLocalTFPlayer->IsPlayerClass( TF_CLASS_SPY );
bool bMedic = pLocalTFPlayer->IsPlayerClass( TF_CLASS_MEDIC );
bool bHeavy = pLocalTFPlayer->IsPlayerClass( TF_CLASS_HEAVYWEAPONS );
int iSeeEnemyHealth = 0;
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( pLocalTFPlayer, iSeeEnemyHealth, see_enemy_health )

// See if the player wants to fill in the data string
bool bIsAmmoData = false;
bool bIsKillStreakData = false;
pPlayer->GetTargetIDDataString( bDisguisedTarget, sDataString, sizeof(sDataString), bIsAmmoData, bIsKillStreakData );
if ( pLocalTFPlayer->GetTeamNumber() == TEAM_SPECTATOR || bInSameTeam || bSpy || bDisguisedEnemy || bMedic || bHeavy )
if ( pLocalTFPlayer->GetTeamNumber() == TEAM_SPECTATOR || bInSameTeam )
{
printFormatString = "#TF_playerid_sameteam";
bShowHealth = true;
}
else if ( pLocalTFPlayer->m_Shared.GetState() == TF_STATE_DYING )
else if ( bSpy || iSeeEnemyHealth || pLocalTFPlayer->m_Shared.GetState() == TF_STATE_DYING )
{
// We're looking at an enemy who killed us.
printFormatString = "#TF_playerid_diffteam";
Expand Down
17 changes: 11 additions & 6 deletions src/game/server/tf/tf_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "tf_weapon_wrench.h"
#include "tf_weapon_grenade_pipebomb.h"
#include "tf_weapon_builder.h"
#include "tf_objective_resource.h"

#include "player_vs_environment/tf_population_manager.h"

Expand Down Expand Up @@ -3105,15 +3106,19 @@ void CBaseObject::UpgradeThink( void )
//-----------------------------------------------------------------------------
// Purpose: Handles health upgrade for objects we've already built
//-----------------------------------------------------------------------------
void CBaseObject::ApplyHealthUpgrade( void )
void CBaseObject::ApplyHealthUpgrade(void)
{
CTFPlayer *pTFPlayer = GetOwner();
if ( !pTFPlayer )
CTFPlayer* pTFPlayer = GetOwner();
if (!pTFPlayer)
return;

int iHealth = GetMaxHealthForCurrentLevel();
SetMaxHealth( iHealth );
SetHealth( iHealth );
int iMaxHealth = GetMaxHealthForCurrentLevel();
SetMaxHealth(iMaxHealth);
// set health up (or down) to max only between waves in MvM,
// or if current health would end up higher than max health (possible via "unbuying" the building health upgrade).
// fixes "infinite" building health exploit in both cases
if (TFObjectiveResource() && !TFObjectiveResource()->GetMannVsMachineIsBetweenWaves() || GetHealth() > iMaxHealth)
SetHealth(iMaxHealth);

//DevMsg( "%i\n", GetMaxHealth() );
}
Expand Down
65 changes: 62 additions & 3 deletions src/game/server/tf/tf_projectile_arrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,70 @@ void CTFProjectile_Arrow::ArrowTouch( CBaseEntity *pOther )
if ( m_bStruckEnemy || (GetMoveType() == MOVETYPE_NONE) )
return;

if ( !pOther )
if (!pOther)
return;

bool bShield = pOther->IsCombatItem() && !InSameTeam( pOther );
CTFPumpkinBomb *pPumpkinBomb = dynamic_cast< CTFPumpkinBomb * >( pOther );
// Used when checking against things like FUNC_BRUSHES.
// Copied from CTFProjectile_EnergyRing::ProjectileTouch(),
// but it's needed for penetrating arrows so this will only run when m_bPenetrate is true.
if (m_bPenetrate && !pOther->IsWorld() && pOther->GetSolid() == SOLID_VPHYSICS)
{
const trace_t* pTrace = &CBaseEntity::GetTouchTrace();
CPhysCollide* pTriggerCollide = modelinfo->GetVCollide(GetModelIndex())->solids[0];
Assert(pTriggerCollide);

CUtlVector<collidelist_t> collideList;
IPhysicsObject* pList[VPHYSICS_MAX_OBJECT_LIST_COUNT];
int physicsCount = pOther->VPhysicsGetObjectList(pList, ARRAYSIZE(pList));
vcollide_t* pVCollide = modelinfo->GetVCollide(pOther->GetModelIndex());

if (physicsCount)
{
for (int i = 0; i < physicsCount; i++)
{
const CPhysCollide* pCollide = pList[i]->GetCollide();
if (pCollide)
{
collidelist_t element;
element.pCollide = pCollide;
pList[i]->GetPosition(&element.origin, &element.angles);
collideList.AddToTail(element);
}
}
}
else if (pVCollide && pVCollide->solidCount)
{
collidelist_t element;
element.pCollide = pVCollide->solids[0];
element.origin = pOther->GetAbsOrigin();
element.angles = pOther->GetAbsAngles();
collideList.AddToTail(element);
}
else
{
return;
}

for (int i = collideList.Count() - 1; i >= 0; --i)
{
const collidelist_t& element = collideList[i];
trace_t tr;
physcollision->TraceCollide(pTrace->startpos, element.origin, element.pCollide, element.angles, pTriggerCollide, GetAbsOrigin(), GetAbsAngles(), &tr);
if (!tr.DidHit())
return;
}
if (!pOther->IsSolid() ||
pOther->IsSolidFlagSet(FSOLID_VOLUME_CONTENTS) ||
(pOther->GetCollisionGroup() == TFCOLLISION_GROUP_RESPAWNROOMS) ||
pOther->IsFuncLOD() ||
pOther->GetFlags() & FL_WORLDBRUSH)
{
return;
}
}

bool bShield = pOther->IsCombatItem() && !InSameTeam(pOther);
CTFPumpkinBomb* pPumpkinBomb = dynamic_cast<CTFPumpkinBomb*>(pOther);

if ( pOther->IsSolidFlagSet( FSOLID_TRIGGER | FSOLID_VOLUME_CONTENTS ) && !pPumpkinBomb && !bShield )
return;
Expand Down
11 changes: 7 additions & 4 deletions src/game/shared/tf/halloween/tf_weapon_spellbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,14 +939,14 @@ void CTFSpellBook::TossJarThink( void )
Vector vecForward, vecRight, vecUp;
AngleVectors( pPlayer->EyeAngles(), &vecForward, &vecRight, &vecUp );

float fRight = 8.f;
float fRight = 7.f;
if ( IsViewModelFlipped() )
{
fRight *= -1;
}
Vector vecSrc = pPlayer->Weapon_ShootPosition();
// Make spell toss position at the hand
vecSrc = vecSrc + (vecUp * -9.0f) + (vecRight * 7.0f) + (vecForward * 3.0f);
vecSrc = vecSrc + (vecUp * -9.0f) + (vecRight * fRight) + (vecForward * 3.0f);

Vector vecVelocity = GetVelocityVector( vecForward, vecRight, vecUp ) * pSpellData->m_flSpeedScale;
QAngle angForward = pPlayer->EyeAngles();
Expand Down Expand Up @@ -1417,6 +1417,7 @@ bool CTFSpellBook::CastRocketJump( CTFPlayer *pPlayer )
CTakeDamageInfo info;
info.SetAttacker( pPlayer );
info.SetInflictor( pPlayer );
info.SetWeapon( pPlayer->GetActiveWeapon() );
info.SetDamage( 20.f );
info.SetDamageCustom( TF_DMG_CUSTOM_SPELL_BLASTJUMP );
info.SetDamagePosition( origin );
Expand Down Expand Up @@ -1716,6 +1717,8 @@ class CTFProjectile_SpellFireball : public CTFProjectile_Rocket
if ( pBaseTarget->GetTeamNumber() == GetTeamNumber() )
return;

CBaseEntity* pInflictor = GetLauncher();

if ( pTarget )
{
if ( pTarget->m_Shared.IsInvulnerable() )
Expand All @@ -1724,13 +1727,13 @@ class CTFProjectile_SpellFireball : public CTFProjectile_Rocket
if ( pTarget->m_Shared.InCond( TF_COND_PHASE ) || pTarget->m_Shared.InCond( TF_COND_PASSTIME_INTERCEPTION ) )
return;

pTarget->m_Shared.SelfBurn( 5.0f );
// self burn from an enemy projectile just feels wrong. credit the damager properly
pTarget->m_Shared.Burn( pThrower, dynamic_cast<CTFWeaponBase*>( pInflictor ), 5.0f );
}

const trace_t *pTrace = &CBaseEntity::GetTouchTrace();
trace_t *pNewTrace = const_cast<trace_t*>( pTrace );

CBaseEntity *pInflictor = GetLauncher();
CTakeDamageInfo info;
info.SetAttacker( pThrower );
info.SetInflictor( this );
Expand Down
22 changes: 12 additions & 10 deletions src/game/shared/tf/tf_dropped_weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,19 +572,21 @@ void CTFDroppedWeapon::InitDroppedWeapon( CTFPlayer *pPlayer, CTFWeaponBase *pWe
}
}

if ( bIsSuicide )
{
m_flChargeLevel = 0.f;
}
else

CWeaponMedigun* pMedigun = dynamic_cast<CWeaponMedigun*>(pWeapon);
if (pMedigun)
{
CWeaponMedigun *pMedigun = dynamic_cast< CWeaponMedigun* >( pWeapon );
if ( pMedigun )
SetBodygroup(1, 1); // previously from when weapons were ammo boxes- removes medigun hose
if (bIsSuicide)
{
m_flChargeLevel = 0.f;
}
else
{
m_flChargeLevel.Set( pMedigun->GetChargeLevel() );
if ( m_flChargeLevel > 0.f )
m_flChargeLevel.Set(pMedigun->GetChargeLevel());
if (m_flChargeLevel > 0.f)
{
SetContextThink( &CTFDroppedWeapon::ChargeLevelDegradeThink, gpGlobals->curtime + 0.1f, "ChargeLevelDegradeThink" );
SetContextThink(&CTFDroppedWeapon::ChargeLevelDegradeThink, gpGlobals->curtime + 0.1f, "ChargeLevelDegradeThink");
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/game/shared/tf/tf_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5679,7 +5679,8 @@ void CTFGameRules::RadiusDamage( CTFRadiusDamageInfo &info )
//-----------------------------------------------------------------------------
void CTFRadiusDamageInfo::CalculateFalloff( void )
{
if ( dmgInfo->GetDamageType() & DMG_RADIUS_MAX )
// hack to ignore caber explosion, otherwise the charge minicrit explosion would actually do less damage
if (dmgInfo->GetDamageCustom() != TF_DMG_CUSTOM_STICKBOMB_EXPLOSION && dmgInfo->GetDamageType() & DMG_RADIUS_MAX)
flFalloff = 0.f;
else if ( dmgInfo->GetDamageType() & DMG_HALF_FALLOFF )
flFalloff = 0.5f;
Expand Down Expand Up @@ -6532,6 +6533,10 @@ bool CTFGameRules::ApplyOnDamageModifyRules( CTakeDamageInfo &info, CBaseEntity
int iForceCritDmgFalloff = 0;
CALL_ATTRIB_HOOK_INT_ON_OTHER( pWeapon, iForceCritDmgFalloff, crit_dmg_falloff );

// Move this higher to fix the lack of minicrit rampup damage upon being crit boosted.
int iDemoteCritToMinicrit = 0;
CALL_ATTRIB_HOOK_INT_ON_OTHER( pWeapon, iDemoteCritToMinicrit, crits_become_minicrits );

#ifdef MCOMS_BALANCE_PACK
// SMG headshots falloff
if ( pWeapon && pWeapon->GetWeaponID() == TF_WEAPON_SMG )
Expand All @@ -6551,7 +6556,7 @@ bool CTFGameRules::ApplyOnDamageModifyRules( CTakeDamageInfo &info, CBaseEntity
( ( bCrit && tf_weapon_criticals_distance_falloff.GetBool() ) ||
( info.GetCritType() == CTakeDamageInfo::CRIT_MINI && tf_weapon_minicrits_distance_falloff.GetBool() ) ||
( iForceCritDmgFalloff ) );
bool bDoShortRangeDistanceIncrease = !bCrit || info.GetCritType() == CTakeDamageInfo::CRIT_MINI ;
bool bDoShortRangeDistanceIncrease = !bCrit || iDemoteCritToMinicrit != 0 || info.GetCritType() == CTakeDamageInfo::CRIT_MINI ;
bool bDoLongRangeDistanceDecrease = !bIgnoreLongRangeDmgEffects && ( bForceCritFalloff || ( !bCrit && info.GetCritType() != CTakeDamageInfo::CRIT_MINI ) );

// If we're doing any distance modification, we need to do that first
Expand Down Expand Up @@ -6781,8 +6786,6 @@ bool CTFGameRules::ApplyOnDamageModifyRules( CTakeDamageInfo &info, CBaseEntity
}
else if ( bCrit )
{
int iDemoteCritToMinicrit = 0;
CALL_ATTRIB_HOOK_INT_ON_OTHER( pWeapon, iDemoteCritToMinicrit, crits_become_minicrits );
if ( iDemoteCritToMinicrit != 0 )
{
bitsDamage &= ~DMG_CRITICAL; // this is to shutup the assert in lambdaDoMinicrit
Expand Down
28 changes: 28 additions & 0 deletions src/game/shared/tf/tf_item_wearable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,34 @@ ShadowType_t CTFWearableVM::ShadowCastType( void )

return SHADOWS_RENDER_TO_TEXTURE;
}

//-----------------------------------------------------------------------------
// Purpose:
// Allow botkiller attachments and server mod viewmodel VMs to properly flip with the player's weapon.
//-----------------------------------------------------------------------------
int CTFWearableVM::InternalDrawModel(int flags)
{
C_TFPlayer* pOwner = ToTFPlayer(GetOwnerEntity());

CMatRenderContextPtr pRenderContext(materials);

if (pOwner)
{
CTFWeaponBase* pWpn = pOwner->GetActiveTFWeapon();

if (pWpn)
{
if (pWpn->IsViewModelFlipped())
pRenderContext->CullMode(MATERIAL_CULLMODE_CW);
}
}

int ret = BaseClass::InternalDrawModel(flags);

pRenderContext->CullMode(MATERIAL_CULLMODE_CCW);

return ret;
}
#endif


2 changes: 2 additions & 0 deletions src/game/shared/tf/tf_item_wearable.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class CTFWearableVM : public CTFWearable

#if defined( CLIENT_DLL )
virtual ShadowType_t ShadowCastType( void );

virtual int InternalDrawModel(int flags);
#endif
};

Expand Down
1 change: 1 addition & 0 deletions src/game/shared/tf/tf_projectile_dragons_fury.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class CTFProjectile_BallOfFire : public CTFProjectile_Rocket
pOther->IsSolidFlagSet( FSOLID_NOT_SOLID ) ||
( pOther->GetCollisionGroup() == TFCOLLISION_GROUP_RESPAWNROOMS ) ||
pOther->IsFuncLOD() ||
// pOther->GetFlags() & FL_WORLDBRUSH && !pOther->IsWorld() || // hack for func_brushes
pOther->IsBaseProjectile() )
{
return;
Expand Down
6 changes: 4 additions & 2 deletions src/game/shared/tf/tf_projectile_energy_ring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ void CTFProjectile_EnergyRing::ProjectileTouch( CBaseEntity *pOther )
!pOther->IsSolid() ||
pOther->IsSolidFlagSet( FSOLID_VOLUME_CONTENTS ) ||
( pOther->GetCollisionGroup() == TFCOLLISION_GROUP_RESPAWNROOMS ) ||
pOther->IsFuncLOD() )
pOther->IsFuncLOD() ||
pOther->GetFlags() & FL_WORLDBRUSH) // Hack for func_brushes
{
return;
}
Expand Down Expand Up @@ -257,7 +258,8 @@ void CTFProjectile_EnergyRing::ProjectileTouch( CBaseEntity *pOther )
if ( bCombatEntity )
{
// Bison projectiles shouldn't collide with friendly things
if ( ShouldPenetrate() && ( pOther->InSameTeam( this ) || ( gpGlobals->curtime - m_flLastHitTime ) < tf_bison_tick_time.GetFloat() ) )
// Pomson projectiles shouldn't collide with nearby teammates
if ( ( ShouldPenetrate() || !CanCollideWithTeammates() ) && ( pOther->InSameTeam( this ) || ( gpGlobals->curtime - m_flLastHitTime ) < tf_bison_tick_time.GetFloat() ) )
return;

m_flLastHitTime = gpGlobals->curtime;
Expand Down
Loading