Jump to content
avibird 1

Is there a (OR) command for triggers like three is for (AND) for example && ||

Recommended Posts

I will try my best to explain what I mean on this.🤪

 

 

When setting up  triggers I know how to add multiple units (man vehicles object) to a trigger with !alive ect.  There are various ways you can add multiple things. The trigger can only be activated if all of the man vehicles object are killed or destroyed.

 

Is three a (or command) for example if I have three objects radar towers that need to be destroyed each one when destroyed stops reinforcements to the AO.  I can set individual triggers for each one but is there a way to set a trigger to be activated if one of the radar towers is destroyed not all three with a hint reinforcements have been stopped. 

 

if I set it to repeat.  Will it activate again when the second tower is destroyed giving a hint reinforcements have been stopped again. And again for the third tower.  

 

My question is there a command code I can pur into the trigger that will allow or to work in a trigger setup.

 

I know how to use  &&  ||  ECT to make a trigger for multiple objects.  

Share this post


Link to post
Share on other sites
6 hours ago, avibird 1 said:

 

if I set it to repeat.  Will it activate again when the second tower is destroyed giving a hint reinforcements have been stopped again. And again for the third tower.  

No, use 3 individual triggers with no repeat for each tower separately

  • Thanks 1

Share this post


Link to post
Share on other sites

Just curious how come there is none. If there is AND command  for example  &&  ||  why no OR command. 

Share this post


Link to post
Share on other sites

The condition, activation and deactivation are nothing but code blocks, so there is nothing stopping you from calculating if a tower is dead in code, as long as the code for the condition returns a boolean( true/false ).

Even separate the code into functions to make editing functionality easier.

//Trigger
ACTIVATION: None
REPEAT: true
SERVER: true

//Condition

thisTrigger call TAG_fnc_isTowerDestroyed

//On Activation

thisTrigger call TAG_fnc_onTowerDestroyed;
//initServer.sqf

TAG_fnc_isTowerDestroyed = {
	params[ "_trigger" ];
	
	//If the first time the triggers condition is called
	//And the radio towers have not been set
	if ( isNil { _trigger getVariable "radioTowers" } ) then {
		//Set radio towers variable on trigger
		_trigger setVariable[ "radioTowers", [ rad1, rad2, rad3 ] ]; //<< radio tower variable names
	};
	
	//Get the towers
	_towers = _trigger getVariable "radioTowers";
	//Find if one is dead (boolean return)
	_towers findIf{ !alive _x } > -1
};

TAG_fnc_onTowerDestroyed = {
	params[ "_trigger" ];
	
	//Get radio towers
	_towers = _trigger getVariable "radioTowers";
	//Get the index of the first dead one
	_index = _towers findIf{ !alive _x };
	//Remove it from _towers (so it is never checked again)
	_destroyed = _towers deleteAt _index;
	//Update variable on trigger
	_trigger setVariable[ "radioTowers", _towers ];
	
	//Tell everyone the tower was destoyed
	format[ "Radio tower %1 was destroyed, reinforcements have been stopped", _destroyed ] remoteExec[ "systemChat", 0 ];
  
	//Do what ever you like here
};

TBH separate triggers would be the easiest to setup for non scripters.

  • Like 2

Share this post


Link to post
Share on other sites

@Larrow,

Quote

TBH separate triggers would be the easiest to setup for non scripters.


Since everything is named, do we even need triggers?

In the init field of each object (ex. radar_1),

radar_1_checker=[]spawn {waitUntil {sleep 3; !alive radar_1}; 
systemChat "Radar tower 1 is destroyed. Reinforcements are delayed.";
};

3 x 3 second waitUntils is more efficient than three triggers, right?

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

@Larrow Thank you I will probably just use three different triggers for radar tower and radio operator it will just be easy for me to fully understand and implement into my mission.

 

I will definitely full around with the code you posted above because I like to know how to do things multiple ways to expand my knowledge with arma scripting.

 

But the question was never really answered? 

 

How come no OR command within the  scripting language. We can use AND with  &&  ||  to add multiple objects as well as this setup. 

{!alive _x} count  [ radar, tower, radio operator ] <  1

 

 

Share this post


Link to post
Share on other sites

Of course there is an OR command. But you seem to have misunderstood triggers. A trigger is checking the condition over and over (every half second by default). When the condition evaluates to true the activation will execute.

 

If trigger is set to repeat, than the condition will need to evaluate to false sometimes after first activation to be able to activate again, which will not happen in the approach you are suggesting. (When trigger condition goes from true to false is when the deactivation code is executed.)

  • Like 2

Share this post


Link to post
Share on other sites

@engima Let me ask you then if there is a OR command then why can't I setup a trigger with it for three objects for example radar tower and radio operator. These units objects link to reinforcements to the AO. If one is killed or destroyed then the trigger is set stop the reinforcements for that particular unit/object the trigger is set to repeat.

 

If I understand what you're saying the trigger needs to be then reset to false using code in the deactivation box of the trigger.  So the trigger can repeat if the other two unit or object is killed or destroyed. 

 

Is this correct.  Then what is the OR command and how would I set up the deactivation code?

 

Question how many Triggers are much for a mission? Some people suggest it is not the most efficient way of writing code using triggers and it will result in game lag. I've always used a lot of triggers in my missions.

 

What I find causes more lag is multiple scripts/mod running in the mission over a large number of triggers in the mission.

Share this post


Link to post
Share on other sites

@literally_nobody

There is an "OR" command for triggers.
condition:

this && (!alive dude1 or !alive dude2)

2uyk82.jpg

  • Haha 1

Share this post


Link to post
Share on other sites
3 hours ago, avibird 1 said:

@engima Let me ask you then if there is a OR command then why can't I setup a trigger with it for three objects for example radar tower and radio operator. These units objects link to reinforcements to the AO. If one is killed or destroyed then the trigger is set stop the reinforcements for that particular unit/object the trigger is set to repeat.

If you expect repeat then there's a problem. It's not unsolvable, but maybe not the solution I'd chosen.

If your condition is (!alive radar or !alive tower or !alive radio_operator), and radar, tower and radio_operator are variables for objects in the editor, then the condition will evaluate to true if one of them dies, thus the activation code (that sends reinforcement) is executed. However, the contition will need to be false again for the trigger to fire repeatedly, and that will not happen until all objects are intact again.

 

3 hours ago, avibird 1 said:

If I understand what you're saying the trigger needs to be then reset to false using code in the deactivation box of the trigger.  So the trigger can repeat if the other two unit or object is killed or destroyed. 

Is this correct.  Then what is the OR command and how would I set up the deactivation code?

No. The code in the deactivation box is simply executed when the condition goes from being evaluated to true to be evaluated to false (like the opposite of activation).

 

3 hours ago, avibird 1 said:

Question how many Triggers are much for a mission? Some people suggest it is not the most efficient way of writing code using triggers and it will result in game lag. I've always used a lot of triggers in my missions. What I find causes more lag is multiple scripts/mod running in the mission over a large number of triggers in the mission.

I don't know. I seldom use triggers. They are good since they are executing in unsceduled environment, which is much faster. On the other hand the code is not being kept together and command sleep won't work. From Arma 1.97 you can use command setTriggerInterval to slow down the condition check when you do not need to check all the time. And 100 scripts that mostly sleep is not a problem either. But of course, you should keep performance in the back of the head all the time. For exampel command waitUntil can be set to not check too often if you write waitUntil { sleep 10; my_condition };.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×