Home   Help Search Login Register  

Author Topic: DoMove question  (Read 1805 times)

0 Members and 1 Guest are viewing this topic.

Offline Yasirotta

  • Members
  • *
DoMove question
« on: 31 May 2009, 21:46:31 »
im using DoMove command in script, like this:

Code: [Select]
_cost = 25
_pos = getmarkerpos "apple"
_pos2 = getmarkerpos "sako2"
?(playeerimoney < _cost):goto "cantafford"
playeerimoney = playeerimoney - _cost
hint format ["I have %1 in my pocket.",playeerimoney]
playeeri removeaction taxitown1
~1
playeeri moveincargo taxi1
taxi1 domove _pos
~2
tax1 domove _pos2
#check
~1
?( playeeri distance taxi1 < 2):goto "check"
?(taxi1 distance apple > 10):goto "check"
exit
#cantafford
hint "You cannot afford this"
exit

Well, tax1 start to moving _pos but after 2 sec it takes new direction to _pos2  :confused:
How i can make it so, that first move must be done, before tax1 takes new direction to _pos2 ?
« Last Edit: 31 May 2009, 22:25:13 by Yasirotta »

Walter_E_Kurtz

  • Guest
Re: DoMove question
« Reply #1 on: 01 Jun 2009, 02:11:04 »
First, check your spelling. Are tax1 and taxi1 different or should they be the same?

Use unitReady to check if a unit has arrived at its destination.

This would mean some slight rearranging of the script to put the second destination in the "check" loop (assuming tax1 should be taxi1):
Code: [Select]
playeeri moveincargo taxi1
taxi1 domove _pos

#check
~1
? (unitReady taxi1): taxi1 domove _pos2
? (playeeri distance taxi1 < 2): goto "check"
? (taxi1 distance _pos > 10): goto "check"     <--- using _pos instead of apple

@ (unitReady taxi1)     <--- ensures the taxi moves onto _pos2 even if the loop is broken
taxi1 domove _pos2
exit

Offline Yasirotta

  • Members
  • *
Re: DoMove question
« Reply #2 on: 01 Jun 2009, 15:54:24 »
Yes, it was typo  :whistle: tax1 should be taxi1

The script works now, but i still get error. Taxi1 moves to first _pos, and goes then to _pos2.
Still, when taxi1 reaches _pos2 and playeeri jumps off from taxi1,  cames this kinda error message:

'(taxi1 distance _pos > |#| 10)': Error distance: Type Array, expected Object

My whole script of taxitown1.sqs:

Code: [Select]
_cost = 25
_pos = getmarkerpos "apple"
_pos2 = getmarkerpos "sako2"
?(playeerimoney < _cost):goto "cantafford"
playeerimoney = playeerimoney - _cost
hint format ["I have %1 in my pocket.",playeerimoney]
playeeri removeaction taxitown1
~1
playeeri moveincargo taxi1
taxi1 domove _pos


#check
~1
? (unitReady taxi1): taxi1 domove _pos2
? (playeeri distance taxi1 < 2): goto "check"
? (taxi1 distance _pos > 10): goto "check"

@ (unitReady taxi1)
taxi1 domove _pos2

#cantafford
hint "You cannot afford this"
exit

And other script for taking the taxi in taxi1.sqs (in case you need it):
Code: [Select]
#check
?( playeeri distance taxi1 < 5):goto "actions"
~1
goto "check"
#actions
taxitown1 = playeeri addaction ["Take a trip to Apple Hill ($25)","taxitown1.sqs"]
#check2
~1
?( playeeri distance taxi1 < 5):goto "check2"
playeeri removeaction taxitown1
goto "check"
« Last Edit: 01 Jun 2009, 16:11:25 by Yasirotta »

Walter_E_Kurtz

  • Guest
Re: DoMove question
« Reply #3 on: 01 Jun 2009, 16:48:44 »
That's me being foolish. As posted in your other thread:

Quote from: Worldeater, May 28, 2009, 07:38:49 PM
In OFP the distance command expects two objects, using arrays won't work.
What's been tried so far is _pos which is a location in 3 dimensions and "apple" which is a marker. You could try putting "apple" back, but I don't think it will work.

You could try using another object - something nearby or place an invisible H - or else do some trigonometry.
Code: [Select]
? ( (((getPos taxi1 select 0) - (_pos select 0)) ^ 2) +  (((getPos taxi1 select 1) - (_pos select 1)) ^ 2) ) > 100: goto "check"

Offline Yasirotta

  • Members
  • *
Re: DoMove question
« Reply #4 on: 01 Jun 2009, 17:03:24 »
Well, my turn to be foolish and ask where i put that line in my script  :-[

Also, trying to drop player (in script playeeri) to _pos and taxi1 would go to _pos2.

Im using this code:
Code: [Select]
playeeri action ["EJECT", vehicle playeeri]
Or, if easier way whit these im happy if you can help. My ribs are now broken, and eating so much painkiller that my mind isn´t working as 100%  :good:

Walter_E_Kurtz

  • Guest
Re: DoMove question
« Reply #5 on: 01 Jun 2009, 17:11:39 »
Well, my turn to be foolish and ask where i put that line in my script  :-[

Instead of ? (taxi1 distance _pos > 10): goto "check"

Offline Yasirotta

  • Members
  • *
Re: DoMove question
« Reply #6 on: 01 Jun 2009, 18:21:37 »
Thank you, now it works whitout error.
Still, just wonderin how i can throw player out from that taxi1 at _pos before taxi1 goes to _pos2 ???

Walter_E_Kurtz

  • Guest
Re: DoMove question
« Reply #7 on: 01 Jun 2009, 23:23:42 »
Here's an absolutely bare-bones script I've just been practising with, take from it whatever you need:
Code: [Select]
_pos = getMarkerPos "apple"
_pos2 = getMarkerPos "orange"

player moveInCargo taxi1

taxi1 doMove _pos

#journey1
~1
? (unitReady taxi1): goto "destination"
goto "journey1"

#destination
if (player in taxi1) then {(driver taxi1) globalchat "We're here."} else {goto "journey2"}

~10
if (player in taxi1) then {(driver taxi1) globalchat "Get out, you bum."; unassignVehicle player; player action ["Eject", taxi1]}

#journey2
taxi1 doMove _pos2

exit
Once the script is started, the taxi will make the journey (to _pos and then on to _pos2) all on it's own - whether the player is on board or not.
The player will only receive messages if he is in the taxi at the time.
If he does not get out at _pos, he will be kicked out after 10 seconds.

Offline Yasirotta

  • Members
  • *
Re: DoMove question
« Reply #8 on: 02 Jun 2009, 11:30:33 »
Thank you very much, this is lovely !

Well, your script is working but one tiny problem found.
I have moneycheck, that checks do player have money to take taxi. I have tried to put that "you cant afford this" diffrent places but it always shows that as hint, even if you can afford it. I think this script checks all #-marked, so umm... help ?

Code: [Select]
_cost = 25
_pos = getmarkerpos "apple"
_pos2 = getmarkerpos "sako2"
?(playeerimoney < _cost):goto "cantafford"
playeerimoney = playeerimoney - _cost
hint format ["I have %1 in my pocket.",playeerimoney]
playeeri removeaction taxitown1
~1
playeeri moveincargo taxi1
taxi1 domove _pos

#journey1
~1
? (unitReady taxi1): goto "destination"
goto "journey1"

#destination
if (playeeri in taxi1) then {(driver taxi1) globalchat "We're here."} else {goto "journey2"}

~10
if (playeeri in taxi1) then {(driver taxi1) globalchat "Get out, you bum."; unassignVehicle playeeri; playeeri action ["Eject", taxi1]}

#journey2
taxi1 doMove _pos2

#cantafford
hint "You cannot afford this"

exit
« Last Edit: 02 Jun 2009, 11:54:03 by Yasirotta »

Walter_E_Kurtz

  • Guest
Re: DoMove question
« Reply #9 on: 02 Jun 2009, 15:28:13 »
Add another exit after #journey2, to end the script there (ie. once the taxi has finished its route):
Code: [Select]
#journey2
taxi1 doMove _pos2

exit   <---


#cantafford
hint "You cannot afford this"

exit