Jump to content

Group Conditions


Go to solution Solved by Grimes,

Recommended Posts

Posted (edited)

In the Mission editor there are 2 functions to determine if a group is created. The first is "condition" and the second is simply a % chance.

I have no idea how to script other than copy/pasting others work with a few hacks. I have a trigger at misison start to randomly select flag1 with a value of 1-6.

How do I add a condition to the group such that it's only created if flag1=1 for example. it's gotta be really easy....but it's not as easy as    Flag1=1 lol.

 

The following works as a LUA Predicate when used as a trigger  but not as a group condition so Im thinking that what I want isn't possible as the triggers are run AFTER the creation of the groups

if trigger.misc.getUserFlag("1") == 1 then
    return true
end
return false

 

Edited by gmangnall
update
Posted (edited)

Hello.

  • Use SWITCHED.
  • In conditions pass your "LUA PREDICATE" check:

(You may use a loop of 1 .. 6 but this example is step-by-step)

if  trigger.misc.getUserFlag("1") == 1
or ......
or trigger.misc.getUserFlag("6") == 1 then
    return true
else
    return false
end

  • Then, in actions add a "DO SCRIT" and paste a function and the call, such as:

function CheckThem()
         if trigger.misc.getUserFlag("1") == 1 then trigger.action.activateGroup("Group-1")
  elseif .......
  elseif trigger.misc.getUserFlag("6") == 1 then trigger.action.activateGroup("Group-6")
    end
end

CheckThem() -- call the function.

NOTE: Once any of the FLAGS becomes true, you have to "FLAG OFF" all of them, after the above "DO SCRIPT" action.
DO SCRIPT
FLAG OFF 1
......
FLAG OFF 6

Thank you.

 

Edited by ADHS

Democracy was already invented, while Scrat was eating oak fruits.

Posted

BE VERY VERY CAREFUL. 

The UI/UX/Naming Convention is VERY VERY misleading. 

The % chance that you think you are setting as a CONDITION IS NOT WHAT YOU THINK IT IS.

I've had a two hour 'argument' with people on the official discord about this and even talked directly to the dev for the ME. 

It works (Don't even try to convince me this is a good idea) as a TIMER and not a CHANCE x will happen. EVEN if you use the PROBABILITY tick box on a waypoint action or a LUA PREDICATE to determine if something should happen. 

Basically, every condition is processed once per second. They are only 'removed' from being interrogated IF AND ONLY IF THEIR RELATED ACTION HAS BEEN TRIGGERED.

This means when you set a probability of 40% that at a waypoint you want a switch waypoint command to happen or a group to activate or whatever it is you want.. 

That 'condition' will be processed once a second until the Random Number Generator makes it true. 

It's NEVER PROCESSED JUST ONCE. So if you do this on a waypoint, thinking it happens when the unit gets to a waypoint - it's not - it happens EVERY SECOND ALL ALONG THE PATH TO THE FOLLOWING WAYPOINT - which could be hundreds of NM's... So it will always RNG true at some point. 

The 'way around this' complete misrepresentation of the UI/Words/Concept is that you have to have TWO triggers to do ONE job. The first will evaluate true and set a flag to a random value say -  between 1 and 100. 

The second trigger then is a condition where that flag is greater than 0 and less than the probability you want to use, and that conditions action is the action that you want. 

 

I know.. totally unintuitive and totally not what the UI/UX/English words semantically mean... but this DOES in fact work and gives you want you need. 

Just remember - EVERY CONDTION WILL BE TESTED ONCE EVERY SECOND. It will ONLY STOP when it's related ACTIONS have been triggered. 

EVEN when you set the trigger to ONCE ONLY. 

Posted (edited)

You are completely missing what I am trying to do. The code I need isn't in the triggers section of the editor. It's in the group section.

When you create a group in the editor you can set the unit, callsign waypoints etc. Near to the top of that screen there is a field for "condition" and one for %.

If you leave the condition blank and the % as 100 the unit will be created at the start of the mission. If set at 50% then there will be a 50% chance that the unit is created (not 50% every second).

I am tryng to populate this field such that if flag1=1 (set at mission start via the usual triggers) the unit is created and if flag1 doesn't =1 then the unit is not created.  null

nullImage shows the condition field I am talking about

image.png

Edited by gmangnall
Posted (edited)
6 hours ago, gmangnall said:

You are completely missing what I am trying to do.

This was what i undestood from your description without picture. Thanks for clarify this, ignore the rest 😀

As for what are you looking for: You are just enetering a value 0 to 100 that later you can check with Group.getLife

I haven't ever use the condition field, but you inserting LUA somehow (copy/paste or through in advanced commands) sorry.

3 hours ago, PravusJSB said:

I think that relates to 'life'. I'm not 100% (intended) but pretty sure.

Yes, me too. Obviously refers to the overall group's LIFE in percentage that can be spawned damaged and not 100% healthy.

In page 191 DCS Manual refers to a condition (seems LIFE to me) and a random percenatge.

CONDITION. The condition for the random spawning of a group in a mission. For this, LUA
expressions used in the Simulator Scripting Engine Documentation are entered into the field.

Edited by ADHS

Democracy was already invented, while Scrat was eating oak fruits.

Posted

The percantage is most defintely the chance of spawning and not the unit health. For a unit to spawn it needs to meet both the condition (if set) and the percentage. I have used the condition to activate a trigger AFTER mission start e.g. activating a flag.

Posted
1 hour ago, gmangnall said:

The percantage is most defintely the chance of spawning and not the unit health. For a unit to spawn it needs to meet both the condition (if set) and the percentage. I have used the condition to activate a trigger AFTER mission start e.g. activating a flag.

I have no use for the condition option under groups.

With triggers, it's simple:

Mission Start : Flag set random value

Once : Time More than X : If Flag > X, spawn group.

The second line can probably be mission start too, but I usually delay spawns to keep mission impact low.

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

 

Posted
3 hours ago, gmangnall said:

I have used the condition to activate a trigger AFTER mission start e.g. activating a flag

Try activate a GROUP with and with no %.

Democracy was already invented, while Scrat was eating oak fruits.

Posted

@TJTAS - that doesn't do what I need it to. Your suggestion kinda works, however it will show the threat rings for both SAMs even if only one gets activated. The only way to ensure that a threat ring is created (or not) is via the group condition

@Exorcet As above - it doesn't solve that I am trying to achieve.

@ADHS - if you put the group condition as 0% the unit will not be created.

Posted (edited)
9 hours ago, gmangnall said:

@ADHS - if you put the group condition as 0% the unit will not be created.

Hello.

What about other values higher than 0 f.e 15, 35, 55, 75 etc ? Let me know please.

If the group respawns but the health of the units or the units are less than 4, then it is a health factor.

Edited by ADHS

Democracy was already invented, while Scrat was eating oak fruits.

Posted (edited)

If you set it at 50% the unit will appear at full health.....half the time. The other half it will not spawn.. I have read the documention and for a unit to spawn - BOTH conditions must be met......one condition being "the condition" and the other being the %

Edited by gmangnall
.
Posted (edited)
7 hours ago, gmangnall said:

the unit will appear at full health

By saying unit means that your group is just one unit ?
If so, please do try with a group of four units.

7 hours ago, gmangnall said:

BOTH conditions must be met

From the time that you had results just with % maybe not.
If those two have to go together, then a guru of dcs may
help further to solve this. Unless if this is another dcs
secret also.🙂

Thank you for letting me know.

Edited by ADHS

Democracy was already invented, while Scrat was eating oak fruits.

Posted

The condition and percentage values are both used to determine if the group exists in the mission. In the .miz file this entry is labeled as "probability". Condition is just a lua condition that you might want to hook into other code and uses return true or return false to define the spawn rules. 

I underlined "group exists" above because that is an important distinction from using late activate. If the percentage is 0 then think of it as the trigger Group Deactivate, also the scripting function of destroy(), is always being run on the group. If its any other percentage then its whatever RNG you set to determine if that happens. Anyway that group won't exist and you can't use group activate to spawn it* at a later point in time if you wanted to like you can with late activating groups. 

On the face of it this is an easy triggerless way to get some basic unit randomization. Instead of creating a dozen Mission Start>Random X>Group Activate triggers and also setting late activate for the relevant groups, you just set whatever percentage value you want in the probability value to get the same basic result. 

 

* I heavily use this as a property with the bubble spawning script used on the Grayflag server. Anything with probability == 0 means that group can be controlled by the bubble script. The group doesn't exist but the group table within the mission file still does, thus it gets used as a template of sorts being passed to coalition.addGroup when the bubble spawner decides to spawn the group. Since the game automatically despawns these groups on mission load I don't have to manually remove them as the mission starts. 

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

Posted

Thank you Grimes!!!!! But back to my original question..... what I'd like is for the condition to check if a flag exists (at mission start). What I am looking to achieve is to set up say 4 SAM sites but only one of them be created so if flag1=true SAM 1 gets created and if flag 2=2 only sam2 is created....but I have to use this condition becasue I only actually want the threat rings creating. Once that's created I will (in some random cases but not all) delete the SAM and move it elsewhere (e.g. simulating bad intel).

Is there code I can put in theh condition to achieve this?

  • Solution
Posted
On 1/5/2023 at 6:38 PM, gmangnall said:

Thank you Grimes!!!!! But back to my original question..... what I'd like is for the condition to check if a flag exists (at mission start). What I am looking to achieve is to set up say 4 SAM sites but only one of them be created so if flag1=true SAM 1 gets created and if flag 2=2 only sam2 is created....but I have to use this condition becasue I only actually want the threat rings creating. Once that's created I will (in some random cases but not all) delete the SAM and move it elsewhere (e.g. simulating bad intel).

Is there code I can put in theh condition to achieve this?

The game really doesn't make it easy to do that. With the threat rings it is a question of whether or not the hiddenOnMFD is checked and when the group spawns relative to the player spawning. Group spawns with hiddenOnMFD, then player spawns, that player shouldn't see the threat ring. Same if the player spawns and then the group spawns with any setting. 

By those rules you just need what you want the player to be seen when the player spawns and then add/change whatever after the player spawns. To make things much easier you can always spawn the player later. This would be the easiest way to do it with just triggers. Force the player to start at 2 seconds into the mission. At mission start set a flag to whatever value. Once time less than 10 seconds, so it runs first thing after mission start occurs, for each sam if my flag is false then group deactivate. Now player spawns. After player spawns then you can activate a group that had hiddenOnMFD checked and deactivate the sam representing the threat ring. 

 

However to utilize the lua condition is a little on the annoying side. The only thing that runs before it is the initialization script found on the trigger panel. You can add something like this to every sam you want to conditionally exist.

if tbl["Ground-1"] then return true end

Then in the initialization script you need to define tbl and add the groups you want to add to it. 

tbl = {}
local choices = {"Ground-1", "Ground-2","Ground-3","Ground-4","Ground-5"}
local rnd = math.random(#choices)
tbl[choices[rnd]] = true

What this is doing is the initialization code creates the table and adds the group name as a key that gets checked by the condition. Then the condition checks to see if their respective group name is found in the table, if it is then spawn the group.

 

This would be a whole lot easier if we could just draw a threat ring on the MFD and ignore the units. But we can't yet, so here we are. 

  • Like 1

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

Posted

Hi  Grimes the late activation option works a treat!!!! Thank you!!!! I might take a look at the LUA option though I utterly suck at coding. Id have to read on how to define a table....but I am sure that's jsut about within my capability 🙂

  • Recently Browsing   0 members

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