Difference between revisions of "Template talk:Metrics/Capture return"
(→Source digging: new section) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 50: | Line 50: | ||
</code></tt> | </code></tt> | ||
− | Long code short: subtract sum of deltaTime/ | + | Long code short: subtract sum(<var>i</var>=1 to <var>capCount</var>) of <var>deltaTime</var>/<var>i</var> each tick when capturing and add <var>deltaTime</var>/convar(<code><var>mp_capdeteriorate_time</var></code>)*(<var>overtime</var>?6:1) when not capturing. |
− | --[[User:Henke37|Henke37]] 17: | + | --[[User:Henke37|Henke37]] 17:39, 3 February 2013 (PST) |
+ | :Where did you find this? Somewhere in the SDK? --[[User:Org|Org]] 18:44, 4 February 2013 (PST) | ||
+ | :: <tt>trigger_area_capture.cpp</tt> is indeed distributed with the sdk. Select to create a new mod and the file will be extracted.--[[User:Henke37|Henke37]] 13:00, 7 February 2013 (PST) |
Latest revision as of 21:00, 7 February 2013
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)