Jump to content
Sign in to follow this  
Kilbur

Choose a random Trigger

Recommended Posts

Hello, I am currently making a mission in which I have placed Triggers in each Grid Reference on the map. What I would like the trigger to do is kill ANY players who are in the zone at that time. Currently I have the killing part working with the trigger act as "player setDamage 1;" but I need something which will allow a random trigger to be selected every 15 mins to be activated and not to have all activated at once.

Thanking you in advance!

Share this post


Link to post
Share on other sites

In each trigger's condition, add a unique global variable, e.g. abc_var_areaXYActive.

Then run a script that sets a random one (or more) of these variables to true every 15th minutes.

Share this post


Link to post
Share on other sites
In each trigger's condition, add a unique global variable, e.g. abc_var_areaXYActive.

Then run a script that sets a random one (or more) of these variables to true every 15th minutes.

How would I set it to choose a random one? I can't visualise it atm sorry

Share this post


Link to post
Share on other sites

In easiest way, make a script that you call ActivateRandomTrigger.sqf and call it when you want to activate one random trigger.

abc_var_trigger00Activated = false;
abc_var_trigger01Activated = false;
abc_var_trigger10Activated = false;
abc_var_trigger11Activated = false;

_x = floor random 2;
_y = floor random 2;

If (_x == 0 && _y == 0) then {
 abc_var_trigger00Activated = true;
};
If (_x == 0 && _y == 1) then {
 abc_var_trigger01Activated = true;
};
If (_x == 1 && _y == 0) then {
 abc_var_trigger10Activated = true;
};
If (_x == 1 && _y == 1) then {
 abc_var_trigger11Activated = true;
};

publicVariable "abc_var_trigger00Activated";
publicVariable "abc_var_trigger01Activated";
publicVariable "abc_var_trigger10Activated";
publicVariable "abc_var_trigger11Activated";

This is an example. Last publicVariable part is only important if you create a multiplayer mission. And in that case, consider only publicVariable variables that have changed, since they are broadcast over Internet (I've been a bit lazy in the example).

Share this post


Link to post
Share on other sites

A simple way for single player would be this, tested in a mission:

You need to set up your triggers the way you want them but leave the activation set to None. Also put a functions module on the map.

//run from init with: [] execVM "trigscript.sqf";
waituntil {!isnil "bis_fnc_init"};

while {true} do {
_trigarr = [trig1,trig2,trig3];//all trigger names in here
_rndtrig = _trigarr call BIS_fnc_selectRandom;
_crntset = triggerActivation _rndtrig;//saves current settings

_text = triggerText _rndtrig;
_output = hint format ["%1 active", _text];//displays active trigger

_rndtrig setTriggerActivation ["WEST", "PRESENT", true];
sleep 10;//change to 900 for 15 mins
_rndtrig setTriggerActivation _crntset;//sets trigger activation back to none
};

Edited by PELHAM

Share this post


Link to post
Share on other sites

Thanks for all the help! I will try them out now and I should have mentioned this will be an MP mission!

Share this post


Link to post
Share on other sites
A simple way for single player would be this, tested in a mission:

You need to set up your triggers the way you want them but leave the activation set to None. Also put a functions module on the map.

Why does this only work in singleplayer? Is it the BIS_fnc_selectRandom function that only works in singleplayer?

Share this post


Link to post
Share on other sites

Find a spot on the map out of the way of the battle.

Place 4 different triggers on the map in a group.

Place a civilian on the map. He should be set up so that he appears at random within a circle.

Place a way point for that civilian on the other side of the triggers.

The way point should be set so that the exact centre of the way point is a spot at random.

Start the mission. The civilian starts in a different place every time. He walks to a different location every time ……..and walks straight through your group of triggers.

A different trigger will fire every time.

****************************************

+++++++++++++++++++++++++++++++

In the meantime you must ensure that triggers do fire at random. Whilst testing........

On the trigger screen, see the left corner “Effects†. Use the text effect so that when a trigger fires you see the message “Trigger1†or “Trigger 2†etc etc.

Once you have completed your testing you should remove this effect.

Have fun!

.

.

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
Sign in to follow this  

×