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

Moving unit instantly when far

Status
Not open for further replies.
  • HeroMove
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to <THE UNIT'S SPELL>
    • Actions
      • Set PointVariable = (Position of (Triggering unit))
      • Set PointVariable2 = (Position of <HERO>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between PointVariable and PointVariable2) Greater than or equal to <YOUR DISTANCE>
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to PointVariable2
        • Else - Actions
      • Custom script: call RemoveLocation(udg_PointVariable)
      • Custom script: call RemoveLocation(udg_PointVariable2)
That is how it'd look if the unit were to cast a spell. If you want them to be moved in general when they are far away, then use this:
  • HeroMove
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set PointVariable = (Position of <YOUR UNIT>)
      • Set PointVariable2 = (Position of <YOUR HERO>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between PointVariable and PointVariable2) Greater than or equal to <YOUR DISTANCE>
        • Then - Actions
          • Unit - Move <YOUR UNIT> instantly to PointVariable2
        • Else - Actions
      • Custom script: call RemoveLocation(udg_PointVariable)
      • Custom script: call RemoveLocation(udg_PointVariable2)
If you want it so that ALL (or certain units, but more than one) units will be ported near the hero if they are too far, then do this:
  • HeroMove
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Actions)
  • //You can modify the condition of this however you'd like
    • Loop - Actions
      • Set PointVariable = (Position of (Picked unit))
      • Set PointVariable2 = (Position of <YOUR HERO>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between PointVariable and PointVariable2) Greater than or equal to <YOUR DISTANCE>
        • Then - Actions
          • Unit - Move (Picked unit) instantly to PointVariable2
        • Else - Actions
      • Custom script: call RemoveLocation(udg_PointVariable)
      • Custom script: call RemoveLocation(udg_PointVariable2)
Good luck. =)
 
Level 10
Joined
Mar 31, 2009
Messages
732
Please post threads like this in the Requests forum. You clearly have no intention of learning how to do this yourself, nor do you want assistance fixing something you've written.

Be more descriptive about exactly how your spell should work.
 
Status
Not open for further replies.
Top