groshnak 1 Posted June 27, 2017 Hey guys, a bit of a puzzle here. I'm trying to create a trigger that opens a one way gate. Tigger has following conditions: Player present inside trigger. No OpFor within trigger. Gate is alive. Gatekeeper is alive. Players vehicle is facing correct direction. I managed to get everything except the direction so far with this: Activated by player present - this and (alive gatekeeper) and (alive gate02) and (east countside thislist) == 0 However i'm having hard time implementing getdir in to the condition. I managed to get getdir working like this: if (direction (vehicle player) >200) then {hint "Going out"} if (direction (vehicle player) <200) then {hint "Going in"} But how would i make this into a trigger condition? Somehow with _x thislist i would assume..? It's for multiplayer so i can't use command "player" in the trigger. How do you refer to the unit that is inside the tigger instead of "player"? Share this post Link to post Share on other sites
pierremgi 4850 Posted June 27, 2017 Just place your trigger in front of the working side, and avoid the wrong side. It's more realistic as far as theses systems work independently on people's direction. Why couldn't you use player in MP? Player is local to a PC but your trigger will fire. Share this post Link to post Share on other sites
groshnak 1 Posted June 28, 2017 7 hours ago, pierremgi said: Just place your trigger in front of the working side, and avoid the wrong side. It's more realistic as far as theses systems work independently on people's direction. Why couldn't you use player in MP? Player is local to a PC but your trigger will fire. If i dont extend it to the other side the gate will close and crash with some long vehicles because driver is out of trigger area but rear of the truck is not. Now that i think of it, i guess you are correct about player working in MP, I'll try with that. Share this post Link to post Share on other sites
sarogahtyp 1108 Posted June 28, 2017 You could spawn ur code for closing the gateway to get a scheduled scripting environment where suspension is allowed and then use sleep to suspend some time after gate will be closed. Something like this in deact field should be fine for it: spawn { sleep 10; // put your commands to close the gate here }; 1 Share this post Link to post Share on other sites
mrcurry 496 Posted June 28, 2017 (edited) I don't see why you need to tell the player which way they are going but... (count thisList > 0 && { getDir (thisList select 0) < (getDir thisTrigger + 30)%360 && getDir (thisList select 0) > (getDir thisTrigger - 30)%360}) will return true if the first thing in the trigger is facing in the direction of the trigger +/- 30 degrees. If you want one trigger to handle both directions then ( count thisList > 0 && { getDir (thisList select 0) < (dirIn + 30)%360 && getDir (thisList select 0) > (dirIn - 30)%360 || getDir (thisList select 0) < (dirOut + 30)%360 && getDir (thisList select 0) > (dirOut - 30)%360 } ) just replace dirIn and dirOut with the respective directions for in and out. Edited June 28, 2017 by mrcurry Syntax shenanigans Share this post Link to post Share on other sites
pierremgi 4850 Posted June 28, 2017 Or place a second trigger, same condition but working only if the first one (displaced) is activated. condition: this && triggerActivated trig1 (for example). Share this post Link to post Share on other sites
pierremgi 4850 Posted June 28, 2017 4 minutes ago, mrcurry said: I don't see why you need to tell the player which way they are going but... (count thisList > 0 && { getDir (_this select 0) < (getDir thisTrigger + 30)%360 && getDir (_this select 0) > (getDir thisTrigger - 30)%360}) will return true if the first thing in the trigger is facing in the direction of the trigger +/- 30 degrees. If you want one trigger to handle both directions then ( count thisList > 0 && { getDir (_this select 0) < (dirIn + 30)%360 && getDir (_this select 0) > (dirIn - 30)%360 || getDir (_this select 0) < (dirOut + 30)%360 && getDir (_this select 0) > (dirOut - 30)%360 } ) just replace dirIn and dirOut with the respective directions for in and out. Tested? Share this post Link to post Share on other sites
sarogahtyp 1108 Posted June 28, 2017 (edited) And another solution for ur direction check...untested. It checks if the player (_x of thisList) faces (+/- 20 degree) the gate and if the player is inside an angle of +/- 20 degree of the gates entry. { _reldir_g2x = gate getRelDir _x; _reldir_x2g = _x getRelDir gate; _reldir_g2x > (360 - 20) and _reldir_g2x < 20 and _reldir_x2g > (360 -20) and _reldir_x2g < 20 } count thisList > 0 { _reldir_g2x = gate getRelDir _x; _reldir_x2g = _x getRelDir gate; _reldir_g2x > (180 - 20) and _reldir_g2x < (180 + 20) and _reldir_x2g > (360 -20) and _reldir_x2g < 20 } count thisList > 0 each code is fo one direction. one for outgoing and one for incoming objects. Edited June 28, 2017 by sarogahtyp Share this post Link to post Share on other sites
mrcurry 496 Posted June 28, 2017 31 minutes ago, pierremgi said: Tested? Doh! Corrected. Share this post Link to post Share on other sites
groshnak 1 Posted July 1, 2017 Cheers guys! For some reason getDir on of the trigger didnt work, but i made it check the direction of the gate. Works perfectly. One of many uses for this that i needed was a race track kind of thing, prevents players from accidentally entering the circuit going wrong way, and OpFor trackmarshall can prevent entering the track by standing near the gate so it wont open until he moves aside. And if players run over the guy operating the gate it also wont open anymore. This is what the trigger condition looks like if someone else needs something similiar: Player present, condition: this and (alive gatekeeper01) and (alive gate01) and (east countside thislist) == 0 and (count thisList > 0 && { getDir vehicle (thisList select 0) < (getDir gate01 + 60)%360 && getDir vehicle (thisList select 0) > (getDir gate01 - 30)%360}) Share this post Link to post Share on other sites
Tankbuster 1744 Posted July 1, 2017 Not specifically what you are asking, but this function might be of use. https://community.bistudio.com/wiki/BIS_fnc_inAngleSector Share this post Link to post Share on other sites