Jump to content
Sign in to follow this  
igneous01

question about checking for group in vehicle

Recommended Posts

ok so ive got a question concerning checking whether a group is in a vehicle or not.

im using a trigger that if unitA is not present in the trigger area, then unitb (who is supposed to be driving to meet him there) will turn back, and head to his last waypoint (which is to leave the map, where the mission will fail)

this part works, but the question is:

I am currently using this statement in the activation field:

hvtincar = hvtppl in suv; 
hint "turning back"; 
if (!hvtincar) then { hvtppl ordergetin true; 
hint "not in vehicle"};
hvtgroup setCurrentWaypoint [hvtgroup, 5]; 

note that hvtppl is a variable array that lists all the units in the group hvtgroup.

now i realize this doesnt work right now because the in command doesnt pass a value for the whole array. i can get that working later using a foreach loop.

but the real question is, say for example unita leaves the trigger area JUST when unitb arrives and half of the group get out. how can i check that if certain units are out and in the vehicle, the proper ordergetin commands are issued. I realize that if you use ordergetin = true twice, the unit will get out of his assigned vehicle. Last thing i want is for the HVT to get out, the driver is still in, and suddenly the HVT gets in the vehicle, but the driver gets out and walks to the last waypoint, leaving everyone in the suv behind.

this is all part of a very complicated meeting between two personnel, using firednear event handler on each of them so that either of them will leave the meeting area, and the second guy whos driving there will turn back and getin his vehicle if hes not in it (the whole group, because a drive is assigned to them) so far the meeting does get broken up properly in almost all aspects except for the part where unitb arrives just in time and gets out as unita is leaving.

thanks for any help you guys can give

edit********

i guess i have 2 problems now, everytime unita leaves the trigger unitb always gets out of the vehicle and walks to the last waypoint.

i tried this inside the trigger act:

{if (_x in suv) then {} else {_x ordergetin true}} foreach hvtppl; hvtgroup setCurrentWaypoint [hvtgroup, 5]; 

yet they still get out, they shouldnt tho since they are inside the vehicle suv. why isnt it working?

edit********

looks like this has gotten even more complicated. I think the reason why they were getting out for no reason might be because of the previous waypoints that have ordergetin and leavevehicle commands attached to them. so instead i gave them a domove command with the above if statement, and now when they arrive and unita leaves, unitb ignores the domove, follows all of his waypoints (goes to where hes supposed to stand to talk) and instead of getting in the suv again (as the waypoint is scripted) he instead ignores that and walks on foot to the last waypoint.

I really dont understand whats going on, it works flawlessly if unita leaves before unitb arrives in the area. but once hes there, he wont do it anymore.

also the eventhandler firednear causes him to go back to waypoint 3 each time, but the problem is if i give a domove and ordergetin command through the eventhandler, he wont execute it.

how am i supposed to get this to work?

Edited by Igneous01

Share this post


Link to post
Share on other sites

alright i have managed to solve the check group vehicle issue, it seems that ordergetin true used twice will not make a unit getout if he is in a vehicle.

However now i have run into a problem with doMove and waypoints.

Ive simplified my approach to making this work. I removed all the waypoints for the groups after them getting close to each other to talk. once in this range they do their animations and stuff. if the meeting is done (the guys are done talking) or the meeting is interrupted (player spotted, fired near EH) then this will make a variable called endmeeting == 1, when this variable is 1 a trigger will launch a script to make the units leave (like they would if they had waypoints)

but now im experiencing a different problem. Sometimes unita will get in vehicle and leave, sometimes he'll be in his vehicle and wont leave. Same applies to unitb as well, its either or will follow the domove command while the other one doesnt.

here is a look at the script i made to do this:

// check if fired near then leave area
// check if meeting done then leave area

player sidechat "enabling groups";
// set attributes for groups
{_x setbehaviour "AWARE"; _x enableai "MOVE"} foreach bossppl;   
{_x setbehaviour "AWARE"} foreach hvtppl;

player sidechat "groups getting in vehicles";
// tell the groups to get in their vehicles
bossppl ordergetin true;
hvtppl ordergetin true;

player sidechat "groups moving at full speed";
// make the groups rush to their vehicles
bossgroup setSpeedMode "FULL";
hvtgroup setspeedMode "FULL";

player sidechat "checking....";
// check to see if everyone is either in a vehicle or dead then execute rest of code
waitUntil {{_x in suv or !alive _x} foreach hvtppl};
player sidechat "hvtgroup is ready"; 
waitUntil {{_x in volx or !alive _x} foreach bossppl}; 
player sidechat "bossgroup is ready";

// order the groups to get away
bossppl domove (getmarkerpos "bossleavemarker");
hvtppl domove (getmarkerpos "suvspawn");
player sidechat "groups moving out";

now ive tested it a couple times and it goes all the way through the script.

but still both units wont leave the area, only 1 of them will. I know that this is not exactly on topic as my original problem, but for some reason this method does not work.

any ideas?

Share this post


Link to post
Share on other sites

may be try to AssignAsCargo, befor orderGetIn

may be try to set to "CARELESS", and disableAI "Target" and "AutoTarget", then after some sleep set to "AWARE" again

Share this post


Link to post
Share on other sites

yea thats pretty close to what i have done.

i had them when in their animation state disableai move and reenabled again when the animation ended (whether abruptly or just the time ended)

also the units are already assigned proper places in their vehicles.

but after 5 hrs straight of debugging i managed to solve this. it seems that the check:

waitUntil {{_x in suv or !alive _x} foreach hvtppl};

does not wait to see if all the units are dead or in a vehicle, so it will continue with the rest of the script if it finds 1 person in the vehicle. i managed to get it working correctly by doing it the manual way (if unit1 !alive or in suv etc etc....

also, i just realized that when i had used the leavevehicle command in the waypoint for unitb, he would not return to his vehicle afterwards because it was unassigned to him from leavevehicle (my bad on this one) so now i just changed it to ordergetout false and it works.

so I managed to get everything working properly and everybody does their thing when the meeting ends either way. hurray for me ^^

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  

×