This commit is contained in:
iTracerFacer
2024-12-26 23:40:55 -06:00
parent f084e5e815
commit 06413684ca
8 changed files with 337 additions and 30 deletions

View File

@@ -1,8 +1,16 @@
-- This script takes Layouts orginally created by Redkite: https://www.youtube.com/user/RedKiteRender/
-- and rotates through the layouts to spawn them on the carrier deck.
-- Adds a menu item to clear the deck of all spawned objects.
-- Adds menu items to spawn the layouts on the deck.
local RotateLayoutInterval = 900 -- Time in seconds to rotate through the layouts
local shipName = "CVN-72 Abraham Lincoln" -- Replace with the actual name of your ship
local shipUnit = Unit.getByName(shipName)
shipID = shipUnit:getID()
env.info(shipName .. ": " .. shipID)
local RotateLayoutInterval = 300 -- Time in seconds to rotate through the layouts
local function CarrierCleanDeck()
@@ -2555,6 +2563,7 @@ local carrierLayouts = {
local currentLayoutIndex = 1
local function cycleCarrierLayouts()
-- Clean the deck before changing the layout
CarrierCleanDeck()
@@ -2568,12 +2577,40 @@ local function cycleCarrierLayouts()
-- Move to the next layout in the list
currentLayoutIndex = currentLayoutIndex % #carrierLayouts + 1
-- Schedule the next execution in 15 minutes (900 seconds)
-- Schedule the next layout change
timer.scheduleFunction(cycleCarrierLayouts, nil, timer.getTime() + RotateLayoutInterval)
end
-- Start the cycle
cycleCarrierLayouts()
CarrierMenu = MENU_MISSION:New("Carrier Operations", missionMenu)
CarrierLayoutCleanDeck = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Clear Deck", CarrierMenu, CarrierCleanDeck)
CarrierMenu = MENU_MISSION:New("Carrier Operations", missionMenu)
CarrierLayouts = MENU_MISSION:New("Carrier Layouts", CarrierMenu)
CarrierLayoutCleanDeck = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Total Clear Deck", CarrierLayouts, CarrierCleanDeck)
CarrierClearDeck8Spawns = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Clear Deck 8 Spawns", CarrierLayouts, CarrierClearDeck8Spawns)
CarrierBlockedDeck8Spawns = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Blocked Deck 8 Spawns", CarrierLayouts, CarrierBlockedDeck8Spawns)
CarrierClearDeck4Spawns = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Clear Deck 4 Spawns", CarrierLayouts, CarrierClearDeck4Spawns)
CarrierBlockedDeck4Spawns = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Blocked Deck 4 Spawns", CarrierLayouts, CarrierBlockedDeck4Spawns)
CarrierCleanDeck16Spawns = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Clean Deck 16 Spawns", CarrierLayouts, CarrierCleanDeck16Spawns)
CarrierBlockedDeck16Spawns = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Blocked Deck 16 Spawns", CarrierLayouts, CarrierBlockedDeck16Spawns)
CarrierMassRecoveryCat2Tomcats = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Mass Recovery Cat 2 Tomcats", CarrierLayouts, CarrierMassRecoveryCat2Tomcats)
CarrierChangeIntervalMenu = MENU_MISSION:New("Change Rotate Interval", CarrierLayouts)
-- Function to change the rotate layout interval
local function ChangeRotateLayoutInterval(newIntervalMinutes)
RotateLayoutInterval = newIntervalMinutes * 60 -- Convert minutes to seconds
MESSAGE:New("Rotate layout interval set to " .. newIntervalMinutes .. " minutes.", 15):ToAll()
end
-- Add the menu items to change the interval
CarrierChangeInterval15 = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Set Rotate Interval to 15 Minutes", CarrierChangeIntervalMenu, ChangeRotateLayoutInterval, 15)
CarrierChangeInterval30 = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Set Rotate Interval to 30 Minutes", CarrierChangeIntervalMenu, ChangeRotateLayoutInterval, 30)
CarrierChangeInterval60 = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Set Rotate Interval to 60 Minutes", CarrierChangeIntervalMenu, ChangeRotateLayoutInterval, 60)
CarrierChangeInterval120 = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Set Rotate Interval to 2 Hours", CarrierChangeIntervalMenu, ChangeRotateLayoutInterval, 120)
CarrierChangeInterval240 = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Set Rotate Interval to 4 Hours", CarrierChangeIntervalMenu, ChangeRotateLayoutInterval, 240)
CarrierChangeInterval480 = MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Set Rotate Interval to 8 Hours", CarrierChangeIntervalMenu, ChangeRotateLayoutInterval, 480)

View File

@@ -1,9 +1,6 @@
BlueAWACS = SPAWN:New("BLUE EWR AWACS")
:InitLimit(1, 99)
:InitRepeatOnLanding()
:SpawnScheduled(30, 0.5)
RedAWACS = SPAWN:New("RED EWR AWACS")
:InitLimit(1, 99)

View File

@@ -12,10 +12,7 @@ local RedDefaultCAP = 1
local BlueA2ADefaultOverhead = 1
local BlueDefaultCAP = 1
local shipName = "CVN-72 Abraham Lincoln" -- Replace with the actual name of your ship
local shipUnit = Unit.getByName(shipName)
shipID = shipUnit:getID()
env.info(shipName .. ": " .. shipID)
-- Create the main mission menu.
missionMenu = MENU_MISSION:New("Mission Menu")
@@ -52,7 +49,7 @@ BLUEA2ADispatcher:SetDefaultLandingAtRunway()
BLUEA2ADispatcher:SetDefaultTakeoffInAir()
BLUEA2ADispatcher:SetTacticalDisplay(TAC_DISPLAY)
BLUEA2ADispatcher:SetDefaultFuelThreshold( 0.20 )
BLUEA2ADispatcher:SetRefreshTimeInterval( 300 )
BLUEA2ADispatcher:SetRefreshTimeInterval( 900 )
BLUEA2ADispatcher:SetDefaultOverhead(BlueA2ADefaultOverhead)
BLUEA2ADispatcher:SetDisengageRadius( 100000 )
BLUEA2ADispatcher:SetEngageRadius( 50000 )
@@ -64,7 +61,7 @@ RedA2ADispatcher:SetDefaultLandingAtRunway()
RedA2ADispatcher:SetDefaultTakeoffInAir()
RedA2ADispatcher:SetTacticalDisplay(TAC_DISPLAY)
RedA2ADispatcher:SetDefaultFuelThreshold( 0.20 )
RedA2ADispatcher:SetRefreshTimeInterval( 300 )
RedA2ADispatcher:SetRefreshTimeInterval( 900 )
RedA2ADispatcher:SetDefaultOverhead(RedA2ADefaultOverhead)
RedA2ADispatcher:SetDisengageRadius( 100000 )
RedA2ADispatcher:SetEngageRadius( 50000 )

View File

@@ -166,8 +166,8 @@ red_ctld:AddCratesCargo("T-90",{"Red-T90"},CTLD_CARGO.Enum.VEHICLE, 1, 8500, 25)
blue_ctld:AddCratesCargo("M1A2",{"Blue-M1A2"},CTLD_CARGO.Enum.VEHICLE, 1, 8500, 25)
-- Add FOBs
red_ctld:AddCratesCargo("Forward Ops Base",{"Red-FOB"},CTLD_CARGO.Enum.FOB, 4, 500, 3)
blue_ctld:AddCratesCargo("Forward Ops Base",{"Blue-FOB"},CTLD_CARGO.Enum.FOB, 4, 500, 3)
red_ctld:AddCratesCargo("Forward Ops Base",{"Red-FOB"},CTLD_CARGO.Enum.FOB, 4, 500, 5)
blue_ctld:AddCratesCargo("Forward Ops Base",{"Blue-FOB"},CTLD_CARGO.Enum.FOB, 4, 500, 5)
-- AA Crates
red_ctld:AddCratesCargo("SA-8",{"SA8"},CTLD_CARGO.Enum.CRATE, 4, 500, 10)

View File

@@ -1,7 +1,7 @@
--[[
Script: Moose_DynamicGroundBattle.lua
Written by: [F99th-TracerFacer]
Version: 1.0.3
Version: 1.0.4
Date: 11 November 2024
Updated: 12 Dec 2024
Description: This script creates a dynamic ground battle between Red and Blue coalitions
@@ -98,7 +98,7 @@
-- Due to some maps or locations where infantry moving is either not desired or has problems with the terrain you can disable infantry moving patrols.
-- Set to false, infantry units will spawn, and never move from their spawn location. This could be considered a defensive position and probably a good idea.
local ENABLE_CAPTURE_ZONE_MESSAGES = false -- Enable or disable attack messages when a zone is attacked.
local ENABLE_CAPTURE_ZONE_MESSAGES = true -- Enable or disable attack messages when a zone is attacked.
local MOVING_ARMOR_PATROLS = true -- Units with armor will move to patrol zones if set to true. (default is true)
local MOVING_INFANTRY_PATROLS = false -- Units with infantry will not move to patrol zones if set to false. (default is false, to many moving units can cause performance issues)
local MOVING_UNITS_CAP = 10 -- Too many moving ground units can cause performance issues.
@@ -316,13 +316,13 @@ local function addMarkPoints(warehouses, coalition)
if warehouse:GetCoalition() == 2 then
details = "Warehouse: " .. warehouse:GetName() .. "\nThis warehouse needs to be protected.\n"
else
details = "Warehouse: " .. warehouse:GetName() .. "\nThis is a primary target as it is directly supplying enemy units.\n"
details = "Warehouse: " .. warehouse:GetName() .. "\nThis is a primary target! Reduce the enmey capacity to replenish their units!\n"
end
elseif coalition == 1 then
if warehouse:GetCoalition() == 1 then
details = "Warehouse: " .. warehouse:GetName() .. "\nThis warehouse needs to be protected.\nNearby Units:\n"
details = "Warehouse: " .. warehouse:GetName() .. "\nThis warehouse needs to be protected.\n"
else
details = "Warehouse: " .. warehouse:GetName() .. "\nThis is a primary target as it is directly supplying enemy units.\n"
details = "Warehouse: " .. warehouse:GetName() .. "\nThis is a primary target! Reduce the enmey capacity to replenish their units!\n"
end
end
else
@@ -381,14 +381,14 @@ function ZONE_CAPTURE_COALITION:OnEnterCaptured(From, Event, To)
if Coalition == coalition.side.BLUE then
self:UndrawZone()
self:DrawZone(-1, {0, 0, 1}, 2) -- Draw the zone on the map for 30 seconds, blue color, and thickness 2
if ENABLE_CAPTURE_ZONE_MESSAGES == true
MESSAGE:New(string.format("%s has been captured by the USA", zoneName)), 6):ToAll()
if ENABLE_CAPTURE_ZONE_MESSAGES == true then
MESSAGE:New(string.format("%s has been captured by the USA", self:GetZoneName()), 6):ToAll()
end
else
self:UndrawZone()
self:DrawZone(-1, {1, 0, 0}, 2) -- Draw the zone on the map for 30 seconds, red color, and thickness 2
if ENABLE_CAPTURE_ZONE_MESSAGES == true
MESSAGE:New(string.format("%s has been captured by Russia", zoneName)), 6):ToAll()
if ENABLE_CAPTURE_ZONE_MESSAGES == true then
MESSAGE:New(string.format("%s has been captured by Russia", self:GetZoneName()), 6):ToAll()
end
end
end
@@ -743,6 +743,7 @@ local function AssignTasks(group, zoneStates)
group:PatrolZones(patrolZones, speed, formation, delayMin, delayMax)
movingUnitsCount = movingUnitsCount + 1 -- Increment the counter when a unit starts moving
MESSAGE:New("Moving Units Count: " .. movingUnitsCount, 10):ToAll()
else
env.info("AssignTasks: No suitable zone found for group " .. group:GetName())
end
@@ -752,11 +753,23 @@ end
-- Function to decrement the moving units counter when a unit stops moving
local function OnUnitStopMoving()
movingUnitsCount = movingUnitsCount - 1
MESSAGE:New("Moving Units Count: " .. movingUnitsCount, 10):ToAll()
end
-- Function to spawn infantry units from a template at a given location
local function SpawnInfantryAtLocation(location)
local spawnTemplate = SPAWN:New("InfantryTemplate") -- Replace "InfantryTemplate" with your actual template name
local function SpawnInfantryAtLocation(location, coalition)
local spawnTemplateName
if coalition == coalition.side.RED then
spawnTemplateName = "RedInfantry1" -- Replace with your actual red coalition template name
elseif coalition == coalition.side.BLUE then
spawnTemplateName = "BlueInfantry1" -- Replace with your actual blue coalition template name
else
env.info("SpawnInfantryAtLocation: Invalid coalition")
return
end
local spawnTemplate = SPAWN:New(spawnTemplateName)
spawnTemplate:SpawnFromCoordinate(location)
end
@@ -765,19 +778,21 @@ local function OnUnitReachedLastWaypoint(unit)
OnUnitStopMoving()
local unitCoordinate = unit:GetCoordinate()
SpawnInfantryAtLocation(unitCoordinate)
local unitCoalition = unit:GetCoalition()
SpawnInfantryAtLocation(unitCoordinate, unitCoalition)
end
-- Event handler for waypoint reached
-- Create an event handler class
local EventHandler = EVENTHANDLER:New()
-- Define the event handler function for waypoint reached
function EventHandler:OnEventWaypointReached(EventData)
if EventData and EventData.IniUnit then
OnUnitReachedLastWaypoint(EventData.IniUnit)
end
end
-- Set up the event handler globally
-- Set up the event handler to handle the WaypointReached event
EventHandler:HandleEvent(EVENTS.WaypointReached)
-- Function to check if a group contains infantry units

View File

@@ -0,0 +1,201 @@
-- Expected Behavior
-- CVN Will patrol designated patrol zones. Staying in the zone assigned.
-- Player can designate which zone to move to.
-- Plyaer can request turning into the wind.
-- After turning into the wind, CVN should return to orignal coord then resume waypoints.
--
---
local msgTime = 15
local SetCVNActivePatrolZone = 1 --if active waypoint is 1, steam between 1 and 2, if active is 2, steam between 2 and 3.
local CVN_carrier_group = GROUP:FindByName("CVN-72 Abraham Lincoln Carrier Group") -- put the exact GROUP name of your carrier-group as set in the mission editor within the " "
local CVN_beacon_unit = UNIT:FindByName("CVN-72 Abraham Lincoln")-- -- put the exact UNIT name of your carrier-unit as set in the mission editor within the " "
local CVN_ICLS_Channel = 1 -- replace with the ICLS channel you want
local CVN_ICLS_Name = "CVN" -- put the 3-letter ICLS identifier you want to use for the ICLS channel
local CVN_TACAN_Channel = 72 -- replace with the TACAN channel you want
local CVN_TACAN_Name = "CVN" -- put the 3-letter TACAN identifier you want to use for the TACAN channel
local CVN_RecoveryWindowTime = 20 -- time in minutes for how long recovery will be open, feel free to change the number
-- Functions to move ship to designated waypoint/zones
local msgCVNPatrol = "Sending Carrier Group to Patrol Zone: "
function SetCVNWayPoint1()
SetCVNActivePatrolZone = 1
MESSAGE:New(msgCVNPatrol .. SetCVNActivePatrolZone, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
BlueCVNGroup:GotoWaypoint(1)
end
function SetCVNWayPoint2()
SetCVNActivePatrolZone = 2
MESSAGE:New(msgCVNPatrol .. SetCVNActivePatrolZone, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
BlueCVNGroup:GotoWaypoint(3)
end
function SetCVNWayPoint3()
SetCVNActivePatrolZone = 3
MESSAGE:New(msgCVNPatrol .. SetCVNActivePatrolZone, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
BlueCVNGroup:GotoWaypoint(5)
end
if CVN_beacon_unit then
BlueCVNGroup_Beacon = CVN_beacon_unit:GetBeacon()
BlueCVNGroup_Beacon:ActivateICLS(CVN_ICLS_Channel,CVN_ICLS_Name)
end
SCHEDULER:New(nil,function()
if CVN_beacon_unit then
BlueCVNGroup_Beacon = CVN_beacon_unit:GetBeacon()
BlueCVNGroup_Beacon:ActivateTACAN(CVN_TACAN_Channel,"X",CVN_TACAN_Name,true)
end
end,{},5,5*60)
-- Function to turn ship into the wind.
function start_recovery()
if BlueCVNGroup:IsSteamingIntoWind() == true then
MESSAGE:New(CVN_beacon_unit:GetName() .. " is currently launching/recovering aircraft, currently active recovery window closes at time " .. timerecovery_end, msgTime, "CVNNAVINFO",false):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
else
local timenow=timer.getAbsTime( )
local timeend=timenow+CVN_RecoveryWindowTime*60 -- this sets the recovery window to 45 minutes, you can change the numbers as you wish
local timerecovery_start = UTILS.SecondsToClock(timenow,true)
timerecovery_end = UTILS.SecondsToClock(timeend,true)
BlueCVNGroup:AddTurnIntoWind(timerecovery_start,timerecovery_end,25,true,-9)
MESSAGE:New(CVN_beacon_unit:GetName().." is turning into the wind to begin " .. CVN_RecoveryWindowTime .. " mins of aircraft operations.\nLaunch/Recovery Window will be open from time " .. timerecovery_start .. " until " .. timerecovery_end, msgTime, "CVNNAVINFO",false):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
end
end
BlueAwacs = nil
Spawn_US_AWACS = SPAWN:New("BLUE EWR AWACS")
:InitLimit(1,500)
:InitRepeatOnLanding()
:OnSpawnGroup( function (SpawnGroup)
BlueAwacs = SpawnGroup
end
):SpawnScheduled(30,.5)
function ResetAwacs()
BlueAwacs:Destroy()
MESSAGE:New("Resetting AWACS...", msgTime, "CVNNAVINFO",false):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
end
-- Build the Menu
local CarrierMovement = MENU_COALITION:New(coalition.side.BLUE, "Carrier Movement", CarrierMenu)
MENU_COALITION_COMMAND:New(coalition.side.BLUE, "CVN Group - Patrol Zone 1", CarrierMovement, SetCVNWayPoint1)
MENU_COALITION_COMMAND:New(coalition.side.BLUE, "CVN Group - Patrol Zone 2", CarrierMovement, SetCVNWayPoint3)
MENU_COALITION_COMMAND:New(coalition.side.BLUE, "CVN Group - Patrol Zone 3", CarrierMovement, SetCVNWayPoint5)
MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Reset AWACS", CarrierMovement,ResetAwacs)
MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Launch/Recover Aircraft (Turn carrier into the wind)", CarrierMovement, start_recovery)
-- Create a NAVYGROUP object and activate the late activated group.
BlueCVNGroup=NAVYGROUP:New("CVN-72 Abraham Lincoln Carrier Group")
BlueCVNGroup:SetVerbosity(1)
BlueCVNGroup:MarkWaypoints()
--- Function called each time the group passes a waypoint.
function BlueCVNGroup:OnAfterPassingWaypoint(From, Event, To, Waypoint)
local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint
-- Debug info.
local text=string.format(CVN_beacon_unit:GetName().." passed waypoint ID=%d (Index=%d) %d times", waypoint.uid, BlueCVNGroup:GetWaypointIndex(waypoint.uid), waypoint.npassed)
MESSAGE:New(text, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
env.info(text)
--- Patrol zone 1
if SetCVNActivePatrolZone == 1 and waypoint == 1 then
BlueCVNGroup:GotoWaypoint(2)
end
if SetCVNActivePatrolZone == 1 and waypoint == 2 then
BlueCVNGroup:GotoWaypoint(1)
end
---- Patrol zone 2
if SetCVNActivePatrolZone == 2 and waypoint == 3 then
BlueCVNGroup:GotoWaypoint(4)
end
if SetCVNActivePatrolZone == 2 and waypoint == 4 then
BlueCVNGroup:GotoWaypoint(3)
end
---- Patrol Zone 3
if SetCVNActivePatrolZone == 3 and waypoint == 5 then
BlueCVNGroup:GotoWaypoint(6)
end
if SetCVNActivePatrolZone == 3 and waypoint == 6 then
BlueCVNGroup:GotoWaypoint(5)
end
end
--- Function called when the group is cruising. This is the "normal" state when the group follows its waypoints.
function BlueCVNGroup:OnAfterCruise(From, Event, To)
local text=CVN_beacon_unit:GetName().." is cruising straight and steady."
MESSAGE:New(text, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
env.info(text)
end
--- Function called when the groups starts to turn.
function BlueCVNGroup:OnAfterTurningStarted(From, Event, To)
local text=CVN_beacon_unit:GetName().." has started turning!"
MESSAGE:New(text, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
env.info(text)
end
--- Function called when the group stopps to turn.
function BlueCVNGroup:OnAfterTurningStopped(From, Event, To)
local text=CVN_beacon_unit:GetName().." has stopped turning..proceeding to next waypoint."
MESSAGE:New(text, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
env.info(text)
end
-- Turn the carrier into the wind for a few mins
function
BlueCVNGroup:AddTurnIntoWind()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
end
-- Monitor entering and leaving zones.
local ZoneSet=SET_ZONE:New():FilterPrefixes("CVN Patrol"):FilterOnce()
-- Set zones which are checked if the group enters or leaves it.
BlueCVNGroup:SetCheckZones(ZoneSet)
--- Function called when the group enteres a zone.
function BlueCVNGroup:OnAfterEnterZone(From, Event, To, Zone)
local text=string.format(CVN_beacon_unit:GetName().." has entered patrol zone %s.", Zone:GetName())
MESSAGE:New(text, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
env.info(text)
end
--- Function called when the group leaves a zone.
function BlueCVNGroup:OnAfterLeaveZone(From, Event, To, Zone)
local text=string.format(CVN_beacon_unit:GetName().." left patrol zone %s.", Zone:GetName())
MESSAGE:New(text, msgTime):ToBlue()
USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE)
env.info(text)
end