DaleRFU Posted December 9, 2020 Share Posted December 9, 2020 Good morning all, I'm trying to create a mission where I can sit on CAP/CAS and have random enemy units appear. I have been able to get the random units to appear however they are continuous so as soon as one dies the next spawns in. I would like it so that once I've killed the first one that there is a random time thay the next will spawn in. If anyone knows how to do this please let me know, I would be most greatful to you. Kind Regards Dale Link to comment Share on other sites More sharing options...
dark_wood Posted December 9, 2020 Share Posted December 9, 2020 you need LUA and MIST, something like this: --set your respawn function function yourFunctionName() if not Group.getByName('groupName') then mist.respawnGroup('groupName', true) end end --call your function periodic --function name // parameter (if needed) // Start function after 5 minutes // Call function again random, between 1 or 2 minutes // end calling function after 60 minutes mist.scheduleFunction(yourFunctionName, {}, timer.getTime() + 300, math.random(60, 120), timer.getTime() + 3600) Documentation here: https://wiki.hoggitworld.com/view/Mission_Scripting_Tools_Documentation https://wiki.hoggitworld.com/view/Category:Functions Hope it helps Link to comment Share on other sites More sharing options...
DaleRFU Posted December 11, 2020 Author Share Posted December 11, 2020 Thank you for that, it's very much appreciated. I shall give it a go. Link to comment Share on other sites More sharing options...
DaleRFU Posted December 28, 2020 Author Share Posted December 28, 2020 On 12/9/2020 at 12:28 PM, dark_wood said: you need LUA and MIST, something like this: --set your respawn function function yourFunctionName() if not Group.getByName('groupName') then mist.respawnGroup('groupName', true) end end --call your function periodic --function name // parameter (if needed) // Start function after 5 minutes // Call function again random, between 1 or 2 minutes // end calling function after 60 minutes mist.scheduleFunction(yourFunctionName, {}, timer.getTime() + 300, math.random(60, 120), timer.getTime() + 3600) Documentation here: https://wiki.hoggitworld.com/view/Mission_Scripting_Tools_Documentation https://wiki.hoggitworld.com/view/Category:Functions Hope it helps Sorry to drag up an old thread, but if I used this where would I insert it (condition or action), when would I insert it and which parts of the test do I change exactly? Regards Dale Link to comment Share on other sites More sharing options...
dark_wood Posted December 28, 2020 Share Posted December 28, 2020 You can do something like this: MISSION START > no condition > do script file: load MIST here ONCE > time more 5 seconds > load your LUA script here Link to comment Share on other sites More sharing options...
DaleRFU Posted December 28, 2020 Author Share Posted December 28, 2020 (edited) Brilliant, and I assume I only change the ('groupName') parts to the group that I am referring to? Also where to I put the activate group part? Really sorry if I am being a biff here. Edited December 28, 2020 by DaleRFU Link to comment Share on other sites More sharing options...
dark_wood Posted December 28, 2020 Share Posted December 28, 2020 (edited) 1 - yes, put there your group name 2 - open Notepad++ an copy/paste my code there, then save as LUA - this file you will load after MIST 3 - no need to be sorry, i like to help, but you will need to test it by yourself - this is how you will learn - i'm only show you the path to follow Edited December 28, 2020 by dark_wood 1 Link to comment Share on other sites More sharing options...
DaleRFU Posted December 28, 2020 Author Share Posted December 28, 2020 56 minutes ago, dark_wood said: 1 - yes, put there your group name 2 - open Notepad++ an copy/paste my code there, then save as LUA - this file you will load after MIST 3 - no need to be sorry, i like to help, but you will need to test it by yourself - this is how you will learn - i'm only show you the path to follow Thank you so much for helping I really appreciate it. Once I have loaded the .lua file I find that the unit does not activate, so I added "activate group" so now the unit is present however it is activated instantly after 5 seconds as per the condition. I tried the same with flags and then having a separate line for group activate but I got the same results. Link to comment Share on other sites More sharing options...
dark_wood Posted December 28, 2020 Share Posted December 28, 2020 Soo, let me explain: this MIST function, only respawn a dead group, it doesn't activate it at all. Like i said, this script is doing a check (at random times) to see if your group is dead - if it is dead, it respawn it. Why don't you activate it from the start, and remove the GROUP ACTIVATE (Test)? Unit is active (at mission start), you kill it (or not), then after a random time it is respawned. Anyway, if you want to play with LUA (which is good): trigger.action.activateGroup(Group.getByName('Test')) you will have something like: MISSION START > no condition > load MIST file ONCE > time more 10 seconds > do script - trigger.action.activateGroup(Group.getByName('Test')) ONCE > time more 20 seconds > do script file Test.lua Link to comment Share on other sites More sharing options...
Fisherman82 Posted December 31, 2020 Share Posted December 31, 2020 (edited) On 12/9/2020 at 8:48 AM, DaleRFU said: Good morning all, I'm trying to create a mission where I can sit on CAP/CAS and have random enemy units appear. I have been able to get the random units to appear however they are continuous so as soon as one dies the next spawns in. I would like it so that once I've killed the first one that there is a random time thay the next will spawn in. If anyone knows how to do this please let me know, I would be most greatful to you. Kind Regards Dale I would not need to use MIST for this kind of thing, just DCS mission editor triggers and conditions. In all missions I do I have a trigger that sets flag 1 to a value between 1 and 60 every minute. Instead of spawning a new group directly when another dies as I guess you have it set up now you could instead set another flag, lets call it flag 2, to a random value between an interval of your choosing. Then you activate the group using the flag is less than flag condition for flag 1 and 2. If flag 2 gets a value of 30 there will be 50% chance that flag 1 is less than that because it is set between 1 and 60 every minute. If not its the same chance the next minute. So if flag 2 is 30 the next group will activate in a couple of minutes. If you want longer delay then have flag 2 get a value that is lower than 30, if you set it to 2 you should statisticly have to wait a long time since the only time the group will activate is the minute when flag 1 gets the value 1. Therfore set flag 2 randomly between an interval, perhaps 10-30. Its a bit more complicated to calculate the chance using mathematical statistics than this but roughly you can just think what the chance is every minute depending on flag 2s value. If flag 2 is 10 then its 1/6 chance every minute so roughly in 6 minutes it should happen for example. I dont know exactly how you have your mission set up so I dont know exactly how you should apply this but its possible this way. Edited December 31, 2020 by Fisherman82 Link to comment Share on other sites More sharing options...
Recommended Posts