Template talk:Metrics/Capture return

From Team Fortress Wiki
Revision as of 21:00, 7 February 2013 by Henke37 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

After putting the data provided into Excel, I ran a logarithmic regression and came up with the formula y = 0.9019ln(x) + 0.8738. This matches the data points with a coefficient of determination of R² = 0.9975. I am adding this to the information on the page. Zedadex 23:40, 12 July 2010 (UTC)

Source digging

I dug up the actual code that does the calculations:

/* from CTriggerAreaCapture::CaptureThink in trigger_area_capture.cpp */
// Calculate the amount of modification to the cap time
float flTimeDelta = gpGlobals->curtime - m_flLastReductionTime;
float flReduction = flTimeDelta;
if ( mp_capstyle.GetInt() == 1 )
{
// Diminishing returns for successive players.
for ( int i = 1; i < m_TeamData[m_nTeamInZone].iNumTouching; i++ )
{
flReduction += (flTimeDelta / (float)(i+1));
}
}
m_flLastReductionTime = gpGlobals->curtime;
/* Code removed for clarity in this post */
// Now remove the reduction amount after we've determined there's only 1 team in the area
if ( m_nCapturingTeam == m_nTeamInZone )
{
SetCapTimeRemaining( m_fTimeRemaining - flReduction );
}
else if ( m_nOwningTeam == TEAM_UNASSIGNED && m_nTeamInZone != TEAM_UNASSIGNED )
{
SetCapTimeRemaining( m_fTimeRemaining + flReduction );
}
else
{
// Caps deteriorate over time
if ( TeamplayRoundBasedRules() && m_hPoint && TeamplayRoundBasedRules()->TeamMayCapturePoint(m_nCapturingTeam,m_hPoint->GetPointIndex()) )
{
float flDecrease = (flTotalTimeToCap / mp_capdeteriorate_time.GetFloat()) * flTimeDelta;
if ( TeamplayRoundBasedRules() && TeamplayRoundBasedRules()->InOvertime() )
{
flDecrease *= 6;
}
SetCapTimeRemaining( m_fTimeRemaining + flDecrease );
}
else
{
SetCapTimeRemaining( flTotalTimeToCap );
}
}

Long code short: subtract sum(i=1 to capCount) of deltaTime/i each tick when capturing and add deltaTime/convar(mp_capdeteriorate_time)*(overtime?6:1) when not capturing.

--Henke37 17:39, 3 February 2013 (PST)

Where did you find this? Somewhere in the SDK? --Org 18:44, 4 February 2013 (PST)
trigger_area_capture.cpp is indeed distributed with the sdk. Select to create a new mod and the file will be extracted.--Henke37 13:00, 7 February 2013 (PST)