HiJack Posted February 19, 2014 Posted February 19, 2014 (edited) Got your script for the tanker working fine. Thank you St3v3f. I would like to edit the script to include check that the tanker has landed and is parking. Is it possible to get the unit speed the same way you got the status for In Air? I want to check the unit.speed < 1 group = group:getUnits()[1] if not group or Unit.inAir(group) == false then return true end EDIT: I'll do a workaround with a flag but if it's possible to read the unit current speed from the script I'm interested! Edited February 19, 2014 by HiJack
St3v3f Posted February 19, 2014 Author Posted February 19, 2014 Try mist.vec.mag(group:getVelocity()) aka: Baron [sIGPIC][/sIGPIC]
Joe Kurr Posted March 5, 2014 Posted March 5, 2014 Incorporated the script in our training mission yesterday, and it works like a charm! Thanks, now we can continue practicing AAR even if someone kills the tanker out of frustration :) Dutch Flanker Display Team | LLTM 2010 Tiger Spirit Award
St3v3f Posted March 5, 2014 Author Posted March 5, 2014 I'm glad you like it :) aka: Baron [sIGPIC][/sIGPIC]
HiJack Posted March 5, 2014 Posted March 5, 2014 Unlimited TANKER and AWACS for Multiplayer By looking at my scripts you will positively pick up that I work in management now. It’s a long time since I have coded anything and newer have I coded with lua script but I must thank St3v3f for the re-spawn scripts as this jumpstarted my scripting. I have used his script to start learning some of the lua and mist functions and have changed the TANKER script to an AWACS script and added some features. As I said it’s a long time since I have coded anything so there may be bugs in the script that I have not discovered. Please use this on your own risk. Also keep in mind that scripts in missions may break track replay so if you are making a movie you should not use these scripts. The TANKER and AWACS spawn scripts is for mission designers and have nothing to do in a single player mission, this is for multiplayer only. I have a lot of debug text messages that can be activated but only activate these for one script simultaneously; they will overwrite each other’s messages if you activate two. The supplied mission is used to stress test the scripts but can be used as a template if you wish. The TANKER and AWACS aircrafts in the mission is loaded with only 9% fuel to further shorten the spawn time for a new unit. All the eight scripts are supplied as files as well but you need to cut and paste the script in to the mission if you make one from scratch. I will try to make one “do” script with functions that solves the creation and spawning of tankers and AWACS from inside the single script but that is on the longer plan. If you are proficient in scripting you can maybe help the community by doing that. I have done these scripts just for my own server missions but I have no problem in sharing these scripts. The scripts are mostly St3v3f’s code and I’ve just expanded some small functions that I wanted. It may be that you don’t want these changes and can use St3v3f’s script as it comes in the original version, check that out also. Here is a short list of my work on the script and what I have planned looking in to: Changes completed: Completely split the TANKER spawn script up in one for BLUE and one for RED. Created a separate script for AWACS on BLUE and RED side. Changed predict script to call the action script to spawn new tanker only occurs once it's needed. Added penalty setting to postpone the spawn time of a new AWACS or TANKER. - The spawning penalty for losing it is set to 120 seconds default. - Set seconds for penalty to 120=2 minutes, 300=5 minutes, 1800=30 minutes, 2700=45 minutes Added delay setting to simulate refueling and servicing of the support unit AWACS or TANKER. - Delay is default set to 120 seconds the tanker should delay spawn to refuel the tanks - Set seconds for delay to 120=2 minutes, 300=5 minutes, 1800=30 minutes, 2700=45 minutes Planned changes and fixes: 1. DONE: Move the coding for "AWACS service off at 2000 feet" to each individual AWACS script. 2. DONE (needs testing): AWACS messages and service disabling stops working after first spawn again. 3. DONE (needs testing): Tanker needs warning message that it is going out of service a couple of times just before RTB. 4. FIX: AWACS sees the Tanker service even if the tanker is set to “NoTask”. Check for solution. 5. WANT: Disable or hold the AWACS task until AWACS is above 2000 feet after takeoff. 6. FIX: AWACS "silence" must be set when creating new task for AWACS. Currently spams the mission. 7. WANT: The possibility to have other aircraft routes spawn on a regular basis and maybe timed randomly. 8. NEEDED: Change the code to one script all together. Unlimited TANKER and AWACS service.miz blue_AWACS_respawn_action.lua blue_AWACS_respawn_predict.lua blue_TANKER_respawn_action.lua blue_TANKER_respawn_predict.lua red_AWACS_respawn_action.lua red_AWACS_respawn_predict.lua red_TANKER_respawn_action.lua red_TANKER_respawn_predict.lua
ENO Posted March 15, 2014 Posted March 15, 2014 Eh Steve... I'm running a relatively simple mission here and the only MIST functions are those in your script... I'm wondering if you can take a look under the hood and see if you can figure out what's up with this. I think the timing is about right for the tankers to be returning to base low on fuel: 18946.851 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:4254: Parameter #1 (unit name string) missed 19512.686 WARNING LOG: 282 duplicate message(s) skipped. 19512.686 INFO NET: Lua: Disconnected client [2] "xxxx" 19512.686 INFO NET: remove: client 2 19512.847 INFO SCRIPTING: mist.scheduleFunction, error in scheduled function: [string "C:\Users\Eno\AppData\Local\Temp\DCS\/~mis00..."]:4241: Object doesn't exist Thanks in advance to anyone who can get their finger on a pulse here...tanker files.zip "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art
HiJack Posted March 15, 2014 Posted March 15, 2014 I posted the same errors and you get them regardless of using the mist functions or not. Create a empty mission and add mist to it and these errors will log.
St3v3f Posted March 15, 2014 Author Posted March 15, 2014 Yeah, my guess would be that there is something going on with the Mist Database updates causing that. Anyways, I think to make sure that the script runs well, you can set the tanker to 10% fuel, if it then respawns twice, the script should be running perfectly. aka: Baron [sIGPIC][/sIGPIC]
HiJack Posted March 15, 2014 Posted March 15, 2014 The script runs fine, I've been up to 20 tankers ;). So the error does not affect the respawning of the tanker.
ENO Posted March 15, 2014 Posted March 15, 2014 I'll go into the .miz and see what's up and share my findings. On a positive note this didn't cause a crash- but on the other hand the only reason I found it was because I was looking for something else. "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art
HiJack Posted March 15, 2014 Posted March 15, 2014 ":4241: Object doesn't exist" 4241 points to the line with the bug in mist. The bug is in mist functions, not the mission itself.
ENO Posted March 15, 2014 Posted March 15, 2014 (edited) [17] = { ["alt"] = 540, ["type"] = "Turning Point", ["action"] = "Turning Point", ["alt_type"] = "BARO", ["formation_template"] = "", ["properties"] = { ["vnav"] = 1, ["scale"] = 0, ["angle"] = 0, ["vangle"] = 0, ["steer"] = 2, }, -- end of ["properties"] Oh! Okay... The above was the lines between 4240 (the [17]) and 4254 but if what you're saying is right then there's no relation with the above. I'll go post this (well, the lines from MIST when I get them) in the MIST section unless you guys have already reported it. 4241: if eventData:getCategory() == 1 then -- normal groups 4254: groupsToAdd[#groupsToAdd + 1] = Unit.getByName(eventData):getGroup():getName() Edited March 15, 2014 by ENO "ENO" Type in anger and you will make the greatest post you will ever regret. "Sweetest's" Military Aviation Art
blaueente Posted December 18, 2015 Posted December 18, 2015 Anyone can give me a hint how to get this working again or point me to a more actual script ? I tested in 2.0 and it spawns a copy of the original Tanker and let the copy orbit until RTB, regardless of the settings. Once the copy landed, nothing happens. All of the time the original is wasting space at its origin airport. It's not throwing an error but maybe I set it up wrong. MfG EnteTanker_Respawn_Test.miz
Sauerkraut Posted December 23, 2015 Posted December 23, 2015 Hello, what it is that the tanker in the attached mission not new spawns? The scripts are from the first post. DCS is 1.5.2tanker_respawn_test_23_12_15.miz
St3v3f Posted December 30, 2015 Author Posted December 30, 2015 Version 2.0 released Hey guys, I'm sorry for not responding, but for the last year and a half I've had too much to do to even start DCS. But things are calming down now and so I've checked the script and fixed it. Actually I've had an improved (more tidy and simplified) version of the script developed back in the days already but not released here. However, that would not have been working either because ED broke the LUA PREDICATE condition in the triggers. That's pretty much the reason why it wasn't working anymore. So I've build a workaround for that. You can find the new version in the OP. Have fun :pilotfly::joystick: aka: Baron [sIGPIC][/sIGPIC]
Justificus Posted December 30, 2015 Posted December 30, 2015 ...So I've build a workaround for that. You can find the new version in the OP. Have fun :pilotfly::joystick: Thanks for doing this! Quick question, is this relatively easy to adapt to the Nevada map? I'm a scripting idiot, meaning I can't do anything but plug them in and use them with only minor edits to get them to work if necessary. Can a dunce like myself be able to use/alter to use this on the Nevada map? Thanks again. Justificus System Specs:i7 4970K @ 4.8, GTX 1080 SC, 32GB G.Skill DDR 2133,Thermaltake Level 10 Full Tower Case, Noctua NH-D15 6 Cooler, Win 10 Pro, Warthog, CH Pro Pedals, CH Throttle Quadrant, Oculus, 1 32" & 2 19" Monitors Modules Owned: A-10C I+II, Ka-50, FC3, F-86, Mig-15, Mig21, UH-1H, Mi-8, CA, P-51D, BF-109K-4, FW-190 D-9, Hawk, NTTR, M-2000C, SA342, F-5E, Spit Mk. IX, AJS-37, Normandy, WWII A.P., AV-8B, F/A-18C, L-39, Persian Gulf, Mig-19P, I-16, Super Carrier, F-16, Channel, Syria
dannyq8 Posted December 31, 2015 Posted December 31, 2015 Welcome back m8, long time no see. Thanks for the update, came along just in time:music_whistling: Wise men speak because they have something to say; Fools because they have to say something. Plato
St3v3f Posted December 31, 2015 Author Posted December 31, 2015 Thanks for doing this! Quick question, is this relatively easy to adapt to the Nevada map? I'm a scripting idiot, meaning I can't do anything but plug them in and use them with only minor edits to get them to work if necessary. Can a dunce like myself be able to use/alter to use this on the Nevada map? Thanks again. I can't tell for certain because I don't own the NTTR terrain, but afaik the engine and everything is the same so it should. Just give it a shot. aka: Baron [sIGPIC][/sIGPIC]
Justificus Posted December 31, 2015 Posted December 31, 2015 I can't tell for certain because I don't own the NTTR terrain, but afaik the engine and everything is the same so it should. Just give it a shot. Thanks, St3v3f, I'll give it a go and see how I make out. Will let you know if I'm successful.:pilotfly: Justificus System Specs:i7 4970K @ 4.8, GTX 1080 SC, 32GB G.Skill DDR 2133,Thermaltake Level 10 Full Tower Case, Noctua NH-D15 6 Cooler, Win 10 Pro, Warthog, CH Pro Pedals, CH Throttle Quadrant, Oculus, 1 32" & 2 19" Monitors Modules Owned: A-10C I+II, Ka-50, FC3, F-86, Mig-15, Mig21, UH-1H, Mi-8, CA, P-51D, BF-109K-4, FW-190 D-9, Hawk, NTTR, M-2000C, SA342, F-5E, Spit Mk. IX, AJS-37, Normandy, WWII A.P., AV-8B, F/A-18C, L-39, Persian Gulf, Mig-19P, I-16, Super Carrier, F-16, Channel, Syria
Mt5_Roie Posted January 1, 2016 Posted January 1, 2016 Two questions: 1) Does it work with 2.0? 2) Would it work with other aircraft beside a tanker? Thinking of using it to respawn drones to shoot down for training. Coder - Oculus Rift Guy - Court Jester
Sauerkraut Posted January 1, 2016 Posted January 1, 2016 I have no luck with your workaround or what is wrong in my mission?tanker_respawn_test_01_01_16.miz
St3v3f Posted January 1, 2016 Author Posted January 1, 2016 Two questions: 1) Does it work with 2.0? 2) Would it work with other aircraft beside a tanker? Thinking of using it to respawn drones to shoot down for training. As I said, I don't own the NTTR terrain, so I can't tell for certain. But I guess it will work. And it should work for any kind of aircraft. I have no luck with your workaround or what is wrong in my mission? Two reasons:The getFuel function is supposed to return 1.0 (100%) for an aircraft with filled internal tanks. However you are using a S-3B Tanker and for that particular aircraft, a value of about 0.68 is returned. You had it set to 9% fuel in the mission, which means that the function returned about 0.06 which is below the 0.08 threshold. So it could never be detected as "good". The S-3B has a maximum health of 25, again this is below the 50 threshold. I've updated the script to use relative values for health. So if you use the new version and set the initial fuel to above 12% it should work. aka: Baron [sIGPIC][/sIGPIC]
Rickety Posted January 1, 2016 Posted January 1, 2016 Baron's Tanker (and AWACS) Respawn Script; Version 2.1 If you have a long-running mission and want to have unlimited tanker support without having to place multiple tankers in the mission or are tired of being afraid of idiots killing the tanker, this is for you. The Tanker will respawn when one of three conditions is met: The Tanker is destroyed or damaged If it landed If it's fuel is low Steps: Add Mist to the mission. The script is working with DCS 1.5.2 and Mist 4.0.57 Place a tanker in the mission just like you always do. Give him waypoints and orbit instructions etc. It should have a RTB-Waypoint as well Create a MISSION START Trigger. For Action, select DO SCRIPT Paste the following code --RESPAWN SCRIPT; MISSION START -> DO SCRIPT local oldGroupRemovalTime = 2700 -- Time (seconds) after which old groups are removed barons_respawn_script = {} barons_respawn_script.predicate = function(groupName, lowFuelThreshold, lowHealthThreshold) if barons_respawn_script and barons_respawn_script[groupName] then groupName = groupName .. barons_respawn_script[groupName] end local group = Group.getByName(groupName) if not group then return true end group = group:getUnits()[1] if not group or Unit.inAir(group) == false then return true end if group:getFuel() < lowFuelThreshold or group:getLife() / group:getLife0() < lowHealthThreshold then return true end return false end barons_respawn_script.removeGroup = function(group) group = Group.getByName(group) if group then trigger.action.deactivateGroup(group) end end barons_respawn_script.action = function(groupName) local oldName = groupName if barons_respawn_script[groupName] == nil then barons_respawn_script[groupName] = 0 else oldName = groupName .. barons_respawn_script[groupName] end barons_respawn_script[groupName] = barons_respawn_script[groupName] + 1 local newName = groupName .. barons_respawn_script[groupName] mist.scheduleFunction(barons_respawn_script.removeGroup, {oldName}, timer.getTime() + oldGroupRemovalTime) local group = Group.getByName(oldName) if group then group = group:getController() Controller.setCommand(group, {id = 'DeactivateBeacon', params = {}}) Controller.setTask(group, {id = 'NoTask', params = {}}) end group = mist.getGroupData(groupName) group.route = { points = mist.getGroupRoute(groupName, true) } group.groupName = newName group.groupId = nil group.units[1].unitId = nil group.units[1].unitName = newName group.category = 'AIRPLANE' mist.dynAdd(group) group = Group.getByName(newName) group = group:getController() end barons_respawn_script.checkstate = function(groupName, lowFuelThreshold, lowHealthThreshold, oldresult) local newresult = barons_respawn_script.predicate(groupName, lowFuelThreshold, lowHealthThreshold) if oldresult == false and newresult == true then barons_respawn_script.action(groupName) end mist.scheduleFunction(barons_respawn_script.checkstate, {groupName, lowFuelThreshold, lowHealthThreshold, newresult}, timer.getTime() + 1) end Change the variable at the top as you desire Add another DO SCRIPT action to the trigger Paste the following code --RESPAWN SCRIPT; MISSION START -> DO SCRIPT local groupName = 'Tanker_Texaco' -- Name of the group in the ME local lowFuelThreshold = 0.08 -- RTB when less then this amount of fuel local lowHealthThreshold = 0.75 -- RTB when less then this amount of health barons_respawn_script.checkstate(groupName, lowFuelThreshold, lowHealthThreshold, true) Edit the first three lines to fit into your mission Repeat steps 5 - 7 for other tankers I don't understand where to add the name of the tanker to get this to work or even if I have it set right. I created a simple single player mission(attached). Can someone help a brother out? Note: this is for 2.0 at Nellis. Thanks, -RicketyRefueling Practice Test.miz
Rickety Posted January 1, 2016 Posted January 1, 2016 Two questions: 1) Does it work with 2.0? 2) Would it work with other aircraft beside a tanker? Thinking of using it to respawn drones to shoot down for training. Please share if you get it to work in 2.0(just tanker respawn only). Thanks, -Rickety
Recommended Posts