From 06e7b018c39365d0efce07ad79e88079a0a3ade1 Mon Sep 17 00:00:00 2001 From: Tagener Noisu Date: Sun, 9 Jul 2023 17:58:15 +0600 Subject: [PATCH 1/6] Add IFV vehicle type, add IFV related perks --- ext/Server/BotSpawner.lua | 4 ++++ ext/Shared/Constants/VehicleData.lua | 16 ++++++++-------- ext/Shared/Settings/BotEnums.lua | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ext/Server/BotSpawner.lua b/ext/Server/BotSpawner.lua index dc5a0e27..846db8e5 100644 --- a/ext/Server/BotSpawner.lua +++ b/ext/Server/BotSpawner.lua @@ -1417,6 +1417,8 @@ function BotSpawner:_GetUnlocks(p_Bot, p_TeamId, p_SquadId) "persistence/unlocks/vehicles/jetstealth", "persistence/unlocks/vehicles/jetflarelauncher", "persistence/unlocks/vehicles/jetheatseekerstance", + "persistence/unlocks/vehicles/ifvtow", + "persistence/unlocks/vehicles/ifvsmokelaunchers", -- Xp3 perks. "persistence/unlocks/vehicles/lbtcoaxlmg", "persistence/unlocks/vehicles/lbtsmokelaunchers", @@ -1429,9 +1431,11 @@ function BotSpawner:_GetUnlocks(p_Bot, p_TeamId, p_SquadId) if MathUtils:GetRandomInt(1, 100) <= 50 then table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/mbtreactivearmor") table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/lbtreactivearmor") + table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/ifvreloadupgrade") else table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/mbtproximityscan") table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/lbtproximityscan") + table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/ifvreactivearmor") end end diff --git a/ext/Shared/Constants/VehicleData.lua b/ext/Shared/Constants/VehicleData.lua index 2dec8601..59a15842 100644 --- a/ext/Shared/Constants/VehicleData.lua +++ b/ext/Shared/Constants/VehicleData.lua @@ -81,33 +81,33 @@ VehicleData = { }, -- 24,25 ["LAV25"] = { Name = "[LAV-25]", - Type = VehicleTypes.Tank, + Type = VehicleTypes.IFV, Terrain = VehicleTerrains.Amphibious, - Parts = { 10, 25, -1, -1, -1, -1 }, + Parts = { { 10, 0 }, 25, -1, -1, -1, -1 }, Speed = { 200, 610, 350, 350, 350, 350 }, Drop = { 4.9, 9.81, 9.81, 9.81, 9.81, 9.81 } }, -- 10,19 ["LAV25_AI"] = { Name = "[LAV-25]", - Type = VehicleTypes.Tank, + Type = VehicleTypes.IFV, Terrain = VehicleTerrains.Land, - Parts = { 10, 25, -1, -1, -1, -1 }, + Parts = { { 10, 0 }, 25, -1, -1, -1, -1 }, Speed = { 200, 610, 350, 350, 350, 350 }, Drop = { 4.9, 9.81, 9.81, 9.81, 9.81, 9.81 } }, -- 10,19 ["LAV25_Paradrop"] = { Name = "[LAV-25]", - Type = VehicleTypes.Tank, + Type = VehicleTypes.IFV, Terrain = VehicleTerrains.Land, - Parts = { 10, 25, -1, -1, -1, -1 }, + Parts = { { 10, 0 }, 25, -1, -1, -1, -1 }, Speed = { 200, 610, 350, 350, 350, 350 }, Drop = { 4.9, 9.81, 9.81, 9.81, 9.81, 9.81 } }, -- 10,19 ["BTR90"] = { Name = "[BTR-90]", - Type = VehicleTypes.Tank, + Type = VehicleTypes.IFV, Terrain = VehicleTerrains.Land, - Parts = { 4, 29, -1, -1, -1, -1 }, + Parts = { { 4, 0 }, 29, -1, -1, -1, -1 }, Speed = { 200, 600, 350, 350, 350, 350 }, Drop = { 4.9, 9.81, 9.81, 9.81, 9.81, 9.81 } }, diff --git a/ext/Shared/Settings/BotEnums.lua b/ext/Shared/Settings/BotEnums.lua index a94e6adc..a5d09890 100644 --- a/ext/Shared/Settings/BotEnums.lua +++ b/ext/Shared/Settings/BotEnums.lua @@ -51,7 +51,8 @@ VehicleTypes = { StationaryAA = 8, StationaryLauncher = 9, MobileArtillery = 10, - Gadgets = 11 + Gadgets = 11, + IFV = 12 } ---@enum VehicleTerrains From d38c9aa996b2abb061b8756d5e492db18b11eaa1 Mon Sep 17 00:00:00 2001 From: Tagener Noisu Date: Wed, 12 Jul 2023 23:12:29 +0600 Subject: [PATCH 2/6] Chopper gunners use ATGMs --- ext/Server/Bot/VehicleAttacking.lua | 10 ++++++++++ ext/Shared/Constants/VehicleData.lua | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ext/Server/Bot/VehicleAttacking.lua b/ext/Server/Bot/VehicleAttacking.lua index d1087b60..0d3c8294 100644 --- a/ext/Server/Bot/VehicleAttacking.lua +++ b/ext/Server/Bot/VehicleAttacking.lua @@ -39,6 +39,16 @@ function VehicleAttacking:UpdateAttackingVehicle(p_Bot) if p_Bot.m_Player.controlledEntryId == 0 and (p_Bot._ShootPlayerVehicleType == VehicleTypes.Chopper or p_Bot._ShootPlayerVehicleType == VehicleTypes.Plane) then p_Bot._VehicleWeaponSlotToUse = 2 + elseif p_Bot.m_Player.controlledEntryId == 1 and + (p_Bot._ShootPlayerVehicleType == VehicleTypes.Tank + or p_Bot._ShootPlayerVehicleType == VehicleTypes.IFV + or p_Bot._ShootPlayerVehicleType == VehicleTypes.MobileArtillery + or p_Bot._ShootPlayerVehicleType == VehicleTypes.AntiAir + or p_Bot._ShootPlayerVehicleType == VehicleTypes.LightVehicle + or p_Bot._ShootPlayerVehicleType == VehicleTypes.NoArmorVehicle + or p_Bot._ShootPlayerVehicleType == VehicleTypes.MavBot) + then + p_Bot._VehicleWeaponSlotToUse = 2 else p_Bot._VehicleWeaponSlotToUse = 1 end diff --git a/ext/Shared/Constants/VehicleData.lua b/ext/Shared/Constants/VehicleData.lua index 59a15842..0cec4f78 100644 --- a/ext/Shared/Constants/VehicleData.lua +++ b/ext/Shared/Constants/VehicleData.lua @@ -344,7 +344,7 @@ VehicleData = { Name = "[AH-1Z VIPER]", Type = VehicleTypes.Chopper, Terrain = VehicleTerrains.Air, - Parts = { { -2, -2 }, 1 }, -- 0,1,14 + Parts = { { -2, -2 }, {1, 1} }, -- 0,1,14 Speed = { { 300, 10000 }, 600 }, Drop = { { 0.0, 0.0 }, 0.0 } }, @@ -384,7 +384,7 @@ VehicleData = { Name = "[MI-28 HAVOC]", Type = VehicleTypes.Chopper, Terrain = VehicleTerrains.Air, - Parts = { { -2, -2 }, 2 }, -- 0,1,14 + Parts = { { -2, -2 }, {2, 1} }, -- 0,1,14 Speed = { { 300, 10000 }, 600 }, Drop = { { 0.0, 0.0 }, 0.0 } }, From 3d53022f6cbbb0bf3516dc18889a21b2645978db Mon Sep 17 00:00:00 2001 From: Tagener Noisu Date: Tue, 11 Jul 2023 19:12:44 +0600 Subject: [PATCH 3/6] Add scout heli perks, use laser designator for attack helis --- ext/Server/BotSpawner.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/Server/BotSpawner.lua b/ext/Server/BotSpawner.lua index 846db8e5..ee3d1941 100644 --- a/ext/Server/BotSpawner.lua +++ b/ext/Server/BotSpawner.lua @@ -1413,7 +1413,10 @@ function BotSpawner:_GetUnlocks(p_Bot, p_TeamId, p_SquadId) "persistence/unlocks/vehicles/atkhelihellfiremissile", "persistence/unlocks/vehicles/atkheliheatseekermissile", "persistence/unlocks/vehicles/atkheliflarelauncher", - "persistence/unlocks/vehicles/atkhelistealth", + "persistence/unlocks/vehicles/atkhelilaserdesignator", + "persistence/unlocks/vehicles/scoutatgmissile", + "persistence/unlocks/vehicles/scoutflares", + "persistence/unlocks/vehicles/scoutstealth", "persistence/unlocks/vehicles/jetstealth", "persistence/unlocks/vehicles/jetflarelauncher", "persistence/unlocks/vehicles/jetheatseekerstance", From c68c7853cdaf473b6ed20022920860607f24e20c Mon Sep 17 00:00:00 2001 From: Tagener Noisu Date: Fri, 14 Jul 2023 01:54:04 +0600 Subject: [PATCH 4/6] Use coax lmg on tanks destroyers. Change tank perks --- ext/Server/BotSpawner.lua | 5 ++++- ext/Shared/Constants/VehicleData.lua | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/Server/BotSpawner.lua b/ext/Server/BotSpawner.lua index ee3d1941..76d7d64b 100644 --- a/ext/Server/BotSpawner.lua +++ b/ext/Server/BotSpawner.lua @@ -1428,17 +1428,20 @@ function BotSpawner:_GetUnlocks(p_Bot, p_TeamId, p_SquadId) "persistence/unlocks/vehicles/artilleryreloadupgrade", "persistence/unlocks/vehicles/artillerysmokelaunchers", "persistence/unlocks/vehicles/artilleryairburst", - "persistence/unlocks/vehicles/landvehiclefireextinguisher", } -- some variation in appearance if MathUtils:GetRandomInt(1, 100) <= 50 then table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/mbtreactivearmor") table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/lbtreactivearmor") table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/ifvreloadupgrade") + table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/mbtsmokelaunchers") + table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/lbtsmokelaunchers") else table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/mbtproximityscan") table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/lbtproximityscan") table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/ifvreactivearmor") + table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/mbtenvgoptics") + table.insert(s_VehiclePerksToAdd, "persistence/unlocks/vehicles/lbtenvgoptics") end end diff --git a/ext/Shared/Constants/VehicleData.lua b/ext/Shared/Constants/VehicleData.lua index 0cec4f78..d333a3cf 100644 --- a/ext/Shared/Constants/VehicleData.lua +++ b/ext/Shared/Constants/VehicleData.lua @@ -133,7 +133,7 @@ VehicleData = { Name = "[SPRUT-SD]", Type = VehicleTypes.Tank, Terrain = VehicleTerrains.Land, - Parts = { 16, -1, -1, -1, -1 }, + Parts = { {16, 1}, -1, -1, -1, -1 }, Speed = { 200, 350, 350, 350, 350 }, Drop = { 4.9, 9.81, 9.81, 9.81, 9.81 } }, @@ -141,7 +141,7 @@ VehicleData = { Name = "[M1128]", Type = VehicleTypes.Tank, Terrain = VehicleTerrains.Land, - Parts = { 26, -1, -1, -1, -1 }, + Parts = { {26, 1}, -1, -1, -1, -1 }, Speed = { 200, 350, 350, 350, 350 }, Drop = { 4.9, 9.81, 9.81, 9.81, 9.81 } }, From a55f63e9bf84538a51c4f8f8c2273eb09a5b1abb Mon Sep 17 00:00:00 2001 From: Tagener Noisu Date: Tue, 11 Jul 2023 22:10:45 +0600 Subject: [PATCH 5/6] Use ATGMs in scout choppers --- ext/Server/AirTargets.lua | 5 ++++- ext/Server/Bot.lua | 10 ++++++++-- ext/Server/Bot/VehicleAiming.lua | 17 +++++++++++++---- ext/Server/Bot/VehicleAttacking.lua | 15 ++++++++++++++- ext/Server/Bot/VehicleMovement.lua | 19 +++++++++++++------ ext/Server/GameDirector.lua | 5 ++++- ext/Server/Vehicles.lua | 20 +++++++++++++++----- ext/Shared/Constants/VehicleData.lua | 16 ++++++++-------- ext/Shared/Settings/BotEnums.lua | 3 ++- 9 files changed, 81 insertions(+), 29 deletions(-) diff --git a/ext/Server/AirTargets.lua b/ext/Server/AirTargets.lua index 5c08f2ba..14b7735d 100644 --- a/ext/Server/AirTargets.lua +++ b/ext/Server/AirTargets.lua @@ -95,7 +95,10 @@ function AirTargets:_CreateTarget(p_Player) if p_Player.controlledEntryId == 0 then local s_Vehicle = m_Vehicles:GetVehicle(p_Player, 0) - if m_Vehicles:IsVehicleType(s_Vehicle, VehicleTypes.Chopper) or m_Vehicles:IsVehicleType(s_Vehicle, VehicleTypes.Plane) then + if m_Vehicles:IsVehicleType(s_Vehicle, VehicleTypes.Chopper) + or m_Vehicles:IsVehicleType(s_Vehicle, VehicleTypes.ScoutChopper) + or m_Vehicles:IsVehicleType(s_Vehicle, VehicleTypes.Plane) + then table.insert(self._Targets, p_Player.name) end end diff --git a/ext/Server/Bot.lua b/ext/Server/Bot.lua index 5441a39a..69227010 100644 --- a/ext/Server/Bot.lua +++ b/ext/Server/Bot.lua @@ -380,6 +380,7 @@ function Bot:OnUpdatePassPostFrame(p_DeltaTime) -- Fast code. if s_Attacking then if m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.Chopper) or + m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.ScoutChopper) or m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.Plane) then m_VehicleAiming:UpdateAimingVehicleAdvanced(self) else @@ -569,6 +570,7 @@ function Bot:GetAttackDistance(p_ShootBackAfterHit, p_VehicleAttackMode) end else if m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.Chopper) and + m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.ScoutChopper) and m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.Plane) and m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.MobileArtillery) and m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.AntiAir) then @@ -686,7 +688,7 @@ function Bot:ShootAt(p_Player, p_IgnoreYaw) local s_PitchHalf = 0 -- If target is air-vehicle and bot is in AA → ignore yaw. - if (s_Type == VehicleTypes.Chopper or s_Type == VehicleTypes.Plane) then + if (s_Type == VehicleTypes.Chopper or s_Type == VehicleTypes.ScoutChopper or s_Type == VehicleTypes.Plane) then if (self.m_InVehicle and m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.AntiAir)) or (s_VehicleAttackMode == VehicleAttackModes.AttackWithMissileAir) then p_IgnoreYaw = true @@ -718,6 +720,7 @@ function Bot:ShootAt(p_Player, p_IgnoreYaw) s_PitchHalf = Config.FovVerticleVehicleAAForShooting / 360 * math.pi elseif ( m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.Chopper) or + m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.ScoutChopper) or m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.Plane)) and self.m_Player.controlledEntryId == 0 then -- Chopper as driver. s_FovHalf = Config.FovVehicleForShooting / 360 * math.pi s_PitchHalf = Config.FovVerticleChopperForShooting / 360 * math.pi @@ -1267,7 +1270,10 @@ function Bot:_EnterVehicleEntity(p_Entity, p_PlayerIsDriver) end if not Config.UseAirVehicles and - (s_VehicleData.Type == VehicleTypes.Plane or s_VehicleData.Type == VehicleTypes.Chopper) then + (s_VehicleData.Type == VehicleTypes.Plane + or s_VehicleData.Type == VehicleTypes.Chopper + or s_VehicleData.Type == VehicleTypes.ScoutChopper) + then return -3 -- Not allowed to use. end diff --git a/ext/Server/Bot/VehicleAiming.lua b/ext/Server/Bot/VehicleAiming.lua index 4e946503..01af5412 100644 --- a/ext/Server/Bot/VehicleAiming.lua +++ b/ext/Server/Bot/VehicleAiming.lua @@ -102,6 +102,7 @@ function VehicleAiming:UpdateAimingVehicleAdvanced(p_Bot) -- Abort attacking in chopper or jet if too steep or too low. if (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) and p_Bot.m_Player.controlledEntryId == 0) or + (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) and p_Bot.m_Player.controlledEntryId == 0) or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) then local s_PitchHalf = Config.FovVerticleChopperForShooting / 360 * math.pi if math.abs(p_Bot._TargetPitch) > s_PitchHalf then @@ -112,9 +113,14 @@ function VehicleAiming:UpdateAimingVehicleAdvanced(p_Bot) s_FullPositionBot:Distance(s_FullPositionTarget) < Registry.VEHICLES.ABORT_ATTACK_AIR_DISTANCE_JET then p_Bot:AbortAttack() end - if p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Chopper and p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Plane then + if p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Chopper + and p_Bot._ShootPlayerVehicleType ~= VehicleTypes.ScoutChopper + and p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Plane + then local s_DiffVertical = s_FullPositionBot.y - s_FullPositionTarget.y - if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) then + if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) + or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) + then if s_DiffVertical < Registry.VEHICLES.ABORT_ATTACK_HEIGHT_CHOPPER then -- Too low to the ground. p_Bot:AbortAttack() end @@ -211,6 +217,7 @@ function VehicleAiming:UpdateAimingVehicle(p_Bot) -- Abort attacking in chopper or jet if too steep or too low. if (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) and p_Bot.m_Player.controlledEntryId == 0) or + (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) and p_Bot.m_Player.controlledEntryId == 0) or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) then local s_PitchHalf = Config.FovVerticleChopperForShooting / 360 * math.pi if math.abs(p_Bot._TargetPitch) > s_PitchHalf then @@ -221,9 +228,11 @@ function VehicleAiming:UpdateAimingVehicle(p_Bot) s_FullPositionBot:Distance(s_FullPositionTarget) < Registry.VEHICLES.ABORT_ATTACK_AIR_DISTANCE_JET then p_Bot:AbortAttack() end - if p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Chopper and p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Plane then + if p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Chopper and p_Bot._ShootPlayerVehicleType ~= ScoutChopper and p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Plane then local s_DiffVertical = s_FullPositionBot.y - s_FullPositionTarget.y - if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) then + if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) + or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) + then if s_DiffVertical < Registry.VEHICLES.ABORT_ATTACK_HEIGHT_CHOPPER then -- Too low to the ground. p_Bot:AbortAttack() end diff --git a/ext/Server/Bot/VehicleAttacking.lua b/ext/Server/Bot/VehicleAttacking.lua index 0d3c8294..b47fab7b 100644 --- a/ext/Server/Bot/VehicleAttacking.lua +++ b/ext/Server/Bot/VehicleAttacking.lua @@ -37,7 +37,10 @@ function VehicleAttacking:UpdateAttackingVehicle(p_Bot) -- Chopper on Plane / Chopper → weapon 2 (seaker). if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) then if p_Bot.m_Player.controlledEntryId == 0 and - (p_Bot._ShootPlayerVehicleType == VehicleTypes.Chopper or p_Bot._ShootPlayerVehicleType == VehicleTypes.Plane) then + (p_Bot._ShootPlayerVehicleType == VehicleTypes.Chopper + or p_Bot._ShootPlayerVehicleType == VehicleTypes.ScoutChopper + or p_Bot._ShootPlayerVehicleType == VehicleTypes.Plane) + then p_Bot._VehicleWeaponSlotToUse = 2 elseif p_Bot.m_Player.controlledEntryId == 1 and (p_Bot._ShootPlayerVehicleType == VehicleTypes.Tank @@ -52,6 +55,16 @@ function VehicleAttacking:UpdateAttackingVehicle(p_Bot) else p_Bot._VehicleWeaponSlotToUse = 1 end + elseif m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) then + if p_Bot.m_Player.controlledEntryId == 0 and + (p_Bot._ShootPlayerVehicleType == VehicleTypes.Chopper + or p_Bot._ShootPlayerVehicleType == VehicleTypes.Plane + or p_Bot._ShootPlayerVehicleType == VehicleTypes.ScoutChopper) + then + p_Bot._VehicleWeaponSlotToUse = 1 + else + p_Bot._VehicleWeaponSlotToUse = 2 + end else p_Bot._VehicleWeaponSlotToUse = 1 end diff --git a/ext/Server/Bot/VehicleMovement.lua b/ext/Server/Bot/VehicleMovement.lua index 87c562b3..6f192f4d 100644 --- a/ext/Server/Bot/VehicleMovement.lua +++ b/ext/Server/Bot/VehicleMovement.lua @@ -149,8 +149,10 @@ function VehicleMovement:UpdateNormalMovementVehicle(p_Bot) p_Bot._NextTargetPoint = s_NextPoint if math.abs(s_CurrentWayPointDistance - p_Bot._LastWayDistance) < 0.02 or p_Bot._ObstacleSequenceTimer ~= 0 then - if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) or - m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) then + if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) + or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) + or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) + then p_Bot._ObstacleRetryCounter = 0 p_Bot._ObstacleSequenceTimer = 0 s_DistanceFromTarget = 0 @@ -465,9 +467,10 @@ function VehicleMovement:UpdateYawVehicle(p_Bot, p_Attacking, p_IsStationaryLaun else p_Bot._VehicleDirBackPositive = true end - elseif ( - m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) and p_Bot.m_Player.controlledEntryId == 0) or - m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) then + elseif (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) and p_Bot.m_Player.controlledEntryId == 0) + or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) + or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) + then s_Pos = p_Bot.m_Player.controlledControllable.transform.forward local s_AtanDzDx = math.atan(s_Pos.z, s_Pos.x) local s_Yaw = (s_AtanDzDx > math.pi / 2) and (s_AtanDzDx - math.pi / 2) or (s_AtanDzDx + 3 * math.pi / 2) @@ -503,7 +506,11 @@ function VehicleMovement:UpdateYawVehicle(p_Bot, p_Attacking, p_IsStationaryLaun end -- Chopper driver handling here. - if p_Bot.m_Player.controlledEntryId == 0 and m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) then + if p_Bot.m_Player.controlledEntryId == 0 + and (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) + or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) + ) + then if p_Bot._VehicleWaitTimer > 0.0 then return end diff --git a/ext/Server/GameDirector.lua b/ext/Server/GameDirector.lua index d523f234..7fe05550 100644 --- a/ext/Server/GameDirector.lua +++ b/ext/Server/GameDirector.lua @@ -425,7 +425,10 @@ function GameDirector:OnVehicleSpawnDone(p_Entity) end if not Config.UseAirVehicles and - (s_VehicleData.Type == VehicleTypes.Plane or s_VehicleData.Type == VehicleTypes.Chopper) then + (s_VehicleData.Type == VehicleTypes.Plane + or s_VehicleData.Type == VehicleTypes.Chopper + or s_VehicleData.Type == VehicleTypes.ScoutChopper) + then return -- Not allowed to use. end diff --git a/ext/Server/Vehicles.lua b/ext/Server/Vehicles.lua index 26c7f776..893bedd6 100644 --- a/ext/Server/Vehicles.lua +++ b/ext/Server/Vehicles.lua @@ -122,6 +122,16 @@ function Vehicles:IsVehicleType(p_VehicleData, p_VehicleType) end end +function Vehicles:IsChopper(p_VehicleData) + return self:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) + or self:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) +end + +function Vehicles:IsAirVehicle(p_VehicleData) + return self:IsChopper(p_VehicleData) + or self:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) +end + function Vehicles:IsNotVehicleType(p_VehicleData, p_VehicleType) if p_VehicleData and p_VehicleData.Type then return p_VehicleData.Type ~= p_VehicleType @@ -201,16 +211,16 @@ function Vehicles:CheckForVehicleAttack(p_VehicleType, p_Distance, p_Gadget, p_I if p_Gadget.type == WeaponTypes.Rocket then s_AttackMode = VehicleAttackModes.AttackWithRocket -- Always use rocket if possible. elseif p_Gadget.type == WeaponTypes.C4 and p_Distance < 25 then - if p_VehicleType ~= VehicleTypes.Chopper and p_VehicleType ~= VehicleTypes.Plane then -- No air vehicles. + if p_VehicleType ~= VehicleTypes.Chopper and p_VehicleType ~= VehicleTypes.ScoutChopper and p_VehicleType ~= VehicleTypes.Plane then -- No air vehicles. s_AttackMode = VehicleAttackModes.AttackWithC4 -- Always use C4 if possible. end elseif p_Gadget.type == WeaponTypes.MissileAir then - if p_VehicleType == VehicleTypes.Chopper or p_VehicleType == VehicleTypes.Plane then -- No air vehicles. - s_AttackMode = VehicleAttackModes.AttackWithMissileAir -- Always use C4 if possible. + if p_VehicleType == VehicleTypes.Chopper or p_VehicleType == VehicleTypes.ScoutChopper or p_VehicleType == VehicleTypes.Plane then -- No air vehicles. + s_AttackMode = VehicleAttackModes.AttackWithMissileAir end elseif p_Gadget.type == WeaponTypes.MissileLand then - if p_VehicleType ~= VehicleTypes.Chopper and p_VehicleType ~= VehicleTypes.Plane then -- No air vehicles. - s_AttackMode = VehicleAttackModes.AttackWithMissileLand -- Always use C4 if possible. + if p_VehicleType ~= VehicleTypes.Chopper and p_VehicleType ~= VehicleTypes.ScoutChopper and p_VehicleType ~= VehicleTypes.Plane then -- No air vehicles. + s_AttackMode = VehicleAttackModes.AttackWithMissileLand end end end diff --git a/ext/Shared/Constants/VehicleData.lua b/ext/Shared/Constants/VehicleData.lua index d333a3cf..d829622a 100644 --- a/ext/Shared/Constants/VehicleData.lua +++ b/ext/Shared/Constants/VehicleData.lua @@ -358,17 +358,17 @@ VehicleData = { }, ["AH6_Littlebird"] = { Name = "[AH-6J LITTLE BIRD]", - Type = VehicleTypes.Chopper, + Type = VehicleTypes.ScoutChopper, Terrain = VehicleTerrains.Air, - Parts = { { -2, -2 } }, + Parts = { { -2, -2 }, -1, -1, {-1, 2} }, Speed = { { 900, 10000 } }, Drop = { { 0.0, 0.0 } } }, ["AH6_Littlebird_EQ"] = { Name = "[AH-6J LITTLE BIRD]", - Type = VehicleTypes.Chopper, + Type = VehicleTypes.ScoutChopper, Terrain = VehicleTerrains.Air, - Parts = { { -2, -2 }, -1, -1, -1 }, + Parts = { { -2, -2 }, -1, -1, {-1, 2} }, Speed = { { 900, 10000 }, 300, 300, 300 }, Drop = { { 0.0, 0.0 }, 9.81, 9.81, 9.81 } }, @@ -406,17 +406,17 @@ VehicleData = { }, ["Z-11w"] = { Name = "[Z-11W]", - Type = VehicleTypes.Chopper, + Type = VehicleTypes.ScoutChopper, Terrain = VehicleTerrains.Air, - Parts = { { -1, -1 }, -1, -1 }, -1, + Parts = { { -1, -1 }, -1, -1, {-1, 2} }, Speed = { { 900, 10000 }, 350, 350, 350 }, Drop = { { 0.0, 0.0 }, 9.81, 9.81, 9.81 } }, ["Wz11_SP_Paris"] = { Name = "[Z-11W]", - Type = VehicleTypes.Chopper, + Type = VehicleTypes.ScoutChopper, Terrain = VehicleTerrains.Air, - Parts = { { -1, -1 }, -1, -1 }, -1, + Parts = { { -1, -1 }, -1, -1, {-1, 2} }, Speed = { { 900, 10000 }, 350, 350, 350 }, Drop = { { 0.0, 0.0 }, 9.81, 9.81, 9.81 } }, diff --git a/ext/Shared/Settings/BotEnums.lua b/ext/Shared/Settings/BotEnums.lua index a5d09890..9bb8dbd9 100644 --- a/ext/Shared/Settings/BotEnums.lua +++ b/ext/Shared/Settings/BotEnums.lua @@ -52,7 +52,8 @@ VehicleTypes = { StationaryLauncher = 9, MobileArtillery = 10, Gadgets = 11, - IFV = 12 + IFV = 12, + ScoutChopper = 13, } ---@enum VehicleTerrains From 251c9eca8c5bd9a5e478dc8d96946bc0516f88fd Mon Sep 17 00:00:00 2001 From: Tagener Noisu Date: Sat, 15 Jul 2023 20:49:54 +0600 Subject: [PATCH 6/6] Refactoring --- ext/Server/AirTargets.lua | 5 +---- ext/Server/Bot.lua | 20 +++++--------------- ext/Server/Bot/VehicleAiming.lua | 16 ++++------------ ext/Server/Bot/VehicleMovement.lua | 16 +++------------- ext/Server/GameDirector.lua | 6 +----- ext/Server/Vehicles.lua | 6 +++--- 6 files changed, 17 insertions(+), 52 deletions(-) diff --git a/ext/Server/AirTargets.lua b/ext/Server/AirTargets.lua index 14b7735d..111d7249 100644 --- a/ext/Server/AirTargets.lua +++ b/ext/Server/AirTargets.lua @@ -95,10 +95,7 @@ function AirTargets:_CreateTarget(p_Player) if p_Player.controlledEntryId == 0 then local s_Vehicle = m_Vehicles:GetVehicle(p_Player, 0) - if m_Vehicles:IsVehicleType(s_Vehicle, VehicleTypes.Chopper) - or m_Vehicles:IsVehicleType(s_Vehicle, VehicleTypes.ScoutChopper) - or m_Vehicles:IsVehicleType(s_Vehicle, VehicleTypes.Plane) - then + if m_Vehicles:IsAirVehicle(s_Vehicle) then table.insert(self._Targets, p_Player.name) end end diff --git a/ext/Server/Bot.lua b/ext/Server/Bot.lua index 69227010..0dabd52e 100644 --- a/ext/Server/Bot.lua +++ b/ext/Server/Bot.lua @@ -379,9 +379,7 @@ function Bot:OnUpdatePassPostFrame(p_DeltaTime) -- Fast code. if s_Attacking then - if m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.Chopper) or - m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.ScoutChopper) or - m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.Plane) then + if m_Vehicles:IsAirVehicle(self.m_ActiveVehicle) then m_VehicleAiming:UpdateAimingVehicleAdvanced(self) else if Config.VehicleMoveWhileShooting and m_Vehicles:IsNotVehicleTerrain(self.m_ActiveVehicle, VehicleTerrains.Air) then @@ -569,9 +567,7 @@ function Bot:GetAttackDistance(p_ShootBackAfterHit, p_VehicleAttackMode) end end else - if m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.Chopper) and - m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.ScoutChopper) and - m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.Plane) and + if not m_Vehicles:IsAirVehicle(self.m_ActiveVehicle) and m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.MobileArtillery) and m_Vehicles:IsNotVehicleType(self.m_ActiveVehicle, VehicleTypes.AntiAir) then if p_ShootBackAfterHit then @@ -718,10 +714,8 @@ function Bot:ShootAt(p_Player, p_IgnoreYaw) if m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.AntiAir) then s_FovHalf = Config.FovVehicleAAForShooting / 360 * math.pi s_PitchHalf = Config.FovVerticleVehicleAAForShooting / 360 * math.pi - elseif ( - m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.Chopper) or - m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.ScoutChopper) or - m_Vehicles:IsVehicleType(self.m_ActiveVehicle, VehicleTypes.Plane)) and self.m_Player.controlledEntryId == 0 then -- Chopper as driver. + elseif m_Vehicles:IsAirVehicle(self.m_ActiveVehicle) and + self.m_Player.controlledEntryId == 0 then s_FovHalf = Config.FovVehicleForShooting / 360 * math.pi s_PitchHalf = Config.FovVerticleChopperForShooting / 360 * math.pi else @@ -1269,11 +1263,7 @@ function Bot:_EnterVehicleEntity(p_Entity, p_PlayerIsDriver) return -2 end - if not Config.UseAirVehicles and - (s_VehicleData.Type == VehicleTypes.Plane - or s_VehicleData.Type == VehicleTypes.Chopper - or s_VehicleData.Type == VehicleTypes.ScoutChopper) - then + if not Config.UseAirVehicles and m_Vehicles:IsAirVehicle(s_VehicleData) then return -3 -- Not allowed to use. end diff --git a/ext/Server/Bot/VehicleAiming.lua b/ext/Server/Bot/VehicleAiming.lua index 01af5412..ef4fc4ce 100644 --- a/ext/Server/Bot/VehicleAiming.lua +++ b/ext/Server/Bot/VehicleAiming.lua @@ -101,9 +101,7 @@ function VehicleAiming:UpdateAimingVehicleAdvanced(p_Bot) -- Abort attacking in chopper or jet if too steep or too low. - if (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) and p_Bot.m_Player.controlledEntryId == 0) or - (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) and p_Bot.m_Player.controlledEntryId == 0) or - m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) then + if m_Vehicles:IsAirVehicle(p_Bot.m_ActiveVehicle) and p_Bot.m_Player.controlledEntryId == 0 then local s_PitchHalf = Config.FovVerticleChopperForShooting / 360 * math.pi if math.abs(p_Bot._TargetPitch) > s_PitchHalf then p_Bot:AbortAttack() @@ -118,9 +116,7 @@ function VehicleAiming:UpdateAimingVehicleAdvanced(p_Bot) and p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Plane then local s_DiffVertical = s_FullPositionBot.y - s_FullPositionTarget.y - if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) - or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) - then + if m_Vehicles:IsChopper(p_Bot.m_ActiveVehicle) then if s_DiffVertical < Registry.VEHICLES.ABORT_ATTACK_HEIGHT_CHOPPER then -- Too low to the ground. p_Bot:AbortAttack() end @@ -216,9 +212,7 @@ function VehicleAiming:UpdateAimingVehicle(p_Bot) -- Abort attacking in chopper or jet if too steep or too low. - if (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) and p_Bot.m_Player.controlledEntryId == 0) or - (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) and p_Bot.m_Player.controlledEntryId == 0) or - m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) then + if m_Vehicles:IsAirVehicle(p_Bot.m_ActiveVehicle) and p_Bot.m_Player.controlledEntryId == 0 then local s_PitchHalf = Config.FovVerticleChopperForShooting / 360 * math.pi if math.abs(p_Bot._TargetPitch) > s_PitchHalf then p_Bot:AbortAttack() @@ -230,9 +224,7 @@ function VehicleAiming:UpdateAimingVehicle(p_Bot) end if p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Chopper and p_Bot._ShootPlayerVehicleType ~= ScoutChopper and p_Bot._ShootPlayerVehicleType ~= VehicleTypes.Plane then local s_DiffVertical = s_FullPositionBot.y - s_FullPositionTarget.y - if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) - or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) - then + if m_Vehicles:IsChopper(p_Bot.m_ActiveVehicle) then if s_DiffVertical < Registry.VEHICLES.ABORT_ATTACK_HEIGHT_CHOPPER then -- Too low to the ground. p_Bot:AbortAttack() end diff --git a/ext/Server/Bot/VehicleMovement.lua b/ext/Server/Bot/VehicleMovement.lua index 6f192f4d..64b85f30 100644 --- a/ext/Server/Bot/VehicleMovement.lua +++ b/ext/Server/Bot/VehicleMovement.lua @@ -149,10 +149,7 @@ function VehicleMovement:UpdateNormalMovementVehicle(p_Bot) p_Bot._NextTargetPoint = s_NextPoint if math.abs(s_CurrentWayPointDistance - p_Bot._LastWayDistance) < 0.02 or p_Bot._ObstacleSequenceTimer ~= 0 then - if m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) - or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) - or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) - then + if m_Vehicles:IsAirVehicle(p_Bot.m_ActiveVehicle) then p_Bot._ObstacleRetryCounter = 0 p_Bot._ObstacleSequenceTimer = 0 s_DistanceFromTarget = 0 @@ -467,10 +464,7 @@ function VehicleMovement:UpdateYawVehicle(p_Bot, p_Attacking, p_IsStationaryLaun else p_Bot._VehicleDirBackPositive = true end - elseif (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) and p_Bot.m_Player.controlledEntryId == 0) - or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) - or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) - then + elseif m_Vehicles:IsAirVehicle(p_Bot.m_ActiveVehicle) and p_Bot.m_Player.controlledEntryId == 0 then s_Pos = p_Bot.m_Player.controlledControllable.transform.forward local s_AtanDzDx = math.atan(s_Pos.z, s_Pos.x) local s_Yaw = (s_AtanDzDx > math.pi / 2) and (s_AtanDzDx - math.pi / 2) or (s_AtanDzDx + 3 * math.pi / 2) @@ -506,11 +500,7 @@ function VehicleMovement:UpdateYawVehicle(p_Bot, p_Attacking, p_IsStationaryLaun end -- Chopper driver handling here. - if p_Bot.m_Player.controlledEntryId == 0 - and (m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) - or m_Vehicles:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) - ) - then + if p_Bot.m_Player.controlledEntryId == 0 and m_Vehicles:IsChopper(p_Bot.m_ActiveVehicle) then if p_Bot._VehicleWaitTimer > 0.0 then return end diff --git a/ext/Server/GameDirector.lua b/ext/Server/GameDirector.lua index 7fe05550..589157b3 100644 --- a/ext/Server/GameDirector.lua +++ b/ext/Server/GameDirector.lua @@ -424,11 +424,7 @@ function GameDirector:OnVehicleSpawnDone(p_Entity) return -- No vehicle found. end - if not Config.UseAirVehicles and - (s_VehicleData.Type == VehicleTypes.Plane - or s_VehicleData.Type == VehicleTypes.Chopper - or s_VehicleData.Type == VehicleTypes.ScoutChopper) - then + if not Config.UseAirVehicles and m_Vehicles:IsAirVehicle(s_VehicleData) then return -- Not allowed to use. end diff --git a/ext/Server/Vehicles.lua b/ext/Server/Vehicles.lua index 893bedd6..00bd2bce 100644 --- a/ext/Server/Vehicles.lua +++ b/ext/Server/Vehicles.lua @@ -123,13 +123,13 @@ function Vehicles:IsVehicleType(p_VehicleData, p_VehicleType) end function Vehicles:IsChopper(p_VehicleData) - return self:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Chopper) - or self:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.ScoutChopper) + return self:IsVehicleType(p_VehicleData, VehicleTypes.Chopper) + or self:IsVehicleType(p_VehicleData, VehicleTypes.ScoutChopper) end function Vehicles:IsAirVehicle(p_VehicleData) return self:IsChopper(p_VehicleData) - or self:IsVehicleType(p_Bot.m_ActiveVehicle, VehicleTypes.Plane) + or self:IsVehicleType(p_VehicleData, VehicleTypes.Plane) end function Vehicles:IsNotVehicleType(p_VehicleData, p_VehicleType)