• 🏆 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!

Distance Between Points

Status
Not open for further replies.
Level 6
Joined
May 1, 2009
Messages
156
Hi, I'm trying to make it so when my character comes in 500 range of any of the neutral passive animals in the Forest region the animals basically run to a random point in the forest region.
  • Spook
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
      • (Distance between (Position of Villager (Male 2) 0011 <gen>) and (Position of (Picked unit))) Less than or equal to 500.00
    • Actions
      • Unit Group - Pick every unit in (Units owned by Neutral Passive) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Move To (Random point in (Playable map area))
The Unit group action is just me messin around with it but I dont know how to have it so any units in that 500 range will do the action of moving to random point in the Forest Region (Playable Map area is wrong)
 
Level 9
Joined
May 28, 2007
Messages
365
Yeah, that's a bad way to do it.

I'm not sure the best way to do it, but here is a suggestion.

Pick every unit in (Units Owned By Neatural Passive) and do...
Event - Register Event (unit comes within 500 range of picked unit) for the trigger (ANOTHER TRIGGER)

Then in ANOTHER TRIGGER
Action - Issue Point Order( thetriggerunit(), randomarea )

Really rough, hope you get it.
 
  • Trigger
  • Events
    • Time - Every 0.20 seconds of game time
  • Conditions
  • Actions
    • Set Points[1] = (Position of (Villager (Male 2) 0011 <gen>)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (your forest region) matching ((Owner of (Matching unit)) Equal to Neutral Passive) and do (Actions)
      • Loop - Actions
        • Set Points[2] = (Position of (Picked unit))
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (Distance between Points[1] and Points[2]) Less than or Equal to 500.00
          • Then - Actions
            • Set Points[3] = (Random point in (your forest region))
            • Unit - Order (Picked unit) to Move To (Points[3])
            • Custom script: call RemoveLocation (udg_Points[3])
          • Else - Actions
        • Custom script: call RemoveLocation (udg_Points[2])
    • Custom script: call RemoveLocation (udg_Points[1])
Picked unit cannot be used in the main condition, since you do not do any pick of units. Try the one I gave you.
References:
[•] http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/variables-5896/

I wouldn't do the trigger this way, but I just edited your trigger, so that it actually works.
 
Level 6
Joined
May 1, 2009
Messages
156
THaNk yOu both...

And the picked unit thing was just me clicking around because i had no idea how to do it.

Thank you again
 
Status
Not open for further replies.
Top