OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Black Operative on 14 Jun 2003, 12:32:28

Title: doMove with slightly random destination?
Post by: Black Operative on 14 Jun 2003, 12:32:28
Hi fellas! :)

How can I make a soldier move to another soldier using the doMove command (not waypoints!)- but I do not want to just make him move to the exact location of the other soldier, I'd rather have him move to a point that is set randomly in an area of about 50 meters AROUND the soldier.


JUST AN EXAMPLE, I ASSUME IT'S A ENTIRELY WRONG WAY OF DOING IT:  ;)
In my example, I want a soldier called "SS2" to move to a random position around a standing soldier called "SS1". So dere's da code:

SS2 doMove [(getPos SS1 select 0)+(random 20-random 30), (getPos SS1 select 1)+(random 20-random 30), getPos SS2 select 2]

But with this the unit SS2 always moves to a random position LEFT of the soldier SS1.


Thanks in advance for any help! :)
Title: Re:doMove with slightly random destination?
Post by: LCD on 14 Jun 2003, 12:46:56
u r close ;D but i think more bout (not sure ;D)

Code: [Select]
SS2 doMove [(getPos SS1 select 0)-50+(random 100), (getPos SS1 select 1)-50+(random 100), getPos SS2 select 2]

but ur way is workin also ;D

LCD OUT
Title: Re:doMove with slightly random destination?
Post by: Black Operative on 14 Jun 2003, 12:53:16
u r close ;D but i think more bout (not sure ;D)

Code: [Select]
SS2 doMove [(getPos SS1 select 0)-50+(random 100), (getPos SS1 select 1)-50+(random 100), getPos SS2 select 2]

but ur way is workin also ;D

LCD OUT

Yes, this is working perfectly. Can't quite make out the difference between the two systems of calculating the pos  ;D but yours is working as I had it in mind.
I also tried my way again- REALLY isn't working.  :-\ Maybe it's da touch of your holy coding hand or somin' ;)

Thanks anyway, great master!  ;D