Jump to content
Sign in to follow this  
Icaruk

How to run a script just to the unit that is on the trigger.

Recommended Posts

Well, I want to create a script that does this:

q1 setVelocity [-10, -10, 30];

But I have q1, q2, q3... q10.

How can I make it working like when q3 enters on the trigger, just q3 runs the script and not the other q ?

Thanks.

Share this post


Link to post
Share on other sites

anyone present repeating

cond

q3 in thislist

on act

q1 setVelocity [-10, -10, 30];

Share this post


Link to post
Share on other sites

how about?

on act:

{_x setVelocity [-10, -10, 30]}forEach thislist

any and all units entering the trigger and meeting the other conditions (side etc.) will have their velocity set.

edit: might have misunderstood your intention, if you only ever want to affect q3 then you don't need this ;)

Edited by Ashram 1-1
reading comprehension, lack theirof

Share this post


Link to post
Share on other sites

I want to do this:

Single trigger and single script.

When q1 enters, just q1 gets affected but not the others.

When q2 enters, just q2 gets affected but not the others.

...

When q7 enters, just q7 gets affected but not the others.

Sorry for my bad explaination.

Share this post


Link to post
Share on other sites

Edit:

{_x setVelocity [-10, -10, 30]}forEach thislist

from Ashram 1-1 worked, thanks a lot! :D

Edited by Icaruk

Share this post


Link to post
Share on other sites
Edit:
{_x setVelocity [-10, -10, 30]}forEach thislist

from Ashram 1-1 worked, thanks a lot! :D

That code will only work as long as the trigger is reset by the previous unit leaving the trigger area. If q1 stays within the trigger - the effect will not work for q2. Scripted solution:

trigger name: trigger01

trigger text: trigger01

init.sqf:

[trigger01,4] execVM "monitor.sqf";

run code on next 4 units entering trigger - only new entrants will be affected - existing units may remain in trigger.

monitor.sqf

private ["_temp","_list","_newGuy","_count","_trig"];

sleep 1;
_trig = _this select 0;
_num = _this select 1; 

if (!(typeOf _trig == "EmptyDetector")) exitWith {hint "error monitor.sqf param 0 is not trigger"};

monitor = true;
_temp = [];
_list = list _trig;
_count = count _list;

while {monitor} do 
{
waitUntil {triggeractivated _trig};

if (count (list _trig) != _count) then 
{
_newGuy = (list _trig) select (count (list _trig))-1;

	if (!(_newGuy in _temp)) then 
	{
	_count = count (list _trig);
	_temp set [count _temp,_newGuy];
	hint format ["%1 is the new guy in %2",_newGuy,triggerText _trig];
	_newGuy playmove "AmovPercMstpSsurWnonDnon";//replace this line with your code
	};
};
if (count _temp == _num) exitWith {hint "trigger quota full monitor.sqf halt"; monitor = false;};
};

If you have something constant it is possible to do it without a script:

BLUFOR

Repeatedly

Present

condition:

this && {!(animationState _x == "AmovPercMstpSsurWnonDnon")} count thisList > 0

OnAct:

{_x playMove "AmovPercMstpSsurWnonDnon"; _x setCaptive true;} forEach thislist;

That will make each unit that enters surrender and not affect those already present.

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites
That code will only work as long as the trigger is reset by the previous unit leaving the trigger area. If q1 stays within the trigger - the effect will not work for q2. Scripted solution:

trigger name: trigger01

trigger text: trigger01

init.sqf:

[trigger01,4] execVM "monitor.sqf";

run code on next 4 units entering trigger - only new entrants will be affected - existing units may remain in trigger.

monitor.sqf

private ["_temp","_list","_newGuy","_count","_trig"];

sleep 1;
_trig = _this select 0;
_num = _this select 1; 

if (!(typeOf _trig == "EmptyDetector")) exitWith {hint "error monitor.sqf param 0 is not trigger"};

monitor = true;
_temp = [];
_list = list _trig;
_count = count _list;

while {monitor} do 
{
waitUntil {triggeractivated _trig};

if (count (list _trig) != _count) then 
{
_newGuy = (list _trig) select (count (list _trig))-1;

	if (!(_newGuy in _temp)) then 
	{
	_count = count (list _trig);
	_temp set [count _temp,_newGuy];
	hint format ["%1 is the new guy in %2",_newGuy,triggerText _trig];
	_newGuy playmove "AmovPercMstpSsurWnonDnon";//replace this line with your code
	};
};
if (count _temp == _num) exitWith {hint "trigger quota full monitor.sqf halt"; monitor = false;};
};

If you have something constant it is possible to do it without a script:

BLUFOR

Repeatedly

Present

condition:

this && {!(animationState _x == "AmovPercMstpSsurWnonDnon")} count thisList > 0

OnAct:

{_x playMove "AmovPercMstpSsurWnonDnon"; _x setCaptive true;} forEach thislist;

That will make each unit that enters surrender and not affect those already present.

My trigger is for making a turbo/boost on a quad race mission, but I'll save your script for further use, thanks.

Share this post


Link to post
Share on other sites

why not make the trigger set a variable instead, lets say you race and when player enters trigger area var x =1, then while (x) call boost_function. then just use another trigger to reset x.. then make x private to that quad. i don't know just a thought, or maybe some eventhandlers??

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  

×