Jump to content
gc8

Scripted guard waypoint

Recommended Posts

Hi

I'm trying to use the "Guard" waypoint to make group move to position to guard it. This works well when I place everything from editor. But not when I try to write script function to make the group move to the guard point.

 

This is my code:

deleteWaypoints =
{
params ["_group"];

for "_i" from (count (waypoints _group) - 1) to 0 step -1 do
{
deleteWaypoint [_group, _i];
};

};

testg =
{

_group = teg; // The guard group

/*
{
 _x setpos (getMarkerPos "start");
} foreach (units _group);
*/

createGuardedPoint [west, getMarkerPos "guardMarker", -1, objNull ];



systemchat "Point created";



_group call deleteWaypoints; // Delete old wps



_wp = _group addWaypoint [getMarkerpos "somePos", 0];
_wp setWaypointType "GUARD";

};

 

i call that from console "call testg"

 

This code only works if its called right at start of the mission. But if I call it after the groups have reached their editor placed waypoints in wont work. (They just stand there) I tried deleting the old WPs to fix this but without avail.

 

So does anyone know how to make this working?

 

thx!

 

Share this post


Link to post
Share on other sites

Why do you have to use a "GUARD" waypoint to make them "MOVE"?

I remember "GUARD" waypoints being unpredictable unless used exactly as intended-- multiple zones for the AI to select based on priority.

Can they just move there?

Share this post


Link to post
Share on other sites

I was thinking that I could use the guard feature spread the defenders to important positions. Due to my existing scripted waypoint solution the guard points would have been ideal 

Share this post


Link to post
Share on other sites

@gc8,
I've been trying to figure this out and I have a couple ideas but without recreating the conditions in exacting detail I can't be sure.

As a troubleshooting tip, I'd suggest simplifying the script or removing it from the scenario. You CAN make this happen, just under different conditions. Load up a VR mission, plug in your script with the needful elements/objects/markers, then break it / fix it until you figure it out.

The script,
1) deletes the group's waypoints
2) Creates the guarded point
3) Adds the "Guard" waypoint

so
_group = teg;
deleteWaypoint [_group, 0];
sleep 0.5
createGuardedPoint [west, getMarkerPos "guardMarker", -1, objNull ];
systemchat "Point created";
_wp = _group addWaypoint [getMarkerpos "somePos", 0]; _wp setWaypointType "GUARD";


I don't know. Sorry, best luck.

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/Waypoint:Guard

 

I'm having some trouble understanding what you are trying to achieve with your script.  Note that adding guardPoints creates a hierarchy of importance (starting with the first) which gives some explanation why your group won't move.  Again: to what end are you using dynamic Guard waypoints? If you want the unit to dynamically hold and fortify positions, there are better options. 

 

The best use of Guard WP and guardPoints is to create a network.  A single GuardPoint (by script or 'Guarded By' X trigger) surrounded by one or more units with Guard WP.   When the guardpoint is undefended, a fresh unit will move to it.  Additionally, free units will move to respond to spotted units in the area. 

 

-k 

 

Share this post


Link to post
Share on other sites
2 hours ago, nkenny said:

Again: to what end are you using dynamic Guard waypoints?

 

 

I wanted to first give a group position they should be at and then later create guard point so that they go check to position out. Kinda like patrolling but not cycling, just moving from point A to B. And I wanted this for multiple groups so that some stay at position A and some checks out the guard points

 

Share this post


Link to post
Share on other sites
18 minutes ago, gc8 said:

 

 

I wanted to first give a group position they should be at and then later create guard point so that they go check to position out. Kinda like patrolling but not cycling, just moving from point A to B. And I wanted this for multiple groups so that some stay at position A and some checks out the guard points

 

That's not how guard waypoints work though.

AI with guard waypoints will move towards them only if "guarded by" triggers are under attack.

 

Cheers

Share this post


Link to post
Share on other sites
13 minutes ago, Grumpy Old Man said:

AI with guard waypoints will move towards them only if "guarded by" triggers are under attack.

 

Didn't read that from anywhere but i suppose you'r right

Share this post


Link to post
Share on other sites

Check the link I posted.

 

You would be better served with a MOVE wp

Share this post


Link to post
Share on other sites
1 minute ago, nkenny said:

Check the link I posted.

 

You would be better served with a MOVE wp

 

Yeah I did. I was just thinking it might be good for dynamic AI behavior if I create the guardpoint(s) to random locations. But I never got it working this way

Share this post


Link to post
Share on other sites

Create a script which assigns move waypoints to a random selection predetermined locations. 

 

Add a Cycle WP to have them repeat it. Break the cycle on a trigger or variable. Then update all units with a Guard WP on their current location.

 

Now the AI will react somewhat dynamically to your cleverly preplaced 'Guarded By' triggers. 

 

Share this post


Link to post
Share on other sites

@nkenny Yeah I was just hoping to use engine functionality rather than my own script but I'll work something out. thx guys 🙂

Share this post


Link to post
Share on other sites

bis_fnc_taskPatrol is not bad.

 

[group,position,range] call bis_fnc_taskPatrol;

 

If you are running CBA there are even more powerful solutions.

  • Like 1
  • Thanks 1

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

×