tornado66 Posted November 2, 2011 Posted November 2, 2011 Hi. I have a question about this action trigger: in my mission i have to set three flight activate by flag 9 , 10 , 11. Than i have to set a trigger with a trigger action: SET FLAG RANDOM: -in FLAG box set flag 10 -in FLAG box val. min. set flag 9 -in FLAG box val. max. set flag 11. Everytime i start the mission , be activate only and ever the flag 10. It is a bug or is my wrong action? TNX [sIGPIC]www.21gt.it[/sIGPIC]
nomdeplume Posted November 2, 2011 Posted November 2, 2011 (edited) Flags can be boolean (true/false) or integers (counting numbers, positive and negative). FLAG SET RANDOM sets the specified flag to a random value between the minimum and maximum values you specified (inclusive). So what you're doing is setting flag 10 to a value of either 9, 10, or 11. The boolean logic (flag is true/flag is false) will treat a flag value which isn't zero (or which hasn't been explicitly set) as 'false', anything else as 'true'. So in your case, flag 10 is the only one that's been set to a value, and that value is evaluated as 'true' by the boolean logic. For your logic you either want to have three separate triggers like: condition: RANDOM 50% -> action: set flag 9 condition: RANDOM 50% -> action: set flag 10 condition: RANDOM 50% -> action: set flag 11 However in this basic form, you may end up with any combination of those three flags (all true, all false, one true and two false, or two true and one false). You could also use FLAG SET RANDOM to set flag 10 to e.g. 1, 2 or 3. And then use separate triggers to check the value of flag 10. At present you need to use a pair of "flag less than" and "flag more than" in lieu of "flag is equal to", but that condition is [probably] coming in the next patch. Edited November 2, 2011 by nomdeplume
tornado66 Posted November 2, 2011 Author Posted November 2, 2011 Thank you, very good explanation. So if I understand correctly quoted the command does not work and then is good for nothing? To get the result I want I use the RANDOM? [sIGPIC]www.21gt.it[/sIGPIC]
nomdeplume Posted November 3, 2011 Posted November 3, 2011 Thank you, very good explanation. So if I understand correctly quoted the command does not work and then is good for nothing? To get the result I want I use the RANDOM? The command works exactly as it's supposed to, and is very useful for achieving its purpose - to set the value of a flag to a random number between the minimum and maximum you specify. Using the RANDOM condition to set one out of a set of flags to true is the 'traditional' way of achieving your goal - because the 'flag set random' action is a recent addition. If you're wanting to create a situation where exactly one of three (or however many) potential outcomes is randomly selected, then I think 'flag set random' is actually the easiest way of doing it. For just three items, setting individual flags isn't too bad, but it's a very complicated method to try to scale up to add more variations. Using the random value method instead just requires the addition of an extra trigger, with the exact same conditions as the others (just different values to test for), so it's simple to use.
Weta43 Posted November 4, 2011 Posted November 4, 2011 (edited) You can use the set flag between values trigger to randomly activate one (or more) of a fixed number of scenarios (at start, or when a condition is met), but in conjunction with other flags you can also then randomly start one of the remaining scenarios when that one is done (or other conditions are met), etc, till all have been completed Edited November 4, 2011 by Weta43 Cheers.
JEFX Posted November 4, 2011 Posted November 4, 2011 You can use the set flag between values trigger to randomly activate one (or more) of a fixed number of scenarios (at start, or when a condition is met), but in conjunction with other flags you can also then randomly start one of the remaining scenarios when that one is done (or other conditions are met), etc, till all have been completed Could you please explain step by step ??? Thanks [sIGPIC][/sIGPIC] In DCS I fly jets with thousands of pounds of thrust... In real life I fly a humble Cessna Hawx XP II with 210 HP :D
tornado66 Posted November 4, 2011 Author Posted November 4, 2011 What I still do not understand is what are the values that are put in boxes "val.min" and "val.max" are the numbers of flags or random values with which you will activate the flag? I did many tests but my impression is that the command does not work well ... [sIGPIC]www.21gt.it[/sIGPIC]
Speed Posted November 4, 2011 Posted November 4, 2011 What I still do not understand is what are the values that are put in boxes "val.min" and "val.max" are the numbers of flags or random values with which you will activate the flag? I did many tests but my impression is that the command does not work well ... Those min and max values are probably the limits of the random value the flag can take. Once you set a flag to a random value, then you can use triggers to detect where exactly that flag value lies- you can use the trigger conditions flag more than, flag less than, etc. It's rather complicated, but it should work fine. I did present and alternative and easier method with the mod I just released (Slmod), at least for missions flown in multiplayer. It is capable of randomly selecting a single flag to be set to true out of a range of flags with a single line of Lua. For example: slmod.rand_flag_choice(11, 21) will set a single flag between 11 and 21 (inclusive) to true. Another function I included is the rand_flags_on, which randomly sets a range of flags (or a single flag, if you want) to true at a specified probability. For example, when the following Lua function call is run, slmod.rand_flags_on(101, 151, 30) it will randomly set each flag between 101 and 151 true, at a probability of 30% each. These two Slmod functions do not do anything that the mission editor cannot do, but if you need to do a lot of random flag actions, these functions do these things MUCH more easily than the mission editor can. Obviously, if you only need to select like one of four possibilities, it will probably be better to avoid the mod and use solely the trigger system (unless you were going to use the mod for something else, too)- setting a flag to a random value, and then detecting what that random value is with the appropriate "flag is more than"/ "flag is less than" trigger conditions. 1 Intelligent discourse can only begin with the honest admission of your own fallibility. Member of the Virtual Tactical Air Group: http://vtacticalairgroup.com/ Lua scripts and mods: MIssion Scripting Tools (Mist): http://forums.eagle.ru/showthread.php?t=98616 Slmod version 7.0 for DCS: World: http://forums.eagle.ru/showthread.php?t=80979 Now includes remote server administration tools for kicking, banning, loading missions, etc.
Weta43 Posted November 6, 2011 Posted November 6, 2011 Could you please explain step by step ??? Thanks you need: a continuous random-between trigger (say, trigger 1, between 1 & 5) that opperates while a 'looking for scenario' trigger is true. a number of scenario trigger flags (same as range of trigger above) that start when the trigger above is at their value (any other desired conditions are met) & their 'used' trigger is false, & which on use set their used trigger to true & the 'looking for scenario' trigger to false (all false at start). the same number of 'used' triggers that on completion of the scenario set the 'looking for scenario' trigger to true (all false at start). a 'looking for scenario' trigger (true or false at start depending on whether you want to get straight into it or not... can start at some point after mission start). 1/ At some point in the mission (mission start or arrive on station?) set the 'looking for scenario' trigger. 2/ that allows the continuous rand between to generate a number that corresponds to one of the scenarios. 3/ a.If the number generated's used flag is false, the scenario is activated, setting its used flag to true, and unsetting the 'looking for scenario' trigger. 3/ b.(If the number generated's used flag is True, no triggers are activated, and another number is generated. > 3/ a) 4/ you complete the scenario (or complete the scenario, and get back on station), and that re-sets the 'looking for scenario', which takes you back to 2/ Cheers.
JEFX Posted November 8, 2011 Posted November 8, 2011 Thanks Weta very clever! [sIGPIC][/sIGPIC] In DCS I fly jets with thousands of pounds of thrust... In real life I fly a humble Cessna Hawx XP II with 210 HP :D
JEFX Posted November 8, 2011 Posted November 8, 2011 Hey, may I ask the advice of our experts^ I am not sure what I am doing wrong but I am trying to make this SET FLAG RANDOM to work and I cannot... I made a very very simple experiment to see if it worked, please tell me what I am doing wrong: I have put 4 groups (#001-004) with a big delay in their activation (in order for them to spawn upon a trigger only). I have made 4 triggers to activate them ONCE ... FLAG 2 IS TRUE ... ACTIVATE GROUP (groupe 001) ONCE ... FLAG 3 IS TRUE ... ACTIVATE GROUP (groupe 002) ETC.. UP TO FLAG 5 AND GROUP 004 I made a trigger to activate the SET RANDOM FLAG process : ONCE ... RANDOM 100% ... FLAG TRUE (1) and finally I made the SET RANDOM like this : ONCE ... FLAG IS TRUE (1) ... SET RANDOM FLAG (1, MIN: 2 and MAX : 5) In my logics, that means that FLAG 1 is going to be activated (100% probability!) and therefore, when it is activated, it will be turned into # 2-3-4 or 5 randomly... which in turn will activate one of the groups (001-2-3-or 4)... But it just doesnt work and nothing spawns... :( any hint?? thanks! Jean-Francois [sIGPIC][/sIGPIC] In DCS I fly jets with thousands of pounds of thrust... In real life I fly a humble Cessna Hawx XP II with 210 HP :D
nomdeplume Posted November 8, 2011 Posted November 8, 2011 You need to understand that the SET FLAG RANDOM function does not set one out of a bunch of numbered flags to true. It sets the value of one particular flag to a number. So 'set flag random' when given the parameter 'flag 1' and min '2' max '5' will result in FLAG 1 having a value somewhere between 2 and 5 (inclusive). It will not ever set flags 2, 3, 4 or 5. Calling them "flags" at this point is a bit incorrect - more of a holdover from when they really could only be true or false values. While you can treat them as true or false, they also now have the ability to store whole numbers/counting numbers/integer values. You can test for them with the "FLAG LESS THAN" and "FLAG MORE THAN" conditions, and in 1.1.1.0 when it's available, "FLAG EQUAL TO" and "FLAG LESS THAN FLAG" (to compare the values of two flags).
JEFX Posted November 8, 2011 Posted November 8, 2011 I see... I had not gotten that at all... Thanks for the clarification. [sIGPIC][/sIGPIC] In DCS I fly jets with thousands of pounds of thrust... In real life I fly a humble Cessna Hawx XP II with 210 HP :D
JEFX Posted November 8, 2011 Posted November 8, 2011 but now, I really dont understand how Weta's idea can work in this context ??? :huh: [sIGPIC][/sIGPIC] In DCS I fly jets with thousands of pounds of thrust... In real life I fly a humble Cessna Hawx XP II with 210 HP :D
nomdeplume Posted November 8, 2011 Posted November 8, 2011 (edited) My understanding of Weta's idea is: 1. Set a flag (call it flag #1) to true whenever you want a new scenario to be started. 2. While flag #1 is true, set another flag (let's call it flag #2) to a random value representing the number of scenarios you have. Let's say there's 4. So flag #2 gets set to one of {1,2,3,4}. 3. Each of these scenarios has a corresponding trigger to start the scenario, whatever that entails (setting flags, activating groups, etc.). But they'll all follow the following basic form, where 'scenario flag' is a flag which indicates if that particular scenario is activated (let's call it flag #11 for scenario 1, #12 for scenario 2, etc.): CONDITIONS: FLAG #2 is equal to {scenario number} and FLAG #{scenario flag} is false ACTIONS: SET FLAG #{scenario flag} true CLEAR FLAG #1 (i.e. make it false) CLEAR FLAG #2 <anything else required to start up the scenario> Doing this ensures that a) only one scenario is active at a time and b) each scenario only gets run once. 4. Once the scenario ends, you just need to set flag #1 again and the trigger that sets flag #2 to a random value will activate again (it'd be a 'continuous' type of trigger). If it sets the value to a scenario that's already been used, then its scenario flag will be true and therefore it won't be able to trigger again. That means it'll keep setting flag #2 to a random value until it finally picks a scenario which hasn't been used yet. Technically you don't really need to track if the scenario has been used or not (since if the activation trigger is of the 'once' type, it will only be able to activate once). However you would want a way to track which scenarios have been used so you can notify the player once they're all exhausted. Or, you might want to count the number used so you only run a certain number of them in each playthrough. Anyway... hopefully that helps, or at least doesn't make things even more confusing. Edited November 8, 2011 by nomdeplume
tornado66 Posted November 8, 2011 Author Posted November 8, 2011 You need to understand that the SET FLAG RANDOM function does not set one out of a bunch of numbered flags to true. It sets the value of one particular flag to a number. So 'set flag random' when given the parameter 'flag 1' and min '2' max '5' will result in FLAG 1 having a value somewhere between 2 and 5 (inclusive). It will not ever set flags 2, 3, 4 or 5. Calling them "flags" at this point is a bit incorrect - more of a holdover from when they really could only be true or false values. While you can treat them as true or false, they also now have the ability to store whole numbers/counting numbers/integer values. You can test for them with the "FLAG LESS THAN" and "FLAG MORE THAN" conditions, and in 1.1.1.0 when it's available, "FLAG EQUAL TO" and "FLAG LESS THAN FLAG" (to compare the values of two flags). Ahhhh , i have understand: in my case: MISSION SATRT =>RANDOM 100%=>SET FLAG RANDOM ( flag 30 , min 1 , max 30) ONCE=>FLAG30 LESS THAN 10=>ACTIVE GROUP X ONCE==>FLAG30 , MORE THAN 10-LESS THAN20=>ACTIVE GROUP Y ONCE=>FLAG30 , MORE THAN 20-LESS THAN 30=>ACTIVE GROUP Z At every mission start , i will have only a group random activate between X Y Z correct?? [sIGPIC]www.21gt.it[/sIGPIC]
JEFX Posted November 9, 2011 Posted November 9, 2011 My understanding of Weta's idea is: 1. Set a flag (call it flag #1) to true whenever you want a new scenario to be started. 2. While flag #1 is true, set another flag (let's call it flag #2) to a random value representing the number of scenarios you have. Let's say there's 4. So flag #2 gets set to one of {1,2,3,4}. 3. Each of these scenarios has a corresponding trigger to start the scenario, whatever that entails (setting flags, activating groups, etc.). But they'll all follow the following basic form, where 'scenario flag' is a flag which indicates if that particular scenario is activated (let's call it flag #11 for scenario 1, #12 for scenario 2, etc.): CONDITIONS: FLAG #2 is equal to {scenario number} and FLAG #{scenario flag} is false ACTIONS: SET FLAG #{scenario flag} true CLEAR FLAG #1 (i.e. make it false) CLEAR FLAG #2 <anything else required to start up the scenario> Doing this ensures that a) only one scenario is active at a time and b) each scenario only gets run once. 4. Once the scenario ends, you just need to set flag #1 again and the trigger that sets flag #2 to a random value will activate again (it'd be a 'continuous' type of trigger). If it sets the value to a scenario that's already been used, then its scenario flag will be true and therefore it won't be able to trigger again. That means it'll keep setting flag #2 to a random value until it finally picks a scenario which hasn't been used yet. Technically you don't really need to track if the scenario has been used or not (since if the activation trigger is of the 'once' type, it will only be able to activate once). However you would want a way to track which scenarios have been used so you can notify the player once they're all exhausted. Or, you might want to count the number used so you only run a certain number of them in each playthrough. Anyway... hopefully that helps, or at least doesn't make things even more confusing. Thanks Nom de Plume, you are a great pedagogue! Very clear explanation! I take for granted that FLAG #2 IS (value of course) EQUAL TO is a condition that is not yet implemented but coming in the next patch, that is why Weta was talking about MORE THAN and SMALLER THAN, as a workaround to do EQUALS TO... ?? merci Jean-Francois [sIGPIC][/sIGPIC] In DCS I fly jets with thousands of pounds of thrust... In real life I fly a humble Cessna Hawx XP II with 210 HP :D
nomdeplume Posted November 9, 2011 Posted November 9, 2011 Ahhhh , i have understand: in my case: MISSION SATRT =>RANDOM 100%=>SET FLAG RANDOM ( flag 30 , min 1 , max 30) ONCE=>FLAG30 LESS THAN 10=>ACTIVE GROUP X ONCE==>FLAG30 , MORE THAN 10-LESS THAN20=>ACTIVE GROUP Y ONCE=>FLAG30 , MORE THAN 20-LESS THAN 30=>ACTIVE GROUP Z At every mission start , i will have only a group random activate between X Y Z correct?? Yes, almost. Just bare in mind that "LESS THAN" and "MORE THAN" are quite literally that, as opposed to "less than or equal to" and "more than or equal to". Or if you're familiar with the commonly used notation in many programming languages, the conditions implemented are < and > as opposed to <= and >=. So, you probably want to do FLAG30 LESS THAN 11 FLAG30 MORE THAN 10 FLAG30 LESS THAN 21 FLAG30 MORE THAN 20 in order to cover all possibilities. Otherwise if the flag gets set to e.g. 10, none of the conditions will actually match for it. I take for granted that FLAG #2 IS (value of course) EQUAL TO is a condition that is not yet implemented but coming in the next patch, that is why Weta was talking about MORE THAN and SMALLER THAN, as a workaround to do EQUALS TO... ?? Yes, that's exactly right. The 'equal to' condition will just make it a bit easier to implement.
Weta43 Posted November 10, 2011 Posted November 10, 2011 (edited) As mentioned above, you can use a 'less than' & a 'greater than' to get "=" Thanks Nom de Plume, you are a great pedagogue! Very clear explanation! (Another chance for Nom de Plume to translate:) ) Another use I've been putting the random between flag to (maybe already mentioned) is where I have groups of vehicles engaging & don't want them to just continuously run (Drive) at each other or sit laying down fire till they're all dead (either to appear less suicidal, or to drag the battle out long enough to allow the player a chance to intervene...) Set up a continuous random between say 1 & 20, and divide the group into mental 'groups of groups' Set (using > & < ) triggers to : Turn on group_of_groups_1 AI if trigger > 18 (so 19 or 20) Turn on group_of_groups_2 AI if trigger > 16 < 19 Turn off group_of_groups_1 AI if trigger > 14 < 17 Turn off group_of_groups_2 AI if trigger > 12 < 15 Turn off group_on_groups_1 & group_of_groups_2 AI if trigger =1 (<2) Turn off group_of_groups_1 & group_of_groups_2 AI if trigger =2 (>1 & <3 You can use other triggers to over-ride, or start this behaviour... By playing with the proportions, you can have anywhere from continuous action down to sporadic bursts of activity with one or both sides firing at each other. Also usefull to make it appear infantry are searching / patrolling - move, pause, move pause... Edited November 10, 2011 by Weta43 Cheers.
johnboy Posted January 18, 2023 Posted January 18, 2023 I've just found this thread (late to the party, as always). Thank you to the contributors, especially nomdeplume and Weta43! This was a great help to me to set up random explosions in an area. Cheers, johnboy Intel i7-2600K 3.4Ghz ASUS P8P67 EVO Motherboard B3 Kingston HyperX KHX1600C9D3K2/8GX (2x4GB) DDR3 OCZ RevoDrive PCI-Express SSD 120GB Corsair Hydro Series H70 CPU Cooler 2 xWestern Digital Caviar Black 1TB WD1002FAEX TM Warthog Hotas TrackIR 5 Pro
Recommended Posts