Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 36 additions & 30 deletions ext/Server/Bot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 8 additions & 1 deletion ext/Server/BotManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading