Home   Help Search Login Register  

Author Topic: Vehicle follow marker Help!  (Read 1398 times)

0 Members and 1 Guest are viewing this topic.

Offline Mille

  • Members
  • *
Vehicle follow marker Help!
« on: 28 Dec 2008, 12:55:02 »
Somebody would be able to help, it how it is possible to do that it is a vehicle markers not though waypoint. Car Follow marker "w1" "w2" "w3" "w4" "w5" and other.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Vehicle follow marker Help!
« Reply #1 on: 28 Dec 2008, 13:04:52 »
Have a look at the doMove command in the COMREF.  :good:

Offline Mille

  • Members
  • *
Re: Vehicle follow marker Help!
« Reply #2 on: 28 Dec 2008, 18:49:22 »
yes yes but the moveto command only a wp for me multiple wp would be needed. :(
« Last Edit: 28 Dec 2008, 19:10:55 by bedges »

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re: Vehicle follow marker Help!
« Reply #3 on: 28 Dec 2008, 19:36:34 »
I'm sorry not exactly following that. But with the doMove command, you specify a position to move to, not a necessarily a WP.

So, if you wanted a unit to move to the position of a marker called w1, you could find it's position using
Code: [Select]
w1Pos = getMarkerPos w1

The doMove command uses the format:
unit/vehicle doMove position
such as
Code: [Select]
myBodyguard doMove (position blondeWoman)
I'm sure you can figure the rest of that out. ;)

Then, if you have many markers, you can just loop through them with a script, making sure you wait until the unit is ready (hint unitReady) before you issue the next doMove.

[EDIT] Haha, thanks bedges. Forgot that you can't send a unit directly to a marker...
« Last Edit: 28 Dec 2008, 20:03:01 by Tyger »
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: Vehicle follow marker Help!
« Reply #4 on: 28 Dec 2008, 19:39:29 »
Firstly, don't quote the post to which you're replying - it's a waste of space and bandwidth.

If you have multiple markers, and you wish a unit or group to move to those markers in succession, all you need is a small script to use the doMove command each time you wish to change the target marker. The obvious question is: why don't you want to do this with waypoints?

The usual answer is that you want the unit/group to move to the markers in any order, which can be a hassle to set up with waypoints. Doing the same thing with markers naturally introduces the problem of how to determine the distance between your unit/group and the destination marker. You could either create a Game Logic and place it at the marker's position, or you could use the ID of a pre-existing object on the map - which would negate the use of markers, since you could just tell the unit/group to move to the object's position. That said, markers can be moved: map objects cannot.

Either way, the following example should get you started on the right path:

Call using group player exec "marker_waypoints.sqs"

Code: (marker_waypoints.sqs) [Select]
; set up variables
_group = _this select 0
_markers = ['marker1', 'my_marker', 'church_marker', 'another_marker']
_current_marker = 0

;create a game logic
gl = "logic" createvehicle [0,0,0]

#marker_loop
; move the game logic to the current marker's position
gl setpos (getmarkerpos (_markers select _current_marker))

; move the unit/group
#move_loop
leader _group domove getpos gl
~5

; if the unit/group is within 5 metres, choose the next marker
? (leader _group distance gl) > 5 : goto "move_loop"

_current_marker = _current_marker + 1

; if it's the last marker, go back to the first
? (_current_marker >= count _markers) : _current_marker = 0

; still going?
? (alive leader _group) : goto "marker_loop"
exit
« Last Edit: 29 Dec 2008, 18:36:48 by bedges »

Offline Mille

  • Members
  • *
Re: Vehicle follow marker Help!
« Reply #5 on: 29 Dec 2008, 08:24:26 »
I say thank you for it I start understanding the thing.

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re: Vehicle follow marker Help!
« Reply #6 on: 30 Dec 2008, 02:11:46 »
Doing the same thing with markers naturally introduces the problem of how to determine the distance between your unit/group and the destination marker.

Er, the distance command parameters are either object or position. So you can find the distance in between a unit/group and the destination marker.

Code: [Select]
; Define variables
_markers = ["marker_town","marker_church","marker_camp","marker_road"]
; Define which marker to start at. We assume the first marker
_index = 0

; Where all the fun happens
#MainLoop
; Check that there is someone alive in the group
? (count units _this < 1) : exit

; Send the group to the marker. This prevents the issue of the rest of the units in the group staying at
; their current position while the leader runs off. The units will still maintain formation since you
; are preforming the equivalent of ordering a team to a location.
units _this doMove (getMarkerPos (_markers select _index))
~5

; Wait until they are 5 meters from the marker or less
?(leader _this distance (getMarkerPos (_markers select _index)) > 5): goto "MainLoop"

; Move to the next marker
_index = _index + 1

; If you are trying to use a marker that doesn't exsist, loop back to the first
?(_index > count _markers) : _index = 0

; Continue script
goto "MainLoop"

A quick note, the (alive leader _group) test can cause the script to execute prematurely. If the leader is killed, and the group has not realized/radioed the information yet, the leader of the group will be dead while there are still more members to carry on the patrol. Unless your intent was to exit if the leader is dead.

Also, your script would not have executed, because you are sending it a group, not an array. So when you declare
Code: [Select]
_group = _this select 0the game would flag an error.
« Last Edit: 30 Dec 2008, 02:15:28 by Tyger »
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08