Home   Help Search Login Register  

Author Topic: Cycle Waypoints in Script Format  (Read 3511 times)

0 Members and 1 Guest are viewing this topic.

Offline sardaukar17

  • Members
  • *
Cycle Waypoints in Script Format
« on: 29 Aug 2009, 04:23:16 »
I know how to use cycling waypoints in the editor but I am creating waypoints in a script and it would seem the cycling command doesn't cause them to cycle in script form. The squads just go to the last waypoint and stop. I don't have any wait time assigned to it. They should just turn around and head back. THis is what I have in a simplified form:
Code: [Select]
#Randomize
_rand = random 3
_num = _rand - (_rand mod 1)
~1
?(_num==0):goto "Waypoint1"
?(_num==1):goto "Waypoint2"
?(_num==2):goto "Waypoint3"

#Waypoint1
_WP1 = _grp addWaypoint [wp1, 1]
[wp1, 1] setWaypointType "SAD"
[wp1, 1] setwaypointBehaviour "COMBAT"
[wp1, 1] setWaypointCombatMode "RED"
[wp1, 1] setWaypointSpeed "NORMAL"

goto "wpCity"

#Waypoint2
_WP2 = _grp addwaypoint [wp2, 1]
[wp2, 1] setWaypointType "SAD"
[wp2, 1] setwaypointBehaviour "COMBAT"
[wp2, 1] setWaypointCombatMode "RED"
[wp2, 1] setWaypointSpeed "NORMAL"

_WP2_1 = _grp addwaypoint [wp2_1, 2]
[wp2_1, 2] setWaypointType "SAD"
[wp2_1, 2] setwaypointBehaviour "COMBAT"
[wp2_1, 2] setWaypointCombatMode "RED"
[wp2_1, 2] setWaypointSpeed "NORMAL"
goto "wpCitySide"

#Waypoint3
_WP3 = _grp addwaypoint [wp3, 1]
[wp3, 1] setWaypointType "SAD"
[wp3, 1] setwaypointBehaviour "COMBAT"
[wp3, 1] setWaypointCombatMode "RED"
[wp3, 1] setWaypointSpeed "NORMAL"

_WP3_1 = _grp addwaypoint [wp3_1, 2]
[wp3_1, 2] setWaypointType "SAD"
[wp3_1, 2] setwaypointBehaviour "COMBAT"
[wp3_1, 2] setWaypointCombatMode "RED"
[wp3_1, 2] setWaypointSpeed "NORMAL"
goto "wpCitySide"

#wpCity
_WPCity = _grp addWaypoint [wpCity, 2]
[wpCity, 2] setWaypointType "SAD"
[wpCity, 2] setwaypointBehaviour "COMBAT"
[wpCity, 2] setWaypointCombatMode "RED"
[wpCity, 2] setWaypointSpeed "NORMAL"

_WPCityPat = _grp addWaypoint [wpCityPat, 3]
[wpCitypat, 3] setWaypointType "CYCLE"
[wpCitypat, 3] setwaypointBehaviour "COMBAT"
[wpCitypat, 3] setWaypointCombatMode "RED"
[wpCitypat, 3] setWaypointSpeed "NORMAL"

goto "exit"

#wpCitySide
_WPCity = _grp addWaypoint [wpCity, 3]
[wpCity, 3] setWaypointType "SAD"
[wpCity, 3] setwaypointBehaviour "COMBAT"
[wpCity, 3] setWaypointCombatMode "RED"
[wpCity, 3] setWaypointSpeed "NORMAL"

_WPCitypat = _grp addWaypoint [wpCityPat, 4]
[wpCitypat, 4] setWaypointType "CYCLE"
[wpCitypat, 4] setwaypointBehaviour "COMBAT"
[wpCitypat, 4] setWaypointCombatMode "RED"
[wpCitypat, 4] setWaypointSpeed "NORMAL"
goto "exit"

#exit
exit

My issue is the setwaypointtype "cycle". It is the last waypoint assigned to the _grp for each path they may follow. I could set up a loop of some sort to add like 30 waypoints and force it that way.. But that seems like a good way of bogging things down. Shouldn't Cycle work? And if Not is there another way? Waypoints in the Editor won't work... Unless you know of a way to assign them to created units that spawn at a certain interval. And then to be able to move the waypoints themselves to new cities...

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Cycle Waypoints in Script Format
« Reply #1 on: 29 Aug 2009, 09:29:16 »
Just a clarification, Cycle makes the group to return to the closest WP to the Cycle one. So, if you place the cycle waypoint quite close to the first one, you will have a loop. For example:
WPA (MOVE)-> group moves to A
WPB (MOVE)-> group moves to B
WPC (CYCLE) and placed quite close to WPA -> group returns to WPA.

So, for your city pat you might need to add another move wp before the cycle one, and then place the cycle one quite close to the first wp in city.

Offline sardaukar17

  • Members
  • *
Re: Cycle Waypoints in Script Format
« Reply #2 on: 29 Aug 2009, 19:27:23 »
how close are we talking? my understanding was that cycle would revert to the neareat waypoint in the path.. when i get home I will try adding another one back at the first entry into the city.

-Edit-

I Tried it and we had the same result. The squads go to the last waypoint and then just stop.
« Last Edit: 30 Aug 2009, 01:52:16 by sardaukar17 »

Offline Pirin

  • Members
  • *
Re: Cycle Waypoints in Script Format
« Reply #3 on: 30 Aug 2009, 10:51:35 »
I wrote something earlier that did a CYCLE waypoint via script, it's working fine for me.

Code: [Select]
_wp = HR_flightgroup addWaypoint [getMarkerpos "HR_LZ", 1];
_wp1 = HR_flightgroup addWaypoint [getMarkerPos "HR_SPAWN", 1];
_wp2 = HR_flightgroup addWaypoint [getMarkerPos "HR_SPAWN", 1];
[HR_flightgroup, 1] setWaypointType "TR UNLOAD";
[HR_flightgroup, 2] setWaypointType "MOVE";
[HR_flightgroup, 3] setWaypointType "CYCLE";

That's all I needed really.  That said, while they do cycle, they appear to fly to [0,0,0] then turn back and follow their normal waypoints.  It's odd.

Offline sardaukar17

  • Members
  • *
Re: Cycle Waypoints in Script Format
« Reply #4 on: 31 Aug 2009, 09:53:45 »
I noticed that you assigned the cycle waypoint to the exact same location as the first. Maybe that is what is required in script format. Unfortunatly, the way I have the thing set up I don't see that working for me either. Not without rewriting the thing. I need the waypoint to respond like it does in the editor. Where all "Cycle" does is go back to the closest waypoint on it's path and starts it's cycle from there. As far as I can tell I have no errors in the syntax that would cause the units to simply just not cycle. I don't knwo  :dunno:

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Cycle Waypoints in Script Format
« Reply #5 on: 01 Sep 2009, 01:37:13 »
WP 0 for any group is its starting position, so placing a cycle WP near the original position of a group makes it to return to its WP 0. Cycle WP doesnt represent a position at all, it is just there to link one WP with another.
As said, you need TWO waypoints as minimum and then the Cycle one placed close to the wp that will be the next. If you have a single WP and then cycle, then if cycle is closer to start position (WP 0) than WP1, the group will return to start position. If cycle wp is closer to WP1, then the group will be at WP1 forever.

Offline sardaukar17

  • Members
  • *
Re: Cycle Waypoints in Script Format
« Reply #6 on: 01 Sep 2009, 08:10:49 »
I currently have this thing set up to choose randomly 6 out of 25 possible waypoints in and around a city. The last of the 6 waypoints is the cycle waypoint always set to city center. The start positions are set way out from the main city which are also chosen randomly. Everything works like a charm except that at that last waypoint they stop. 

I just tried removing all the other setwaypoint commands from the Cycle waypoint itself Other than the cycle command which had no effect

I also did a check to make sure the string is actually reaching the cycle waypoint and it is.

I noticed that  that pirin used the group name in the location section of his Waypoint array. Tried that as a shot in the dark and had no effect.

I also found a way to make the last waypoint the same as the first one. (not the start) No effect.

I have no idea why this thing isn't working.

Offline sardaukar17

  • Members
  • *
Re: Cycle Waypoints in Script Format
« Reply #7 on: 06 Sep 2009, 17:53:44 »
I was doing this:

Code: [Select]
#wp1
_wp1 = _grp addWaypoint [wp1, 1]
[wp1, 1] setWaypointType "MOVE"
[wp1, 1] setwaypointBehaviour "COMBAT"
[wp1, 1] setwaypointcombatmode "RED"
[wp1, 1] setWaypointSpeed "NORMAL"
When I should have been doing this:

Code: [Select]
#wp1
_wp1 = _veh addWaypoint [wp1, 1]
_wp1 setWaypointType "SAD"
_wp1 setwaypointBehaviour "Aware"
_wp1 setwaypointcombatmode "RED"
_wp1 setWaypointSpeed "NORMAL"

Offline jones

  • Members
  • *
Re: Cycle Waypoints in Script Format
« Reply #8 on: 10 Sep 2009, 21:52:08 »
Try using the taskpatrol function in the function module.

If it doesn't fully suit your need, take a look at it and use that as a template.

Quote
scriptName "Functions\spawning\fn_taskPatrol.sqf";
/*
   File: taskPatrol.sqf
   Author: Joris-Jan van 't Land

   Description:
   Create a random patrol of several waypoints around a given position.

   Parameter(s):
   _this select 0: the group to which to assign the waypoints (Group)
   _this select 1: the position on which to base the patrol (Array)
   _this select 2: the maximum distance between waypoints (Number)
   _this select 3: (optional) blacklist of areas (Array)
   
   Returns:
   Boolean - success flag
*/