AdamAb44 0 Posted September 11, 2017 Hello, I am making a CQB shooting range, in which I use triggers to pop up the targets. How it should work like: 1) you spawn in the mission, all targets are down 2) you come to the trigger´s area, which activates and pops up a target 3) you continue going through the shooting range and activate other triggers popping up other targets 4) when you finish, you can come back to the beginning of the shooting range and "press a button" on a laptop for a shooting range reset (button is an action added via addAction command) Now I am running into problems with the trigger activation. If you set it to non-repeatable, you can active it (and pop up the target) only once in the mission. If you set it to repeatable, the player could walk back and forth causing to pop up still the same target, which I do not want to happen. The idea is, as described in step 4), the triggers are non-repeatable, but once you finish the shooting range and come back to the beggining to "press the button" on the laptop, they will "reset", or however you might call it. Any idea on how to make this or design it in a better way? Share this post Link to post Share on other sites
pierremgi 4890 Posted September 11, 2017 Consider an extra variable for a repeatable trigger. this && isnil "myVariable" then the trigger wait for 2 conditions this and a non-existing variable (general case as far as you have not yet defined it) On activation: bla bla (your code) ; myVariable = true So you set myVariable to true (or else) and then this variable exists. Just kill the variable with your addAction: myVariable = nil to rearm the trigger. 1 Share this post Link to post Share on other sites
Larrow 2822 Posted September 12, 2017 Make the triggers repeatable and just change their statements in the pop up targets code.. //Initial triggers statements, either code or in editor RangeTargetTrigger setTriggerStatements ["player in thisList", "[ thisTrigger ] call TAG_fnc_ActivateTarget", ""]; TAG_fnc_ActivateTarget = { params[ "_trigger" ]; //disable trigger _trigger setTriggerStatements ["false", "", ""]; //Activate targets }; _laptop addAction[ "Reset Range", { RangeTargetTrigger setTriggerStatements ["player in thisList", "[ thisTrigger ] call TAG_fnc_ActivateTarget", ""]; }]; 2 Share this post Link to post Share on other sites
AdamAb44 0 Posted September 12, 2017 19 hours ago, pierremgi said: Consider an extra variable for a repeatable trigger. this && isnil "myVariable" then the trigger wait for 2 conditions this and a non-existing variable (general case as far as you have not yet defined it) On activation: bla bla (your code) ; myVariable = true So you set myVariable to true (or else) and then this variable exists. Just kill the variable with your addAction: myVariable = nil to rearm the trigger. Thanks for the advice! It works perfectly, the only problem I found about this is that when you have 30 triggers connected to 30 targets (each trigger controls 1 target) you have to set up 30 variables (for each trigger), which is a little time-consuming. As I´m no lazy-man I am OK with that (even though I don´t know the impact on performance of the game due to it´s engine...). Share this post Link to post Share on other sites
AdamAb44 0 Posted September 12, 2017 6 hours ago, Larrow said: Make the triggers repeatable and just change their statements in the pop up targets code.. //Initial triggers statements, either code or in editor RangeTargetTrigger setTriggerStatements ["player in thisList", "[ thisTrigger ] call TAG_fnc_ActivateTarget", ""]; TAG_fnc_ActivateTarget = { params[ "_trigger" ]; //disable trigger _trigger setTriggerStatements ["false", "", ""]; //Activate targets }; _laptop addAction[ "Reset Range", { RangeTargetTrigger setTriggerStatements ["player in thisList", "[ thisTrigger ] call TAG_fnc_ActivateTarget", ""]; }]; Thank you for advice as well! Firstly, I thought I will have the same problem with too many things as I described in my answer to pierremgi (variables in that case). In this case though, I ran into a problem in which I had to have too many lines saying: trigger_1 setTriggerStatements ["player in thisList", "[ thisTrigger ] call TAG_fnc_ActivateTarget", ""]; trigger_2 setTriggerStatements ["player in thisList", "[ thisTrigger ] call TAG_fnc_ActivateTarget", ""]; etc... in the addAction of the laptop. The way I dealt with this is that I simply grouped the triggers into an array and then used "_x ... forEach". However, there´s another issue I don´t know the solution to: for activating the targets in the function I use the code: target_1 animate ["Terc", 0]; target_2 animate ["Terc", 0]; etc... The problem is that once I put all these into the function the trigger calls, all the targets pop up when any of the triggers activate, not only the one, which I want. Is there a way where I could use this function for all the triggers but where I could also determine that trigger_1 should only pop up target_1, trigger_2 pops up target_2 etc...? Share this post Link to post Share on other sites
Larrow 2822 Posted September 13, 2017 13 hours ago, AdamAb44 said: However, there´s another issue I don´t know the solution to: for activating the targets in the function I use the code: target_1 animate ["Terc", 0]; target_2 animate ["Terc", 0]; etc... The problem is that once I put all these into the function the trigger calls, all the targets pop up when any of the triggers activate, not only the one, which I want. Is there a way where I could use this function for all the triggers but where I could also determine that trigger_1 should only pop up target_1, trigger_2 pops up target_2 etc...? Yes. Sync each of the targets to their relevant trigger. TAG_fnc_ActivateTarget = { params[ "_trigger" ]; //disable trigger _trigger setTriggerStatements ["false", "", ""]; //Activate triggers targets _targets = synchronizedObjects _trigger select { typeOf _x isKindOf "TargetBase" }; { _x animate [ "Terc", 0 ]; }forEach _targets; }; Same can also be done in the laptop action to reset the target. You could even use the one function for both activating and resetting everything. //Initial triggers statements, either code or in editor RangeTargetTrigger setTriggerStatements ["player in thisList", "[ thisTrigger, true ] call TAG_fnc_ActivateTarget", ""]; TAG_fnc_ActivateTarget = { params[ "_trigger", "_activate" ]; //set trigger if ( _activate ) then { _trigger setTriggerStatements [str !_activate, "", ""]; }else{ _trigger setTriggerStatements ["player in thisList", "[ thisTrigger, true ] call TAG_fnc_ActivateTarget", ""]; }; //Activate triggers targets _targets = synchronizedObjects _trigger select { typeOf _x isKindOf "TargetBase" }; { _x animate [ "Terc", parseNumber !_activate ]; }forEach _targets; }; _laptop addAction[ "Reset Range", { { [ _x, false ] call TAG_fnc_ActivateTarget; }forEach ArrayOfRangeTriggers; }]; Where ArrayOfRangeTriggers is your triggers, or you could even do the same trick here with synchronisedObjects and sync all your triggers to the laptop. _laptop addAction[ "Reset Range", { params[ "_laptop" ]; { [ _x, false ] call TAG_fnc_ActivateTarget; }forEach ( allMissionObjects "EmptyDetector" select { _synced = synchronizedObjects _x; //trigger that is synced to the laptop and also has synced targets _laptop in _synced && { typeOf _x isKindOf "TargetBase" }count _synced > 0 } ); }]; Then you have no need to keep updating your trigger list, just sync them to the laptop, job done. Heres a little experimental project I done back at the beginning of the year. Not quite finished needs some TLC to make it MP compatible, may give you some ideas. 2 Share this post Link to post Share on other sites
AdamAb44 0 Posted September 13, 2017 9 hours ago, Larrow said: Yes. Sync each of the targets to their relevant trigger. TAG_fnc_ActivateTarget = { params[ "_trigger" ]; //disable trigger _trigger setTriggerStatements ["false", "", ""]; //Activate triggers targets _targets = synchronizedObjects _trigger select { typeOf _x isKindOf "TargetBase" }; { _x animate [ "Terc", 0 ]; }forEach _targets; }; Worked just perfectly. Much appreciated, thanks alot! Share this post Link to post Share on other sites
dc207 11 Posted June 28, 2018 Interesting thread. I am currently working on a training scenario with live targets (AI) as part of each task. I would like to 'reset' the task once it has been completed, without resetting the scenario. Any ideas or help on how to do that? This thread seems to be more specific to pop-up targets, and I was not sure how much of that would be applicable to actual AI that spawn in. Thanks. Share this post Link to post Share on other sites