Jump to content
Sign in to follow this  
Lucky44

The "Switch" type of Waypoint...issues

Recommended Posts

This seems like a bug, but maybe I'm missing something.

I have a situation where 1 unit (call him Boss) is going to flee to a helo and take off and exit the area. But if the helo is damaged, he will skip the helo and go to a car, and if the car is damaged, he'll skip it and go to a boat to exit the area.

So I have Boss's waypoints set up to basically move near the helo, then GetIn the helo, then move near the car, then GetIn the car, then move near the boat, then GetIn the boat, then leave.

I've messed with using empty vehicles and crewed vehicles (crewed is what I want so they can each have their own exit waypoints after Boss gets in).

And it works fine until I add the Switch triggers to the GetIn waypoints to detect the damage and make Boss skip the GetIn waypoint if the vehicle is damaged. (For testing purposes, I've tried making the triggers detect other things, btw.) Once I add the trigger, the Boss just runs near the vehicle and stands there, maybe stuttering a little. It's as if he wants to get in but he can't. And it's not a matter of his path to entering the vehicle being physically blocked; nothing has changed except the addition of the Switch trigger.

I can throw the trigger and make him skip the helo and go to the car, but then he won't get in the car either. If I then make him skip the car and go to the boat (which has no Switch trigger on its GetIn waypoint since it's last in the chain), he will get in.

So what's going on with Switch triggers messing with my GetIn waypoints?

Thanks!

Share this post


Link to post
Share on other sites

Why not just assignasdriver + ordergetin, would be so much easier than waypoints.

Share this post


Link to post
Share on other sites
Why not just assignasdriver + ordergetin, would be so much easier than waypoints.

Well, I don't want him to be the driver, but I guess I could assignascrew or some such. Would that go in a trigger? I'm not familiar with its use: does it make the unit move to the vehicle, or does he teleport to it?

Edited by Lucky44

Share this post


Link to post
Share on other sites

unitName assignascargo vehicleName;

[unitName] orderGetIn true;

Then just assign different vehicle with script/trigger/whatever.

Share this post


Link to post
Share on other sites

That's the designed behavior, switch triggers are turning your get in waypoints into hold waypoints.

According to the BIKI:

If the vehicle was not there / destroyed he would just move on to the next waypoint.

On a dedicated server, an A.I. unit will only get in vehicles that are empty. (Don't know how true this is)

A switch trigger needs to synchronized to the waypoint prior to the one you want him to wait for, so that the unit will wait at that waypoint until the conditions are met. However, that gives you only a linear path. Switch triggers are only good for getting out of hold or guard waypoints. Even if you put set up switch triggers on waypoints prior to each Get In waypoint, the only thing that you create would be a pause, then he would continue on his waypoints like normal.

So forgot about the switch triggers, regular Get In waypoints can be made to work.

Give each escape vehicle a Hold waypoint right where they are and a Move waypoint for the escape route. For the first vehicle (heli), put a switch trigger named swHeli on the Hold waypoint and make the condition:

false

Next, in the helicopter's init line, put:

this addEventHandler ["Hit", {swHeli setTriggerStatements ["true", "", ""];}];

And so on for the rest of the escapes.

If any of the escape vehicles get hurt, they will take off. Now, the Boss needs a straight Move and Get In for each escape. If the boss gets there, and the vehicle already took off, he will just move to the next one. You'll want to have the vehicle to take off once the Boss is inside so set On Act for the Heli Get In waypoint to:

swHeli setTriggerStatements ["true", "", ""];

And so on for each escape.

According to the BIKI, this won't work on a dedicated server since the vehicle is not empty. There's a few methods to try but I don't know if synchronizing the boss' Get In waypoint to a pilot/driver's Load waypoint, or putting them in the same group will matter. I haven't tested it, so if it doesn't work, you'll have to use scripted waypoints which allow for more advanced behavior.

Scripted Alternative

init.sqf

if(isServer) then {esc_list = [escHeli, escBoat, escCar];}; //list of possible escape vehicles

Each escape vehicles init line

this addEventHandler ["Hit", {esc_list = esc_list - this; swHeli setTriggerStatements ["true", "", ""];}];

Set up the same waypoints and switch trigger for the escape vehicles as before.

For the boss, give him a move waypoint in a neutral location and then a scripted waypoint that will call escape.sqf

escape.sqf

if(!isServer) exitWith{};
if(count esc_list == 0) exitWith {hint "Boss is trapped";};
private ["_unit", "_group", "_escveh", "_wpEscape"];
_unit = _this select 0;
_group = group _unit;
_escveh = esc_list select 0;

_wpEscape = _group addWaypoint [getWPPos[group _escveh,0],5];
_wpEscape setWaypointType "MOVE";
call compile format['_wpEscape setWaypointStatements ["true", "if(%1 distance %2 < 10) then {%1 assignAsCargo %2; [%1] orderGetIn true;} else {esc_list = esc_list - %2; Nul = %1 execVM "escape.sqf";}"]',_unit,_escveh];

This changes the behavior in that the Boss will know which vehicles are gone when he chooses to move to one. After that, he will act as normal, he will keep moving to the position where the escape vehicle started and will only choose a different destination if he gets there and the helicopter left in the meantime (simulates not having enough time to receive the information that his ride left). This will also bypass any restrictions about AI not getting in non-empty vehicles on dedicated servers.

Edited by tcp

Share this post


Link to post
Share on other sites

OK, thanks SHK. That's helpful.

Wow, thanks TCP! That was a lot of effort, and I appreciate it; I also learned some things that will be useful. I don't, however, want the vehicles to leave if they're hit, I just want the Boss to skip them if they can't transport him away quickly. Minor detail, and I get your point, so thanks.

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  

×