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

Keeping Two Units Together Within a Boundry

Status
Not open for further replies.
Level 6
Joined
May 1, 2009
Messages
156
I'm wondering how I can get my two characters to not be able to leave a certain distance away from each other. I.e. "Bob cant get 500.00 spaces away from Jim without being teleported back to Jim." Help!
 
Level 6
Joined
May 1, 2009
Messages
215
Events
Unit A is within 800 range of Unit B
Actions
Move Unit A to position of Unit B offeset by x,y
Display text "lol you can't separate those doods, guys"

something like that

If you want an effect, the easiest way would be to give Unit A a blink ability and have it cast it at the position of B (then removing the ability immediately after), though that could be a potential point of abuse.

The above should work fine though, if you don't mind the fact there isn't any SFX, just a message telling the player not to do that.

You could also do it with an aura, if a unit leaves the range of the aura, he's teleported back to the unit.

...The messiest way would be to create a rather large region and place it at the position of your hero, make a trigger move the region to the position of Unit B every 0.5-1 seconds, if Unit A leaves that region, teleport him back to the center of the region. That's just an idea though, now that I think of it, something like that wouldn't probably work.
 
Level 6
Joined
May 1, 2009
Messages
156
Thanks man for the aura idea, but the unit A getting to certain range of unit B doesnt work because if A is already inside that range he can leave that range and will only be teleported back to unit B if he leaves the range then comes back into the range. Oh and the region thing also has kind of same problem, idk its screwed also but i'll try aura thing, ty.


(EDIT) Only event i can find corresponding is unit begins effect of an ability or unit unit notices a target in range, but then again im falling off my seat tired so... not really thinking about it hard.
 
Level 8
Joined
Dec 8, 2007
Messages
312
Here is a simple way
  • Events
    • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set point1 = (Position of (Triggering unit))
      • Set point2 = (Position of (Triggering unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between point1 and point2) Greater than or equal to 500.00
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to point1
        • Else - Actions
      • Custom script: call RemoveLocation(udg_point1)
      • Custom script: call RemoveLocation(udg_point2)
condition for if then else can be found in Real Comparison. Look for Math - Distance between points.

If you don't know what means fixing leaks you can ignore last 2 lines
 
Status
Not open for further replies.
Top