Jump to content
gruntage

SetWaypointBehaviour Issue

Recommended Posts

Hi Everyone,

 

Got a weird issue with SetWaypointBehaviour and hopefully you guys can shed some light on what's happening here. So I have this function (shown below) that assigns some waypoints to a couple of AI guys. They're supposed to stay in careless behaviour until they reach their second waypoints, at which point they switch to stealth. I added the code to the first AI guy first (called Hawk 2) and it worked fine; he executed his waypoints perfectly. Then I added code to the second AI guy (called Hawk 3) and then the problems started.

 

For some reason, Hawk 2 was switching to stealth too early...in fact, he was switching to stealth when Hawk 3 was assigned his waypoints. This doesn't make sense at all. Why would Hawk 2 be affected by code affecting Hawk 3? They're not in the same group, as you can see from the code below. In fact, it gets even crazier...Hawk 3 is in careless behaviour as intended, and he executes his waypoints perfectly; switching to stealth when instructed to by the script. Like, what is going on?! I've double checked to make sure that I haven't got 2s and 3s mixed up..but I guess it could be possible that I've missed something.

 

I did some error trapping already by process of elimination and I've found that the problem code is: _hawk3wpB setWaypointbehaviour "stealth";. When I disable that line, Hawk 2 stays in careless behaviour, when I enable it, Hawk 2 goes to stealth. Is this a bug within Arma? Because this is the best mind f*** I've come across.

 

TLDR: Code affecting Guy B is affecting Guy A..how and why?

 

Very eager to find out what the deal is here, so many thanks in advance.

 

hawk2group = group hawk2;
hawk3group = group hawk3;

{_x setunitpos "up";} foreach [hawk2,hawk3];
{_x setbehaviour "careless";} foreach [hawk2,hawk3];

//Hawk 2 waypoints
_hawk2wpA = hawk2group addWaypoint [getmarkerpos "hawk2_a", 0];
_hawk2wpB = hawk2group addWaypoint [getmarkerpos "hawk2_b", 0];
_hawk2wpC = hawk2group addWaypoint [getmarkerpos "hawk2_c", 0];
_hawk2wpA setWaypointType "Move";
_hawk2wpA setWaypointbehaviour "careless";
_hawk2wpA setWaypointcombatmode "white";
_hawk2wpA setWaypointspeed "Full";

_hawk2wpB setWaypointStatements ["true", "hawk2 setunitpos 'middle'; hawk2 allowdamage false; hint 'Hawk 2 is closing in on his target';"];
_hawk2wpB setWaypointTimeout [20,20,20];
_hawk2wpB setWaypointbehaviour "stealth";
_hawk2wpC setWaypointStatements ["true", "_nil = [] execVM 'Functions\SH_Hawk2Plant.sqf';"];

sleep 2;

//Hawk 3 Waypoints
_hawk3wpA = hawk3group addWaypoint [getmarkerpos "hawk3_a", 0];
_hawk3wpB = hawk3group addWaypoint [getmarkerpos "hawk3_b", 0];
_hawk3wpC = hawk3group addWaypoint [getmarkerpos "hawk3_c", 0];
_hawk3wpA setWaypointType "Move";
_hawk3wpA setWaypointbehaviour "careless";
_hawk3wpA setWaypointcombatmode "white";
_hawk3wpA setWaypointspeed "Full";

//_hawk3wpB setWaypointStatements ["true", "hawk3 setunitpos 'middle'; hawk3 allowdamage false; hint 'Hawk 3 is closing in on his target';"];
//_hawk3wpB setWaypointTimeout [20,20,20];
_hawk3wpB setWaypointbehaviour "stealth";
//_hawk3wpC setWaypointStatements ["true", "_nil = [] execVM 'Functions\SH_Hawk3Plant.sqf';"];

 

Share this post


Link to post
Share on other sites

Tested and... not reproduced. In a trigger (set to true) I run these lines:

0 = [] spawn {while {true} do {
uisleep 0.2;
hintSilent str [behaviour hawk2,behaviour hawk3]
}};

Everything goes well. Check your marker positions. If too close, you can have an early completion.

 

Share this post


Link to post
Share on other sites

Thanks for the reply. I've done some more digging and I may have found a solution. I've run your code to find out when Hawk 2's behaviour is switching exactly and he's switching to stealth at some arbitrary time shortly after the mission begins. The switching does not coincide with anything else happening. There's no accidental completion of waypoints because Hawk 2's first waypoint is 600m away. Maybe this is just a bug within my game...Sounds ridiculous and I still can't believe it.

 

But anyway, the solution is to simply force Hawk 2's behaviour and his first waypoint to careless about 30 seconds into the mission - i.e. right after the arbitrary switch. From that point on, everything seems to be working..for now 🙄.

 

Thanks for the help.

 

 

 

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

×