Home   Help Search Login Register  

Author Topic: Random patrol script using objects  (Read 1040 times)

0 Members and 2 Guests are viewing this topic.

fahterbob

  • Guest
Random patrol script using objects
« on: 16 Jun 2003, 21:08:58 »
1st ?
The idear is to make a group move from one marker point to the next. Thus creating a partol rute. The problem is, that the script doesnt wait until the group is ready - it just "ignores" the @unitready...????

#Loop
"MarkerOne" SetMarkerPos GetPos (object xxxxx)
[UnitOne,1] SetWPPos GetMarkerPos "MarkerOne"
@UnitReady [UnitOne,1]
"MarkerOne" SetMarkerPos GetPos (object yyyyy)
[UnitOne,1] SetWPPos GetMarkerPos "MarkerOne"
@UnitReady [UnitOne,1]
goto "loop"

2'nd ?
If I would like to have 4 object ID's and make the script randomly choose between theese objects - how would I do that ?

Regards
:afro: - [RT] ThåMadz

fahterbob

  • Guest
Re:Random patrol script using objects
« Reply #1 on: 16 Jun 2003, 21:29:59 »
#Loop
"MarkerOne" SetMarkerPos GetPos (object xxxxx)
[UnitOne,1] SetWPPos GetMarkerPos "MarkerOne"
@UnitReady [UnitOne,1]
"MarkerOne" SetMarkerPos GetPos (object yyyyy)
[UnitOne,1] SetWPPos GetMarkerPos "MarkerOne"
@UnitReady [UnitOne,1]
goto "loop"

Okaay I admit it - stupid like a barfin' allycat.
@ Unitready - and not @UnitReady .....DOUGH !

Anyway - 2 ? I still haven't figgerd out.
Help would be gratefuly apriciated.

Regards
 :afro: [RT] ThÃ¥Madz

deaddog

  • Guest
Re:Random patrol script using objects
« Reply #2 on: 16 Jun 2003, 22:02:11 »
Quote
@UnitReady [UnitOne,1]

That is incorrect syntax.  Use:
@unitready (leader unitone)

And replace this:
Quote
"MarkerOne" SetMarkerPos GetPos (object xxxxx)
[UnitOne,1] SetWPPos GetMarkerPos "MarkerOne"

with this:

unitone move getpos (object xxxxx)

You don't need the markers if you are already using an object as the destination.
Also,  @unitready is to be used in conjunction with a move or domove command, not with the setwppos command.  Basically, in your script, the unit is always ready because it hasn't been ordered anywhere.
« Last Edit: 16 Jun 2003, 22:05:58 by deaddog »

fahterbob

  • Guest
Re:Random patrol script using objects
« Reply #3 on: 16 Jun 2003, 23:46:43 »
Markers are only used for debuggin.
I use setwppos so I can control groups behaviour and formation etc. in a singel waypoint.
Keeps me from specifying it in scrpit.....sorry, but it's the easy way.

Anyway script works like a charm now with setwppos and @ unitready.

Now all I need is a rutine to make the unit choose randomly between 4 specified objects - and I have a random patrol rute with dynamic waypoints.

*Help* anyone ?

Regards
:afro: [RT] ThåMadz

Ace

  • Guest
Re:Random patrol script using objects
« Reply #4 on: 17 Jun 2003, 11:04:22 »
check ed depot for icarus_uk random patrol script.

fahterbob

  • Guest
Re:Random patrol script using objects
« Reply #5 on: 17 Jun 2003, 13:36:43 »
check ed depot for icarus_uk random patrol script.
Sorry , no luck.

*Help* Any one ?

Regards
:afro: [RT] ThåMadz

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:Random patrol script using objects
« Reply #6 on: 17 Jun 2003, 14:10:37 »
To :
Quote
make the script randomly choose between theese objects

you could :

create an array with your four objects :

Code: [Select]
_myarray=[_obj1,_obj2,_obj3,_obj4]
and then type something like :

Code: [Select]
_chosenobj=_myarray select (random 3)
This should do what you are looking for, even though I haven't tested it myself.

Another suggestion is to use toadlife's shuffle function.

Hope this helps.

*edit :*
 first suggestion doesn't seem to be satisfactory, check this thread.
« Last Edit: 17 Jun 2003, 14:25:18 by Igor Drukov »

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:Random patrol script using objects
« Reply #7 on: 17 Jun 2003, 20:54:48 »
I've made a random patrol script that doesn't need any WP at all.

->  http://www.ofpec.com/editors/resource_view.php?id=526

fahterbob

  • Guest
Re:Random patrol script using objects
« Reply #8 on: 17 Jun 2003, 21:16:16 »
Tnx Igor, that did the trick.

So heres the script for making a patrol move randomly between 4 objects, like 4 buildings, lampposts etc.

#Start
_obj1 = getpos (object 22222)
_obj2 = getpos (object 33333)
_obj3 = getpos (object 44444)
_obj4 = getpos (object 11111)
_myarray   = [_obj1,_obj2,_obj3,_obj4]
_choose = _myarray select (random 3)
"MarkerOne" SetMarkerPos _choose
[UnitOne,1] SetWPPos GetMarkerPos "ptr"
@ UnitReady [UnitOne,1]
Goto "start"

It should make AI patrols less predictebel, yet controlebel.
Now just add grouplink II and U'r set for a hours, off sneeking through the bushes.

*Tnx* all
Regards
:afro: [RT] ThåMadz