From b5397fc08f6db8882092a29e04baac4fd1a5d72e Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Wed, 15 May 2024 14:51:47 +0200 Subject: [PATCH] Add failsafe to IsGrounded check --- Fika.Core/Coop/Players/CoopBot.cs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Fika.Core/Coop/Players/CoopBot.cs b/Fika.Core/Coop/Players/CoopBot.cs index 1d97be72..de3de920 100644 --- a/Fika.Core/Coop/Players/CoopBot.cs +++ b/Fika.Core/Coop/Players/CoopBot.cs @@ -225,7 +225,8 @@ private IEnumerator WaitForPlayersToLoadBot() Teleport(new Vector3(spawnPosition.x, spawnPosition.y + 1f, spawnPosition.z)); AIData.BotOwner.BotState = EBotState.PreActive; isStarted = true; - yield return new WaitUntil(() => { return MovementContext.IsGrounded; }); + DateTime fallStart = DateTime.Now; + yield return new WaitUntil(() => { return MovementContext.IsGrounded || Math.Abs((fallStart - DateTime.Now).TotalSeconds) < 2; }); #if DEBUG FikaPlugin.Instance.FikaLogger.LogWarning($"{gameObject.name} is now grounded, started at Y: {randomY}, now at {Position.ToStringVerbose()}"); #endif @@ -320,19 +321,6 @@ private IEnumerator DestroyNetworkedComponents() public override void UpdateTick() { base.UpdateTick(); - - // Temp test to fix AI dying from hydration and energy... - /*if (ActiveHealthController.Energy.Current < 1) - { - logger($"Setting energy to 50 on {ProfileId}"); - ActiveHealthController.ChangeEnergy(50); - } - - if (ActiveHealthController.Hydration.Current < 1) - { - logger($"Setting hydration to 50 on {ProfileId}"); - ActiveHealthController.ChangeHydration(50); - }*/ } public override void OnDestroy()