| 04-03-2004, 07:54 AM | #1 |
How do I make this: Units that has no order (standing still) to make them attack move to a region I can't get this to work with -Pick Units and then If / Then / Else- ----- Unit Group - Pick every unit in (Units of type Worm Hunter) and do (If ((Current order of (Picked unit)) Equal to (Order(stop))) then do (Unit - Order (Triggering unit) to Attack-Move To (Center of GoldMines[(Random integer number between 1 and 15)])) else do (Do nothing)) That's how I made it, but it doesn't work :\ |
| 04-03-2004, 12:02 PM | #2 |
The thing is, there is no straight out way to detect if a unit is idle. My best idea is to make 3 parralel arrays, one representing the unit to check, one representing the X position of it, and one representing the Y. You would fill up these arrays using the pick every player, then later on check to see if the unit in the first array is not moving (corresponding to the old X and Y of the second and third array). If that makes no sense, then Ill explain. |
| 04-03-2004, 12:13 PM | #3 |
You're welcome to explain :D |
| 04-03-2004, 01:31 PM | #4 |
Ok you are going to need 2 different arrays. One will be the unit itself. The other will hold the units position. They will relate to each other because the unit(3) will be where point(3) designates. I hope you know how to make arrays. Here's the code you want: Code:
Events: 5 seconds have passed Actions: Pick every unit in (units in(playable map area)) and do multiple actions[indent]unitcounter = unitcounter + 1 unit(unitcounter) = (picked unit) point(unitcounter) = (position of(picked unit)) [/indent] Unitcounter is so each array 'element' (section) will have a different unit. Think about this trigger for a bit and you will understand what it does. Now the code to check if units are idle. Code:
Events: Periodic Event: every 5 seconds Actions: For each integer A from 1 to (units in(playable map area)) do multiple functions[indent]If unit(integer A) = point(integer A) then [i]order unit to wherever [/i]else do nothing. [/indent] What this does is look at every unit and check it to the old position of the unit. If the unit is still where it used to be, then its considered idle, and ordered wherever you want it to go. Just think about this trigger for a bit, and you'll probably get it. |
| 04-03-2004, 02:39 PM | #5 |
Nice, Thanks for the help! I will try it out ASAP! |
| 04-03-2004, 10:00 PM | #6 | |
Quote:
|
