Zlin Posted November 15, 2011 Posted November 15, 2011 Need some help please... I would like to set up a rule to check to see if Enemy unit X is still alive every 60 seconds and if the Enemy unit X is still alive, then perform this action (send message, play sound, etc) Ex: I have a friendly unit on a roadway, stopped. The friendly unit is being fired upon by an Enemy unit. I would like a message sent to (coalition) (something like, "I'm still taking fire") I would like this to repeat every 60 seconds until the Enemy unit is dead. I'm thinking I can use a CONTINUOUS ACTION rule to check if the Enemy Unit DEAD but how do I get it to repeat every XX seconds until dead? If I initially set a FLAG, then I understand I can check the TIME SINCE FLAG, but how do I get it to keep checking every, say, 60 seconds? Any help is greatly appreciated. Thanks in advance. Z
WildFire Posted November 15, 2011 Posted November 15, 2011 (edited) The continuous triggers check the conditions ever second or two I think. Once it starts have it activate another flag. Use this other flag to start your timer. Basically you need something like, Continuous, unit alive, flag 1 on Once, flag 1 on, set flag 2 on have a new set of conditions that is a repeatable trigger that checks for flag 2 every XX seconds. Also have it check that flag 3 is false. in the activation have it display the message, then turn flag 2 off and back on. and in XX seconds it will repeat its actions. When unit dies or is killed add a new condition that sets flag 3 to true, and it will stop. Edited November 15, 2011 by WildFire 1
WildFire Posted November 15, 2011 Posted November 15, 2011 If you dont like continuous triggers, I dont, you could do it this way, Once, unit alive(Enemy Unit), Set flag 2 to true SwitchedAction, Time since Flag(2,60) AND Flag 3 false, display message AND set flag 2 off AND set flag 2 on Once, unit dead(enemy unit), set Flag 3 true. Although you will need more conditions to find the right time to activate that first trigger, such as when you activate the enemy group you could just set flag 2 on. Keep in mind the first time will take XX seconds to show the message.
EvilBivol-1 Posted November 15, 2011 Posted November 15, 2011 Example mission attached. I'm not sure if it's the most elegant solution, but it works like this: 1) Continuous Action > Group Alive && Flag 1 OFF > Set Flag 1 ON 2) Switched Condition > Time Since Flag 1 = 60 > Set Flag 1 OFF 3) Switched Condition > Flag Is True 1 > Message (xxx)Repeat-60.miz 1 - EB [sIGPIC][/sIGPIC] Nothing is easy. Everything takes much longer. The Parable of Jane's A-10 Forum Rules
Geskes Posted November 15, 2011 Posted November 15, 2011 I would do this with two continuous triggers Continuous > Unit Alive AND flag 1 false > message "taking fire" AND set flag 1 true Continuous > Time since flag 1 (60) > set flag 1 false First trigger checks if unit is still alive and if flag is false. If flag false it will display message and set flag 1 true. The second trigger will then turn the flag off again after 60 seconds which will trigger the first trigger again. To control when it starts set flag 1 true at mission start and make it false once you want the messaging to start. 1 I7920/12GBDDR3/ASUS P6T DELUXE V2/MSI GTX 960 GAMING 4G /WIN 10 Ultimate/TM HOTAS WARTHOG
Zlin Posted November 15, 2011 Author Posted November 15, 2011 Thanks everyone for your replies. I will try the suggested methods as soon as I get home. :)
WildFire Posted November 15, 2011 Posted November 15, 2011 The nice thing is you can use one trigger to run its own loop, example being a my second trigger where the flag turns itself on and off by itself. All you have to do is start it and stop it. Start it by flipping that flag at anytime and stop it with a separate unrelated flag. For this method any one of these three will work fine, however the flag 2 line in my example is extremely useful for loops. And that is something you can use in every mission. When you start building very large missions with tons of triggers your going to need triggers that are simple to keep track of, run themselves, and are known to work. When your trying to limit and troubleshoot the million of bugs in every mission being able to keep everything very simple and not depending on each other is important. Therefore I would suggest memorizing this method, it is very useful and will you aid you many times in the future.
Druid_ Posted November 16, 2011 Posted November 16, 2011 (edited) ONCE > Unit Friendly is damaged > FLAG 1 ON && perform whatever action you want Continuous Action > Group Alive && TIME SINCE FLAG 1,60> Set Flag 1 ON && perform whatever action you want (setting it ON resets the time to zero, even if it was previously ON, useful as it cuts down number of triggers req'd) there is no need to check using continuous if an enemy unit is dead once will do e.g. ONCE > UNIT x DEAD > FLAG 1 OFF && Display "Enemy Unit x destroyed" Edited November 16, 2011 by Druid_ i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q
Zlin Posted November 16, 2011 Author Posted November 16, 2011 Got it working. Thanks everyone for your help. Z 1
WildFire Posted November 16, 2011 Posted November 16, 2011 Questions for sir Druid, looking at your method kind of interests me, regardless of my own ability I always observe others for ideas and such, hence my trolling here.... Anyhow, just one question, 1) whenever I made an MP mission with "is damaged" as a condition for an AI, it never worked. Have you been able to somehow get this to work? Or maybe it has been implemented since when I tested it (I think it was .8 ). And thanks for letting us know you dont have to turn a flag off each time, that does cut down a bit. Isnt it neat with this flag system how many options you can come up with to do the same thing?
Druid_ Posted November 19, 2011 Posted November 19, 2011 I've used 'is damaged' successfully in Op Lagavulin which was tested fully in 1.1.0.9 so I know it works fine. Can't vouch for 1.1.10 though as I am staying away from it at the moment. Just make sure you have the percentage logic right in 'is damaged' and it should work fine. D_ i7-7700K : 16Gb DDR4 2800 Mhz : Asus Mobo : 2TB HDD : Intel 520 SSD 240gb : RTX 2080ti: Win10 64pro : Dx10 : TrackiR4 : TM Warthog : ASUS ROG SWIFT PG348Q
Recommended Posts