SNAFU Posted March 25, 2015 Posted March 25, 2015 (edited) Inspired by MBot`s great Dynamic Campaign for the MiG-21Bis, I took his approach to save intermediate situations and wrote a more general script. Attached below you find a lua-script file, which gives a unit with the name defined in line 5 - here called "Script Manager" - the option (accessible via the F-10 radio option) to save an actual situation on the map into a file with the name defined in line 6 - here called "Intermediate_savefile.lua". The file will be stored in the DCS World folder and contain the position, movement and composition of all ground- and ship groups present at the moment the status was saved. The weather, time, resources, planes, helicopter and static objects are not considered by this script and will not be stored in the file. Upon loading the status with the F-10 Option menu, all active ground- and ship groups will be deleted from the actual map and the groups stored in the save-file, are generated on the last stored position and continue to move as last saved. You can define groups of ships or ground units, which shall not be removed during the loading of the previous file, by adding the groupnames to the table "TemplateGroupExcludedFromRemoval" in the script. Please note that units, which AI were deactivated by the advanced ME options will be generated with active AI. To keep the script simple, generated units only have the nationality "Russian" for red coalition and "USA" for blue coalition. The individual nationality of ground- or ship groups are not stored, only their coalition. The skins and type shall remain the same as before. Units IDs are not stored either and randomised upon generation. So if triggers or other scripts depend on fixed unit IDs, this might break them. I tested this script in single-player environment only and not by all thinkable constellations, so if you face problems, please report back. In order to get this script working you need a MIST function library initialised and you need to modify the default DCS World the following. 1. Go to the folder "DCS World\Scripts" 2. Open the file "MissionScripting.lua" with notepad++ or Notepad 3. Add in line 17 and 18 the "--" infront of the sanitizeModule-functions, so that the content of the file looks as following: --Initialization script for the Mission lua Environment (SSE) dofile('Scripts/ScriptingSystem.lua') --Sanitize Mission Scripting environment --This makes unavailable some unsecure functions. --Mission downloaded from server to client may contain potentialy harmful lua code that may use these functions. --You can remove the code below and make availble these functions at your own risk. local function sanitizeModule(name) _G[name] = nil package.loaded[name] = nil end do sanitizeModule('os') --sanitizeModule('io') --sanitizeModule('lfs') require = nil loadlib = nil end 4. Save changes done to "MissionScripting.lua" 5. Open DCS World ME Mission 6. Initialize MIST in the Triggerpage 7. Initialize MIST3_5_SaveSituation_v1.lua script via a trigger or advance waypoint action of a unit´s first waypoint -> Do Script File 8. Add a client plane/ helicopter with the unit name "Script Manager" Attention: Be advised that this modified "MissionScripting.lua" gives DCS World the rights to write on your PC/ Server. Potentially harmful scripts in missions downloaded from sources you don´t know might be hazard when played. Update 07/10/15: This version uploaded here has some issue with dynamically generated AI waypoints. After removing the waypoints from the savefile it is doing what it is supposed to do and we currently use it in an internal vJaBoG32 Campaign. After reloading, the ground commander has to issue new orders to the generated groups, but the saving position and composition of all AI ground groups is working fine.MIST3_5_SaveSituation_v1.lua Edited October 7, 2015 by SNAFU [sIGPIC][/sIGPIC] Unsere Facebook-Seite
xcom Posted March 25, 2015 Posted March 25, 2015 (edited) First of all, looks awesome! :thumbup: I will definitely try to use this to create an ongoing large scale mission, the only problem is that the number of participants needs to be limited in order to accommodate many moving ground units. A few questions - The weather, time, resources, planes, helicopter and static objects are not considered by this script and will not be stored in the file. -Storing static objects as if they are dead or not, should not be that hard to add, will you be adding it later on? -Weather/time is an important addition as well, will you be adding it later on? Please note that units, which AI were deactivated by the advanced ME options will be generated with active AI. To keep the script simple, generated units only have the nationality "Russian" for red coalition and "USA" for blue coalition. The individual nationality of ground- or ship groups are not stored, only their coalition. The skins and type shall remain the same as before. Units IDs are not stored either and randomized upon generation. So if triggers or other scripts depend on fixed unit IDs, this might break them. -Coalition nationality could change from mission to mission, Russian could be blue USA could be red etc, does the russian side and USA have all the units? what if it is a Georgian Strela that is on the blue side? it means it would be respawned as a USA Strela on the blue side? I don't think that USA has a strela in the ME selection and it could cause issues. Would be wise to fix this. Now, here is a thought for resource management using this script. As we know, we have no control on the airfield resources, but what we do control is warehouses and warehouses resources that can be alive/dead. I would suggest to anyone using this script and wants to have an active resource system using the internal DCS resource system, to use warehouse buildings in the airfields/near the airfields/FARPS, and have 0 or very little resources at the airfields themselves. EDIT - Will this script also save the status of dynamically added units into the mission? Edited March 25, 2015 by xcom [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook
FSFIan Posted March 25, 2015 Posted March 25, 2015 -Weather/time is an important addition as well, will you be adding it later on? Do you know of any way at all to interact with the weather system from Lua code? DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
SNAFU Posted March 25, 2015 Author Posted March 25, 2015 The weather, time, resources, planes, helicopter and static objects are not considered by this script and will not be stored in the file. [/Quote]-Storing static objects as if they are dead or not, should not be that hard to add, will you be adding it later on? -Weather/time is an important addition as well, will you be adding it later on? [/Quote]Regarding static objects: In another script I tried to account for dynamically added static objects, but couldn´t detect if the static object was destroyed or not. I didn´t get any return via scripting. Maybe my scripting knowledge is too limited. So I think should not be too difficult, I just don´t know how. Concerning the weather and time: I don´t think that is possible in the current scripting environment. I have not seen any function accessing the weather data. Please note that units, which AI were deactivated by the advanced ME options will be generated with active AI. To keep the script simple, generated units only have the nationality "Russian" for red coalition and "USA" for blue coalition. The individual nationality of ground- or ship groups are not stored, only their coalition. The skins and type shall remain the same as before. Units IDs are not stored either and randomized upon generation. So if triggers or other scripts depend on fixed unit IDs, this might break them. [/Quote]-Coalition nationality could change from mission to mission, Russian could be blue USA could be red etc, does the russian side and USA have all the units? what if it is a Georgian Strela that is on the blue side? it means it would be respawned as a USA Strela on the blue side? I don't think that USA has a strela in the ME selection and it could cause issues. Would be wise to fix this. [/Quote]So far you can create any unit dynamically for any nation, as far as I know. I regularly create US Su-27 oder Russian F-15 for air to air training sparring partner and also ground units are not effected by the nation. Even their skin remains default. So far I have never seen any mission, in which Russia is on the blue side and USA on the red, so I just kept it simple. I had troubles with getting the country.id in a format accepted by coalition.addGroup(). It definitly should be possible to keep the nation, I just couldn´t find a way with reasonable efforts. If you have a suggestion, feel free, this is all open source... ;) Now, here is a thought for resource management using this script. As we know, we have no control on the airfield resources, but what we do control is warehouses and warehouses resources that can be alive/dead. I would suggest to anyone using this script and wants to have an active resource system using the internal DCS resource system, to use warehouse buildings in the airfields/near the airfields/FARPS, and have 0 or very little resources at the airfields themselves. [/Quote]Yes, as far as I know, we cannot access the resource system via scripting. EDIT - Will this script also save the status of dynamically added units into the mission? [/Quote]In my tests it did. [sIGPIC][/sIGPIC] Unsere Facebook-Seite
xcom Posted March 25, 2015 Posted March 25, 2015 Ian;2359501']Do you know of any way at all to interact with the weather system from Lua code? Yes, editing the mission file in the miz file and saving a new miz file, as you probably know. There's no way that I know of currently using the DCS Scripting engine. Regarding static objects: In another script I tried to account for dynamically added static objects, but couldn´t detect if the static object was destroyed or not. I didn´t get any return via scripting. Maybe my scripting knowledge is too limited. So I think should not be too difficult, I just don´t know how. Concerning the weather and time: I don´t think that is possible in the current scripting environment. I have not seen any function accessing the weather data. About the dynamically added, it is being saved in the MIST DB - mist.DBs.dynGroupsAdded. There should be info there in order to get a save of the units, but I see that you answered that it does work with them. About static units, there is a way, I wrote it on the other thread, just look at my edit of Ian's online mission editor code - http://forums.eagle.ru/showpost.php?p=2184515&postcount=59 Check the files - doscript.txt and admintool.html (under the update_waypoints function). About the weather, see the answer above to Ian. So far you can create any unit dynamically for any nation' date=' as far as I know. I regularly create US Su-27 oder Russian F-15 for air to air training sparring partner and also ground units are not effected by the nation. Even their skin remains default. So far I have never seen any mission, in which Russia is on the blue side and USA on the red, so I just kept it simple. I had troubles with getting the country.id in a format accepted by coalition.addGroup(). It definitly should be possible to keep the nation, I just couldn´t find a way with reasonable efforts. If you have a suggestion, feel free, this is all open source... [/quote'] I'll take a look, I think I have some script lying around that shows how to get it easily :) [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook
SNAFU Posted March 25, 2015 Author Posted March 25, 2015 Do you know of any way at all to interact with the weather system from Lua code? Yes, editing the mission file in the miz file and saving a new miz file, as you probably know. There's no way that I know of currently using the DCS Scripting engine. Exactly. About static units, there is a way, I wrote it on the other thread, just look at my edit of Ian's online mission editor code - http://forums.eagle.ru/showpost.php?...5&postcount=59 Check the files - doscript.txt and admintool.html (under the update_waypoints function). Ok sounds good, If you get it implemented in the script, please share your results. So far you can create any unit dynamically for any nation, as far as I know. I regularly create US Su-27 oder Russian F-15 for air to air training sparring partner and also ground units are not effected by the nation. Even their skin remains default. So far I have never seen any mission, in which Russia is on the blue side and USA on the red, so I just kept it simple. I had troubles with getting the country.id in a format accepted by coalition.addGroup(). It definitly should be possible to keep the nation, I just couldn´t find a way with reasonable efforts. If you have a suggestion, feel free, this is all open source...I'll take a look, I think I have some script lying around that shows how to get it easily Ok. AFAIK you can get the countryID as an integer easily, but coalition.addGroup() doesn´t accept integer in my tests. MIST DBs only have the nations as lower case strings, which doesn´t help either. I could create a table an assign the number of every country (return of getCountryID() ) to a parameter accepted by coalition.addGroup(), but for my purpose that is an effort not worth the results, since I don´t see difference anyway, as long as the group is on the right coalition side. ;) [sIGPIC][/sIGPIC] Unsere Facebook-Seite
Pikey Posted March 26, 2015 Posted March 26, 2015 Guys, your individual and your community team work is so very much appreciated and this work is such an important line to achieve persistent campaigns. Collectively I need to spread some rep to other people. I can contribute some brainstorming only I think. Resource system - XCom's method is one of two I came up with. Essentially you have nothing in any warehouse close and manage the supply by dripping resources from other warehouses with careful timing. That way there is little change between missions in the content of the warehouses. My additional plan was via a delivery system using C-17's. Watching for the engine shutdown event at the airport on this aircraft type, spawn 3 strykers or one Abrams equivalent as the plane shuts down to generate new ground forces. We currently don't have an in-game resource management for ground units and this method would bring an interesting supply method to defend. I will be testing the script above this week and following the thread with great interest! ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
markh Posted September 15, 2022 Posted September 15, 2022 (edited) hahahah 7 years later is this script capable of saving just a players location in multiplayer when logging out ?, i want to load in where i logged off, this could be on a field, next to a road or any other locations i find my self . i searched around on google but cant find what im looking for, any suggestions are welcome Edited September 15, 2022 by markh
Recommended Posts