Jump to content

Simple Saving Scripts


Go to solution Solved by Pikey,

Recommended Posts

Simple Saving

Updated August '23

I did some basic mission persistence scripts that some people might use.

There are four persistence scripts and one that is for ensuring Slot blocking at the mission level is made without addon level files:

https://github.com/thebgpikester/SimpleGroupSaving

https://github.com/thebgpikester/SimpleStaticSaving

https://github.com/thebgpikester/SimpleScenerySaving

https://github.com/thebgpikester/SWS

https://github.com/thebgpikester/MPSG


To ensure version quality, you'll need to download directly from Github.

Simple Group Saving scans all Ground Groups and Units and puts them in a file every few seconds. When you reload the mission, you get back exactly what you had before restart, minus the debris.

Simple Static Saving does the same with Statics Units, which behave differently to Normal Groups. Not every scenario would appreciate these being merged, it was a core aim to simplify this down to provide flexibility.

Simple Scenery saving does the same for scenery saving, basically recording what blew up and ensuring it is dead the next time the mission is launched. There's also tools for finding scenery ID's in mission, but that was largely superseeded by an ED update to the mission editor some time back.

Simple Warehouse Saving saves the warehouse contents from mission to mission using the new API's released in August 2023. It's the only script with no 3rd party dependency, buy each can be run together in any combination.

Multi Player Slot Guard its not a persistence script but of the same server admin ilk this forces any player spawning into a slot owned by a coalition that is not your own, will be punted to the F12 view.

I did a very boring video going into depth how Simple Unit Saving works. Probably of interest to scripters and admins that hadn't learned how to do this already. Maybe 5 or 6 of us worldwide, the subsect of DCS players, that weren't already from a formal developer background, that went and learned both DCS and LUA! Panda's have a more stable population...

 

FAQ:

 

What is the difference between this and DAWS/DSMC?

This is just saving Ground units, no messing around with mods, different mission files, weather, time of day or any other complexities. It also works fine with MOOSE. DAWS is better for folks not using additional scripting over the top, or if it works just fine for you.

What type of person might be interested?

I'd say anyone wanting to look at scripting and start their own campaign, but didn't know how to begin. Server admins looking for a bit extra or an 'off-the-shelf' solution to saving their game. People wanting to explore the ideas in Dynamic persistent campaigns their own way, rather than the DCS style campaign which is unconnected strings of linear missions. Sandbox people.

Why no routes!?

Well I didn't know either, that if you give a group a route, you cannot extract that route back out! Until I got quite a way down this road! Sure, you can get the original route but this is so restrictive as to render it pointless to grab as it's old age by the time a mission had run. Eagle Dynamics, please give us this ability 🙂

Why no Naval?

I didn't touch Ships because of the fundamental limitations of spawning ships that have AI and Client slot starts. Just can't be done, you can't move slots outside of what is in the actual mission file. To do that it would require a design that rewrites the mission as it was, just like DAWS did. Sure I could do a version that excluded any carriers or helicopter frigates but then it's getting confusing, why would you only persist some ships and not others? Eagle Dynamics, please give us this ability also (moving farps, ships mod mission)

Why didn't you delete all the statics and respawn them in the static script just like for Groups?

I saw some issues with rapid spawning of statics and destroying them whilst having a SET and I bailed on that idea and just blew them up at the start instead. If I discover the reasons I got script errors by doing it that way, I'd like to revert to spawning in dead and alive statics instead. I reverted that.

Why do servers need to be restarted when DCS is so performant now?

Restarts are needed on persistent servers for several reasons that are not performance related, even if there were no memory accumulation issues, patching or maintenance required. My two favorite reasons are:

1. There is no way to tidy up dead ground units.

2. Runways don't fix themselves and AI will stop using airbases if a runway is bombed. (At least they haven't since many years and if it's just changed then please supply details). With the advent of JDAM, I can shut down AI at four airbases in one sortie.

General performance reasons, tidying up carnage, memory and scenery.

Will you support and develop this?

Highly unlikely, I wrote it for myself and just felt that sharing was appropriate. I did so far, but in four years its not needed change except where DCS broke or fixed itself. Features can be forked on Github however you like.

If you found this useful I'd like to hear how you used it and what you came up with. There's a few things you can extend on this. The SET can be configured for more or less with Filters. You can access the SaveUnits table and do other things with it, like a mini database. For counting and such.

Have fun.

[Added demo mission]

SimpleSaving.miz


Edited by Pikey
2023 updates

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Update 25th March 2020

I took some time to fix some nagging issues with SGS and SSS. Note that Simple Scenery saving also exists as a tool.

 

 

 

SGS:

1. Someone had discovered that the GetHeading() returned from a unit is in Radians and I hadn't coverted it to degrees or vice-versa. I've now fixed that so that units should correctly face the way you intended.

 

 

SSS:

1. Mostly rewritten, since, programmatically speaking, statics are a GIANT PAIN IN THE BACKSIDE that do not obey convention in DCS.

2. Now excludes Farps and SeaShelf Objects, Smoke Effects and anything that will refuse to report its type of category or details that are required. This was a showstopper in various patches.

3. Will now replace the Static that was destroyed with a destroyed object of the same type by default, but this is easy to remove.

 

 

Scenery Tools:

1. I added this a while back and don't think I made any notes on the release specifically. This is a tool that can persist 'map scenery' (or remove it with explosions) rather than unit or statics. It also can be used to

 

-create an explosion at a marker point

-Get the COORDINATE of the marker point

-Record target scenery and add to a list of targets

 

 

 

KNOWN ISSUES:

When spawning a new dead static, Moose will error as it attempts to inject the new dead static into the Moose database. I don't know why, but this is mostly cosmetic since you dont need to think about these objects, they are for visual continuity , mission to mission. You can disable the dead model swap on restart.

 

Ships, always report they are alive, even after sunk. This is a DCS thing, probably a legacy from where the model is replaced for statics, but for ships it has animation to sink and disappear slowly. Cannot do anything about it, so just avoid Static ships, the only use case is for harbour decoration, if its a ship target, use a UNIT type please.


Edited by Pikey
Updates!

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Yes. Literally at any point in time it captures what is alive (ground groups). So if something appears, then disappears, it was in the table saved, then removed. Will capture any spawned unit of any type, mods included, from any script, coalition.addGroup, SPAWN, dyn.add, whatever.

 

To give you an idea, it was super handy for catching deployed CTLD stuff.

 

 

For JTACs I'll need another script to go through the table after mission start to check by names and do the CTLD command for JTAC. The group and unit names are the same, so you can use any of the table.insert() on the internal CTLD tables. There's probably more things you can do to work around things like that, but should do most of the heavy lifting.

 

 

Have fun! :)

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

  • 3 weeks later...

Nice job! I have test it and work fine!

 

I have 2 questions:

 

1- It's possible add the persistence for ONLY red ships? like Moskva?

2-It's possible add the persistence for time ad date of mission?

101^Squadrone Multiruolo Ariete 

by SimItaliaGames.com | WebSite FaceBook Forum Discord

Visit: AF Allied Forces

Joint Operations, Joint Communities

Un progetto per promuovere la collaborazione tra gruppi volo virtuali!

Link to comment
Share on other sites

1- It's possible add the persistence for ONLY red ships? like Moskva?

 

From the script comments:

 

 

--LIMITATIONS

--Only Ground Groups and Units are specified, play with the SET Filter at your own peril. Could be adjusted for just one Coalition or a FilterByName().

--See line 107 and 168 for the SET.

--See https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Set.html##(SET_GROUP)

--Naval Groups not Saved. If Included, there may be issues with spawned objects and Client slots where Ships have slots for aircraft/helo. Possible if not a factor

 

Link to comment
Share on other sites

From the script comments:

 

 

 

 

--LIMITATIONS

 

--Only Ground Groups and Units are specified, play with the SET Filter at your own peril. Could be adjusted for just one Coalition or a FilterByName().

 

--See line 107 and 168 for the SET.

 

--See https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Set.html##(SET_GROUP)

 

--Naval Groups not Saved. If Included, there may be issues with spawned objects and Client slots where Ships have slots for aircraft/helo. Possible if not a factor

 

 

 

Yes, i have read the comment. I talk about ship without spawn slot.

101^Squadrone Multiruolo Ariete 

by SimItaliaGames.com | WebSite FaceBook Forum Discord

Visit: AF Allied Forces

Joint Operations, Joint Communities

Un progetto per promuovere la collaborazione tra gruppi volo virtuali!

Link to comment
Share on other sites

Yes, i have read the comment. I talk about ship without spawn slot.

 

I guess there shouldn't be a problem then:

 

--Naval Groups not Saved. If Included, there may be issues with spawned objects and Client slots where Ships have slots for aircraft/helo. Possible if not a factor

 

---Ok, so provided we don't have spawn slots on ships, then I guess it's a matter of replacing lines 107 and 168

 

---Line 107:

AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart()

 

---Replace by:

AllGroups = SET_GROUP:New():FilterCoalitions("red"):FilterCategories("ship"):FilterActive(true):FilterStart()

 

 

---Line 168:

AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart()

 

---Replace by:

AllGroups = SET_GROUP:New():FilterCoalitions("red"):FilterCategories("ship"):FilterActive(true):FilterStart()

 

 

 


Edited by Hardcard
Link to comment
Share on other sites

I guess there shouldn't be a problem then:

 

--Naval Groups not Saved. If Included, there may be issues with spawned objects and Client slots where Ships have slots for aircraft/helo. Possible if not a factor

 

---Ok, so provided we don't have ship spawns, then I guess it's a matter of replacing lines 107 and 168

 

---Line 107:

AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart()

 

---Replace by:

 

AllGroups = SET_GROUP:New():FilterCoalitions("red"):FilterCategories("ship"):FilterActive(true):FilterStart()

 

 

---Line 168:

AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart()

 

---Replace by:

AllGroups = SET_GROUP:New():FilterCoalitions("red"):FilterCategories("ship"):FilterActive(true):FilterStart()

 

 

 

 

 

ok... i think is necessary new file .lua only for ship . I will try it, many thanks

 

 

Inviato dal mio iPhone utilizzando Tapatalk

101^Squadrone Multiruolo Ariete 

by SimItaliaGames.com | WebSite FaceBook Forum Discord

Visit: AF Allied Forces

Joint Operations, Joint Communities

Un progetto per promuovere la collaborazione tra gruppi volo virtuali!

Link to comment
Share on other sites

ok... i think is necessary new file .lua only for ship

 

If your goal is to save ground units as well as red coalition ships, then you'll need to include additional code in that script (I don't think a separate script is required).

 

But if you're only interested in saving red ships, I think that replacing those two lines should be enough.

 

Hopefully Pikey will come back and clear this up for us.


Edited by Hardcard
Link to comment
Share on other sites

If your goal is to save ground units as well as red coalition ships, then you'll need to include additional code in that script (I don't think a separate script is required).

 

But if you're only interested in saving red ships, I think that replacing those two lines should be enough.

 

Hopefully Pikey will come back and clear this up for us.

 

 

 

My goal is add ship red( offensive ships) and keep ground units

 

 

Inviato dal mio iPhone utilizzando Tapatalk

101^Squadrone Multiruolo Ariete 

by SimItaliaGames.com | WebSite FaceBook Forum Discord

Visit: AF Allied Forces

Joint Operations, Joint Communities

Un progetto per promuovere la collaborazione tra gruppi volo virtuali!

Link to comment
Share on other sites

  • 2 weeks later...
My goal is add ship red( offensive ships) and keep ground units

 

 

Inviato dal mio iPhone utilizzando Tapatalk

 

 

Hi,

You see this line

 

 

AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart()

 

 

what you sound like you need is a combination of that plus:

AllGroups2 = SET_GROUP:New():FilterCategories("ship"):FilterCoalitions("red"):FilterActive(true):FilterStart()

 

I'm writing this right out into a post so haven't tested but I did something similar with a couple of lines after that went like this:

 

AllGroups2:ForEachGroup(function(grp)
AllGroups:AddGroupsByName(grp:GetName())
end)

 

 

Which adds all the groups from AllGroups2 to the AllGroups SET.

 

 

 

The SET is from MOOSE: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Set.html##(SET_GROUP).FilterCategories

 

 

You could try playing with stuff from here. You could also use Prefixes and such. Let me know if you had any success, i'm not inclined to try it as I know it leads down a bad path, but it should be possible to do at least what you said.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Hi,

You see this line

 

 

AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart()

 

 

what you sound like you need is a combination of that plus:

AllGroups2 = SET_GROUP:New():FilterCategories("ship"):FilterCoalitions("red"):FilterActive(true):FilterStart()

 

I'm writing this right out into a post so haven't tested but I did something similar with a couple of lines after that went like this:

 

AllGroups2:ForEachGroup(function(grp)
AllGroups:AddGroupsByName(grp:GetName())
end)

 

 

Which adds all the groups from AllGroups2 to the AllGroups SET.

 

 

 

The SET is from MOOSE: https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Set.html##(SET_GROUP).FilterCategories

 

 

You could try playing with stuff from here. You could also use Prefixes and such. Let me know if you had any success, i'm not inclined to try it as I know it leads down a bad path, but it should be possible to do at least what you said.

 

 

 

Many thanks! It work fine! Now i will try to save the time and date of the mission!

 

 

Inviato dal mio iPhone utilizzando Tapatalk

101^Squadrone Multiruolo Ariete 

by SimItaliaGames.com | WebSite FaceBook Forum Discord

Visit: AF Allied Forces

Joint Operations, Joint Communities

Un progetto per promuovere la collaborazione tra gruppi volo virtuali!

Link to comment
Share on other sites

That is not doable :(

You can't change the time and the date of a mission (you can get them, but you cannot change them inside a mission)

 

 

Maybe check out the METAR script that does this. It gets super painful because it has to create a new mission to load from an existing. Very much like DAWS (which might still work for you if you can find a copy).

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

That is not doable :(

You can't change the time and the date of a mission (you can get them, but you cannot change them inside a mission)

 

 

Maybe check out the METAR script that does this. It gets super painful because it has to create a new mission to load from an existing. Very much like DAWS (which might still work for you if you can find a copy).

 

 

 

Yep, i know but i have an idea! I will teel

to you if i will complete my goal

 

 

Inviato dal mio iPhone utilizzando Tapatalk

101^Squadrone Multiruolo Ariete 

by SimItaliaGames.com | WebSite FaceBook Forum Discord

Visit: AF Allied Forces

Joint Operations, Joint Communities

Un progetto per promuovere la collaborazione tra gruppi volo virtuali!

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

Hello Surrexen,

I haven't touched this since May and I had to look at it to find out if I even tried. I save the heading of the units then I use Ed's coalition.addGroup in the format that it wants. I believed it was saving the heading and reusing it. I certainly felt during testing that was also fine. Could you provide any further feedback on this, if it was consistent with different uses?

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

I cannot support CTLD even though I tried. Any JTAC, FOB, CTLD known object reverts to a normal object after restart because CTLD doesnt know about it. I did try to insert them into the tables of CTLD but that didnt work. I think I spoke to Ciribob about it some time back but he was busy and coulnt remember much more.

 

So, script is working as expect, object copied over, CTLD doesn't work.

 

 

If you manage to fix this, let me know how, I spent a while trying.

 

Hi there.

 

Pikey, one question : CTLD FOB are not showing up after a restart, only the motar simulating the beacon.

 

Am I wrong with something using this script ?

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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