Jump to content

Recommended Posts

Posted

I'm trying to liven up the dynamic scenery by randomly spawning some aircraft. That's all working out nice and well, but I want to take it a step further: by also changing the aircraft's liveries. To do that, I'l like to know what liveries are available for a particular type. Lett's say we take the Yak-40. I notice that there are 5 liveries available, and their livery names match the 5 folder names inside Bazaar/Liveries/Yak-40, so there evidently seems to be a strong relationship.

Now, since I don't want to trawl a users (would they want to run my mission) storage to glean information that I assume is there already, so my question is this:

Is there an API that allows me to get a unit type's available liveries?

for example is there something akin to (table) Object.getTypeLiveries(string type) that would return a table of livery names for any given type name and that I can then use to spawn a properly liveried unit?

For example, invoking Object.getTypeLiveries("Yak-40") would return {"Aeroflot", "Algeria GLAM", "Georgian Airlines", "Olympian Airways", "Ukrainian"}

Is there anything like that available?

Thank you for any pointers,

-ch

 

  • Like 1
Posted

There seems to be a function that the mission editor uses to get the livery for a unit type on a per country basis but that doesn't exist as something available to the mission scripting env. It is a good idea and one would hope it could be easily added by ED. 

Your best bet would be to either make a static list or to use the liveries set in the mission file as an option. What I mean is parse the file to get to the unit data where info like payload is at, then add whatever is in the livery_id to a look up table as something to pick at random. Requires a user to place a unit with the liveries to be set, but it would work. 

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted (edited)
9 hours ago, Grimes said:

parse the file to get to the unit data where info like payload is at, then add whatever is in the livery_id to a look up table as something to pick at random.

Thank you so much, @Grimes-- that was indeed my first attempt. I was looking for a better way since that method pre-supposes that the mission designer first all variants of a plane on the map first, and will not automatically react to new liveries when they come available - which appears like somewhat of a kludge to me.

In the past year I've looked into liveries when spawning aircraft, and if you don't mind, I'd like to compare notes (since after all, the initial information was gleaned from this (your?) great site, which still helps me daily.

 

Liveries - according to cfrag

Liveries can be applied to units when they are spawned by invoking coalition.addGroup(countryID, category, groupData). They cannot be changed after the unit has spawned.

groupData contains an array units[] which contains individual unit data.

unit data is a table that contains various mandatory and optional elements that describe the unit to be spawned, and for aircraft and helicopters, an optional unit element is the 'livery_id' entry. This entry defines which livery is applied to that unit when it spawns. Warning: several restrictions apply (see below)

Type: livery_id is a string
Value: name of the livery to apply to the unit. 
Notes:

  • the name of the livery can't be discovered from within DCS/Lua. It appears to be the name for the folder that describes the livery inside the type's folder structure in "Bazar/Liveries/<Type_Name>". It must be provided and hard-coded.
  • Liveries are tied to countryID that is passed to coalition.addGroup(), and their in-game representation is heavily influenced as follows:
    •     A type's livery is only available for certain countries, but it can't be discovered in code which livery is available for which country per type.  
    •     Contries can have multiple liveries available, but it can't be discovered in code which country has which liveries available for any given type.
    •     the synthetic countries 'combined joint task force' have access to all liveries, except for UN peacekeepers, which has access to none [EDIT: UN peacekeepers seems to work mostly, further investigation required]
    •     should you spawn a unit for a country for with the chosen livery is not available (e.g. spawn a Yak-40 with "Olympian Airways" livery for Argentinia), the livery displayed on the unit in-game can revert to the default livery 
    • if the a livery with the name that you specified does not exist (any more), the aircraft will display the default livery instead
    • the default livery for a unit can't be discovered in code, and appears to be the first livery placed in the internal livery hash table for that unit. Since it is a hash, it is not necessarily numerically nor alphabetically the first livery read from storage for that type.

    
How much of that Is in line with your own notes?

 

Thanks,
-ch

Edited by cfrag
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...