Home   Help Search Login Register  

Author Topic: Total Random Movement without WP's  (Read 892 times)

0 Members and 1 Guest are viewing this topic.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Total Random Movement without WP's
« on: 22 Aug 2002, 20:46:05 »
Ok I have an idea for a new mission.  Theres a convoy moving along the roads of the island.  It starts at a random location (not really random, but one of 73 places where markers are placed).  A script is activated in the init, this script tells to which marker to drive to next.  When it arrives at the marker the script then tells the convoy to drive to another location.

Now I have thought of a number of ways of doing this.

One is that I have a script that tells the convoy where to drive to.  Once it checks the distance of the convoy to the destination and the convoy has arrived it selects another destination from the list and tells the convoy to driver there.  Wash, rinse and repeat.

The other way is to have triggers instead of markers (or over the top of markers).  They detect the leader of the convoy and tell the convoy to go to another marker.  The trigger will only send the convoy to one location.  But on the route the convoy may pass over another trigger which will send the convoy to yet another location.

Which is the best way of doing it do you reckon?  Is it possible to randomly select a marker from a list of 73?  Would running a script continually slow the game down?  What effect would a mass of trigger have on the game?

Offline Black_Feather

  • Former Staff
  • ****
  • I'll never forget you Daisey.
Re:Total Random Movement without WP's
« Reply #1 on: 22 Aug 2002, 20:56:14 »
how about something like this

#loop
_number = Random 10
? ((_number mod 1) >= 0.5): _number = _number + 1
_number = _number - (_number mod 1)

? _number == 0 :truckname domove getpos logic0;goto "end"
? _number == 1 :truckname domove getpos logic1;goto "end"
? _number == 2 :truckname domove getpos logic2;goto "end"
? _number == 3 :truckname domove getpos logic3;goto "end"
? _number == 4 :truckname domove getpos logic4;goto "end"
? _number == 5 :truckname domove getpos logic5;goto "end"
? _number == 6 :truckname domove getpos logic6;goto "end"
? _number == 7 :truckname domove getpos logic7;goto "end"
? _number == 8 :truckname domove getpos logic8;goto "end"
? _number == 9 :truckname domove getpos logic9;goto "end"
? _number == 10 :truckname domove getpos logic10;goto "end"
#end
@unitready truckname
goto "loop"

Bremmer

  • Guest
Re:Total Random Movement without WP's
« Reply #2 on: 23 Aug 2002, 21:06:46 »
Black_Feather's idea looks good (don't they always  8)), but you might be able to save on some typing by putting the logics into and array (_logics = [logic1,logic2 ...]) then using:

_random = random (count _logics)
truck domove getpos (_logics select _random)


Beware though that AI are useless at navigating in towns, and frequently get snarled up at corners.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Total Random Movement without WP's
« Reply #3 on: 24 Aug 2002, 19:38:59 »
Works nicely.  I added in a check for the distance to the destination then it selects another logic and heads out again.

Problem I have encountered is that only the leader of a group moves, well technically its only the unit name "truck".  Even if "truck" is a group leader his fellow group members dont go with him.  Is there a fix for this?  I want a convoy moving, not just a lone unit.

Offline Black_Feather

  • Former Staff
  • ****
  • I'll never forget you Daisey.
Re:Total Random Movement without WP's
« Reply #4 on: 24 Aug 2002, 19:49:35 »
try using move instead of domove

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Total Random Movement without WP's
« Reply #5 on: 24 Aug 2002, 21:05:45 »
'Twas indeed the Move.  Trés bien.

This is most perplexing.  How do I get the script to wait till my distance line is correct?

So far the distance check is written thusly;

?(truck distance _RandomLogic) < 10: Goto "RoundAgain"

Now its all setup correctly apart from the fact that it doesnt wait until its true.  So how do I get it to wait?  I always thought you put a @ infront of the brackets like the ? is, but when I do that I get an error.
« Last Edit: 24 Aug 2002, 21:37:36 by [icarus_uk] »

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Total Random Movement without WP's
« Reply #6 on: 24 Aug 2002, 21:43:56 »
Hoho, a much faster and less typing way.

Put in the gamelogics.  Put a trigger over them and select it to detect gamelogics present.  Give it a name, here I have used "LogicList".

Then the script is just this;


_logics = List LogicList

#GetAnotherPosition

_random = random (count _Logics)

_randomLogic = _logics select _random

truck move getpos (_RandomLogic)

?(truck distance _RandomLogic) < 10: Goto "GetAnotherPosition"


And there we have it. Alot less typing.

But I still need an answer on that waiting to detect malarky.
« Last Edit: 24 Aug 2002, 21:44:45 by [icarus_uk] »

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Total Random Movement without WP's
« Reply #7 on: 25 Aug 2002, 00:16:50 »
Note the script wont run from the init.  Only a trigger or WP.

Bremmer

  • Guest
Re:Total Random Movement without WP's
« Reply #8 on: 25 Aug 2002, 00:21:28 »
using an @ isn't the same as using a ?

The ? is determined instantaneously (or pretty close) and is either true or false. Either way the script carries on with what it should be doing. A question also needs an outcome that will depend on whether the expression is true or false.

An @ forces the script to halt until the condition becomes true. Only then will the script continue. You don't need to define true/false outcomes since the script will not continue unless the expression is true. Therefore if you look at your command you should see the problem -

@(truck distance _RandomLogic) < 10 : Goto "GetAnotherPosition"[/i]

The last bit is totally redundant. What you should have is:

@(truck distance _RandomLogic) < 10
Goto "GetAnotherPosition"

I hope that makes some sort of sense.

 :)

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Total Random Movement without WP's
« Reply #9 on: 25 Aug 2002, 02:44:22 »


[attachment deleted by admin]
« Last Edit: 25 Aug 2002, 02:55:35 by [icarus_uk] »

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:Total Random Movement without WP's
« Reply #10 on: 28 Feb 2003, 22:51:45 »
Someone wanted the finished script along with a sample mission.  So here it all is.