• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Random move...

Status
Not open for further replies.
Level 3
Joined
Jul 13, 2010
Messages
46
do:




  • Events
  • Map Initalization
  • Actions
  • Variable - Set movepoint - position of Unit
  • Events
  • Time - Every 0.01
  • Actions
  • Variable - Set range - Distance between position of unit and movepoint
hope it helps.

  • Events
  • Value of real variable - range less than or equal to 50
  • Actions
  • Variable - Set movepoint - random point in region
  • Unit - order Unit to attack move to movepoint
 
  • Trigger
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • Set Points[1] = (Position of (Your unit))
    • Set Points[2] = (Points[1] offset by (Random real number between 150.00 and 300.00) towards (Random angle))
    • Unit - Order (Your unit) to Move to Points[2]
    • Custom script: call RemoveLocation (udg_Points[1])
    • Custom script: call RemoveLocation (udg_Points[2])
Edit: Damn backup ;p
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
Hmmm it don't work - just the unit moves one time but not a second time... here are my triggers:

  • Trig 1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Trigger - Run Trig 2 <gen> (ignoring conditions)
  • Trig 2
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Set Points[1] = (Position of (Picked unit))
      • Set Points[2] = (Points[1] offset by (Random real number between 150.00 and 300.00) towards (Random angle) degrees)
      • Unit - Order (Entering unit) to Move To Points[2]
      • Custom script: call RemoveLocation (udg_Points[1])
      • Custom script: call RemoveLocation (udg_Points[2])

Variable : Type: Point, 2 array
Custom script : i don't know what this is , just copy from Pharaoh_ :D

Please help! :cry:
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Trust me, use this ability instead:

attachment.php


Equip this ability in ANY unit you want in their "Abilities - Normal"
 

Attachments

  • untitled.JPG
    untitled.JPG
    207.3 KB · Views: 175
Level 3
Joined
Jul 13, 2010
Messages
46
  • Trigger
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • Set Points[1] = (Position of (Your unit))
    • Set Points[2] = (Points[1] offset by (Random real number between 150.00 and 300.00) towards (Random angle))
    • Unit - Order (Your unit) to Move to Points[2]
    • Custom script: call RemoveLocation (udg_Points[1])
    • Custom script: call RemoveLocation (udg_Points[2])
but every second the point is set.The unit would walk and stop on the spot.the trigger i mentioned runs a check on whether the unit has reached the area and generates an area afterwards.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
(Note to author: I'm sorry to go into this subject deeper, if you want a unit to move randomly: use Wander, like defskull mentioned a few times before).

but every second the point is set.The unit would walk and stop on the spot.the trigger i mentioned runs a check on whether the unit has reached the area and generates an area afterwards.
Still, "every 0.01 seconds" is NOT good: I always use every 0.032 seconds (JASS), or every 0.03 seconds (GUI).
And since it's just to check the distance between two points, every 0.30 seconds would do (also goes unnoticed).

Additionally, your triggers do not support multiple units (only 1 unit, if you want more units to randomly wander it'll fail).
And of course, you do not remove the leak (only change the variable to another location, it still leaks that way).
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
"every second at long distances", the unit probably won't reach his final destination in one second.

I attached the base system (exactly as you described it), it probably needs some fixes, but this is to show you you should explain your problem correctly :wink:
 

Attachments

  • Wander.w3x
    16.7 KB · Views: 44
Level 28
Joined
Jan 26, 2007
Messages
4,789
Wow, how can you know the trigger is in JASS without downloading it? o_O
Either way, it's not hard: right-click the trigger and select "copy", go to your map and paste it :D

It should always work, BUT: it makes ALL units on the map move every 1 second, no exceptions (except locusts I think, but whatever, nobody cares about those).
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
The only thing that worries me is that every unit will move... Lets say i have 10 units that have to move with the trigger and i have runner controlled by me (the runner don't need to make a random move) and if the runner touches the units - he dies. That's all i need, thanks again. :)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I edited the above system. You do need to set up one thing now: check the first trigger ("vis") and change the "RunnerType" to the unit type of the runner. That'd be all.

I could do the touch runner-thing as well (not hard), but then it would require you to understand how I do things like that :p (I would create the runners via triggers, store them in a variable and then create a new event for every runner).
 

Attachments

  • Wander.w3m
    16.8 KB · Views: 40
Last edited:
Status
Not open for further replies.
Top