Jump to content

Tanker Respawn Script


St3v3f

Recommended Posts

Your mission was fine, you just needed to add the correct tanker group name in the ME.

 

In Baron's respawn script the tanker is called Tanker_Texaco, in your mission it was just called Tanker

 

Tested with 2.0

Refueling Practice Test.miz


Edited by dannyq8

Wise men speak because they have something to say; Fools because they have to say something.

Plato

Link to comment
Share on other sites

Thanks for the script. I got it working fine on 1.5.2. It was fun adding a SAM battery at the end of the runway to test the re-spawn :D I am hoping to use this with GCICAP for full air cover.

Windows 10 64bit, Intel i7 6700K, 32GB Corsair 2400Mhz, 970 NVMe 500Gb SSD, GeForce 2080 super, HP Reverb, VKB GF PRO, Thrustmaster Warthog throttle, Thrustmaster Pendular rudders, Windows + DCS :thumbup:

 

My youtube channel

Link to comment
Share on other sites

Your mission was fine, you just needed to add the correct tanker group name in the ME.

 

In Baron's respawn script the tanker is called Tanker_Texaco, in your mission it was just called Tanker

 

Tested with 2.0

 

Awesome! Thank you thank you thank you. I was scratching my head about it. Much appreciated :thumbup: I tested it out and it works perfectly! The tanker did respawn exactly as intended.

 

I've attached the updated mission for those of you who would like to use it however you want. It is just a single player F-15C refueling practice mission. You and the tanker both start off on the ground.

 

-Rickety

Nellis Single Player Refueling Practice .miz

Link to comment
Share on other sites

Your mission was fine, you just needed to add the correct tanker group name in the ME.

 

In Baron's respawn script the tanker is called Tanker_Texaco, in your mission it was just called Tanker

 

Tested with 2.0

 

dannyq8, thanks for posting this working version. It allowed me to go in and look at how things were done and just do a little copy and pasting to add it to my current practice mission. Thanks again! Will come in handy.

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

Link to comment
Share on other sites

  • 2 weeks later...

Quick question for you smart LUA/ME guys out there. I have used this script in one of my missions I'm creating and would like to modify this to have it work with AWACS planes as well. Knowing nothing about LUA scripting at all, looking at what has been posted in the first mission, do I only need to change the name of the "groupName =" line in the 2nd script? I looked in the first script for any specific plane type but couldn't find it so I'm assuming that it will work with any plane that you use and insert the groupName there? Is that how this works? If not, is there an easy way for me to get this to work with an E3? Thanks for any tips/insight you can give!

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

Link to comment
Share on other sites

Quick question for you smart LUA/ME guys out there. I have used this script in one of my missions I'm creating and would like to modify this to have it work with AWACS planes as well. Knowing nothing about LUA scripting at all, looking at what has been posted in the first mission, do I only need to change the name of the "groupName =" line in the 2nd script? I looked in the first script for any specific plane type but couldn't find it so I'm assuming that it will work with any plane that you use and insert the groupName there? Is that how this works? If not, is there an easy way for me to get this to work with an E3? Thanks for any tips/insight you can give!

 

Just did this last night with a mission. Just change the group name and it works exactly the same as the tanker :-)

-16AGR- 16th Air Guards Regiment is always looking for pilots - http://www.16agr.com

 

EWRS - Early Warning Radar Script

 

Specs:

 

 

Gigabyte Sniper Z5-S

Intel i5-4670k 3.4GHz OC'd 3.9GHz w/ Thermaltake 120mm Water 3.0 Pro Liquid CPU Cooler

16GB RAM

Gigabyte GTX 1080

TM Hotas Warthog: SN: 06976

Saitek Pro Flight Combat Rudder Pedals

TrackIR5 with TrackClipPro & Oculus Rift

2x 28" 4k UHD Monitors (3840x2160 each) + 1280x1024

 

 

Link to comment
Share on other sites

Just did this last night with a mission. Just change the group name and it works exactly the same as the tanker :-)

 

Excellent! Thank you sir.

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

Link to comment
Share on other sites

Hello,

i'm testing our script, and i would know if i can manage two or more group with it, if yes what what would be the correct syntax ?

 

local groupName = 'Tanker_Texaco' 'Awacs 1' -- Name of the group in the ME

 

Or

 

local groupName = 'Tanker_Texaco' -- Name of the group in the ME

local groupName = 'Awacs' -- Name of the group in the ME

 

Or ?

I'm a bit noob :book: :doh:

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • 2 months later...

Hello.

 

I'm not very good with programming. Really I do not understand anything. I am slowly reading forums and testing; it emepeora the fact of not having a good English. What you created with this script is fantastic. I tried it with the TANKER and the AWACS and works great. I need to run this script but with an An-26B or a MiG-25 or any other aircraft and I can not make it work.

 

I can not find the error code which is due to my lack of knowledge. But if it works with the TANKER and the AWACS why not with others?

 

Some kind person who can help me.

 

thanks.

Link to comment
Share on other sites

I have tested again and only works with IL78M / KC135 TANKERS and A50 / E3 AWACS. But I have also done with the E-2D (AWACS) and does not work.

 

I could get it done with various groups but I can not do with other types of aircraft other than those described in the preceding paragraph.

 

What part of the script should be modified or what does not work?

 

Thanks for the help and quick response.

 

If you want i can upload the .miz flie.

 

EDIT: I Fixed the problem, thanks for your help and this excellent script!


Edited by GaSi
Fix the problem :)
Link to comment
Share on other sites

Hello,

I want to use the scripts but when I active in the map editor, it has no function in the game.

I active the "MIST" code after 2 sec, then I executed the scripts after 4sec. But when I destroyed the tanker via a command, it never reappears, nothing happens.

So I think I hurt my configure scripts. How to do ?

 

What to you it changed in the scripts for this to work? or how to settle in more detail the script

Link to comment
Share on other sites

  • 2 weeks later...

Hi St3v3f.

 

I need some help with the lua script.

 

I have tried to modify the script with helicopters but had no luck. I try to modify this part (in red) and nothing.

 

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'

 

I tried with CHOPPER or HELICOPTER and nothing results.

 

How do I have to do to work with helicopters too?

 

Thanks!

Link to comment
Share on other sites

Try moose. You can do this with one sentence:

 

SpawnTanker = SPAWN:New("Tanker"):Limit(1,10):Repeat():SpawnScheduled(180,0.5)

 

This sequence of commands will spawn the tanker every 180 seconds, with a 50% random time variation.

There can only be one tanker alive at the same time, with 10 tankers in the reserve.

Once the tanker lands, it will respawn immediately.

 

Check out the moose framework following the links in the signature.

 

Hope this helps.

 

Fc


Edited by FlightControl

[TABLE][sIGPIC][/sIGPIC]|

[/TABLE]

Link to comment
Share on other sites

  • 1 year later...

I Got this to work. but what do i add to it for it to work when the plane gets destroyed.

As it is now it will stop respawning. And if i add the lines above it wont'even start at all.:helpsmilie::helpsmilie::helpsmilie:

 

do
-- Declare SPAWN objects
 Spawn_KC_135 = SPAWN:New("USA_TANKER"):InitLimit( 1, 20 )
 Spawn_IL_78M = SPAWN:New("RUSSIA_TANKER"):InitLimit( 1, 20 )
 Spawn_IL_76 = SPAWN:New("RED_IL76")
 
-- Repeat on landing and engine shutdown
 Spawn_KC_135:InitRepeatOnEngineShutDown()
 Spawn_IL_78M:InitRepeatOnEngineShutDown()
 
-- Repeat on landing
 Spawn_IL_76:InitRepeatOnLanding()
  
-- Now SPAWN the GROUPs
 Spawn_KC_135:Spawn()
 Spawn_IL_78M:Spawn()
 Spawn_IL_76:Spawn()
 end

Link to comment
Share on other sites

  • 2 months later...
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:

  1. The Tanker is destroyed or damaged
  2. If it landed
  3. If it's fuel is low

 

Steps:

  1. Add Mist to the mission. The script is working with DCS 1.5.2 and Mist 4.0.57
  2. 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
  3. 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
    


  4. Change the variable at the top as you desire
  5. Add another DO SCRIPT action to the trigger
  6. 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)
    


  7. Edit the first three lines to fit into your mission
  8. Repeat steps 5 - 7 for other tankers

 

Gents, Happy new year. Is this script working? Anyone tested with 1.5.8?

  • Like 1

My Hardware: ROG Strix X570-F Gaming - AMD 5600X @ 4.7 ghz - G.SKILL TRIDENT 32GB DDR4 3200 (14-14-14-34 CL) - GigaByte 3080ti OC 12gb - Corsair MP600 Force 1TB - 2 x EVO Nvme 500GB - Virpil Warbird Base T-50CM2 and TM Throttle + Trackhat + G25 + AOC AG271QG 27"

My Modules: JF-17, F-16C, AV-8N/A, F-18C, ASJ37, MiG-15Bis, MiG-21Bis, Fw-190D, Bf-109K, P-51D, F-86F, Ka-50 III, UH-1H, Mi-8MTV2, NS430, FC3, A-10C, Mirage 2000C, L-39, F-5E-3, SA342, Spitfire, AH-64, Mirage F-1CE.

My Maps: Nevada, Normandy, Persian Gulf, Syria, South Atlantic.

Link to comment
Share on other sites

  • 1 month later...

Good day everyone

Quick question, is this script still working in 2.5? the reason why I ask I for the life of me can't seem to get it to work using the script above which is on the first page of this thread.

 

I'm using the latest mist_4_3_74

 

I have 3 tankers departing from Nellis at different times and are suppose to RTB at a particular WP. I've created a trigger zone over Nellis that when leaving the zone they will trigger the script as far as I'm understanding this.

 

First I see a few things going on.

 

The KC-130 tanker when beginning it's RTB does not even attempt to head back to home plate it lands at the closest airport. When it lands nothing happens. Very frustrating to say the least so I requesting any help on this... Please and thank you..

 

Wood


Edited by Wood

[sIGPIC][/sIGPIC]

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

I don't use the first page script, I don't need all options, I simply want to respawn a tanker after landing for short petrol reason.

 

Thus I use mist.respawnGroup('groupname', true) to do that.

 

The script work fine, my concern is about the condition to launch the script:

1) I see with the default scriptiong system the function group.getgroupname() to check if the group exist or not. Placing this script in lua predicate condition, that work but not when the tanker normally landing.

2) I put some standard conditions for the script working; Time > 120s AND unit speed < 2 kts OR unit dead

3) BUT, previous conditions are not 100% sure (unexpected traffic on airport...), I saw in wiki the event for engine shut down; can be used for launching mist respawn script? If yes, how to use it? In not developer and I don't understand the mecanism of scipting engine :cry:

The better way should be to check the unit alive OR the engine shut down to launch the respawn script

 

Thanks for your support

Link to comment
Share on other sites

  • 2 weeks later...
  • 6 months later...
  • 2 months later...
  • Recently Browsing   0 members

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