From 3a823af3a83a6037301e37e67e675e142afde717 Mon Sep 17 00:00:00 2001 From: William Miller Date: Wed, 1 Jan 2025 20:50:14 -0300 Subject: [PATCH] Add custom OOB timer per level scope (#907) Allows mods or custom gamemodes to override the amount of time players can stay in the Out of Bounds areas. --- .../mod/scripts/vscripts/mp/_base_gametype.gnut | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut index 362407b39..7283f318b 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut +++ b/Northstar.CustomServers/mod/scripts/vscripts/mp/_base_gametype.gnut @@ -36,6 +36,7 @@ function BaseGametype_Init() level.titanAlwaysAvailableForTeam <- [ 0, 0, 0, 0 ] level.missingPlayersTimeout <- null + level.customOOBTimer <- 0.0 CreateTeamColorControlPoints() @@ -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 ) } @@ -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