Skip to content

Commit 1292d25

Browse files
committed
gameplay: fix reflect bugs and related projectile bugs
This was a doozy. I tried scanning through the codebase for all usages and interactions to make sure everything was working properly, and also tested the interactions. * Fix reflected sandman balls not dealing damage * Fix reflected ornament not dealing damage/bleed properly * Fix Scout playing hit/miss voicelines on reflected balls * Fix some projectile's lifetime not being tied to the reflector * Fix reflected rescue ranger not healing buildings * Fix reflected flares not exhibiting their correct properties * Fix reflected flares and sticky bombs lifetimes not being tracked properly * Fix projectiles not using the correct team color when reflected * Fix reflected air strike not showing the correct particles * Fix reflected sentry rockets causing flamethrower sound * Fix reflected projectiles not dealing correct damage * Fix reflected projectiles not having correct radius * Fix reflected projectiles not having correct speed in some cases * Fix reflected projectiles not contributing to buildings destroyed strange part * Fix reflected cannonballs not double donking * Fix sentry rockets/bullets not contributing to buildings destroyed strange part * Fix reflected bow having incorrect push force and other effects * Fix reflected projectiles not using the correct spells * Fix enemy Snipers receiving extinguish bonus from reflected Jarate * Fix kill icons for reflected ball, cleaver, flares, arrow headshot burning arrow, burning arrow headshot ref: https://www.youtube.com/watch?v=EDsDnR2dzlw ref: https://www.youtube.com/watch?v=NxeljS6GE9g ref: ValveSoftware/Source-1-Games#4298 ref: ValveSoftware/Source-1-Games#4171 ref: ValveSoftware/Source-1-Games#3368 ref: ValveSoftware/Source-1-Games#3292
1 parent 2bc76a4 commit 1292d25

22 files changed

+218
-142
lines changed

src/game/client/tf/c_tf_projectile_flare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void C_TFProjectile_Flare::CreateTrails( void )
9898

9999
int nType = 0;
100100

101-
C_TFFlareGun *pFlareGun = dynamic_cast< C_TFFlareGun* >( GetLauncher() );
101+
C_TFFlareGun *pFlareGun = dynamic_cast< C_TFFlareGun* >( GetOriginalLauncher() );
102102
if ( pFlareGun )
103103
{
104104
nType = pFlareGun->GetFlareGunType();

src/game/client/tf/c_tf_projectile_rocket.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void C_TFProjectile_Rocket::CreateTrails( void )
7777
// Halloween Spell Effect Check
7878
int iHalloweenSpell = 0;
7979
// if the owner is a Sentry, Check its owner
80-
CBaseObject *pSentry = GetOwnerEntity() && GetOwnerEntity()->IsBaseObject() ? assert_cast<CBaseObject*>( GetOwnerEntity() ) : NULL;
80+
CBaseObject *pSentry = GetOriginalLauncher() && GetOriginalLauncher()->IsBaseObject() ? assert_cast<CBaseObject*>( GetOriginalLauncher() ) : NULL;
8181
if ( TF_IsHolidayActive( kHoliday_HalloweenOrFullMoon ) || true )
8282
{
8383
if ( pSentry )
@@ -86,7 +86,7 @@ void C_TFProjectile_Rocket::CreateTrails( void )
8686
}
8787
else
8888
{
89-
CALL_ATTRIB_HOOK_INT_ON_OTHER( GetOwnerEntity(), iHalloweenSpell, halloween_pumpkin_explosions );
89+
CALL_ATTRIB_HOOK_INT_ON_OTHER( GetOriginalLauncher(), iHalloweenSpell, halloween_pumpkin_explosions );
9090
}
9191
}
9292

@@ -98,10 +98,10 @@ void C_TFProjectile_Rocket::CreateTrails( void )
9898
}
9999
else if ( !pSentry )
100100
{
101-
if ( GetLauncher() )
101+
if ( GetOriginalLauncher() )
102102
{
103103
int iMiniRocket = 0;
104-
CALL_ATTRIB_HOOK_INT_ON_OTHER( GetLauncher(), iMiniRocket, mini_rockets );
104+
CALL_ATTRIB_HOOK_INT_ON_OTHER( GetOriginalLauncher(), iMiniRocket, mini_rockets );
105105
if ( iMiniRocket )
106106
{
107107
ParticleProp()->Create( "rockettrail_airstrike", PATTACH_POINT_FOLLOW, iAttachment );

src/game/client/tf/hud_basedeathnotice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ struct DeathNoticeItem
5454

5555
DeathNoticePlayer Killer;
5656
DeathNoticePlayer Victim;
57-
char szIcon[32]; // name of icon to display
57+
char szIcon[64]; // name of icon to display
5858
wchar_t wzInfoText[32]; // any additional text to display next to icon
5959
wchar_t wzInfoTextEnd[32]; // any additional text to display next to victim name
6060
CHudTexture *iconDeath;

src/game/client/tf/tf_hud_deathnotice.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,18 @@ void CTFHudDeathNotice::OnGameEvent( IGameEvent *event, int iDeathNoticeMsg )
993993
{
994994
Q_strncpy( msg.szIcon, "d_huntsman_headshot", ARRAYSIZE( msg.szIcon ) );
995995
}
996+
else if ( FStrEq( event->GetString( "weapon" ), "huntsman_flyingburn" ) )
997+
{
998+
Q_strncpy( msg.szIcon, "d_huntsman_flyingburn_headshot", ARRAYSIZE( msg.szIcon ) );
999+
}
1000+
else if ( FStrEq( event->GetString( "weapon" ), "deflect_arrow" ) )
1001+
{
1002+
Q_strncpy( msg.szIcon, "d_deflect_huntsman_headshot", ARRAYSIZE( msg.szIcon ) );
1003+
}
1004+
else if ( FStrEq( event->GetString( "weapon" ), "deflect_huntsman_flyingburn" ) )
1005+
{
1006+
Q_strncpy( msg.szIcon, "d_deflect_huntsman_flyingburn_headshot", ARRAYSIZE( msg.szIcon ) );
1007+
}
9961008
else
9971009
{
9981010
// Did this headshot penetrate something before the kill? If so, show a fancy icon
@@ -1026,7 +1038,7 @@ void CTFHudDeathNotice::OnGameEvent( IGameEvent *event, int iDeathNoticeMsg )
10261038

10271039
case TF_DMG_CUSTOM_FLYINGBURN:
10281040
// special-case if the player is killed from a burning arrow as the killing blow
1029-
Q_strncpy( msg.szIcon, "d_huntsman_flyingburn", ARRAYSIZE( msg.szIcon ) );
1041+
Q_strncpy( msg.szIcon, FStrEq( event->GetString( "weapon" ), "deflect_huntsman_flyingburn" ) ? "d_deflect_huntsman_flyingburn" : "d_huntsman_flyingburn", ARRAYSIZE( msg.szIcon ) );
10301042
msg.wzInfoText[0] = 0;
10311043
break;
10321044

src/game/server/tf/tf_obj.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,11 +2469,16 @@ void CBaseObject::Killed( const CTakeDamageInfo &info )
24692469
Explode();
24702470
}
24712471

2472-
// Stats tracking for strange items.
2473-
EconEntity_OnOwnerKillEaterEvent( dynamic_cast<CEconEntity *>( info.GetWeapon() ),
2474-
pScorer,
2475-
GetOwner(),
2476-
kKillEaterEvent_BuildingDestroyed );
2472+
CTFWeaponBase *pTFWeapon = GetKilleaterWeaponFromDamageInfo( &info );
2473+
2474+
if ( pTFWeapon )
2475+
{
2476+
// Stats tracking for strange items.
2477+
EconEntity_OnOwnerKillEaterEvent( pTFWeapon,
2478+
pScorer,
2479+
GetOwner(),
2480+
kKillEaterEvent_BuildingDestroyed );
2481+
}
24772482

24782483
UTIL_Remove( this );
24792484
}

src/game/server/tf/tf_obj_sentrygun.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,7 @@ bool CObjectSentrygun::FireRocket()
13591359
CTFProjectile_SentryRocket *pProjectile = CTFProjectile_SentryRocket::Create( vecSrc, angAimDir, this, GetBuilder() );
13601360
if ( pProjectile )
13611361
{
1362+
pProjectile->SetLauncher( this );
13621363
int iDamage = 100;
13631364
CALL_ATTRIB_HOOK_INT_ON_OTHER( GetOwner(), iDamage, mult_engy_sentry_damage );
13641365
pProjectile->SetDamage( iDamage );

src/game/server/tf/tf_projectile_arrow.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ bool CTFProjectile_Arrow::StrikeTarget( mstudiobbox_t *pBox, CBaseEntity *pOther
578578
}
579579
}
580580

581-
CTakeDamageInfo info( this, pAttacker, m_hLauncher, vecVelocity, vecOrigin, GetDamage(), nDamageType, nDamageCustom );
581+
CTakeDamageInfo info( this, pAttacker, GetOriginalLauncher(), vecVelocity, vecOrigin, GetDamage(), nDamageType, nDamageCustom );
582582
pOther->TakeDamage( info );
583583

584584
// Play an impact sound.
@@ -714,7 +714,7 @@ void CTFProjectile_Arrow::BuildingHealingArrow( CBaseEntity *pOther )
714714
return;
715715

716716
int iArrowsHealBuildings = 0;
717-
CALL_ATTRIB_HOOK_INT_ON_OTHER( pAttacker, iArrowsHealBuildings, arrow_heals_buildings );
717+
CALL_ATTRIB_HOOK_INT_ON_OTHER( GetOriginalLauncher(), iArrowsHealBuildings, arrow_heals_buildings );
718718
if ( iArrowsHealBuildings == 0 )
719719
return;
720720

@@ -1210,6 +1210,8 @@ void CTFProjectile_Arrow::IncrementDeflected( void )
12101210
m_flTrailLife = 1.0f;
12111211
}
12121212
CreateTrail();
1213+
1214+
m_nSkin = GetArrowSkin();
12131215
}
12141216

12151217
//-----------------------------------------------------------------------------

src/game/server/tf/tf_projectile_energy_ball.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void CTFProjectile_EnergyBall::Explode( trace_t *pTrace, CBaseEntity *pOther )
334334
}
335335
}
336336

337-
CTakeDamageInfo info( this, pAttacker, m_hLauncher, vec3_origin, vecOrigin, GetDamage(), GetDamageType(), GetDamageCustom() );
337+
CTakeDamageInfo info( this, pAttacker, GetOriginalLauncher(), vec3_origin, vecOrigin, GetDamage(), GetDamageType(), GetDamageCustom() );
338338
CTFRadiusDamageInfo radiusinfo( &info, vecOrigin, flRadius, NULL, m_bChargedShot ? TF_ROCKET_RADIUS_FOR_RJS*1.33 : TF_ROCKET_RADIUS_FOR_RJS );
339339
TFGameRules()->RadiusDamage( radiusinfo );
340340
}

src/game/server/tf/tf_projectile_flare.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ void CTFProjectile_Flare::Explode( trace_t *pTrace, CBaseEntity *pOther )
207207

208208
CTFPlayer *pTFVictim = ToTFPlayer( pOther );
209209

210-
CTFFlareGun *pFlareGun = dynamic_cast< CTFFlareGun* >( GetLauncher() );
210+
CBaseEntity *pLauncher = GetOriginalLauncher();
211+
CTFFlareGun *pFlareGun = dynamic_cast< CTFFlareGun* >( pLauncher );
211212
if ( pFlareGun )
212213
{
213214
if ( pFlareGun->GetFlareGunType() == FLAREGUN_SCORCHSHOT )
@@ -228,7 +229,7 @@ void CTFProjectile_Flare::Explode( trace_t *pTrace, CBaseEntity *pOther )
228229
iDamageType |= DMG_PREVENT_PHYSICS_FORCE;
229230

230231
// Damage the player to push them back
231-
CTakeDamageInfo info( this, pAttacker, m_hLauncher, vec3_origin, vecOrigin, GetDamage(), iDamageType, m_bIsFromTaunt ? TF_DMG_CUSTOM_FLARE_PELLET : 0 );
232+
CTakeDamageInfo info( this, pAttacker, pLauncher, vec3_origin, vecOrigin, GetDamage(), iDamageType, m_bIsFromTaunt ? TF_DMG_CUSTOM_FLARE_PELLET : TF_DMG_CUSTOM_BURNING_FLARE );
232233
pTFVictim->TakeDamage( info );
233234

234235
bool bIsEnemy = pAttacker && pTFVictim->GetTeamNumber() != pAttacker->GetTeamNumber();
@@ -329,7 +330,7 @@ void CTFProjectile_Flare::Explode( trace_t *pTrace, CBaseEntity *pOther )
329330
m_bCritical = true;
330331
}
331332

332-
CTakeDamageInfo info( this, pAttacker, m_hLauncher, vec3_origin, vecOrigin, GetDamage(), GetDamageType(), TF_DMG_CUSTOM_BURNING_FLARE );
333+
CTakeDamageInfo info( this, pAttacker, pLauncher, vec3_origin, vecOrigin, GetDamage(), GetDamageType(), TF_DMG_CUSTOM_BURNING_FLARE );
333334
pOther->TakeDamage( info );
334335

335336
// Remove the flare.
@@ -380,7 +381,7 @@ void CTFProjectile_Flare::Explode_Air( trace_t *pTrace, int bitsDamageType, bool
380381
WeaponSound_t nSound = SPECIAL1;
381382
if ( pAttacker )
382383
{
383-
CTFFlareGun *pFlareGun = dynamic_cast<CTFFlareGun*>( ToTFPlayer( pAttacker )->GetActiveWeapon() );
384+
CTFFlareGun *pFlareGun = dynamic_cast<CTFFlareGun*>( GetOriginalLauncher() );
384385
if ( pFlareGun )
385386
{
386387
CEconItemView *pItem = pFlareGun->GetAttributeContainer()->GetItem();
@@ -410,7 +411,7 @@ void CTFProjectile_Flare::Explode_Air( trace_t *pTrace, int bitsDamageType, bool
410411
DrawRadius( flRadius );
411412
}
412413
#endif
413-
CTakeDamageInfo info( this, pAttacker, m_hLauncher, vec3_origin, vecOrigin, GetDamage(), bitsDamageType | DMG_HALF_FALLOFF, TF_DMG_CUSTOM_FLARE_EXPLOSION );
414+
CTakeDamageInfo info( this, pAttacker, GetOriginalLauncher(), vec3_origin, vecOrigin, GetDamage(), bitsDamageType | DMG_HALF_FALLOFF, TF_DMG_CUSTOM_FLARE_EXPLOSION );
414415
CTFRadiusDamageInfo radiusinfo( &info, vecOrigin, flRadius, NULL, TF_FLARE_RADIUS_FOR_FJS );
415416
TFGameRules()->RadiusDamage( radiusinfo );
416417
}
@@ -446,7 +447,7 @@ void CTFProjectile_Flare::Detonate( bool bSelfOnly )
446447
float CTFProjectile_Flare::GetRadius( void )
447448
{
448449
float flRadius = TF_FLARE_DET_RADIUS;
449-
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( m_hLauncher, flRadius, mult_explosion_radius );
450+
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( GetOriginalLauncher(), flRadius, mult_explosion_radius );
450451
return flRadius;
451452
}
452453

@@ -459,7 +460,7 @@ void CTFProjectile_Flare::SendDeathNotice( void )
459460
if ( !pAttacker )
460461
return;
461462

462-
CTFFlareGun *pFlareGun = dynamic_cast<CTFFlareGun*>( ToTFPlayer( pAttacker )->GetActiveWeapon() );
463+
CTFFlareGun *pFlareGun = dynamic_cast<CTFFlareGun*>( GetOriginalLauncher() );
463464
if ( pFlareGun && pFlareGun->GetFlareGunType() == FLAREGUN_DETONATE )
464465
{
465466
pFlareGun->DeathNotice( this );
@@ -606,20 +607,22 @@ void CTFProjectile_Flare::Deflected( CBaseEntity *pDeflectedBy, Vector &vecDir )
606607

607608
IncrementDeflected();
608609
SetScorer( pTFDeflector );
610+
611+
m_nSkin = ( GetTeamNumber() == TF_TEAM_BLUE ) ? 1 : 0;
609612
}
610613

611614
float CTFProjectile_Flare::GetProjectileSpeed( void ) const
612615
{
613616
float flLaunchSpeed = FLARE_SPEED;
614-
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( m_hLauncher, flLaunchSpeed, mult_projectile_speed );
617+
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( GetOriginalLauncher(), flLaunchSpeed, mult_projectile_speed );
615618

616619
return flLaunchSpeed;
617620
}
618621

619622
float CTFProjectile_Flare::GetHeatSeekPower( void ) const
620623
{
621624
float flHeatSeekPower = 0.0;
622-
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( m_hLauncher, flHeatSeekPower, mod_projectile_heat_seek_power );
625+
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( GetOriginalLauncher(), flHeatSeekPower, mod_projectile_heat_seek_power );
623626

624627
return flHeatSeekPower;
625628
}

src/game/shared/baseprojectile.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ IMPLEMENT_NETWORKCLASS_ALIASED( BaseProjectile, DT_BaseProjectile )
1414
BEGIN_NETWORK_TABLE( CBaseProjectile, DT_BaseProjectile )
1515
#if !defined( CLIENT_DLL )
1616
SendPropEHandle( SENDINFO( m_hOriginalLauncher ) ),
17+
SendPropEHandle( SENDINFO( m_hLauncher ) ),
1718
#else
1819
RecvPropEHandle( RECVINFO( m_hOriginalLauncher ) ),
20+
RecvPropEHandle( RECVINFO( m_hLauncher ) ),
1921
#endif // CLIENT_DLL
2022
END_NETWORK_TABLE()
2123

@@ -44,6 +46,8 @@ CBaseProjectile::CBaseProjectile()
4446
//-----------------------------------------------------------------------------
4547
void CBaseProjectile::SetLauncher( CBaseEntity *pLauncher )
4648
{
49+
m_hLauncher = pLauncher;
50+
4751
if ( m_hOriginalLauncher == NULL )
4852
{
4953
m_hOriginalLauncher = pLauncher;

0 commit comments

Comments
 (0)