Jump to content
Sign in to follow this  
weaponsfree

MP - Triggered only if unit is human

Recommended Posts

I'm wondering, in an MP environment, Are "player in thislist" area triggers activated by any human players that encounter it? And AI units (of the same group or not) that enter the trigger zone won't?

 

For example, in an MP mission, say I have a repeatable area trigger with "player in thislist" in the condition field. I have 5 playable units, 3 of which are human controlled, the other 2 AI (not grouped for this example).

 

As all 5 units walk through the trigger one by one, it will fire each time a human controlled unit passes, and will NOT fire when AI passes through it?

I'm asking here, because it is difficult to setup an actual test without buddies willing to test in MP. Hoping the splendid community has a clear answer.

Cheers

Share this post


Link to post
Share on other sites

Would the isPlayer check work for you? I'm not familiar with MP editing so I've not used it before.

Share this post


Link to post
Share on other sites

I'm asking here, because it is difficult to setup an actual test without buddies willing to test in MP. Hoping the splendid community has a clear answer.

 

It is not difficult. Make MP mission, start it from EDEN and join, then click on arma3.exe in arma3 directory to start another client. Choose multiplayer, server direct and type localhost for IP and 2302 for port, then you see your hosted server running. You can do this as many times as your CPU allows

  • Like 1

Share this post


Link to post
Share on other sites

It is not difficult. Make MP mission, start it from EDEN and join, then click on arma3.exe in arma3 directory to start another client. Choose multiplayer, server direct and type localhost for IP and 2302 for port, then you see your hosted server running. You can do this as many times as your CPU allows

 

Well damn, that will be very useful. Thanks for the tip.

 

Would the isPlayer check work for you? I'm not familiar with MP editing so I've not used it before.

 

Yes, I think this can be used for my purposes. But the more I work on the mission, the more I realize this is a little more complex than I first thought.

Specifically :

I have 5 playable units, set as captive that have a waypoint accross a city. There are multiple enemy patrols randomly walking around the city with area triggers attached to them. The idea is that the players have to avoid the patrols as they cross the city. If a player gets too close to a patrol, the attached trigger removes the setcaptive setting on that player, and the player gets shot at.

The problem is that I want the mission to be playable in Single Player. Which means the 4 other playable units have to cross the city as AI's following a waypoint. However Arma AI being as it is, I can't expect AI controlled units to successfully avoid patrols and make it to the waypoint. So I want the triggers to simply ignore AI units, and only activate when humans are controlling them.

So this gives me 2 problems to solve :

1. Make sure only human players trigger the patrols (player in thislist should work)

2. Ideally, make that only the individual unit that actually triggered the trigger gets their setcaptive removed, and only if they are human. This part is proving quite tricky. But I'm hoping that if one playable unit is discovered, it doesn't mean all the other 4 are now fired at.

Not sure if all this is 100% clear, but any help would be appreciated as I am a very poor scripter. For now I'm going to try and confirm that problem 1 is solved.

Share this post


Link to post
Share on other sites

Use something with playableUnits?

if (_unit in playableUnits) then {CODE};

Wouldn't work in singleplayer tho.

I do need it to work in SP though...

 

I basically need a script inside an area trigger that asks :

Are you a human player? If so, what's your name? Ok unit_name I'm now removing JUST YOUR setcaptive state.

If only scripting was so easy :P

 

Right now I only seem to be able to do :

Are you a human player? Yes? Ok you and ALL YOUR FRIENDS have setcaptive removed. Which is not what I want.

Share this post


Link to post
Share on other sites

It is not difficult. Make MP mission, start it from EDEN and join, then click on arma3.exe in arma3 directory to start another client. Choose multiplayer, server direct and type localhost for IP and 2302 for port, then you see your hosted server running. You can do this as many times as your CPU allows

 

Didn't know that either. Thanks for the info!

  • Like 1

Share this post


Link to post
Share on other sites

I do need it to work in SP though...

 

I basically need a script inside an area trigger that asks :

Are you a human player? If so, what's your name? Ok unit_name I'm now removing JUST YOUR setcaptive state.

If only scripting was so easy :P

 

Right now I only seem to be able to do :

Are you a human player? Yes? Ok you and ALL YOUR FRIENDS have setcaptive removed. Which is not what I want.

 

Well in singleplayer there is only one playable player.

another way of doing it is naming all your "players", P1, P2, P3, P4, P5, then add that in a array, [P1, P2, P3, P4, P5].

Then use that to check if the unit is a "player".

 

if (_unit in [P1, P2, P3, P4, P5]) then {I'M A SO CALLED PLAYER :D};

Share this post


Link to post
Share on other sites

The condition player in thisList will work just fine as long as you set your trigger activation parameters correct e.g. correct side and such.

It will most likely be best if you set the trigger to Detected by <enemy side> so players can sneak behind buildings and such. Would have to test thoroughly though.

Share this post


Link to post
Share on other sites

 

Well in singleplayer there is only one playable player.

another way of doing it is naming all your "players", P1, P2, P3, P4, P5, then add that in a array, [P1, P2, P3, P4, P5].

Then use that to check if the unit is a "player".

 

if (_unit in [P1, P2, P3, P4, P5]) then {I'M A SO CALLED PLAYER :D};

 

In this case, will the code following then apply only to the unit that triggered the trigger? If so, that is exactly what I'm looking for for problem number 2 :) (will try it shortly).

To mix it with the "are you human check", would look something like

 

if (isPlayer _x && _unit in [P1, P2, P3, P4, P5]) then {_unit setcaptive false}

I again apologize if reading that made some people bleed from the nose. I am an extreme beginner scripter.

 

 

 

The condition player in thisList will work just fine as long as you set your trigger activation parameters correct e.g. correct side and such.

It will most likely be best if you set the trigger to Detected by <enemy side> so players can sneak behind buildings and such. Would have to test thoroughly though.

 

Ah yes, good call for the Detected by. Will allow much more realistic gameplay. Civilian detected by OPFOR since my units will be setcaptive true. Thanks!

Share this post


Link to post
Share on other sites

i'm not sure if the trigger would fire again if there is already a player in its activation zone. haven't used triggers in ages but i remember that being a thing.

 

so what might work is setting the trigger to always true (replace "this" in the condition field with "true") and then in the on activation field you would check who's in it and setcaptive them all.

 

slightly talking out of my ass here though. haven't had any coffee yet :lol:

Share this post


Link to post
Share on other sites

So I've confirmed I can have the trigger only fire when a human enters it using this script in the condition field.

{isPlayer _x} count thisList > 0

However I can't find a way to then trigger a setcaptive false to JUST that unit that walked into the trigger.

I've tried a few variations of these in the On Act field.

thislist setcaptive false
_x setcaptive false

[thislist, _x] setcaptive false

And so on. Still not been able to make it work.

I feel I'm reeeal close! Any ideas how to change setcaptive for only the units that actually fired the trigger?
 

Share this post


Link to post
Share on other sites

Got it. Complete solution is :

Condition of trigger attached to patrol :

 {isPlayer _x} count thisList > 0

On activation field :

{_x setCaptive false} forEach thisList 

This solves both problems :
1. Only humans can activate the trigger
2. Only the units that actually activated the trigger get the Setcaptive change


@Badbenson : Regarding your concern of "i'm not sure if the trigger would fire again if there is already a player in its activation zone. haven't used triggers in ages but i remember that being a thing."

I'll try and test it out, see if that's actually a problem. Thanks for the help btw :)

Share this post


Link to post
Share on other sites

2. Only the units that actually activated the trigger get the Setcaptive change

 

Not exactly.

Unfortunately with this setup if some player activate trigger, the setCaptive command will execute for every units in trigger area.

 

If you want to make this more selectable you need to use Heeeere's johnny!'s  Trigger List Changed

or

use local trigger on each player

or

set some statement inside

{
if (captive _x) then {_x setCaptive false};

} forEach thisList;

Share this post


Link to post
Share on other sites

 

Not exactly.

Unfortunately with this setup if some player activate trigger, the setCaptive command will execute for every units in trigger area.

 

If you want to make this more selectable you need to use Heeeere's johnny!'s  Trigger List Changed

or

use local trigger on each player

or

set some statement inside

{
if (captive _x) then {_x setCaptive false};

} forEach thisList;

 

Hm, I think I see what you mean. Two units are within the trigger area, but only one is actually detected by OPFOR, and both will have their setcaptive switched. Which sucks for the player who was actually still hidden.

I'm checking the Trigger List Changed script you recommend, which is clearly above my paygrade, but from what I can see, it allows you to handle what to do with units entering and leaving the trigger area. But I'm not sure how this could be applied. In my case it's not the act of entering or leaving that requires an action, but rather the act of being spotted, and just because a particular unit was the last to enter the trigger zone, doesn't mean it's the one that will be spotted and therefor requiring the setcaptive switch. Although I may be misunderstanding the functions possible with these scripts.

As for your other two, correct me if I'm wrong :

A local trigger on each player (instead of on the enemy patrol) would have the same limitation no? If a player's trigger area includes another player, both will receive the setcaptive switch no?

For the script you suggest :

{
if (captive _x) then {_x setCaptive false};

} forEach thisList;

Is indeed useful, but since my triggers only change the setcaptive to false, isn't the "if (captive _x)" unnecessary? Because even if we catch an already "non-captive" unit in the trigger, it will just receive a redundent setcaptive false.

Sorry if I misunderstand the suggestions you make. In any case, you point out a problem with my solution which IS problematic, so thanks for the help! I think the solution I would need is something that captures exactly which unit was spotted within a trigger zone. Probably something involving knowsabout.

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  

×