Difference between revisions of "Template talk:Metrics/Capture return"
m (moved Template talk:Control Point Timing/Decay to Template talk:Metrics/Capture return: Moving the control point rate of return information to the game mechanics area, as well as fixing my original poor choice of title.) |
(→Source digging: new section) |
||
Line 1: | Line 1: | ||
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. [[User:Zedadex|Zedadex]] 23:40, 12 July 2010 (UTC) | 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. [[User:Zedadex|Zedadex]] 23:40, 12 July 2010 (UTC) | ||
+ | |||
+ | == Source digging == | ||
+ | |||
+ | I dug up the actual code that does the calculations: | ||
+ | |||
+ | <tt><code> | ||
+ | : /* 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 ); | ||
+ | : } | ||
+ | : } | ||
+ | </code></tt> | ||
+ | |||
+ | Long code short: subtract sum of deltaTime/(i+1) each tick when capturing and add deltaTime/convar(mp_capdeteriorate_time)*(overtime?6:1) when not capturing. | ||
+ | |||
+ | --[[User:Henke37|Henke37]] 17:27, 3 February 2013 (PST) |
Revision as of 01:27, 4 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 of deltaTime/(i+1) each tick when capturing and add deltaTime/convar(mp_capdeteriorate_time)*(overtime?6:1) when not capturing.
--Henke37 17:27, 3 February 2013 (PST)