Jump to content

Static Objects Spawning/Removing


Woodbuster

Recommended Posts

Hi,

I know the basics of mission building however I do not find any documentation on conditions for static objects spawning/removing .

This is quite straightforward with Units/Groups activation but I fail when it comes to static stuff.

Basically I just want make an object spawning (or removing) when a certain aircraft slot (client) is chosen by player.

 

Could someone help ?

Link to comment
Share on other sites

... I can show you how I do it.

 

Yes, please do .. I’d love to be able to place static aircrafts on the place that later will be occupied by an MP client :D ... thanks a lot.

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

Unfortunately, this apparently simple mechanic requires a rather elaborate script (since this stuff isn't actually implemented in the game). I've simplified it as much as I've been able to, but it'll probably freak you out anyway :cry:

 

IMPROVED VERSION OF THE SCRIPT HERE

 

FURTHER IMPROVED VERSION HERE

 

ULTIMATE VERSION HERE (Highly recommended)


Edited by Hardcard
Link to comment
Share on other sites

Unfortunately, this apparently simple mechanic requires a rather elaborate script (since this stuff isn't actually implemented in the game). I've simplified it as much as I've been able to, but it'll probably freak you out anyway :cry:

 

...

 

Demo mission attached

 

Thanks a lot, I’ve learned so much from your scripts .. I will study this one, test it on MP and report back :)

Best regards,

 

Eduardo

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

Basic question..... Do scripts need to be placed in a specific location in DCS directory?

About script itself, I’m not sure about line 91:

ClientSet = SET_CLIENT:New():FilterActive():FilterPrefixes(" common client ME PILOT name prefix "):FilterOnce() -- All the clients you're interested in replacing must use this common prefix in their ME PILOT names

In " Client Static Replacement.miz ", Pilots’ name have no prefix. Should I add them in ME ?

Also, what’s the correct syntax for this prefix and if it uses a separator then should this latter be added to the above line ?


Edited by Woodbuster
Link to comment
Share on other sites

Basic question..... Do scripts need to be placed in a specific location in DCS directory?

 

A script is basically a text file, so it can be stored wherever you like, that is a matter of personal preference .. for me, I prefer to create a separate folder for each mission series, where I store not only the mission itself (the .MIZ file), but also any supporting files, like scripts, briefing images, background texts, etc, like this:

 

rEPPAxk.jpg

 

About script itself, I’m not sure about line 91:

 

ClientSet = SET_CLIENT:New():FilterActive():FilterPrefixes(" common client ME PILOT name prefix "):FilterOnce() -- All the clients you're interested in replacing must use this common prefix in their ME PILOT names

 

In " Client Static Replacement.miz ", Pilots’ name have no prefix. Should I add them in ME ?

 

It isnt really a prefix, but actually a suffix ... on the example mission the suffix is "_Client"

 

Also, what’s the correct syntax for this prefix and if it uses a separator then should this latter be added to the above line ?

 

You can follow the example set on the sample mission: "_Client" :)

 

@Hardcard: Just tried the sample mission and it works beautifully .. the statics are shown without pilot and as soon as I select either of then, the aircraft changes and is shown with pilot and open canopy :D

 

Will try it out on my DCS Server to see if it works on MP missions .. hopefully it does :)

Best regards and thanks again

 

Eduardo

.

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

Another basic question...

Is there a way to extract a script from a mission.

So that I can compare the original one to my failing attempts...

 

Sure .. close the mission on the Mission Editor, now open it on a compression utility, like WinRAR, navigate inside .. the scripts are on /l10n/DEFAULT/

 

HMcEFbk.jpg

 

From here, you can extract a copy of the script into your mission folder.

 

Hardcard's script uses the Moose framework .. that one is better to get from the source:

 

https://forums.eagle.ru/showthread.php?t=138043

 

I prefer to use the Moose_.lua version, as it takes less space inside the mission .. the other one is more oriented towards scripts developers.

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

Many thanks to Hardcard, that is just what I was looking for !

I added a third aircraft and it works fine ! Great script ! :thumbup:

 

Thanks to Eduardo as well for advices.

 

However please note that Moose_.lua from your link above does not work for me with that script. Instead I successfully use the one extracted from the mission.

Link to comment
Share on other sites

However please note that Moose_.lua from your link above does not work for me with that script. Instead I successfully use the one extracted from the mission.

 

Thanks for the tip .. I havent yet tried my own mission with that script, maybe Hardcard is ussing a custom version of Moose?

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

Hi there guys

 

Glad you got it working with additional clients :thumbup:

 

@Rudel: Please, if you get a chance, test this in MP

 

I foresee problems with the script when clients or replacement statics are killed (not 100% sure, though).

 

I'm also afraid that the clientSET won't update properly in MP (I really hope it works, fingers crossed).

 

Also, I don't like the way the script handles country and coalition settings for the replacement statics...

 

Perhaps the script could use another layer of "automation", so less input from the user is required.

 

I might improve this script in the future.

 

 

Now I'll try to answer some questions:

 

ClientSet = SET_CLIENT:New():FilterActive():FilterPrefixes("common client ME PILOT name prefix "):FilterOnce()-- All the clients you're interested in replacing must use this common prefix in their ME PILOT names

In " Client Static Replacement.miz ", Pilots’ name have no prefix. Should I add them in ME ?

Also, what’s the correct syntax for this prefix and if it uses a separator then should this latter be added to the above line ?

 

As Rudel pointed out, it can be either a prefix or suffix.

 

Syntax-wise, I normally use prefix_, although this time I went for _suffix

You can use any letter you want, stuff like * - also works.

 

I'd say most symbols should work, however, I wouldn't use any of the following:

.  ,  : ; () {} [] / \  

 

I mean, as long as they're between quotes (string format) they should work fine... it's just that I don't trust DCS to always tell them apart from regular LUA operators :D

 

 

Hardcard's script uses the Moose framework .. that one is better to get from the source:

https://forums.eagle.ru/showthread.php?t=138043

 

I prefer to use the Moose_.lua version, as it takes less space inside the mission .. the other one is more oriented towards scripts developers.

 

That file is outdated, I'm afraid:

MOOSE GITHUB Commit Hash ID: [color="Red"][b]2018-04-07[/b][/color]

 

Sure, it's a lighter file partly because it doesn't include comments... and partly because it's missing several new classes and methods that have been added over the last year.

 

At the very least, you should be using the latest release ( November 2018 )

 

However, new classes and methods have been added since last november as well, and several bugs have been fixed.

 

I'm using the Moose.lua develop version that I linked in my previous post, which I know to work.

The script might still work with older MOOSE versions...but it might also crash (the moment the old Moose.lua stumbles upon a new class / method).


Edited by Hardcard
Link to comment
Share on other sites

@Rudel: Please, if you get a chance, test this in MP ...

 

Will do, tough at the moment I'm trying to finish an update of my MiG-29 missions .. will test your script starting on Monday :)

 

That file is outdated, I'm afraid:

MOOSE GITHUB Commit Hash ID: [color=red][b]2018-04-07[/b][/color]

Sure, it's a lighter file partly because it doesn't include comments...

 

Didnt knew that ... thanks for pointing it out, hopefully @FlightControl will update it, as the size saving is important when you have many missions that use it :)

 

Cheers and thanks a lot for sharing your experience and knowledge

.

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

Hmm, would this work with statics on a carrier?

Thinking having one set for launch operations and another for recovery. So when calling inbound, or just a trigger somewhere, and it swaps to recovery layout.

- Jack of many DCS modules, master of none.

- Personal wishlist: F-15A, F-4S Phantom II, JAS 39A Gripen, SAAB 35 Draken, F-104 Starfighter, Panavia Tornado IDS.

 

| Windows 11 | i5-12400 | 64Gb DDR4 | RTX 3080 | 2x M.2 | 27" 1440p | Rift CV1 | Thrustmaster Warthog HOTAS | MFG Crosswind pedals |

Link to comment
Share on other sites

@Knock-Knock

 

If the carrier is moving and turning (which I'm assuming will be the case) the script needs to be modified, but yes, it should be possible.

 

Luckily, funkyfranky created a new MOOSE method at my request, which will come in handy here, this is the perfect opportunity to test it ;)

 

 

Here's what I'll do:

 

- First set of statics will appear when clients are on deck

 

- When no clients are on deck, the static set will be swapped

 

 

 

The inbound trigger that you mentioned would require custom F10 menus for carrier based groups and extra logic... I don't want to go there just yet, let's keep it simple.


Edited by Hardcard
Link to comment
Share on other sites

@Knock-Knock

 

If the carrier is moving and turning (which I'm assuming will be the case) the script needs to be modified, but yes, it should be possible.

 

Luckily, funkyfranky created a new MOOSE method at my request, which will come in handy here, this is the perfect opportunity to test it ;)

 

 

Here's what I'll do:

 

- First set of statics will appear when clients are on deck

 

- When no clients are on deck, the static set will be swapped

 

 

 

The inbound trigger that you mentioned would require custom F10 menus for carrier based groups and extra logic... I don't want to go there just yet, let's keep it simple.

 

 

Ah yes of course, you can assign a trigger to the carrier. Simple always does it :thumbup:

- Jack of many DCS modules, master of none.

- Personal wishlist: F-15A, F-4S Phantom II, JAS 39A Gripen, SAAB 35 Draken, F-104 Starfighter, Panavia Tornado IDS.

 

| Windows 11 | i5-12400 | 64Gb DDR4 | RTX 3080 | 2x M.2 | 27" 1440p | Rift CV1 | Thrustmaster Warthog HOTAS | MFG Crosswind pedals |

Link to comment
Share on other sites

@Rudel: Please, if you get a chance, test this in MP

 

I foresee problems with the script when clients or replacement statics are killed (not 100% sure, though).

 

Hello,

 

Finally, tried the sample mission today on my dedicated server .. initially it worked fine, tough I had to adjust the trigger zone of the TF-51 and get it exactly over the parking number .. as it was, the aircraft got damaged when I chose that MP slot.

 

Once the trigger was adjusted the aircraft didnt damage anymore, but there is a crashing noise when I enter the TF-51 .. something that doesnt happen with the Su-25T

 

But for the most part the script worked perfectly, but once the client gets killed, I get this error when trying to take control of other plane:

 

b20UKVA.jpg

 

on the log I get this error message:

 

EDCORE: # C0000005 ACCESS_VIOLATION at FBF310E4 00:00000000

 

Only the client crashes, the Server continues running and I can connect again once I restart the client DCS.

 

I will test it a bit more, using a mission of my own .. will try to gather more debugging data.

Best regards,

 

Eduardo

.

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

@Rudel_chw

 

Hey, thanks for testing!

 

Was the TF-51 static being removed properly when you spawned the client?

As it's written, the static will be removed after the client spawns, so there's a chance it won't be removed in time and cause damage (due to delays in the execution of the script)

 

As for the crash when the client gets killed, I'll need to run tests, might be due to several reasons.

 

Yesterday I managed to make substantial improvements to the script design, I'll probably post an improved version today...


Edited by Hardcard
Link to comment
Share on other sites

Well, I've managed to improve the script quite a lot, now you only need to fill up the reference table and specify the common client prefix/suffix, the script should take care of the rest :thumbup:

 

I've tested it many times, I get no error messages or crashes, I can also respawn clients using the key command as well.

The script keeps working when clients die and respawn as well.

Btw, I've discovered that the template statics don't need to be alive after spawning for the first time, you can set them to DEAD in ME, the script will still work!

 

 

IMPORTANT NOTES:

 

 

 

 

- This is a MOOSE script, which means that you'll need to load Moose.lua using a MISSION START trigger in order for it to work!

 

- This script can be loaded using a ONCE trigger (no conditions), after the Moose.lua MISSION START trigger

 

- Clients must join spectators before entering any client slot (only the first time around)

 

- For each client included, a static aircraft of the same type must be placed somewhere far, far away on the map (out of sight, out of harm's way). Set it to DEAD in ME, that way it shouldn't impact performance.

 

 

- You need to create a small spawn zone (10m, ~30ft) for each client you want to replace. The zones must be centered on the parking spot the clients will spawn from (yes, they're supposed to spawn from ramp, that way you won't notice the swapping :thumbup:)

 

 

- Triple check that all client, static and zone names both in ME and the script match! Make sure that all the values within the script's Reference_Table are correct! ( also remember that LUA is case sensitive! )

 

 

- I haven't tested any of this in MP, certain things might not work there

 

 

 

 

Here's the improved script (all the required values are marked in red, don't remove any commas or quotation marks):

 

 

 

 

local Reference_Table = {

 

[1] = { -- Notice that now clients are identified by an index number instead of a string / name

ClientName = " Unit name of the first client in ME " , -- PILOT name of the first client in ME

StaticName = " Name of the replacement static in ME " , -- Name of the replacement static in ME

Bearing = number , -- Desired heading of the replacement static on spawn

ZoneName = " Name of the zone in ME " , -- Name of the zone where the replacement static is supposed to spawn

Country = country.id.COUNTRY , -- Check the list of country enumerators (constants) for COUNTRY values

Coalition = coalition.side.COLOR -- Coalition color can be either BLUE or RED. Simply match the country and coalition of your client

},

 

-- Copy/paste and modify the subtable for each additional client

 

[2] = { -- Don't forget to change the index number as well

ClientName = " Unit name of the second client in ME " ,

StaticName = " Name of the replacement static in ME " ,

Bearing = number ,

ZoneName = " Name of the zone in ME " ,

Country = country.id.COUNTRY ,

Coalition = coalition.side.COLOR

},

 

-- etc...

}

 

 

local SPAWNSTATIC_Table = {}

 

local Spawned_Static_Table = {}

 

 

local function Spawned_Check(Static__Name)

 

Detected = 0

 

for i, static in pairs( Spawned_Static_Table ) do

 

if static:isExist() ~= true then

 

 

Spawned_Static_Table = nil

 

elseif static:isExist() and string.find( static:getName(), Static__Name ) then

 

Detected = Detected + 1

 

end

end

 

if Detected > 0 then

 

return true

 

elseif Detected == 0 then

 

 

 

return false

 

end

end

 

 

 

local function Cleanup_Statics(Static_Name)

 

 

for i, Object in pairs( Spawned_Static_Table ) do

 

if Object:isExist() ~= true then

 

Spawned_Static_Table = nil

 

elseif Object:isExist() and string.find( Object:getName(), Static_Name ) then

 

 

Object:destroy()

Spawned_Static_Table = nil

 

end

end

end

 

 

 

local function Static_Spawner()

 

ClientSet = SET_CLIENT:New():FilterActive():FilterPrefixes(" Common PILOT name prefix / suffix "):FilterOnce() -- Common unit prefix / suffix for all referenced clients

 

 

for i, client in ipairs( Reference_Table ) do

 

SPAWNSTATIC_Table = SPAWNSTATIC:NewFromStatic(client.StaticName, client.Country, client.Coalition)

 

if ClientSet:FindClient(client.ClientName) == nil and Spawned_Check(client.StaticName) == false then

 

SPAWNSTATIC_Table:SpawnFromPointVec2( ZONE:New(client.ZoneName):GetPointVec2(), client.Bearing, client.StaticName..math.random(1, 100) )

 

end

end

end

 

 

local Handler = {}

 

function Handler:onEvent(event)

 

 

if event.id == 15 then -- 15 means event Birth

 

 

for i , client_ in ipairs( Reference_Table ) do

 

if event.initiator:getCategory() == 3 and string.find( event.initiator:getName() , client_.StaticName ) then

 

table.insert(Spawned_Static_Table, event.initiator)

 

 

 

end

end

 

 

for i , CLIENT in ipairs( Reference_Table ) do

 

 

if event.initiator:getCategory() ~= 3 and event.initiator:getName() == CLIENT.ClientName then

 

Cleanup_Statics(CLIENT.StaticName)

Static_Spawner()

 

end

end

end

end

 

world.addEventHandler(Handler)

 

 

Static_Spawner()

 

 

Loop = 1

 

local function Permanent_Scheduler(Loop, time)

 

Static_Spawner()

 

if Loop == 1 then

return time + 49

end

end

 

timer.scheduleFunction(Permanent_Scheduler, Loop, timer.getTime() + 10)

 

 

 

 

 

 

Demo mission + script file attached

Client Static Replacement (improved).miz

Client Replacement with Statics (improved).lua


Edited by Hardcard
Link to comment
Share on other sites

@Knock-Knock

 

Nope, no dice.

 

Looks like statics can't be spawned on carriers using this method... I can make them spawn on the correct coordinates, but they're placed at the bottom of the sea instead of on the deck... :cry:

 

Ah bummer. Maybe some day DCS will allow it, cause it sure would add an extra dimension to carrier operations. Thank you so much for giving it a go :thumbup:.

- Jack of many DCS modules, master of none.

- Personal wishlist: F-15A, F-4S Phantom II, JAS 39A Gripen, SAAB 35 Draken, F-104 Starfighter, Panavia Tornado IDS.

 

| Windows 11 | i5-12400 | 64Gb DDR4 | RTX 3080 | 2x M.2 | 27" 1440p | Rift CV1 | Thrustmaster Warthog HOTAS | MFG Crosswind pedals |

Link to comment
Share on other sites

Well, I've managed to improve the script quite a lot, now you only need to fill up the reference table and specify the common client prefix/suffix, the script should take care of the rest :thumbup:

 

Demo mission + script file attached

 

Thanks a lot for the time you are dedicating to this, will try your script later today on my dedicated server and report back :)

 

I had played with something like this a while ago, but unsucessfully:

 

https://forums.eagle.ru/showthread.php?t=222981

 

:) thanks again

 

Eduardo

 

For work: iMac mid-2010 of 27" - Core i7 870 - 6 GB DDR3 1333 MHz - ATI HD5670 - SSD 256 GB - HDD 2 TB - macOS High Sierra

For Gaming: 34" Monitor - Ryzen 3600X - 32 GB DDR4 2400 - nVidia GTX1070ti - SSD 1.25 TB - HDD 10 TB - Win10 Pro - TM HOTAS Cougar - Oculus Rift CV1

Mobile: iPad Pro 12.9" of 256 GB

Link to comment
Share on other sites

  • Recently Browsing   0 members

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