Jump to content
Sign in to follow this  
dale

addWaypoint issue regarding vehicles

Recommended Posts

Hey Guys,

Just a slight issue with the addWaypoint script, currently im trying to achieve a system where by you get into a vehicle and it gives you a set of waypoints notably the MH9, I have a trigger which is as thus:

Condition: player in trainmh91;

On Act: null = [this] execVM "script.sqf";

then the script.sqf is:

way1 = (group player) addWaypoint [getMarkerPos "train1", 0];
way1 setWaypointType "MOVE";
way1 setWaypointBehaviour "aware";
way1 setWaypointCombatMode "yellow";
way1 setWaypointDescription "Helicopter Training.";
way1 setWaypointSpeed "FULL";
way2 = (group player) addWaypoint [getMarkerPos "train2", 0];
way2 setWaypointType "MOVE";
way2 setWaypointBehaviour "aware";
way2 setWaypointCombatMode "yellow";
way2 setWaypointDescription "Helicopter Training.";
way2 setWaypointSpeed "FULL";

The issue with this is that when I enter the helicopter or vehicle it completes the objectives instantly, which is an issue due to the fact that it completes the mission instantly, I've added more waypoints and the same issue occours no matter what amount or type of waypoints I put on the map.

As you can see they are linked to markers on the map.

Ive taken a general look around but I can't seem to find any answers, and this is mighty frustrating as it doesn't make sense in my eyes.

If I attach the script to the player it works fine so for example I put this

null = [this] execVM "script.sqf";

in the intialization, just not vehicles :/.

Best Regards

Dale

Share this post


Link to post
Share on other sites

On Act: null = [this] execVM "script.sqf";

You can't use "this" when using it in a trigger it has no meaning you need to pass the name of the unit.

try null = [player] execVM "script.sqf";

Share this post


Link to post
Share on other sites

ah ok thanks :)

just tried it out this doesn't fix the issue but it does enlighten me.

Edited by dale

Share this post


Link to post
Share on other sites

There are a couple of issues, waypoints are stored in memory so all the waypoints in the script are run instantly any code after them will be run before you even move.

You can add a waituntil before adding the next waypoint. This could be a distance check waituntil {player distance getMarkerPos "train1 <20}

Or you can run all the waypoints and just place it after the final waypoint.

Also with choppers the waypoints need to be around 200 meters away or they will complete.

This example uses a variable rather than a distance check.

player setvariable ["wait",false];

way1 = (group player) addWaypoint [getMarkerPos "train1", 0];
way1 setWaypointType "MOVE";
way1 setWaypointBehaviour "aware";
way1 setWaypointCombatMode "yellow";
way1 setWaypointDescription "Helicopter Training.";
way1 setWaypointSpeed "FULL";
way2 setWaypointCompletionRadius 30;

way2 = (group player) addWaypoint [getMarkerPos "train2", 0];
way2 setWaypointType "MOVE";
way2 setWaypointBehaviour "aware";
way2 setWaypointCombatMode "yellow";
way2 setWaypointDescription "Helicopter Training.";
way2 setWaypointSpeed "FULL";
way2 setWaypointCompletionRadius 30;
way2 setWaypointStatements ["true", "player setvariable ['wait',true];"];

waituntil {!alive player or player getvariable "wait";}; 
player setvariable ["wait",false];


// rest of code waits for final waypoint to complete
hint "done"; 

Edited by F2k Sel

Share this post


Link to post
Share on other sites
On Act: null = [this] execVM "script.sqf";

You can't use "this" when using it in a trigger it has no meaning you need to pass the name of the unit.

try null = [player] execVM "script.sqf";

A little OT but I was curious -what happens when you use "Player" in MP to activate a trigger? Will any 'Player' activate it or is it best to use the Unit's name?

Share this post


Link to post
Share on other sites

Player will be any player but to select a specific player you would have to use the name.

There is no right or wrong as it depends on what your doing.

That's how I understand it but I don't do MP scripting really.

Share this post


Link to post
Share on other sites
There are a couple of issues, waypoints are stored in memory so all the waypoints in the script are run instantly any code after them will be run before you even move.

You can add a waituntil before adding the next waypoint. This could be a distance check waituntil {player distance getMarkerPos "train1 <20}

Or you can run all the waypoints and just place it after the final waypoint.

Also with choppers the waypoints need to be around 200 meters away or they will complete.

This example uses a variable rather than a distance check.

player setvariable ["wait",false];

way1 = (group player) addWaypoint [getMarkerPos "train1", 0];
way1 setWaypointType "MOVE";
way1 setWaypointBehaviour "aware";
way1 setWaypointCombatMode "yellow";
way1 setWaypointDescription "Helicopter Training.";
way1 setWaypointSpeed "FULL";
way2 setWaypointCompletionRadius 30;

way2 = (group player) addWaypoint [getMarkerPos "train2", 0];
way2 setWaypointType "MOVE";
way2 setWaypointBehaviour "aware";
way2 setWaypointCombatMode "yellow";
way2 setWaypointDescription "Helicopter Training.";
way2 setWaypointSpeed "FULL";
way2 setWaypointCompletionRadius 30;
way2 setWaypointStatements ["true", "player setvariable ['wait',true];"];

waituntil {!alive player or player getvariable "wait";}; 
player setvariable ["wait",false];


// rest of code waits for final waypoint to complete
hint "done"; 

Wow what a horrible behaviour to have to hold the script open, you would of thought that adding a waypoint would add it to the units memory/allocation.

After playing with this for a while completion radius in an MH9 is 500m yet another weird bahaviour no matter where or how far you tell it the completion radius is. (presume this is because of a setting in the vehicle rather than a fault of the waypoint)

Another option for the script rather than holding the script open is to place it in missionnamespace by wrapping the original script like this

with missionNamespace do {
way1 = (group player) addWaypoint [getMarkerPos "train1", 10];
way1 setWaypointType "MOVE";
way1 setWaypointBehaviour "aware";
way1 setWaypointCombatMode "yellow";
way1 setWaypointDescription "Helicopter Training.";
way1 setWaypointSpeed "FULL";
way2 = (group player) addWaypoint [getMarkerPos "train2", 10];
way2 setWaypointType "MOVE";
way2 setWaypointBehaviour "aware";
way2 setWaypointCombatMode "yellow";
way2 setWaypointDescription "Helicopter Training.";
way2 setWaypointSpeed "FULL";

};

Share this post


Link to post
Share on other sites

this is awesome stuff, ill be trying this weekend for sure, thankyou to everyone who provided insight ill give you the results of the tests tomorrow :)

Share this post


Link to post
Share on other sites

Thread hijack alert!

OK so good stuff on this thread but I have some small troubles with my version.

my waypoint.sqf looks like this

_groupleader = _this select 0;
_marker = _this select 1;
_group = group _groupleader;
_obj = getMarkerPos _marker;
way1 = _group addWaypoint [_obj, 0];
way1 setWaypointType "MOVE";
way1 setWaypointBehaviour "SAFE";
way1 setWaypointCombatMode "BLUE";
way1 setWaypointSpeed "FULL";

This works great if I use it like this from a trigger ("patrolcar2" is the unit and "m1" is the marker i'd like to use) and the unit is AI controled:

null = [patrolcar2, "m1"] execVM "waypoint.sqf";

again this works great if the player is inside the unit "patrolcar2":

null = [player, "m1"] execVM "waypoint.sqf";

however if it is just AI controled "player" wont work.

Is there another var I can use so any unit that passes over the trigger will get a waypoint set to the location of "m1"?

Share this post


Link to post
Share on other sites

As long as the trigger isn't already active then the activating unit can be got by looking at the thisList of the trigger. ThisList is a magic variable only available in triggers that holds an array of objects that satisfy the triggers condition.

[ thislist select 0, "m1" ] execVM "waypoint.sqf";

Get the first thing in the list (select 0), this is usually the object that fired off the trigger.

Share this post


Link to post
Share on other sites
As long as the trigger isn't already active then the activating unit can be got by looking at the thisList of the trigger. ThisList is a magic variable only available in triggers that holds an array of objects that satisfy the triggers condition.

[ thislist select 0, "m1" ] execVM "waypoint.sqf";

Get the first thing in the list (select 0), this is usually the object that fired off the trigger.

ThisList worked a treat.

I'm not allowed to post links but for anyone else that didn't know about "thislist" check out the wiki

community.bistudio.com/wiki/thisList

Thank You :ok:

Share this post


Link to post
Share on other sites

Another good page to check is the Triggers page that gives lots of info about all the options in a trigger including the use of thisList and thisTrigger in the act: fields. This is linked from the main editor page were you can follow links for most of the default objects and find alot of useful information.

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  

×