Skip to content

Commit

Permalink
Add custom OOB timer per level scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Zanieon committed Nov 24, 2024
1 parent 2fa37b4 commit 9a6295c
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function BaseGametype_Init()
level.titanAlwaysAvailableForTeam <- [ 0, 0, 0, 0 ]

level.missingPlayersTimeout <- null
level.customOOBTimer <- 0.0

CreateTeamColorControlPoints()

Expand Down Expand Up @@ -1792,10 +1793,14 @@ void function EntityOutOfBounds( entity trigger, entity ent, entity caller, var

//printt( "Valid Out OfBounds Entity, EntityOutOfBounds" )

float overridenOOBTimer = expect float( level.customOOBTimer )
if ( !(ent in file.outOfBoundsTable) ) //Note that we never remove the ent from the table after adding it
{
OutOfBoundsDataStruct initialDataStruct
initialDataStruct.timeBackInBound = max( 0, Time() - OUT_OF_BOUNDS_DECAY_TIME )

if( overridenOOBTimer > 0.0 )
initialDataStruct.timeLeftBeforeDyingFromOutOfBounds = overridenOOBTimer

ManageAddEntToOutOfBoundsTable( ent, initialDataStruct )
}
Expand All @@ -1813,6 +1818,12 @@ void function EntityOutOfBounds( entity trigger, entity ent, entity caller, var
float outOfBoundsTimeRegained = decayTime * ( OUT_OF_BOUNDS_TIME_LIMIT / OUT_OF_BOUNDS_DECAY_TIME )
float deadTime = clamp( dataStruct.timeLeftBeforeDyingFromOutOfBounds + outOfBoundsTimeRegained, 0.0, OUT_OF_BOUNDS_TIME_LIMIT )

if( overridenOOBTimer > 0.0 )
{
outOfBoundsTimeRegained = decayTime * ( overridenOOBTimer / OUT_OF_BOUNDS_DECAY_TIME )
deadTime = clamp( dataStruct.timeLeftBeforeDyingFromOutOfBounds + outOfBoundsTimeRegained, 0.0, overridenOOBTimer )
}

//printt( "Decay Time: " + decayTime + ", outOfBoundsTimeRegained:" + outOfBoundsTimeRegained + ", timeLeftBeforeDyingFromOutOfBounds: " + dataStruct.timeLeftBeforeDyingFromOutOfBounds + ", deadTime: " + deadTime )

dataStruct.timeLeftBeforeDyingFromOutOfBounds = deadTime
Expand Down

0 comments on commit 9a6295c

Please sign in to comment.