From a68f36ba903b74050c6d3172929ff9c1da0f51fa Mon Sep 17 00:00:00 2001 From: tnoisu Date: Sat, 13 Sep 2025 17:06:31 +0500 Subject: [PATCH] Passengers also exit scout choppers --- ext/Server/Bot.lua | 66 +++++++++++++++++++++------------------ ext/Server/BotManager.lua | 9 +++++- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/ext/Server/Bot.lua b/ext/Server/Bot.lua index ff49278d..4891c697 100644 --- a/ext/Server/Bot.lua +++ b/ext/Server/Bot.lua @@ -735,7 +735,7 @@ function Bot:_CheckForVehicleActions(p_DeltaTime, p_AttackActive) end end - self:_CheckShouldExitVehicleIfPassenger() + self:_CheckShouldExitVehicleIfPassenger(s_VehicleEntity, s_OnVehicle) if m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.MobileArtillery) or m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.LightAA) @@ -792,41 +792,47 @@ function Bot:_CheckForVehicleActions(p_DeltaTime, p_AttackActive) end end -function Bot:_CheckShouldExitVehicleIfPassenger() - if not self._ExitVehicleActive - and m_Vehicles:IsPassengerSeat(self.m_ActiveVehicle, self.m_Player.controlledEntryId) +function Bot:_CheckShouldExitVehicleIfPassenger(p_VehicleEntity, p_OnVehicle) + if self._ExitVehicleActive then + return + end + + if not p_OnVehicle + and not m_Vehicles:IsPassengerSeat(p_VehicleEntity, self.m_Player.controlledEntryId) then - local s_ShouldExit = false - local s_ExitDistance = Registry.BOT.PASSENGER_EXIT_DISTANCE - local s_AllCapturePoints = g_GameDirector:GetAllCapturePoints() - local s_ActiveMcoms = g_GameDirector:GetActiveMcomPositions() - local s_CurrentPosition = self.m_Player.soldier.worldTransform.trans:Clone() - s_CurrentPosition.y = 0 - - s_Coordinates = {} - for l_Index = 1, #s_AllCapturePoints do - s_Coordinates[#s_Coordinates + 1] = s_AllCapturePoints[l_Index].transform.trans - end - for l_Index = 1, #s_ActiveMcoms do - s_Coordinates[#s_Coordinates + 1] = s_ActiveMcoms[l_Index] - end + return + end - for l_Index = 1, #s_Coordinates do - local l_Coord = s_Coordinates[l_Index] - local s_Position = l_Coord:Clone() - s_Position.y = 0 + local s_ShouldExit = false + local s_ExitDistance = Registry.BOT.PASSENGER_EXIT_DISTANCE + local s_AllCapturePoints = g_GameDirector:GetAllCapturePoints() + local s_ActiveMcoms = g_GameDirector:GetActiveMcomPositions() + local s_CurrentPosition = self.m_Player.soldier.worldTransform.trans:Clone() + s_CurrentPosition.y = 0 - if s_Position:Distance(s_CurrentPosition) < s_ExitDistance then - s_ShouldExit = true - break - end - end + s_Coordinates = {} + for l_Index = 1, #s_AllCapturePoints do + s_Coordinates[#s_Coordinates + 1] = s_AllCapturePoints[l_Index].transform.trans + end + for l_Index = 1, #s_ActiveMcoms do + s_Coordinates[#s_Coordinates + 1] = s_ActiveMcoms[l_Index] + end - if s_ShouldExit then - self:AbortAttack() - self:ExitVehicle() + for l_Index = 1, #s_Coordinates do + local l_Coord = s_Coordinates[l_Index] + local s_Position = l_Coord:Clone() + s_Position.y = 0 + + if s_Position:Distance(s_CurrentPosition) < s_ExitDistance then + s_ShouldExit = true + break end end + + if s_ShouldExit then + self:AbortAttack() + self:ExitVehicle() + end end function Bot:ResetVars() diff --git a/ext/Server/BotManager.lua b/ext/Server/BotManager.lua index b4b7c8f5..fb1ebf72 100644 --- a/ext/Server/BotManager.lua +++ b/ext/Server/BotManager.lua @@ -1133,7 +1133,10 @@ function BotManager:ExitVehicle(p_Player) local s_BotStates = g_BotStates for l_Index = 1, #self._BotsByTeam[p_Player.teamId + 1] do local l_Bot = self._BotsByTeam[p_Player.teamId + 1][l_Index] - if (s_BotStates:IsInVehicleState(l_Bot.m_ActiveState)) and l_Bot.m_Player.soldier then + local s_InVehicle = s_BotStates:IsInVehicleState(l_Bot.m_ActiveState) + or s_BotStates:IsOnVehicleState(l_Bot.m_ActiveState) + + if s_InVehicle and l_Bot.m_Player.soldier then local s_BotSoldierPosition = nil if l_Bot.m_Player.controlledControllable then s_BotSoldierPosition = l_Bot.m_Player.controlledControllable.transform.trans @@ -1163,6 +1166,10 @@ function BotManager:ExitVehicle(p_Player) if s_ClosestBot and s_ClosestDistance < Registry.COMMON.COMMAND_DISTANCE then local s_VehicleEntity = s_ClosestBot.m_Player.controlledControllable + if not s_VehicleEntity then + s_VehicleEntity = s_ClosestBot.m_Player.attachedControllable + end + if s_VehicleEntity then for l_EntryId = 0, s_VehicleEntity.entryCount - 1 do local s_Player = s_VehicleEntity:GetPlayerInEntry(l_EntryId)