Rescue Helo-Carrier Formation 24/7 - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 07-14-2018, 09:40 AM   #1
funkyfranky
Senior Member
 
funkyfranky's Avatar
 
Join Date: Sep 2015
Location: Asgård
Posts: 1,804
Lightbulb Rescue Helo-Carrier Formation 24/7

I've seen some people asking about the possibility to have a helo fly in formation with an aircraft carrier. With the ME tools this seems to be quite a hassle when defining the waypoints, i.e. matching the speeds or ETAs of both units etc. Also the situation when the helo runs out of fuel seems problematic.

So here is a little MOOSE script where no fiddling around with speeds etc is necessary. Carrier can have any number of waypoints or any speed. The exact offset of the carrier can be specified. When the helo is out of fuel it will land on the carrier, be respawned and then go back on station again. When the carrier has reached its last waypoint, it will automatically start again at its first waypoint and so on. So this script will run 24/7.



In the script, you only need to specify the name of the carrier unit (here "USS Stenniks" and the name of the helo group (here "Rescue Helo"). There are some other options for letting the carrier travel randomly between its waypoint. Also the helo can be spawned in air rather than on deck since spawning on carriers can sometimes be problematic.

Code and example mission below.

Hope it helps

Code:
----------------------------------------------------------------------------------------------------------
-- Script is loading.
env.info("Loading MOOSE Rescue Helo-Carrier Formation Script v1.0 by FF")

----------------------------------------------------------------------------------------------------------
-- Set parameters.

-- Carrier UNIT name as set in the ME. 
local CarrierUnitName="USS Stennis"

-- Helo GROUP name as set in the ME.
local HeloGroupName="Rescue Helo"

-- Offset [meters] in the direction of travelling. Positive values are in front of Mother.
local OffsetX=300
-- Offset [meters] perpendicular to travelling. Positive = Starboard (right of Mother), negative = Port (left of Mother).
local OffsetZ=200
-- Offset altitude. Should (obviously) always be positve.
local OffsetY=80

-- Take of type. If true, helo is spawned in air. If false, helo is spawned hot on the carrier.
local SpawnInAir=false

-- If true, Carrier will randomly select waypoints from the ones defined in the ME.
local RandomRoute=false

----------------------------------------------------------------------------------------------------------
-- Scripting Part - no need to change anything below unless you know what you are doing.

-- Report mission time every 30 sec.
local ReportTime=false

-- Report fuel of helo group every 60 sec.
local ReportFuel=false

-- Display mission time.
if ReportTime then
  local Scheduler_Mission_Time = SCHEDULER:New(nil, UTILS.DisplayMissionTime, {}, 0, 30)
end

-- Debug info.
env.info(string.format("Carrier Unit Name = %s", CarrierUnitName))
env.info(string.format("Helo Group Name   = %s", HeloGroupName))
env.info(string.format("Offset X (front)  = %.1f m", OffsetX))
env.info(string.format("Offset Z (port)   = %.1f m", OffsetZ))
env.info(string.format("Offset Y (alt)    = %.1f m", OffsetY))
env.info(string.format("Spawn in air      = %s", tostring(SpawnInAir)))
env.info(string.format("Random Route      = %s", tostring(RandomRoute)))

-- Set takeoff type.
local Takeoff=SPAWN.Takeoff.Hot  -- Adjust this to SPAWN.Takeoff.Cold for a cold start, i.e. with engines off. 
if SpawnInAir then
  Takeoff=SPAWN.Takeoff.Air
end

-- Carrier "USS Stennis" = Mother. "USS Stennis" is the name of the unit of the carrier given to the carrier in the ME. 
local Mother=UNIT:FindByName(CarrierUnitName)

-- Carrier group will patrol the defined waypoints indefinetly.
if RandomRoute then
  Mother:PatrolRouteRandom(20)
else
  Mother:PatrolRoute()
end

-- Spawn helo.
local SpawnHelo=SPAWN:New(HeloGroupName)
local HeloSpawn=SpawnHelo:SpawnAtAirbase(AIRBASE:FindByName(CarrierUnitName), Takeoff, OffsetY)

-- Set of group(s) to follow Mother.
local FollowGroupSet = SET_GROUP:New()
FollowGroupSet:AddGroupsByName(HeloSpawn:GetName())

-- Define AI Formation object.
local CarrierFormation = AI_FORMATION:New(Mother, FollowGroupSet, "Helo Formation with Carrier", "Follow Carrier at given parameters.")

-- Formation parameters.
CarrierFormation:FormationCenterWing(-OffsetX, 50, math.abs(OffsetY), 50, OffsetZ, 50)

-- Start formation FSM.
CarrierFormation:__Start(2)

-- Subscribe helo group set to the event land.
FollowGroupSet:HandleEvent(EVENTS.Land)

-- Respawn helo group once it landed because it was out of fuel.
function FollowGroupSet:OnEventLand(EventData)
  local group=EventData.IniGroup --Wrapper.Group#GROUP
  if group and group:GetName():match(HeloGroupName) then
    env.info(string.format("CarrierFormation: Respawning group %s.", group:GetName()))
    group:RespawnAtAirbase(AIRBASE:FindByName(CarrierUnitName), Takeoff)
  end
end
----------------------------------------------------------------------------------------------------------

if ReportFuel then
  --- Report fuel function of following group.
  local function ReportFuel()
    for _,myhelo in pairs(FollowGroupSet:GetSet()) do
      if myhelo and myhelo:IsAlive() then
        local fuel=myhelo:GetFuel()
        local text=string.format("%s: fuel = %.2f %%", myhelo:GetName(), fuel*100)
        MESSAGE:New(text, 5):ToAll()
      end
    end
  end
  
  -- Report fuel state of helo every 10 seconds.
  local Scheduler_Helo_Fuel = SCHEDULER:New(nil, ReportFuel, {}, 60, 60)
end

----------------------------------------------------------------------------------------------------------
Attached Files
File Type: miz CarrierFormation.miz (1.38 MB, 9 views)
File Type: lua Carrier_Formation.lua (4.7 KB, 79 views)
__________________
Of all the things I've lost, I miss my mind the most. --- Mark Twain
i7-8700K | Asus GTX 1080 Ti Strix OC| 32 GB Ram 3200 MHz DDR-4| Win 10 64-bit | Asus Maximus Hero X | Samung EVO 960 Pro SSD | VKB Gunfighter Pro | MFG Crosswind | CV1

Last edited by funkyfranky; 07-17-2018 at 07:03 PM. Reason: Bug Fix
funkyfranky is offline   Reply With Quote
Old 07-14-2018, 12:55 PM   #2
Johnny_Rico
Senior Member
 
Johnny_Rico's Avatar
 
Join Date: Jul 2017
Posts: 1,336
Default

Amazing stuff Franky, very well done
__________________
METAR weather for DCS World missions

Guide to help out new DCS MOOSE Users -> HERE
Havoc Company Dedicated server info Connect IP: 94.23.215.203
SRS enabled - freqs - Main = 243, A2A = 244, A2G = 245
Please contact me HERE if you have any server feedback or METAR issues/requests
Johnny_Rico is online now   Reply With Quote
Old 07-14-2018, 04:14 PM   #3
WildBillKelsoe
Veteran
 
WildBillKelsoe's Avatar
 
Join Date: Jun 2009
Location: Cairo, Egypt
Posts: 6,221
Default

my god this is awesome! thanks for sharing!
__________________
AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS

Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.
WildBillKelsoe is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:12 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.