Jump to content
Sign in to follow this  
DerToXXic

[SOLVED] Helicopter starts when unit is not a player

Recommended Posts

Hello,

I'm building a mission for myself and 7 friends. I want a helicopter to take off only when all 8 units are in the helicopter or not controlled by players.

 

My current condition in the waypoint is the following

 

((!isPlayer p1) OR (p1 in heli1)) AND
((!isPlayer p2) OR (p2 in heli1)) AND
((!isPlayer p3) OR (p3 in heli1)) AND
((!isPlayer p4) OR (p4 in heli1)) AND
((!isPlayer p5) OR (p5 in heli1)) AND
((!isPlayer p6) OR (p6 in heli1)) AND
((!isPlayer p7) OR (p7 in heli1)) AND
((!isPlayer p8) OR (p8 in heli1))

But it didn't works.

Can somebody help me?

Share this post


Link to post
Share on other sites

Could try using: <condition> count <array>, or <array> apply <code>, and if becomes too complicated then easiest method is, in a waypoint's condition field you can run some code beforehand to help determine what you want,  before finally returning Boolean.

 

example:  <code>; <code>; <code>; <code>; <Boolean>

a = false; b = false; if (<condition1>) then {a = true}; if (<condition2>) then {b = true}; (a & b)  //returns condition true only when a and b are both true.

 

Share this post


Link to post
Share on other sites
27 minutes ago, opusfmspol said:

Could try using: <condition> count <array>, or <array> apply <code>, and if becomes too complicated then easiest method is, in a waypoint's condition field you can run some code beforehand to help determine what you want,  before finally returning Boolean.

 

example:  <code>; <code>; <code>; <code>; <Boolean>

a = false; b = false; if (<condition1>) then {a = true}; if (<condition2>) then {b = true}; (a & b)  //returns condition true only when a and b are both true.

 

I have now tested a few things. The problem is not the waypoint, but !IsPlayer. If I execute (isPlayer p1) in a trigger and there is a message on Activation, it will be displayed without problems. However, if I execute ((!isPlayer p1) or (!isPlayer p2)) and only p1 is occupied by a player, the message is not displayed. If I am not mistaken then !isPlayer will trigger the error. Is there another way to query if a unit is NOT a player?

 

PS: Sorry for my bad english.

Share this post


Link to post
Share on other sites
9 minutes ago, opusfmspol said:

isPlayer can sometimes be problematic, so might check whether the unit is found listed in allPlayers array instead.

The code would be the following, right?

((p1 !in allPlayers) or (p1 in heli1)) AND
((p2 !in allPlayers) or (p2 in heli1)) AND
((p3 !in allPlayers) or (p3 in heli1)) AND
((p4 !in allPlayers) or (p4 in heli1)) AND
((p5 !in allPlayers) or (p5 in heli1)) AND
((p6 !in allPlayers) or (p6 in heli1)) AND
((p7 !in allPlayers) or (p7 in heli1)) AND
((p8 !in allPlayers) or (p8 in heli1))

 

Share this post


Link to post
Share on other sites

Make a public variable with array, i.e. myArray = [p1,p2,p3,p4,p5,p6,p7,p8]; publicVariable "myArray";

public variable because locality will change with the players joining.  They all need to have it.

 

waypoint condition: ({(!(_x In AllPlayers)) || _x In heli1} count myArray == count myArray)

 

Share this post


Link to post
Share on other sites
8 minutes ago, opusfmspol said:

Make a public variable with array, i.e. myArray = [p1,p2,p3,p4,p5,p6,p7,p8]; publicVariable "myArray";

public variable because locality will change with the players joining.  They all need to have it.

 

waypoint condition: ({(!(_x In AllPlayers)) || _x In heli1} count myArray == count myArray)

 

When I write in the waypoint condition I get the error: Error invalid number in expression

Share this post


Link to post
Share on other sites

just tested in editor SP, no such error and heli took off when I boarded.

But didn't use publicVariable, I instead set the array in a unit's init field: myArray = [p1,p2,p3];  (used only three units, when tested 1 was player and 2 AI)

 

Variable has to be defined at mission start if going into an editor waypoint condition.

 

So maybe do away with the variable altogether and just use:

({(!(_x In AllPlayers)) || _x In heli1} count [p1,p2,p3,p4,p5,p6,p7,p8] == count [p1,p2,p3,p4,p5,p6,p7,p8])

 

 

 

Share this post


Link to post
Share on other sites

Did you check to see that the load waypoint had completed?

 

I didn't use a load waypoint at all.

Share this post


Link to post
Share on other sites

Can you send me your mission with the waypoints and the helicopter. I tried it with a land waypoint, a load waypoint and with scripts but nothing worked.

 

EDIT: I'm an idiot. Your way works very well. But I disabled the AI. But when I noticed that, I decided not to use the AI for the unused slots. Is there a way to check whether a slot is not being used at all and thus to take it out of the condition so that only occupied units have to go into the helicopter?

Share this post


Link to post
Share on other sites

I did this in editor:

 

- placed a player crewman, named p1.

- placed a crewman, named p2.

- placed a crewman, named p3.

- in p3 init field was put:  myArray = [p1,p2,p3];

- placed a helicopter, named heli1.

- gave heli1 two "MOVE" waypoints, one at heli1 position and another several hundred meters away.

- in first waypoint condition was put:

({(!(_x In AllPlayers)) || _x In heli1} count myArray == count myArray)

 

- launched mission in editor (SP) to test.

- heli1 remained grounded while player was on foot.

- in debug console, code was checked to see what the waypoint condition would be reading,

hint str ({(!(_x In AllPlayers)) || _x In heli1} count myArray == count myArray)

- went to the heli1 and player boarded.

- heli1 spooled up and took off.

 

while on foot, debug console check returned false.  After boarding, debug console check returned true.

 

The condition works, so some questions:

 

Are the 8 units all in one group, or are they split across groups, or are they individual units (each is its own group)?

Is the heli pilot part of the 8 playable units?

I notice the first waypoint (load) has in it's onActivation field: heli1 land "LAND"; so how does the setup look in editor?  Heli1 is flying in at mission start?

 

Share this post


Link to post
Share on other sites

All 8 units are in one group. The pilot is not playable. No, the helicopter is not flying. He take off when all enemies in a area are dead and should pick up the players.

Share this post


Link to post
Share on other sites

The load waypoint condition is "true", so waypoint is connected with a trigger checking that enemy are dead and that tells when to move (I presume)?

 

I've had MP locality issues with "LOAD" waypoints in the past, works fine in SP but problems occur in MP.  Seems as though it uses unitReady command to check status of units loading.

 

I tested unitReady command in multiplayer some time back and found it only gives an accurate return on the machine where the unit being checked is local.  Where the unit is not local, it always returns true whether the unit is busy or not.  And testing a synced "LOAD" waypoint very much indicated it was checking the unitReady status of the units boarding.

 

And in your case it seems you have mixed locality.  The heli group (local to server) may not be local to same machine as the group of 8 (players are in the group).  So you might not be able to use the "LOAD" waypoint if it won't get an accurate return.  That kind of mixed locality is likely why many choose to script a chopper extract rather than do it in editor.

 

- Change waypoint 1 type to "MOVE".

- Move waypoint 2 to the LZ position (where the heli lands at).

- Add a "MOVE" waypoint at current waypoint 2 position (the destination).

 

Test and see what that will do.

 

 

 

Share this post


Link to post
Share on other sites
8 minutes ago, opusfmspol said:

The load waypoint condition is "true", so waypoint is connected with a trigger checking that enemy are dead and that tells when to move (I presume)?

 

I've had MP locality issues with "LOAD" waypoints in the past, works fine in SP but problems occur in MP.  Seems as though it uses unitReady command to check status of units loading.

 

I tested unitReady command in multiplayer some time back and found it only gives an accurate return on the machine where the unit being checked is local.  Where the unit is not local, it always returns true whether the unit is busy or not.  And testing a synced "LOAD" waypoint very much indicated it was checking the unitReady status of the units boarding.

 

And in your case it seems you have mixed locality.  The heli group (local to server) may not be local to same machine as the group of 8 (players are in the group).  So you might not be able to use the "LOAD" waypoint if it won't get an accurate return.  That kind of mixed locality is likely why many choose to script a chopper extract rather than do it in editor.

 

- Change waypoint 1 type to "MOVE".

- Move waypoint 2 to the LZ position (where the heli lands at).

- Add a "MOVE" waypoint at current waypoint 2 position (the destination).

 

Test and see what that will do.

 

 

 

The helicopter lands now precisely on the helipad but he doesn't take off when the AI is turned off. What I mean is that the 8 playable units are not controlled by AI. But the helicopter should take of for example if unit 8 is not played by a player and not controlled by AI. Is this possible?

Share this post


Link to post
Share on other sites

Maybe an isNull check included in the condition?

 

({if (isNull _x) then {true} else {(!(_x In AllPlayers)) || _x In heli1}} count [p1,p2,p3,p4,p5,p6,p7,p8] == count [p1,p2,p3,p4,p5,p6,p7,p8])

 

 

Edited by opusfmspol

Share this post


Link to post
Share on other sites

Yes, this is my unit with zeus for testing all of the mission

Share this post


Link to post
Share on other sites

Maybe try:

({if (isNull _x) then {true} else {if (_x In AllPlayers) then {_x In heli1} else {false}}} count [test,p1,p2,p3,p4,p5,p6,p7,p8] == count [test,p1,p2,p3,p4,p5,p6,p7,p8])
 

I'm grasping for straws now.  Does a Zeus unit appear in allPlayers?  I know very little about Zeus function, tried to use it to emulate Construction Manager from A2 once (failed) and that was about it.

Share this post


Link to post
Share on other sites
5 minutes ago, opusfmspol said:

({if (isNull _x) then {true} else {if (_x In AllPlayers) then {_x In heli1} else {false}}} count [test,p1,p2,p3,p4,p5,p6,p7,p8] == count [test,p1,p2,p3,p4,p5,p6,p7,p8])

I get this error: Error missing ;

Share this post


Link to post
Share on other sites

Okay, then disregard that one.  Check whether "test" unit is listed in allPlayers.

 

I was wondering whether Zeus uses remoteControl to control units, and if so, whether a remoteControl unit would list in allPlayers.  I don't know enough about Zeus function.

 

But then I suppose it depends also whether "test" is your joined player unit who has the Zeus function, or "test" is a Zeus controlled unit.

Share this post


Link to post
Share on other sites

test is the player controlled unit with the zeus function. But I have the same problem when I try it without the test unit

Share this post


Link to post
Share on other sites

myArray = [test,p1,p2,p3,p4,p5,p6,p7,p8] apply {!isNull _x}; ({_x In heli1} count myArray == {_x In allPlayers} count myArray);

 

myArray should list only units present in the mission (AI turned off should not list).

Then == counts should be true when number of players in heli1 equals number of players in myArray.

 

Or maybe I'm mistaken about AI units turned off will be null?

Share this post


Link to post
Share on other sites

Sorry, my mistake, I read apply and misunderstood one of its examples.  That will define myArray as an array of trues and falses.

 

myArray = []; {if (!isNull _x) then {myArray pushBack _x};} forEach [test,p1,p2,p3,p4,p5,p6,p7,p8]; ({_x In heli1} count myArray == {_x In allPlayers} count myArray);

 

 

Edited by opusfmspol

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  

×