Skip to content

Commit

Permalink
Overhauled the calculation of flamer ff burn duration
Browse files Browse the repository at this point in the history
  • Loading branch information
ModdedMarionette committed Nov 8, 2024
1 parent 512e44a commit 3f3b810
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/game/server/swarm/asw_marine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ BEGIN_DATADESC( CASW_Marine )
DEFINE_FIELD( m_fNextAlienWalkDamage, FIELD_FLOAT ),
DEFINE_FIELD( m_iLightLevel, FIELD_INTEGER ),
DEFINE_FIELD( m_fLastFriendlyFireTime, FIELD_FLOAT ),
DEFINE_FIELD( m_fPrevFriendlyFireTime, FIELD_FLOAT ),
DEFINE_FIELD( m_fLastAmmoCheckTime, FIELD_FLOAT ),
DEFINE_FIELD( m_fFriendlyFireAbsorptionTime, FIELD_FLOAT ),
DEFINE_FIELD( m_vecMeleeStartPos, FIELD_VECTOR ),
Expand Down Expand Up @@ -455,7 +456,7 @@ ConVar asw_marine_burn_time_normal( "asw_marine_burn_time_normal", "8", FCVAR_CH
ConVar asw_marine_burn_time_hard( "asw_marine_burn_time_hard", "12", FCVAR_CHEAT, "Amount of time marine burns for when ignited on hard difficulty" );
ConVar asw_marine_burn_time_insane( "asw_marine_burn_time_insane", "15", FCVAR_CHEAT, "Amount of time marine burns for when ignited on insane difficulty" );
ConVar asw_marine_burn_time_min_fraction( "asw_marine_burn_time_min_fraction", "0.1875", FCVAR_CHEAT, "Minimum fraction of the burn time a marine can be ignited for due to friendly fire protection" );
ConVar asw_marine_burn_time_since_last_ff_scale( "asw_marine_burn_time_since_last_ff_scale", "5", FCVAR_CHEAT, "Number of seconds taken off of the burn time for each second since the last friendly fire incident" );
ConVar asw_marine_burn_time_since_last_ff_scale( "asw_marine_burn_time_since_last_ff_scale", "1.0", FCVAR_CHEAT, "Number of seconds taken off of the burn time for each second since the last friendly fire incident" );
ConVar asw_marine_time_until_ignite_expire( "asw_marine_time_until_ignite_expire", "2.0", FCVAR_CHEAT, "Amount of time until repeated burn damage counter expires" );
ConVar asw_marine_time_until_ignite( "asw_marine_time_until_ignite", "0.7", FCVAR_CHEAT, "Amount of time before a marine ignites from taking repeated burn damage" );
ConVar asw_marine_time_until_ignite_hcff( "asw_marine_time_until_ignite_hcff", "0.2", FCVAR_CHEAT, "Amount of time before a marine ignites from taking repeated burn damage (hardcore ff)" );
Expand Down Expand Up @@ -1453,6 +1454,7 @@ int CASW_Marine::OnTakeDamage_Alive( const CTakeDamageInfo &info )
if ( rd_chatter_about_ff.GetBool() && !bFlamerDot )
GetMarineSpeech()->QueueChatter( CHATTER_FRIENDLY_FIRE, gpGlobals->curtime + 0.4f, gpGlobals->curtime + 1.0f );

m_fPrevFriendlyFireTime = m_fLastFriendlyFireTime;
m_fLastFriendlyFireTime = gpGlobals->curtime;
}
}
Expand Down Expand Up @@ -5070,7 +5072,15 @@ void CASW_Marine::ASW_Ignite( float flFlameLifetime, float flSize, CBaseEntity *
// Mari: special scaling for flamer ff
if ( asw_marine_ff_absorption.GetInt() > 0 && bFriendlyFire && pDamagingWeapon && pDamagingWeapon->Classify() == CLASS_ASW_FLAMER )
{
flFlameLifetime = MAX( flFlameLifetime * asw_marine_burn_time_min_fraction.GetFloat(), MIN( flFlameLifetime * m_fFriendlyFireAbsorptionTime, flFlameLifetime + ( m_fLastFriendlyFireTime - gpGlobals->curtime ) * asw_marine_burn_time_since_last_ff_scale.GetFloat() ) );
float flMinTime = flFlameLifetime * asw_marine_burn_time_min_fraction.GetFloat();

// Scaling the burn duration based on the frequency of friendly fire
// This calculation relies on the fact that it takes place after m_fLastFriendlyFireTime is already set to the time of the newest ff incident
// which makes it impossible to calculate the time since last ff incident
// Otherwise this would be used instead: ( gpGlobals->curtime - m_fLastFriendlyFireTime )
float flFlameLifetimeScaled = flFlameLifetime - ( m_fLastFriendlyFireTime - m_fPrevFriendlyFireTime ) * asw_marine_burn_time_since_last_ff_scale.GetFloat();

flFlameLifetime = MAX ( flMinTime, flFlameLifetimeScaled );
}

// if this is an env_fire trying to burn us, ignore the grace period that the AllowedToIgnite function does
Expand Down
1 change: 1 addition & 0 deletions src/game/server/swarm/asw_marine.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ class CASW_Marine : public CASW_VPhysics_NPC, public IASWPlayerAnimStateHelpers,
virtual void ActivateFriendlyFireGuard(CASW_Marine *pVictim);
virtual float GetFFAbsorptionScale();
float m_fLastFriendlyFireTime;
float m_fPrevFriendlyFireTime;
float m_fFriendlyFireAbsorptionTime; // timer for friendly fire damage
float m_fLastAmmoCheckTime;
bool m_bDoneWoundedRebuke;
Expand Down

0 comments on commit 3f3b810

Please sign in to comment.