--env.info("Loading Naval Script", true) -- 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 Tarawa_Carrier_Group = GROUP:FindByName("LHA-1 Tarawa") local Tarawa_Beacon_Unit = UNIT:FindByName("LHA-1 Tarawa") local Tarawa_ICLS_Channel = 1 local Tarawa_ICLS_Name = "LHA" local Tarawa_TACAN_Channel = 4 local Tarawa_TACAN_Name = "LHA" local Tarawa_RecoveryWindowTime = 20 -- Create a NAVYGROUP object and activate the late activated group. BlueLHAGroup=NAVYGROUP:New("LHA-1 Tarawa") BlueLHAGroup:SetVerbosity(1) BlueLHAGroup:MarkWaypoints() -- Function to turn ship into the wind. function LHA_start_recovery() if BlueLHAGroup:IsSteamingIntoWind() == true then MESSAGE:New(Tarawa_Beacon_Unit:GetName() .. " is currently launching/recovering aircraft, currently active recovery window closes at time " .. timerecovery_end, msgTime, "LHANAVINFO",false):ToBlue() USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) else local timenow=timer.getAbsTime( ) local timeend=timenow+Tarawa_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) BlueLHAGroup:AddTurnIntoWind(timerecovery_start,timerecovery_end,25,true,-9) MESSAGE:New(Tarawa_Beacon_Unit:GetName().." is turning into the wind to begin " .. Tarawa_RecoveryWindowTime .. " mins of aircraft operations.\nLaunch/Recovery Window will be open from time " .. timerecovery_start .. " until " .. timerecovery_end, 35, "LHANAVINFO",false):ToBlue() USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) end end --- Function called each time the group passes a waypoint. function BlueLHAGroup:OnAfterPassingWaypoint(From, Event, To, Waypoint) local waypoint=Waypoint --Ops.OpsGroup#OPSGROUP.Waypoint -- Debug info. local text=string.format(Tarawa_Beacon_Unit:GetName().." passed waypoint ID=%d (Index=%d) %d times", waypoint.uid, BlueLHAGroup: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 waypoint == 0 then MESSAGE:New(Tarawa_Beacon_Unit:GetName().. "proceeding to waypoint 1", msgTime):ToBlue() USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) BlueLHAGroup:GotoWaypoint(1) end if waypoint == 2 then MESSAGE:New(Tarawa_Beacon_Unit:GetName().. "proceeding to waypoint 2", msgTime):ToBlue() USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) BlueLHAGroup:GotoWaypoint(0) end end local CVN_carrier_group = GROUP:FindByName("CVN-72 Abraham Lincoln") -- 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 = 5 -- 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 = 3 -- 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(2) end --function SetCVNWayPoint3() -- SetCVNActivePatrolZone = 3 -- MESSAGE:New(msgCVNPatrol .. SetCVNActivePatrolZone, msgTime):ToBlue() -- USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) -- BlueCVNGroup:GotoWaypoint(3) --end -- --function SetCVNWayPoint4() -- SetCVNActivePatrolZone = 4 -- MESSAGE:New(msgCVNPatrol .. SetCVNActivePatrolZone, msgTime):ToBlue() -- USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) -- BlueCVNGroup:GotoWaypoint(4) --end -- Setup TACAN and ILS 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) if Tarawa_Beacon_Unit then BlueTarawaGroup_Beacon = Tarawa_Beacon_Unit:GetBeacon() BlueTarawaGroup_Beacon:ActivateICLS(Tarawa_ICLS_Channel,Tarawa_ICLS_Name) end SCHEDULER:New(nil,function() if Tarawa_Beacon_Unit then BlueTarawaGroup_Beacon = Tarawa_Beacon_Unit:GetBeacon() BlueTarawaGroup_Beacon:ActivateTACAN(Tarawa_TACAN_Channel,"X",Tarawa_TACAN_Name,true) end end,{},5,5*60) -- Function to turn ship into the wind. function CVN_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 E-2D Wizard Group") :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 CVNMenu = MENU_COALITION:New(coalition.side.BLUE,"CVN Command") --MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Patrol Zone 1",CVNMenu,SetCVNWayPoint1) --MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Patrol Zone 2",CVNMenu,SetCVNWayPoint2) --MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Patrol Zone 3",CVNMenu,SetCVNWayPoint3) --MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Patrol Zone 4",CVNMenu,SetCVNWayPoint4) MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Reset AWACS",CVNMenu,ResetAwacs) MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Launch/Recover Aircraft (Turn CVN into the wind)",CVNMenu,CVN_start_recovery) MENU_COALITION_COMMAND:New(coalition.side.BLUE, "Launch/Recover Aircraft (Turn LHA into the wind)",CVNMenu,LHA_start_recovery) -- Create a NAVYGROUP object and activate the late activated group. BlueCVNGroup=NAVYGROUP:New("CVN-72 Abraham Lincoln") 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 MESSAGE:New(CVN_beacon_unit:GetName().. "proceeding to waypoint 2", msgTime):ToBlue() USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) BlueCVNGroup:GotoWaypoint(2) end if SetCVNActivePatrolZone == 1 and waypoint == 2 then MESSAGE:New(CVN_beacon_unit:GetName().. "proceeding to waypoint 3", msgTime):ToBlue() USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) BlueCVNGroup:GotoWaypoint(1) end if SetCVNActivePatrolZone == 1 and waypoint == 3 then MESSAGE:New(CVN_beacon_unit:GetName().. "proceeding to waypoint 2", msgTime):ToBlue() USERSOUND:New("ping.ogg"):ToCoalition(coalition.side.BLUE) BlueCVNGroup:GotoWaypoint(2) 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 -- Monitor entering and leaving zones. There are four zones named "Zone Leg 1", "Zone Leg 2", ... 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