Help adding a customised helo to a ship?

Post new mods and scenarios here.

Moderator: MOD_Command

Post Reply
Pipski
Posts: 2
Joined: Tue Feb 08, 2022 2:36 pm

Help adding a customised helo to a ship?

Post by Pipski »

Hi guys. I'm working on my first ever scenario at the moment, and it's been going well but I've run into a problem.

The precise model of helicopter I need isn't present in the database. No biggie -- I can make an equivalent by renaming a civilian model that is available and then bunging a searchlight on it -- however, I can't find a way to then start that modified helicopter on a ship or in a hangar, or to add one to a ship or airbase in the usual way, with [ctrl+F6], and then edit it once it's on/in there to change the name and sensors.

Is there an alternative way to accomplish this, that I'm just not thinking of? Or am I going to have to start them off nearby with orders to immediately land where I want them? (And yes, I know it's an anally retentive thing to obsess about, but it'll just annoy me every time I load the mission if I can't make it work!)

Any suggestions gratefully received.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Help adding a customised helo to a ship?

Post by KnightHawk75 »

Yes once stored at a base you can't select the unit to make modifications, so either add the customization via Lua (ScenEdit_UpdateUnit), or edit them before placing them into their hosting units during development.

For example adding a searchlight to 10 choppers with similar names who are sitting in a base:

Code: Select all

 local function addSpotlight(unitbasename,sidename,start,stop)
   local arcT={'PB1','PB2','SB1','SB2','SMF1','SMF2','SMA1','SMA2','SS1','SS2','PS1','PS2','PMA1','PMA2','PMF1','PMF2'}; 
   local arcD={'PB1','PB2','SB1','SB2','SMF1','SMF2','SMA1','SMA2','SS1','SS2','PS1','PS2','PMA1','PMA2','PMF1','PMF2'}; 
   local arcM={'360'};
   for i = start,stop do
     local u = ScenEdit_GetUnit({side=sidename,name=unitbasename..i});
     ScenEdit_UpdateUnit({guid=u.guid,mode="add_sensor",dbid=1080,arc_detect=arcD,arc_track=arcT, arc_mount=arcM}) --Generic spotlight 360 view
   end
 end
 addSpotlight("Chopper #","Red",1,10) --- add a spotlight to 'Chopper #1' through 'Chopper #10';
 
If customizing manually and you're just asking how to shove a unit into a base when done adding and customizing it:
You can call ScenEdit_HostUnitToParent({HostedUnitNameOrID='GUIDOF-THEUNITHEREXX',SelectedHostNameOrID='GUIDOF-THEBASEHEREXX'}) on each unit to insert them to a base\hosting unit. You can easily get the guid of a unit in the editor by pressing ctrl-c and pasting into the console. You could use names as well but they'll have to be globally unique names as there is no side specifier.

Code: Select all

 local function insertUnitsIntoBase(unitbasename,sidename,destinationGuid,start,stop)
   for i = start,stop do
     local u = ScenEdit_GetUnit({side=sidename,name=unitbasename..i});
     ScenEdit_HostUnitToParent({HostedUnitNameOrID=u.guid,SelectedHostNameOrID=destinationGuid})
   end
 end
 insertUnitsIntoBase("Chopper #","Red","GUIDOF-BASEHERE",1,10)
 
Or do it all at once create, add the sensor and insert in one go.

Code: Select all

 local function addMyCustomChoppersToBase(unitbasename,type,sidename,number,dbid,loadout,baseguid)
   local arcT={'PB1','PB2','SB1','SB2','SMF1','SMF2','SMA1','SMA2','SS1','SS2','PS1','PS2','PMA1','PMA2','PMF1','PMF2'}; 
   local arcD={'PB1','PB2','SB1','SB2','SMF1','SMF2','SMA1','SMA2','SS1','SS2','PS1','PS2','PMA1','PMA2','PMF1','PMF2'}; 
   local arcM={'360'};
   for i = 1,number do
     local u = ScenEdit_AddUnit({side=sidename,type=type,name=unitbasename..i,dbid=dbid,loadoutID=loadout,latitude=0.0,longitude=0.0,altitude=0}); -- create unit.
     u = ScenEdit_UpdateUnit({guid=u.guid,mode="add_sensor",dbid=1080,arc_detect=arcD,arc_track=arcT, arc_mount=arcM}); --Generic spotlight 360 view
     ScenEdit_HostUnitToParent({HostedUnitNameOrID=u.guid,SelectedHostNameOrID=baseguid}); --insert into base
   end    
 end
 addMyCustomChoppersToBase("GlobalRanger #","Aircraft","Red",10,4848,26432,'4FH7PU-0HMFB711P8969'); --add 10, with customization to base specified.
 
Pipski
Posts: 2
Joined: Tue Feb 08, 2022 2:36 pm

RE: Help adding a customised helo to a ship?

Post by Pipski »

Outstanding, thank you! I will play around with that code and give it a go -- much obliged, dude. :-)

e; worked like a charm!
benefant
Posts: 106
Joined: Fri Jun 05, 2015 8:40 am
Location: Austria

RE: Help adding a customised helo to a ship?

Post by benefant »

I use simple methode:

Set the Base and the aircraft to another continent. Modifify aircraft in flight with Sensors and weapons - a Cessna with guns and ironie bombe etc.

Return to base and then move the base back.
Post Reply

Return to “Mods and Scenarios”