Home   Help Search Login Register  

Author Topic: check soldier's position in script  (Read 469 times)

0 Members and 4 Guests are viewing this topic.

Joe

  • Guest
check soldier's position in script
« on: 12 Apr 2004, 18:23:43 »
hi, this my first post and  a rather simple question ( i hope)

im calling this script with a trigger, it orders a soldier to move an ammodump and perform a working animation. unfortunately i haven't found out yet how to check if the soldier has reached the assigned position (game logic named "dump"). but i need this check, otherwise the guy first goes through the anim and afterwards proceeds to the ammodump.
script enclosed below

edit: the position check always produces the error "type array, expected number,string,object,side,group"

Code: [Select]
;find position of ammocache
_cachepos = getpos dump
_cachex = _cachepos select 0
_cachey = _cachepos select 1
_cachez = _cachepos select 2

;soldiers move to ammocache
ap5 domove [_cachex, _cachey,0]
~5

;check if soldier has reached position
_soldierpos = getpos ap5
_soldierposx = _soldierpos select 0
_soldierposy = _soldierpos select 1
_soldierposz = _soldierpos select 2

?(_soldierpos == _cachepos): goto "loop"

;soldier performs animation
#loop
ap5 playmove "CombattoPutDown"

exit

any help greatly welcome  ;D
« Last Edit: 12 Apr 2004, 18:26:15 by Joe »

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:check soldier's position in script
« Reply #1 on: 12 Apr 2004, 18:27:36 »
? (ap5 distance dump) < 2 : ap5 switchmove "TipToeThruTheMineFieldWithEightCadillacsOnHisBack"

Or something like that.

:beat: *Gets Shot* :beat:

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:check soldier's position in script
« Reply #2 on: 12 Apr 2004, 18:28:29 »
Oh and BTW, welcome to the forums m8y.

:beat: *Gets Shot* :beat:

Joe

  • Guest
Re:check soldier's position in script
« Reply #3 on: 12 Apr 2004, 19:02:45 »
Thanks a lot Armstrong!
a good idea, unfortunately it doesn't work. For some reason the soldier moves to the ammodump but doesn't do the animation.
well a least there is no error-warning, so i'll try to improve on your suggestion.
regards,
j

Joe

  • Guest
Re:check soldier's position in script
« Reply #4 on: 12 Apr 2004, 20:00:31 »
maybe the distance check has to be repeated until the condition is true?
can this be done?
i've tried to solve this with a loop but apparently i'm way too dumb.
anyway, maybe somebody out there has an idea ???

regards
j

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:check soldier's position in script
« Reply #5 on: 12 Apr 2004, 20:02:45 »
No, you're not dumb. OFP is a tart, that's all. :P

Try

@ (ap5 distance dump) < 5 : ap5 switchmove "TipToeThruTheMineFieldWithEightCadillacsOnHisBack"

That should do it I think.

:beat: *Gets Animated* :beat:

Joe

  • Guest
Re:check soldier's position in script
« Reply #6 on: 12 Apr 2004, 20:14:23 »
Yay, I've solved it.  armstrong, vou put me on the right track!

working code:
@ (ap5 distance dump) < 1
ap5 playmove "CombatToPutDown"

thanks a lot for the kind advice  :)

joe