Jump to content

Static objects Despawn and spawn


Cypher1o1

Recommended Posts

  • 2 months later...

@ScopeDope

 

I don't know of a way to spawn static objects once the mission has started, but you can use late activated AI units to "replace" the statics you remove.

 

For instance, the attached MOOSE demo mission has 2 static hornets and 1 static sea stallion (on the Stennis' deck) at mission start.

All these statics will be removed 10 seconds after mission start, then, 2x late activated hornets and a late activated sea stallion will spawn at a different location (starting from ramp).

 

Basically, removing any number of statics from the Stennis' deck is easy to do, "replacing" them, however, not so much :cry:

Stennis static spawn_despawn.miz

Static Spawn Carrier.lua


Edited by Hardcard
Link to comment
Share on other sites

We have 4 spots on the cats and 4 additional. I simulate more by either late-activating groups airborne near the CVN or having them orbit until triggered. Add a triggered message "Wheels up." Once human pilots are launched they can't see the flight deck anyway.

Link to comment
Share on other sites

Thanks Hardcard. Too bad we're still limited to having 4 parking spots...

 

Yup, that's not ideal

 

 

Is there anyway to remove some of the static, or is it an all or nothing switch in the script?

 

The script I provided uses a set of statics, which includes all statics in that mission. The "removal" function is applied to all the statics within the set.

 

I wrote it that way because it makes things simpler, but, sure, the script can be modified to target specific statics:

 

 

local StaticSet = SET_STATIC:New()

:FilterPrefixes("Static_") -- This is the key. It'll look for all statics that use "Static_" as prefix in their ME name. These will be included in the set

:FilterStart()

 

StaticSet:ForEachStatic( -- This iterator will run the following function for each static in the set

function(StaticUnit)

 

Stuff you want to do with the statics in StaticSet

 

end

)

 

-- Now, imagine I had several static hornets and several static sea stallions on the Stennis' deck. I could create two separate sets instead, one for each type

 

local HornetSet = SET_STATIC:New()

:FilterPrefixes("Hornet_") -- This will look for all statics that use "Hornet_" as prefix in their ME name. Needless to say that you need to modify the name of the static hornets in ME, so they use this prefix

:FilterStart()

 

 

HornetSet:ForEachStatic( -- We can use the same kind of iterator as before, this time it'll apply to the static hornet set only

function(HornetUnit)

 

Stuff you want to do with the statics in HornetSet

 

end

)

 

-- Then we do the same thing with the static sea stallions

 

local StallionSet = SET_STATIC:New()

:FilterPrefixes("Stallion_") -- This will look for all statics that use "Stallion_" as prefix in their ME name. Needless to say that you need to modify the name of the static stallions in ME, so they use this prefix

:FilterStart()

 

StallionSet:ForEachStatic( -- We can use the same kind of iterator as before, this time it'll apply to the static stallion set only

function(StallionUnit)

 

Stuff you want to do with the statics in StallionSet

 

end

)

 

 

-- So far, I've only used sets to target statics, since that's the easiest way to handle several groups at once (each static can be considered a separate group),

-- However, if you want to target individual statics instead, you can use:

 

STATIC:FindByName("Name of the static in ME")

 

-- Let's say I want to target the first static hornet only:

 

local Static_Hornet_1 = STATIC:FindByName("Name of the first static hornet in ME")

 

-- Then, I can remove it from the map whenever I choose, by using

 

Static_Hornet_1:Destroy()

 

 

 


Edited by Hardcard
Link to comment
Share on other sites

Hardcore,

 

First. Thanks for this script. Very awesome!

 

But I'm having an issue where the "Static Respawn Test" only seems to work if the Trigger "MOOSE Load" exist.

 

But I do not see the Moose.lua. Is it imbedded into the mission file you provided?

 

As a result, using the "Static Respawn Test" doesn't work on my mission despite having the correct naming. I'm I missing something to get this to work on my mission?

 

Also, launching your mission file and removing the "Moose Load" reference breaks the "Static Respawn Test".

Link to comment
Share on other sites

I do not see the Moose.lua. Is it imbedded into the mission file you provided?

 

Yes, it's in there.

Open the mission file with winzip/winrar/7zip/etc. and navigate to Stennis static spawn_despawn.miz\l10n\DEFAULT , you'll find it there.

 

Alternatively, you can download it here

 

As a result, using the "Static Respawn Test" doesn't work on my mission despite having the correct naming. I'm I missing something to get this to work on my mission?

Also, launching your mission file and removing the "Moose Load" reference breaks the "Static Respawn Test".

 

As you've probably deduced, the script won't work without Moose.lua being loaded first, since it's a MOOSE script.

You need to create that "MOOSE load" trigger at mission start, with a "DO SCRIPT FILE" action that runs Moose.lua


Edited by Hardcard
Link to comment
Share on other sites

Awesome! Thanks again.

 

On a side note, the Moose.lua seems a bit heavy. Is it possible for me to strip what I don't need and keep the functions that allow the "Static Spawn" lua to work, or is the whole script pretty much necessary? Just trying to reduce the number of functions on my mission as possible. But if I need it all, I'll use it!

Link to comment
Share on other sites

Awesome! Thanks again.

 

On a side note, the Moose.lua seems a bit heavy. Is it possible for me to strip what I don't need and keep the functions that allow the "Static Spawn" lua to work, or is the whole script pretty much necessary? Just trying to reduce the number of functions on my mission as possible. But if I need it all, I'll use it!

Not sure which one you have, but looks like there's a smaller file located on the MOOSE thread:

 

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

i9 9900k @5.1GHz NZXT Kraken |Asus ROG Strix Z390 E-Gaming | Samsung NVMe m.2 970 Evo 1TB | LPX 64GB DDR4 3200MHz

EVGA RTX 3090 FTW3 Ultra | Reverb G1  | HOTAS Warthog | Saitek Flight Pedals

Link to comment
Share on other sites

@pimp

 

That's an older MOOSE release

 

@Teriander

 

Modify Moose.lua at your own risk, I don't recommend it, but you are free to try, ofc.

 

As for performance, Moose.lua by itself shouldn't affect it.

Think of it as a "scripting dictionary/translator", it shouldn't do anything by itself. It'll simply "translate" your MOOSE scripts so the DCS scripting engine "understands" them.

 

Anyway, you can always use DCS scripting methods instead, no Moose.lua required for those.


Edited by Hardcard
Link to comment
Share on other sites

@pimp

 

That's an older MOOSE release

 

@Teriander

 

Modify Moose.lua at your own risk, I don't recommend it, but you are free to try, ofc.

 

As for performance, Moose.lua by itself shouldn't affect it.

Think of it as a "scripting dictionary/translator", it shouldn't do anything by itself. It'll simply "translate" your MOOSE scripts so the DCS scripting engine "understands" them.

 

Anyway, you can always use DCS scripting methods instead, no Moose.lua required for those.

 

Where could I get the latest Moose release?

Link to comment
Share on other sites

  • 1 year later...

Hello guys, can i ask you something?.. I'm trying to use your scrypt for spawn statics with 10s delay.

 

Do you see an error? My static name objects is :

FpostB1_Fuel1

FpostB1_Fuel2

FpostB1_Fuel3

FpostB1_Fuel4

 

local StaticSet = SET_STATIC:New()

:FilterPrefixes("FpostB1_")

:FilterStart()

 

local FpostB1Fuel = SPAWN:New("Fuel")

 

 

local SpawnFlag = USERFLAG:New("Spawn Flag")

 

local function StaticDestroy(StaticUnit)

 

StaticUnit:Destroy()

 

if SpawnFlag:Get() ~= 1 then

 

Fuel:Spawn()

 

SpawnFlag:Set(1)

end

end

 

StaticSet:ForEachStatic(

function(StaticUnit)

 

timer.scheduleFunction(StaticDestroy, StaticUnit, timer.getTime() + 10 )

 

end

)

Link to comment
Share on other sites

  • 1 month later...

@Ozone1

 

I don't think it's possible

 

 

 

@SpikeGondorff

 

Static objects can be spawned after mission start (not on ships, though).

 

To do so, you need to define a static group template, then use coalition.addStaticObject()

 

 

Keep in mind that some static units/buildings are broken, they won't work properly.


Edited by Hardcard
Link to comment
Share on other sites

  • 2 months later...

Late answer may help future readers of this post.

Moose.lua is to be loaded separately , ahead of the your lua script in the mission .miz file. It's very likely that you need to download it and keep it in your missions directory as is done in this example. Take a look at the triggers.


Edited by Lineaxe
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...
  • Recently Browsing   0 members

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