From 9e87ca02a076b8be6e62a4ea315cc8d0f3ea6b6c Mon Sep 17 00:00:00 2001 From: ChocoTaco Date: Fri, 24 Mar 2023 13:28:19 -0400 Subject: [PATCH] Flag Ceiling fix --- Classic/scripts/autoexec/flagTunnelingFix.cs | 16 +++++++++++++++- Classic/scripts/supportClassic.cs | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Classic/scripts/autoexec/flagTunnelingFix.cs b/Classic/scripts/autoexec/flagTunnelingFix.cs index 69e2393..04c875e 100644 --- a/Classic/scripts/autoexec/flagTunnelingFix.cs +++ b/Classic/scripts/autoexec/flagTunnelingFix.cs @@ -5,7 +5,7 @@ $flagSimTime = 60;//note a higher the time, the larger the sweep scans will be $flagCheckRadius = 50; $playerBoxA = "-0.6 -0.6 0"; $playerBoxB = "0.6 0.6 2.3"; - +$flagStuckTime = 1000; package flagFix{ function CTFGame::startFlagCollisionSearch(%game, %flag){ parent::startFlagCollisionSearch(%game, %flag); @@ -35,6 +35,7 @@ package flagFix{ if(!isEventPending(Game.flagLoop)){ %game.atHomeFlagLoop(); } + %game.fcs = getSimTime(); } function SCtFGame::startMatch(%game){ @@ -56,6 +57,19 @@ package flagFix{ activatePackage(flagFix); function DefaultGame::flagColTest(%game, %flag){ + if( !%flag.isHome ){// keeps flags from getting stuck in ceilings + %flag.stuckChkTimer += $flagSimTime; + if(%flag.stuckChkTimer > $flagStuckTime){ + %fpos = %flag.getPosition(); + %upRay = containerRayCast(%fpos, vectorAdd(%fpos,"0 0 2.4"), $TypeMasks::InteriorObjectType | $TypeMasks::StaticObjectType | $TypeMasks::ForceFieldObjectType, %flag); + if(%upRay){ + %dist = vectorDist(%fpos,getWords(%upRay,1,3)); + //error(%dist); + %flag.setPosition(vectorSub(%fpos,"0 0" SPC (2.5 - %dist))); + } + %flag.stuckChkTimer = 0; + } + } %Box2 = %flag.getWorldBox(); InitContainerRadiusSearch( %flag.getWorldBoxCenter(), $flagCheckRadius, $TypeMasks::PlayerObjectType); while((%player = containerSearchNext()) != 0){ diff --git a/Classic/scripts/supportClassic.cs b/Classic/scripts/supportClassic.cs index 384f65d..93f736f 100755 --- a/Classic/scripts/supportClassic.cs +++ b/Classic/scripts/supportClassic.cs @@ -319,3 +319,7 @@ function TSStatic::onTrigger(%this, %triggerId, %on){ function TSStatic::onTriggerTick(%this, %triggerId){ //anti console spam } + +function SimObject::setPosition(%obj, %pos){ + %obj.setTransform(%pos SPC getWords(%obj.getTransform(), 3, 6)); +} \ No newline at end of file