Jump to content

Randomizing unit spawns, am I doing this right?


moespeeds

Recommended Posts

I'm currently at work but of course I'm thinking about DCS, and considering how I can randomize some unit spawns in my mission.

 

So I want to create 10 random spawns, triggered by the destruction of various units to further randomize it.

 

Switched condition>unit x dead OR unit y dead OR unit z dead>flag 1 through 10 on

 

Switched condition>time since flag 1 OR time since flag 2 OR etc through flag 10>flag 1 through 10 off

 

Switched condition>random 5 AND flag 1 on>spawn unit

Switched condition>random 1 AND flag 2 on>spawn unit

Etc through flag 10

 

So every time one of the units in that list dies, it runs a random chance of any of those 10 units spawning. Each unit would have a different chance, for instance the sa6 would have a 1% chance while the l39s would have a 20% chance. Am I thinking about this correctly? Or would all ten units spawn every time one of those flags and randoms are met?

Moe "Moespeeds" Colontonio

vVMA 231

http://www.vvma-231.com/

Looking for a serious US based Harrier Squadron? We are recruiting!

 

Link to comment
Share on other sites

This isn't a simple scenario, and you're into script territory with layers of randomness & probability involved.

 

You could try setting a certain flag to a random value on destruction of a particular unit.

 

Have a switched condition for each possible value watch that flag. If it equals 1, spawn enemy1. 2, spawn enemy2.... etc. Then reset the flag

 

The problem here is that you will have a metric ton of triggers and you'll need a set of them for every enemy.

 

This is why a script is a better choice.

 

Banner EDForum2020.jpg

Have fun. Don't suck. Kill bad guys. 👍

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

I tried this, and I'll test it in a little bit. I'm trying to minimize the number of triggers involved, I'll test this a little later. I guess my question will be, will it continue to check for a random, every time a unit on that list is destroyed?

 

mSa13JZ.jpg

 

LXaSPak.jpg

 

1DEzkmk.jpg

Moe "Moespeeds" Colontonio

vVMA 231

http://www.vvma-231.com/

Looking for a serious US based Harrier Squadron? We are recruiting!

 

Link to comment
Share on other sites

The way it's set up it's honestly too confusing for me to comment with authority but I don't think so.

 

It looks like you are manipulating *all* of the flags regardless of which unit is killed.

 

I'm suggesting to have one flag that is set to a random value whenever a unit is killed.

 

Have a switched condition watching that flag and activate whatever group you want based off a TIME_SINCE_FLAG condition.

 

I'll stand by the remark visible in the bottom left of your screenshots. ;-)

 

This would be 25 lines of code or less.

 

Banner EDForum2020.jpg

Have fun. Don't suck. Kill bad guys. 👍

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

I didn't take screenshots because I was lazy.

 

So the solution can not be scripted, because I'm lazy (20%) and because this is an experiment to implement some randomization into a fun map for our squad (80%). Our last builder put a ton of scripts in there, then peaced out without leaving us a manual or roadmap, so we are designing a new one and purposefully avoiding scripting so going forward any noob can work on it.

 

Fargo you were right, the current iteration created a loop, and the DCS engine tags a unit as dead and continually checks it as dead, so within the first few min of the mission, all the triggers would fire.

 

So I made the 15 extra conditions as one time events at random 1%. It still ends up firing all the triggers in pretty short order, but was much better.

 

So my question, does the DCS "Random" function even work as advertised?

Moe "Moespeeds" Colontonio

vVMA 231

http://www.vvma-231.com/

Looking for a serious US based Harrier Squadron? We are recruiting!

 

Link to comment
Share on other sites

So my question, does the DCS "Random" function even work as advertised?

 

The short answer: YES, the random function does work, and I use it constantly within my missions.

 

I don't understand code, so I do pretty much everything with the ME trigger system.

 

If I'm understanding everything correctly, what you want is a "Flag Set Random Value" trigger. Be aware even this can get complicated really quick. It's not uncommon for me to have an Excel spreadsheet open while I do this to keep track of all the flags. I'm going to try and explain this via memory, which isn't the best, so bare with me.

 

---------------

 

Trigger 1: When a unit dies, you'll want to trigger a flag. Example: Unit #1 dead, Flag on (1).

 

Trigger 2: Flag is True (1) > "Flag Set random Value (2, 1,10)".

This random value flag will determine what unit spawns next. To break this down, (2 = next sequential flag); (1,10 = random roll between 1 and 10, where each roll is a different unit).

 

Trigger 3: Flag Equals (2,1) > Unit Activate (Unit #2)

This trigger suggests that, if the random roll from Trigger 2 is a "1" Activate (Unit #2).

 

You would then need to repeat this step via a new trigger for each different possible roll from Trigger 2 as shown below:

 

Trigger 4: Flag Equals (2,2) > Unit Activate (Unit #3)

Trigger 5: Flag Equals (2,3) > Unit Activate (Unit #4)

Trigger 6: Flag Equals (2,4) > Unit Activate (Unit #5)

Trigger 7: Flag Equals (2,5) > Unit Activate (Unit #6)

and so on.

 

-----------------

 

You can easily add a second condition such as "Time Since Flag". Example:

Trigger 3: Flag Equals (2,1) & Time Since Flag (1, 120) > Unit Activate (Unit #2)

 

When the roll from Flag 2 equals 1, and time since Flag 1 equals 120 seconds, Activate Unit #2.

-----------------

 

To randomize even further, you can randomize the time the next unit spawns. Example:

Trigger 2: Flag is True (1) > Flag Set random Value (2, 1,10) & Flag Set random Value (3, 1,10)

 

In this case, the first action determines which unit spawns when Flag 2 is true. The second action determines a time when Flag 3 is true, where each individual roll represents a specific time since Flag 1.

 

The time is something you would have to specify via an additional trigger and flag. EXAMPLE:

 

Trigger 3: Flag Equals (3,1) > Flag On (4)

Trigger 4: Flag Equals (3,2) > Flag On (5)

Trigger 5: Flag Equals (3,3) > Flag On (6) and so on.

 

Once you've stated what the results of Flag 3 are, you would then move on to next step, telling what to spawn and when. Your next set of triggers would look like the following:

 

Trigger 10: Flag Equals (2,1) & Time Since Flag (4, 120) > Unit Activate (Unit 2)

Trigger 11: Flag Equals (2,1) & Time Since Flag (5, 180) > Unit Activate (Unit 2)

Trigger 12: Flag Equals (2,1) & Time Since Flag (6, 240) > Unit Activate (Unit 2) and so on.

 

NOTE: The above set of triggers only determines when Unit 2 spawns when Flag 2 equals 1. You would have to create new triggers for each combination possible. See Below:

 

Trigger 13: Flag Equals (2,2) & Time Since Flag (4, 120) > Unit Activate (Unit 3)

Trigger 14: Flag Equals (2,2) & Time Since Flag (5, 180) > Unit Activate (Unit 3)

Trigger 15: Flag Equals (2,2) & Time Since Flag (6, 240) > Unit Activate (Unit 3)

Trigger 16: Flag Equals (2,3) & Time Since Flag (4, 120) > Unit Activate (Unit 4)

Trigger 17: Flag Equals (2,3) & Time Since Flag (5, 180) > Unit Activate (Unit 4)

Trigger 18: Flag Equals (2,3) & Time Since Flag (6, 240) > Unit Activate (Unit 4)

 

-----------------

 

As you can see, the trigger list can get rather long very quickly. The more variables you add, the longer and more complicated the trigger list gets. I'm sure scripting is the easier and faster solution, I just don't understand what I'm reading when it comes to scripting. Therefore, the only way I can make things work is by the above stated trigger system. It's not uncommon for my trigger list to be in excess of 500+ triggers. Without an Excel spreadsheet, I'd be lost even using this method.

 

I hope everything I stated above makes sense, and you get everything working as you want it to. Good Luck!!

 

/r

Baaz


Edited by Baaz
Link to comment
Share on other sites

It's astonishing that the effort you guys are spending on this rats nest of triggers is greater than it takes to actually learn how to write a simple script to do this. MOOSE has classes that randomize the ever loving stuffing out of every possible thing.

 

Moe - can you make a simple flow chart of what you want to happen here?

 

Banner EDForum2020.jpg

Have fun. Don't suck. Kill bad guys. 👍

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

It's astonishing that the effort you guys are spending on this rats nest of triggers is greater than it takes to actually learn how to write a simple script to do this. MOOSE has classes that randomize the ever loving stuffing out of every possible thing.

 

To each his own I guess. I've flown on servers where they are HEAVILY scripted. But something is always broken, and the server runs like shit. It seems the more things get scripted, the worse the server tends to run with people warping all over the place, lagging in general, or the server just crashing. It's like DCS isn't designed for what server hosts are trying to do with the scripts. There's a post somewhere by Wags where he even hinted at this very issue (sorry, to lazy and tired to bother looking for it atm).

 

On the contrary, by using the mission editor trigger method, I can easily have 1500 units or more on the map, all randomized via various triggers, have 10-20 friends hanging out, and everything run smooth as butter. Coincidence??

 

Don't get me wrong, I do use scripts; but they are strictly plug and play with only minor tweaks to suit my fancy (referring to CTLD, CSAR, SRS). But, in the grand scheme of things, I find it easier to understand the rules of the ME and how flags work, than whether I have enough spaces between letters, what "{" or ":" or "#" even mean, or when I should use them when it comes to code. If it wasn't for Ciribob's explanations within the code, I wouldn't even use his stuff.

 

Again, to each his own. In the end, we accomplish the same thing.

 

 

EDIT: Furthermore, when all is said and done, between Moose, MIST, CTLD, CSAR, SRS, etc., you probably have more lines of code than I have in total triggers. Once you understand the system, vast majority of the work is cloning and changing options in drop-down menus. If all the code is done properly, can your server run for a longer period of time? Certainly. However, I'm just looking to play with a group for friends for at most up to say 10 hours. The ME trigger system is more than adequate to accomplish that.


Edited by Baaz
Link to comment
Share on other sites

A line of code isn't equivalent to a trigger. It just doesn't work that way. A line of code can be equivalent to one, ten, or twenty triggers.

 

And not all scripts are created equal. There are good and bad scripts just like good & bad triggers.

 

The multimissions we run on our servers have some ~2000 lines of code, plus CSAR, CTLD, cmws and many others and among over 50 mini-missions where every single aspect of the AI is fully randomized. The type of enemy, their location, their route, their quantity, their skill, ROE, formation, state, destination... everything. Absolutely nothing fails to work and they run for several days at a time until someone restarts them or loads a different miz.

 

Aside of the functionality you just can't accomplish with the ME alone, the time it takes to put all that together and test a gordian knot of triggers is among the principal issues here. It's a fraction of the time commitment, and testing/debugging it is super simple and lightning fast.

 

In fact, seeing different aspects of how DCS operates through MOOSE/Mist/native lua script development has increased my understanding of not only DCS, but how many features in the ME work.

 

The reason that we're suggesting a script to accomplish this isn't to steer people away from using the ME. We all use it.

 

It's that Moe would be done with this and flying by now.

 

There are a lot of us here who cheerfully assist people with debugging their scripting all the time. It's never been easier to learn what { : and # mean. There are even DCS-specific videos on scripting, MOOSE and all underlying aspects. Dozens and dozens.

 

I used to do it exactly like you're now doing it until I decided to learn, so I know exactly what's involved in both approaches. And with that in mind, I would urge you to reconsider giving the stiffarm to what is undeniably the most powerful aspect of mission development available to us.

 

I'll even help ya.


Edited by fargo007

 

Banner EDForum2020.jpg

Have fun. Don't suck. Kill bad guys. 👍

https://discord.gg/blacksharkden/

Link to comment
Share on other sites

Please forgive me if I seem to be argumentative. That it not the case at all.

 

To be frank, the older I get, the more I miss the old simple ways. I have no doubt scripting is the way to go. I find it amazing what you folks can do. It's just not for me. I don't have the patience to learn a new system, essentially from scratch. Hell, I don't even have the patience to learn the full capabilities of the iphone in my pocket. Furthermore, the older I get, the more I want to throw the damn thing away. :) Embarrassing enough, I even had to ask my soon to be going to college daughter, why the damn thing wouldn't even turn on (turns out I simply wasn't holding the button long enough).

 

Getting back to the OP, Moespeeds gives me the impression of being in the same boat I am. He/she doesn't understand coding, and may not be in the mood or position to start learning it now. All I was trying to show is that it is possible to get the job done with the in-game ME.

Link to comment
Share on other sites

EDIT: Furthermore, when all is said and done, between Moose, MIST, CTLD, CSAR, SRS, etc., you probably have more lines of code than I have in total triggers.

 

That depends on the mission.

Also, keep in mind that writing 100 lines of Lua is quite straightforward (once you know the basics) and takes less time than creating 100 ME triggers with all their flags and conditions.

Complex ME triggers can be merged into a single scripted function and/or just a few lines, that's powerful stuff.

 

I can get considerably more stuff done per hour if I script a mission, instead of using ME triggers.

I mean, handling complex conditions/actions for specific group / unit sets using ME triggers is already a time consuming task (quite maddening too).

That same stuff can be achieved with a dozen lines of code, in 5 minutes or less, without the need for those dreadful trigger lists (where each trigger becomes a needle in a haystack, pretty much).

 

Besides, creators are quite restricted when using ME triggers, much less so when using scripts.

 

Despite what you might think, scripting is faster and less painful (when it comes to programming complex missions / mechanics), it's not that hard to learn either.

 

But ultimately, as you pointed out, to each his own. If you find that ME triggers are less challenging to work with, go for it :thumbup:

 

 

As for script performance hit, I guess that depends on the amount of continuous schedulers / checks present in the script.

Anyway, in order to investigate the script performance hit, you'd need to use the same server, with the same clients, at around the same time.

First record performance using the ME version of a given mission, then do the same using a scripted version of it.

 

If you don't do that, you have no way of knowing what's actually causing the performance hit.

Personally, I've noticed that the amount of units, trees, buildings, rockets, missiles, explosions, etc. contribute the most to performance hits.


Edited by Hardcard
Link to comment
Share on other sites

Remember, this isn't about me, or what I want to learn, it's about what people I don't even know yet are willing to learn. Like I said, we decided to stay away from scripting as much as possible on this next iteration because of the mess we were left the last time someone used moose. We want to make sure that going forward, anyone can work on this.

 

Having said that, we tested something today that was dead simple and worked quite well:

 

3 zones, one being a common zone that sees alot of friendly a/c traffic, such as an airport. I used a FARP on this test mission. The other 2 were small zones, 1500 ft each, offset from popular target areas.

 

I set a bunch of flag triggered events, 10 that I classified as "Easy" and 3 "Hard". Easy events were things like wake up an AI of an SA8 or SA9 off the beaten path, or starting AI a/c sitting on the tarmac.

 

I set a condition for the Easy events that if friendly units occupied 2 zones at once, a random flag would be generated in the Easy range.

 

If friendly units occupied all 3 zones at once, it would generate a random flag that activated one of the hard events, such as activating an SA6, MIG 29s, or triggering an enemy bomber strike on the FARP.

 

I used a flag to force 120 sec between triggered events.

 

I could further tune the randomizing by increasing the range beyond the available number of events, for instance set the range from 1-50 with only 10 being valid events. I could also adjust the size and location of the trigger zones.

 

In testing this worked great and did exactly what we needed. Events occurred randomly, and the more planes we brought into the mission, the more chances of something being triggered.

 

So I guess I probably worded the question wrong, maybe I should have asked for ways to randomize without using scripts. We are going to use moose to control the carrier and tankers, I don't see any other way to effectively do that.

Moe "Moespeeds" Colontonio

vVMA 231

http://www.vvma-231.com/

Looking for a serious US based Harrier Squadron? We are recruiting!

 

Link to comment
Share on other sites

Remember, this isn't about me, or what I want to learn, it's about what people I don't even know yet are willing to learn. Like I said, we decided to stay away from scripting as much as possible on this next iteration because of the mess we were left the last time someone used moose. We want to make sure that going forward, anyone can work on this.

 

Sure, it's completely understandable.

 

The thing with scripting is that it requires keeping up with changes in the DCS scripting engine. Sometimes ED will make changes that break some scripting methods, so workarounds must be found...that's certainly a nuisance :mad:

 

Unless you have a "coder" who checks and updates the scripts, things can get really messy, as you pointed out :cry:

 

Good to hear that you've found a working solution, have fun! :thumbup:

Link to comment
Share on other sites

In the simplest of terms, YES and NO. :) Only once something is done with the value is it either on or off, depending on what action is performed with the value.

 

Consider it a kind of "IF" flag, and not a definite "Flag is True", or "Flag ON" type flag.

 

EXAMPLE: Flag Set random Value (2, 1,2):

In this example there's two possible outcomes. And we'll use ON/OFF as our options. So, IF a 1 is rolled, Flag is on/true. IF a 2, is rolled Flag is off. This is kind of a bad example as it's more work than a simple "Random (50)", but you can see how the "IF" is shown. This particular flag allows for as many possible outcomes that you can come up with.


Edited by Baaz
Link to comment
Share on other sites

Any value greater than 0 is considered on/true.

 

I can't and won't argue with that statement. However, in this specific case, as it pertains to Flag Set Random Value, a value greater than 0 is moot if we don't do something with those values, no? Otherwise a simple Flag On/Flag Off will suffice.

 

If I failed to explain my thought process, I do apologize. If I'm over analyzing the use of Flag Set Random Value, please, do tell me.

 

 

EDIT: Forgive me FFFF, is see now why you made that statement. In my example (as stated it was a bad one), I said a roll of 2 is off. Personally I don't use Flag Set Random Value for anything other than random selection of which units to spawn. I lost sight of that when I went with an example of only two possible outcomes. My example is made even worse when we consider this whole thread is about the random spawning of units.


Edited by Baaz
Link to comment
Share on other sites

  • Recently Browsing   0 members

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