Jump to content

Random spawn


AVZ

Recommended Posts

I haven't been able to figure out how to make it so that there is a certain probability percentage of something actually appearing in a mission. I mean, there doesn't seem to be any way that I can set a probability condition to the object itself, rather than something it does.

 

Thanks in advance :)

Link to comment
Share on other sites

It's a bit tricky... I'll do my best to explain and when I'm back at home I'll post up an simple example mission for you to look at

Basically random spawn triggers (regardless of the % value you set) will keep being evaluated until they're true.

So your triggers might look like:

Once, Spawn group> Condition, player in zone, random 30%> Action, Group activate...

 

The above will always result in the group becoming active, what you have to do is add a flag logic to the condition and action so that once the random trigger is evaluated as true the other potential random groups can no longer spawn.

 

So lets say you have a mission with a target area and you want a Tunguska to always spawn in one of three places...

Make the three tunguska groups and set them to late activation (we'll call them TUNG 1, TUNG 2 and TUNG 3)...

Now add the following triggers (obviously these can be changed to your liking):

 

Once, Spawn TUNG1> Condition, player in zone, random 30%, flag 1 is false> Action, Group activate TUNG1, flag 1 is true

 

Once, Spawn TUNG2> Condition, player in zone, random 30%, flag 1 is false> Action, Group activate TUNG2, flag 1 is true

 

Once, Spawn TUNG3> Condition, player in zone, random 30%, flag 1 is false> Action, Group activate TUNG3, flag 1 is true

 

 

...Hopefully you can follow the logic here, I'm unfortunately not great at explaining it. With any luck some one else will do a better job before I get home but if not I have a small example mission I can post up that should help and be a bit more clear :)

System specifications: Computer, joystick, DCS world, Beer

Link to comment
Share on other sites

Thanks for the info! I will try this out. However, what I personally need, is basically a random beginning mission spawn (but I guess I can just do the player in zone condition), as in, a random percentage of something actually appearing on a mission or not at all. Do you think the following trigger string will work?

 

Once, Spawn Units> Condition, player in zone, random 50%> Action, Group activate Tanks

 

Or should there always be a flag entry in this case, since the "random" condition does not really have anything to randomise in the above case?

Link to comment
Share on other sites

Mission Start> random 50%> group activate works just fine. The method smokey mentioned is great for when you want only 1 or a specific number of the groups to spawn.

 

Make sure you tick the box "late activation" to for each group you want to spawn in with triggers.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Once, Spawn TUNG1> Condition, player in zone, random 30%, flag 1 is false> Action, Group activate TUNG1, flag 1 is true

 

Once, Spawn TUNG2> Condition, player in zone, random 30%, flag 1 is false> Action, Group activate TUNG2, flag 1 is true

 

Once, Spawn TUNG3> Condition, player in zone, random 30%, flag 1 is false> Action, Group activate TUNG3, flag 1 is true

Gets you a chance of one of the 3 (a higher chance of the first), but doesn't guarantee any unit will spawn, unless you change the once to continuous, but that's eating CPU cycles & still favours the one at the start, as they're evaluated sequentially.

Mission Start> random 50%> group activate

will get you a 50 % chance of that unit spawning.

 

If you always want a random one of say 4 units to spawn (or one of two if you make two sets of two conditions that spawn the same units, or one of three and one chance of nothing in 4 if you leave one possibility empty etc, etc - or spawn one of 9 units randomly if you use three initial triggers) then try:

 

Mission start, Random 50% > flag 1 true

Mission start, Random 50% > flag 2 true

 

Once, flag 1 true and flag 2 true > activate group 1

Once, flag 1 true and flag 2 false > activate group 2

Once, flag 1 false and flag 2 true > activate group 3

Once, flag 1 false and flag 2 false > activate group 4

 

 

with some rough & bodgy excel-ing (without using a solver), if you want even probabilities for the first suggestion, you need to use something like 30%, 43% and 75%, which will get you ~ 30% A, 30% B, 30% C & 10% nothing


Edited by Weta43

Cheers.

Link to comment
Share on other sites

Weta, your analysis isn't entirely accurate. It does guarantee one will spawn because Once triggers are always evaluated until it becomes true. It is simply a matter of time before one of them becomes true. The flag is false conditions, and flag 1 set to true forces only one option to be true. Although with a 30% chance per second, one of em will spawn quickly, and chances are the higher choices in the list will occur first. I'd argue its better to leave it at the default 10% as it requires more "chances" for each choice to get chosen.

 

You can also do fun stuff like

 

Once>Flag is less than x && Random 10% > Activate Group, Flag increase 1.

 

With multiple iterations of the above for each group allows you to specify how many groups are chosen.

 

 

Also, the amount of CPU processing required for triggers in microscopic at most. Its a non-factor.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Weta, your analysis isn't entirely accurate. It does guarantee one will spawn because Once triggers are always evaluated until it becomes true.

 

I don't agree. I think you're confusing evaluation and execution.

Yes, all triggers are evaluated each evaluation cycle, but the mission start, once, continuous and "Border" setting defines how often the action will be executed.

 

So, my understanding is that:

"Mission start" triggers are executed once at mission start, then never again regardless of whether their conditions are true.

"Once" triggers are executed once when the initial conditions are first met, then never again, regardless of whether their conditions are true. (For example the first time a unit enters a zone, a 10% chance of activation happens then, but never again after that -Hence "Once")

"Continuous" triggers are executed continuously once the initial conditions are met.(For example, after a unit enters a zone, a 10% chance of activation occurs continuously each evaluation cycle while the unit is in that zone Hence "Continous")

The threshold condition triggers (can't remember the actual name right now) are executed once each and every time the initial conditions are met where they were not the previous evaluation, but not continuously while the conditions are met. (so for example, once each time a unit enters a zone, but not again until the unit leaves the zone & re-enters it...)

 

For smokeythelung's system to guarantee a unit was spawned, the triggers would have to be set to continuous, not once, then the whole set would be looped through till a unit spawned and flag one became true, causing the initial conditions to no longer be true...

 

Although with a 30% chance per second, one of em will spawn quickly, and chances are the higher choices in the list will occur first. I'd argue its better to leave it at the default 10% as it requires more "chances" for each choice to get chosen.

 

Not quite sure what you mean by this.

You agree that the system as originally posted will be more likely to spawn the first item on the list ("chances are the higher choices in the list will occur first." ?)

 

Are you just saying that the likelyhood of the first item being prefferentially chosen goes down with the % that the random is set to (set it to 100% & it's always the first one, set it to 0% & they all have exactly the same (0%) chance of being chosen - the closer to 100% the more likely the first one will be chosen)

 

If so - that's true - but the smpler option is to just pick a method that is actually random the first time around - either the one I originally posted (with my brain turned off & living in the past :-) or the more up-to-date

 

Once > conditions met > set flag to random between 1 and n

flag = 1 activate group 1

flag = 2 activate group 2

...

flag = n activate group n

 

Also, the amount of CPU processing required for triggers in microscopic at most. Its a non-factor.

 

Poor word choice on my part. The cpu processing is small, but the time taken is not as the triggers are evaluated with a small but finite loop time (was originally 5 sec, then 1sec). If you want the trigger to do what it's supposed to at the time the event happens, it's best not to use continuous random evaluations with a low probability of execution.

 

If you want to create delays, continuous low probability loops are great - I set up some loops to randomly turn off and on ground unit AI on opposing forces so that once within range each group would randomly and independantly move and fire for between 1 and an average of 10 seconds, then pause for between 1 and an average of 10 seconds - the battle wasn't just a continuous blaze at each other - there were short and longer periods where both were firing, where only one was, and others where none were. By messing with the %ages you could shift the ratio of active to inactive, and also make one group "braver" than the other...

Also good for airbase perimeter patrols - group walks for a while, occasionally pauses then continues..


Edited by Weta43

Cheers.

Link to comment
Share on other sites

Weta, the trigger types more accurately describe the how the "actions" are executed, not how often the trigger is evaluated. Every trigger is added to a list to check the conditions every second within the mission. There are a few exceptions. Triggers with "events" defined will only check the trigger conditions when the specified event occurs. After "once" triggers are executed the condition is removed from the list, the same goes for Mission Start triggers after one second into the mission.

 

"Once> Random 1%> Activate group" is a guarantee that a random group will activate. Every second there is a 1% chance the trigger condition is true. It is simply a matter of time for it to occur.

 

Likewise the following will guarantee one group will activate.

Once>Random 1% and Flag is False> Activate Group1, Set Flag True

Once>Random 1% and Flag is False> Activate Group2, Set Flag True

 

The method Smokey described works as long as the player is in the zone. Personally I would use a separate trigger to decide "when" to make the random choice. That way you can spawn additional stuff at random later on if you choose to from the remaining choices.

 

You agree that the system as originally posted will be more likely to spawn the first item on the list ("chances are the higher choices in the list will occur first." ?)

 

Assuming the random chance is relatively high (greater than 20%) then the chances of both becoming true at the same time increases.

 

Once> Random 50% and Flag is False> Activate Group1, Set Flag True

Once>Random 50% and Flag is False> Activate Group2, Set Flag True

If this logic is used then Group1 will almost always be picked first as the triggers are evaluated in the order of the list. If both were true at the same time it would do the first trigger before moving on to other triggers. In this case both triggers prevent the other from becoming true when the action is executed, so the first group will more likely spawn more often than not. If we used 1-10% then the chances are more even.

 

 

Picking a random flag value is another way to do the same basic thing. Although it has a little more fun to it because you can combine the two concepts to form something like:

Pick random flag X value between 2-5

 

Once>Flag X is more than 0 AND Random 5%> Flag X decrease 1, Group Activate 1

Once>Flag X is more than 0 AND Random 5%> Flag X decrease 1, Group Activate 2

...

It would randomly spawn 2 to 5 groups.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Weta, the trigger types more accurately describe the how the "actions" are executed, not how often the trigger is evaluated. Every trigger is added to a list to check the conditions every second within the mission. There are a few exceptions. Triggers with "events" defined will only check the trigger conditions when the specified event occurs. After "once" triggers are executed the condition is removed from the list, the same goes for Mission Start triggers after one second into the mission.

 

Yep, I'm fairly sure that's a paraphrase of : "Yes, all triggers are evaluated each evaluation cycle, but the mission start, once, continuous and "Border" setting defines how often the action will be executed."

 

 

Once> Random 1%> Activate group" is a guarantee that a random group will activate.

 

OK, I just think you're wrong :) (unless you're talking about scripting - I know nothing about that :-)

I think continuous, 1%> Activate group" is a guarantee that a random group will activate, and that "Once > Random 1%> Activate group" has a 1% chance that the named (not a random) group will activate . Ever..

 

but I'm at work & can't make a track, so I'll have to wait till I get home to see who's actually right.

 

Out of curiosity, how would you set a 1 % cance that a specific unit will (ever) trigger when another unit enters a zone, using the least amount of triggers & no flags ?


Edited by Weta43

Cheers.

Link to comment
Share on other sites

From an old manual I have on my hard drive:

 

ONCE. The trigger will be executed only once after the condition is evaluated as true. Once set as true, the condition is removed from the list. For example: if you want a message to show only the first time an aircraft enters an area, you would use the ONCE option.

 

CONTINUOUS. The trigger will initiate the set action each time the condition is evaluated as true. The condition is never removed from the list. For example: if you want a message to show every time an aircraft enters an area, you would use the CONTINUOUS option.

 

MISSION START. The trigger will only be checked only at mission start. For example: if you wanted to set multiple units to a random activation, you would use this option to evaluate this condition and determine which units are included in the mission according to the set percentage.

 

FRONT CONDITION. The trigger will perform the set action(s) every time when trigger's conditions is checked and evaluated as true and its previous state was false. For example: if you have a zone trigger assigned with a message with the trigger checking every 5 seconds (be default), you will get message once, at the first true evaluation, but then it will not show again because the previous state wasn't false. When the unit exits the zone and the trigger is evaluated as false. The next time the unit enters the zone, the trigger will again show the message at first true evaluation, and then will not show the message until it exits out of the zone.

 

Notice it doesn't say that the end result has to be true, only that the conditions are true, and a random 10% criteria is true as soon as it's evaluated (did I create a random chance ? yes. Does it matter what the outcome was ? No)

 

So - ONCE. The trigger will be executed only once after the condition is evaluated as true. Once set as true, the condition is removed from the list (& in our example, the condition was set to true by the unit entering the zone and the random having been evaluated.).

 

so if the conditions are unit enters zone, and random 10 %, the first time the unit enters the zone, that, and a 10% chance are evaluated and the corresponding action taken or not taken - resulting in a 10% chance the unit will activate.

 

the conditions have now been fulfilled and an action executed. "the condition is removed from the list" & will never be used again.

 

EDIT - Having written so much, I'll have to write a long retraction if it turns out I'm wrong :)


Edited by Weta43

Cheers.

Link to comment
Share on other sites

I'm with Grimes! :P

 

Once, continuous & switched will be checked every second. Continuous & switched will continue being checked after the conditions are meet.. once will stop being checked once the conditions are meet for the 1st time.

 

Therefore if you have a 1% random once trigger, every second it will be checked..with a 1% chance that it will be actioned. Therefore it will happen.. In 10 minutes it will have had 600 chances at a 100/1 of coming true. All about probability.

 

Mission Start triggers have a one shot try.. so a 1% random condition only has a 1% chance of ever being actioned.


Edited by MadTommy

i5-3570K @ 4.5 Ghz, Asus P8Z77-V, 8 GB DDR3, 1.5GB GTX 480 (EVGA, superclocked), SSD, 2 x 1680x1050, x-fi extreme music.



TM Warthog, Saitek combat pro pedals, TrackIR 4

Link to comment
Share on other sites

On “mission start” the random will evaluate the number of chosen units or groups,.. out of 10 units at 50%, only 5 will activate at random.

 

On “once” it will do the same function and will activate 5 out of 10 units at random if condition is true.

 

“Continuous” if condition is true it will evaluate continuously until Condition is false. Crazy.. Not.

 

If you are outside of continuous action zone or condition, then it stops..and comes ON again when condition is right. Correct?

I know the human being and fish can coexist peacefully.

Link to comment
Share on other sites

Not exactly, its a 50% chance for EACH trigger. It is possible it will spawn anywhere from 0 to 10 of the groups. Its not likely as that means at a coin flip odds it would need 10 false or true evaluations in a row. Chances are it will get somewhere between 3 and 7 groups to spawn in.

 

Continuous will keep repeating the action as long as the conditions are true.

Switched Condition will do an action once each time the condition BECOMES true.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Seems I was wring - I mean wrong (I admit that so infrequently in writing I'd forgotten how to spell it :) )

 

I was so sure that's how I remembered it working I even fired up BS_1 to see if I was remembering how it worked there.

 

Nope, I was wring - I mean wrong ...

 

And, though it almost causes me physical pain to admit it, you were right.


Edited by Weta43

Cheers.

Link to comment
Share on other sites

  • 7 months later...
  • 1 month later...
  • 3 weeks later...

I added a bunch of this stuff to the wiki: http://en.wiki.eagle.ru/wiki/Mission_Editor:_Randomization

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • 6 months later...
  • ED Team

Grimes, thanks for the link. I'll use Mission Start instead of Once. I thought I was losing my mind testing out my random triggers, lol.

Afterburners are for wussies...hang around the battlefield and dodge tracers like a man.
DCS Rotor-Head

Link to comment
Share on other sites

  • 5 months later...

Hi guys, i'm new to these trigger stuff on mission editor. Can you fast tell me how to make a unit respawn (no matter if time dependent, instantly or in any other way) in the same place or close by, after i kill it?

 

I read part of what you've been saying here about flags and such. I'm trying to build a small mission where i kill a ground unit and want to have it respawned again after each kill, in any way possible, but i can't seem to do it.

 

Thanks!

Good knowledge and common sense make the absurd run for defense.

Flying has always been a great interest for mankind, yet learning everything about it brought the greatest challenge!

Link to comment
Share on other sites

True respawning requires MIST scripting (there is a sticky thread in the mission builder section).

 

You can also try copy pasting a unit (Ctrl C and Ctrl V) and when copy 1 dies, you spawn copy 2. This is easy when you're dealing with low numbers, but can be a pain when you want many, many spawns.

 

To do the copy method:

 

1. Add unit to map and check the late activation box

 

2. Copy it X times

 

3. Set triggers to spawn the units, example:

ONCE > TIME MORE 10 seconds > ACTIVATE GROUP copy1

ONCE > GROUP DEAD copy1 & TIME MORE 10 seconds > ACTIVATE GROUP copy2... etc

Awaiting: DCS F-15C

Win 10 i5-9600KF 4.6 GHz 64 GB RAM RTX2080Ti 11GB -- Win 7 64 i5-6600K 3.6 GHz 32 GB RAM GTX970 4GB -- A-10C, F-5E, Su-27, F-15C, F-14B, F-16C missions in User Files

 

Link to comment
Share on other sites

True respawning requires MIST scripting (there is a sticky thread in the mission builder section).

 

You can also try copy pasting a unit (Ctrl C and Ctrl V) and when copy 1 dies, you spawn copy 2. This is easy when you're dealing with low numbers, but can be a pain when you want many, many spawns.

 

To do the copy method:

 

1. Add unit to map and check the late activation box

 

2. Copy it X times

 

3. Set triggers to spawn the units, example:

ONCE > TIME MORE 10 seconds > ACTIVATE GROUP copy1

ONCE > GROUP DEAD copy1 & TIME MORE 10 seconds > ACTIVATE GROUP copy2... etc

 

Thank you Exocet, so i've seen the copy-paste a unit as a solve too, but i have to work a lot even if i want it to spawn for 10 times (requiring 10 units on the map, of course), so i kind of want to find a way around this.

 

I'll try reading about MIST scripting that you tell about, seems the perfect solution for what i plan.

 

Thanks!

Good knowledge and common sense make the absurd run for defense.

Flying has always been a great interest for mankind, yet learning everything about it brought the greatest challenge!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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