Skip to content

Commit

Permalink
Add custom OOB timer per level scope (#907)
Browse files Browse the repository at this point in the history
Allows mods or custom gamemodes to override the amount of time players can stay in the Out of Bounds areas.
  • Loading branch information
Zanieon authored Jan 1, 2025
1 parent 037760a commit 3a823af
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 3a823af

Please sign in to comment.