JEFX Posted April 11, 2010 Posted April 11, 2010 I am new to the Triggers function of the ME because I skipped BS... I am back with this great community now with LOFC2 and I love it. I have a question : I read the manual and several posts, and in general, the concept and functions of the triggers are quite clear but I dont understand the concept of FLAGS ??? What is fa flag, how does it work and how is it used? Obviously we are not talking about a bit of colored rag respected by citizens of one nation...:music_whistling: Can someone explain to me what si it? thanks a lot JEFX [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
foxwxl Posted April 11, 2010 Posted April 11, 2010 Flag maybe use to discribe a airfield is friendly or hostile...maybe wrong..my guess only... Deka Ironwork Tester Team
Case Posted April 11, 2010 Posted April 11, 2010 Basically a flag is used to describe the outcome of a test. A flag can be either true or false. Say you want to use a trigger to see if a unit passed through a trigger zone. You can easily define a trigger like this: ONCE(Unit inside zone) // UNIT INSIDE ZONE(Unit, Trigger zone) // MESSAGE(Unit is inside trigger zone,10) However, as soon as the unit exits the zone, the condition is no longer true. What you can do is use an action to set a flag, like this: ONCE(Unit inside zone) // UNIT INSIDE ZONE(Unit, Trigger zone) // SET FLAG(1) This will set flag 1 to true as soon as the unit enters the zone, and it will remain true for the remainder of the mission or if you reset the flag through some other trigger. Now you can use other triggers to check if the unit passed through the zone: CONTINUOUS ACTION(Unit passed through zone) // FLAG IS TRUE(1) // MESSAGE(Unit passed through the zone,10) CONTINUOUS ACTION(Unit passed through zone) // FLAG IS FALSE(1) // MESSAGE(Unit nas not passed through the zone,10) There are only 10 types of people in the world: Those who understand binary, and those who don't.
MBot Posted April 11, 2010 Posted April 11, 2010 A flag is simply a stored information of "true" or "false". This information can then be used as a condition to triggers in other parts of your mission. Let's say for example you want to activate a SAM if an A-10 flies into area X. You could create a trigger that just exactly that. But you could also create two separate triggers and carry over the information from one to the other using a flag. So the first trigger would be to set Flag 5 (or whatever number you wish to use) to true if the A-10 is in area X. The second trigger would be to activate the SAM if Flag 5 is true. You just used a flag to store an information and used it with another trigger. Of course in this example the use of flags is not really needed and makes things more complicated than without. But it shows the principle how they work. And once you start to create more complex missions with many triggers, those flags will become very useful. Edit: Too slow :)
104th_Crunch Posted April 11, 2010 Posted April 11, 2010 Also, another use is if you need to delay something. You can use the "Time Since Flag Option". So for example, set up an A10 entering an area to a trigger to equal flag 1. Then another trigger with the condition Time Since Flag 1 to have so AAA move in after 2 minutes of the A10 entering the area.
JEFX Posted April 13, 2010 Author Posted April 13, 2010 That is well explained, thanks a lot! I have seen many examples of triggers, either on this forum or in the manual, but somehow, they always refer to some SAM appearing when Unit x goes into a trigger zone.... That is already great but can you guys give examples of other (more suphisticated) use of triggers? I remember reading in the early days of BS that those triggers could be used to simulate a moving front line (with different possible outcomes) and thus help make a campaing almost more immersive than a dynamic campaing (???). Can someone (Case, MBot?) explain how this can be done please? I have always been a big Mission building fan. thanks JEFX [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
Case Posted April 13, 2010 Posted April 13, 2010 I remember reading in the early days of BS that those triggers could be used to simulate a moving front line (with different possible outcomes) and thus help make a campaign almost more immersive than a dynamic campaign (???).Well, here's a few specific examples. Say you have enemy units guarding a bridge where you want your friendly units to cross. You can make triggers to activate your friendly units to move towards the bridge once strikers have taken out all or part of the enemy units. On a bigger scale, you can make a mission where one side is tasked with taking over an airbase. Should they succeed, you can use a trigger to load the new mission where that airbase is actually owned by the coalition that took it. Finally, you could make something as complex as Grimes did for the 3Sqn server: http://forums.eagle.ru/showpost.php?p=877003&postcount=2 Here a coalition must first have air superiority over a given area for ground units to start their advance, and they must then keep it to protect their units. There are only 10 types of people in the world: Those who understand binary, and those who don't.
MBot Posted April 13, 2010 Posted April 13, 2010 An example of a more sophisticated use of triggers would be to introduce a random start delay for a unit. Lets say you want to have a Su-27 take off at a random time into the mission. This is how you can do it: MISSION START "Start Delay 1/3" // RANDOM (100) // SET FLAG (1) SWITCHED CONDITION "Start Delay 2/3" // FLAG IS FLASE (1) // SET FLAG (1) SWITCHED CONDITION "Start Delay 3/3" // TIME SINCE FLAG (1, 30), RANDOM (80) // CLEAR FLAG (1) ONCE "Start Su-27" // TIME SINCE FLAG (1, 31) // ACTIVATE GROUP (Su-27) So what happens here? At the start of the mission a "roundtrip" is initiated for the flag 1. Each time flag 1 is false, it will be set back to true again. 30 second after becoming true, there is a 80% chance that it is cleared, thus starting the 30 seconds rountrip all over again. Of course there remains the 20% chance in our 3rd trigger above that flag 1 is not cleared. In that case the "time since flag 1" will reach 31 seconds for the first time and our 4th trigger activates the Su-27. So what we did is to introduce a random start delay for the Su-27: Every 30 seconds there is a 20% chance that it is activated. 2
Case Posted April 13, 2010 Posted April 13, 2010 Ooh, that is a very clever one! I had tried to get random starts myself, but this is a much better solution! :thumbup: There are only 10 types of people in the world: Those who understand binary, and those who don't.
MBot Posted April 13, 2010 Posted April 13, 2010 A simpler possibility would be to use a single CONTINUOUS trigger with a very low RANDOM condition, perhaps 1-5%. That way you have a 1-5% chance every second. If you want to randomize something to happen within the first 10 or so minutes of a mission this provides ok results. But the methode above is much better to tune and get consistent results. 1
JEFX Posted April 14, 2010 Author Posted April 14, 2010 Thanks, very interesting. Lets keep adding info here, it is a profound topic... JEFX [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
nemises Posted April 14, 2010 Posted April 14, 2010 flags and triggers are the only way of having "dynamic" and statefull logic in the game ... In theory, it should be possible to use flags (and thereby simple boolean logic) to implement complicated rules, such as a basic implementation of "capture the flag". ...perhaps a nice little project for someone to look into?
Grimes Posted April 14, 2010 Posted April 14, 2010 An example of a more sophisticated use of triggers would be to introduce a random start delay for a unit. Lets say you want to have a Su-27 take off at a random time into the mission. This is how you can do it: MISSION START "Start Delay 1/3" // RANDOM (100) // SET FLAG (1) SWITCHED CONDITION "Start Delay 2/3" // FLAG IS FLASE (1) // SET FLAG (1) SWITCHED CONDITION "Start Delay 3/3" // TIME SINCE FLAG (1, 30), RANDOM (80) // CLEAR FLAG (1) ONCE "Start Su-27" // TIME SINCE FLAG (1, 31) // ACTIVATE GROUP (Su-27) Interesting methodology indeed! It would certainly be perfect for co-op or SP missions. I've used the low % random chance method for creating 4 random conditions to spawn sam sites online and soon to be 8 random choices with 4 random conditions each for a co-op I'm working on. Nemisis. Black Shark already has a CTF mode built into it. Most of the classic game-modes from other gaming genre's can be created via the trigger system, but some of them wouldn't exactly be the "best fit" for a sim. But yes anything is possible. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
MBot Posted April 14, 2010 Posted April 14, 2010 (edited) Here is a cross post from the Black Shark forum on how you can work around the lack of a "OR" modifier in the conditions field (since all conditions of a single trigger can only be combined following the rules of "AND"): For example you want to check whether Unit 1 or Unit 2 are death: CONTINUOUS // FLAG IS FALSE (1) // SET FLAG (1) SWITCHED CONDITION // UNIT ALIVE (Unit 1), UNIT ALIVE (Unit 2), TIME SINCE FLAG (1,1) // CLEAR FLAG (1) ONCE // TIME SINCE FLAG (1,2) // MESSAGE ("Unit 1 or Unit 2 is death") In the bold part you list the OPPOSITE of the conditions you want to combine with OR. So we want to check if one unit is death, then we list all the units as alive. Or we want to check if one unit is inside a zone, then we list all units as outside the zone. So again we set up a little roundtrip from the first trigger to the second and back again, which runs as long as the opposite of your combined conditions is true. If any of the opposite conditions becomes false (which equals any of your "real" conditions becoming true), then the roundtrip is broken and your 3rd trigger fires with any action you want. Of course to check only conditions A or B, the above is too complex (better to simply make a seperate trigger for A and B each). But if you want to check conditions A or B or C [...] or Z, the above solution is a lot simpler than to write 26 triggers. Edited April 14, 2010 by MBot
Grimes Posted April 15, 2010 Posted April 15, 2010 MBot, I've created a "math_counter" via triggers. Basically all aircraft set the same flag when they entered a zone and the flags iterate based on how many aircraft it has counted. Generally speaking there is 1 flag needed for how much I want to count up to. I originally built it via switched conditions, but I found that they didn't always fire correctly if two or more were triggered at near the exact time. Simply changing these to continuous triggers fixed the problem. Is there a reason for this? The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
MBot Posted April 15, 2010 Posted April 15, 2010 It is not clear to me what you wanted to do. Could you post the triggers you wrote?
Grimes Posted April 15, 2010 Posted April 15, 2010 SWITCHED CONDITION "P1 In" // Unit inside Zone (Player1, ZoneA) // Set FLAG (1) SWITCHED CONDITION "P2 In" // Unit inside Zone (Player2, ZoneA) // Set FLAG (1) and so on. So each time any of player enters they trigger the same flag... which triggers the counters... SWITCHED CONDITION "One in Zone" // Flag is True (1), Flag is False (11) // Set FLAG (11), Clear Flag (1) SWITCHED CONDITION "Two in Zone" // Flag is True (1), Flag is True (11) // Set FLAG (12), Clear Flag (1), Clear Flag (11) SWITCHED CONDITION "Three in Zone" // Flag is True (1), Flag is True (12) // Set FLAG (13), Clear Flag (1), Clear Flag (12) 11,12,13... keep track of how many are in the zone When set as a switched condition it didn't always iterate to the next one properly. Generally if the aircraft entered the zone at nearly the exact time. When it was set to continuous it tended to work much much better. I've yet to have an error with it. I'm just wondering why that is. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
MBot Posted April 15, 2010 Posted April 15, 2010 Ah I see, very clever counter. The problem with two players entering the zone within the same second sounds logical. If both players set flag 1 within the same "frame", neither one will be left to set flag 1 again after it was cleared by the "one in zone" trigger. But frankly why this will work better with a CONTINUOUS trigger is beyond me. I assume you changed to a CONTINUOUS for the "1/2/3in zone" triggers, not for the "P1/2 In" triggers (as that would break the counter). To me SWITCHED CONDITION and CONTINOUS should make absolutely no difference for the "1/2/3 in zone" triggers with the setup above. 1
Grimes Posted April 15, 2010 Posted April 15, 2010 Yes I did change it to continuous and it seems to be working just fine. I was just trying to figure out exactly why it was a problem. I tested it originally with switched conditions and was very pleased that it worked as expected, then I changed the AI flight paths around and used time acceleration and noticed that the triggers broke all of a sudden. I had been using switched conditions for as many uses I could think of under the assumption its easier and better for the processor to compute. Granted if you use a controller flag on a continuous trigger to limit its functionality is probably just as good. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Recommended Posts