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

Restrict unit's movement radius

Status
Not open for further replies.
Level 5
Joined
Sep 27, 2011
Messages
141
K but even if the units movement speed is 0 it won't allow to move within the givin range because it won't be able to get back into it. And what does unit prop window do?
 
Level 8
Joined
Apr 26, 2011
Messages
403
try play around with some of game constant.

I think there are one call "guard distance" or similar, but those setting are very buggy, I heard it only work for creep and may not work for player's unit.

for example, the neutral creep in Dota will walk back to spawn point if they move too far.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Custom script: call SetUnitPropWindow(*unit*, 0) is the best way. If you set Movement Speed to 0, it will never allow your unit to go under you "Minimum Speed" you can change in the Gamplay Constants, however, UnitPropWindow = 0 works for what you want, and goes over the minimum movement speed, since it doesn't mess with Movement Speed, but with something else, I don't know what :p But prevents moving :D
 
Level 5
Joined
Sep 27, 2011
Messages
141
Still as i said before this will cause the unit to completely be unable to move i just want it to be as if the unit was blocked from going any further like with paving blockers but i can't use them as they will block other units as well.
 
Level 12
Joined
Oct 16, 2010
Messages
680
So u would like to do a barrier spell or something? Or just to cause the creeps not to move too far away from camp positions?
If u want the first one then the best way is pulling back the unit(i can help if u want) and i think this is it, don't know how could that be possible in other ways. (if u would like it to effect only the enemy units)
 
Level 5
Joined
Sep 27, 2011
Messages
141
Ok ill tell you what its actually for. I have created towers that are meant to have a specific movement range but i just need them to be able to move them no further than their range from their original point without affecting the creeps.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here's the basic idea:

  • System
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in grp and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between (Position of (Picked unit)) and (Center of (Playable map area))) Greater than or equal to 500.00
            • Then - Actions
              • Unit - Move (Picked unit) instantly to ((Center of (Playable map area)) offset by 500.00 towards (Angle from (Center of (Playable map area)) to (Position of (Picked unit))) degrees)
            • Else - Actions
Add units into the group. If the group is empty, turn the trigger off.

As each unit can have a different center point, you could store it into a hashtable and then load it in this trigger. Alternatively, use a unit indexer by Bribe (got to spells database for that) and a point array.

Clear leaks: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Level 5
Joined
Sep 27, 2011
Messages
141
Ok i have made my trigger and it works but doesn't look that good that's why i would have prefered something that simply blocks it from going further. Well since no one seems to be able to give me a gui solution is this possible using jass if a jass solution is given please explain to me how to use it and i would give +rep if i knew how.
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
Use SetUnitX/Y, which you do not find in GUI. These do not interrupt orders and such. Therefore it will look like your unit keeps running against an invisible wall.

Considering Maker's trigger as starting position, save the radius in a variable "radius" and your center location in a variable "center". Then replace your current Move action with two "Custom Script" lines (3rd action from above in the all actions list) and put this in:

JASS:
call SetUnitX(GetEnumUnit(), GetLocationX(udg_center) + udg_radius * Cos(Atan2(GetUnitY(GetEnumUnit()) - GetLocationY(udg_center), GetUnitX(GetEnumUnit()) - GetLocationX(udg_center))))
call SetUnitY(GetEnumUnit(), GetLocationY(udg_center) + udg_radius * Sin(Atan2(GetUnitY(GetEnumUnit()) - GetLocationY(udg_center), GetUnitX(GetEnumUnit()) - GetLocationX(udg_center))))
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Okay I have created a system for you

The settings are in the SPMS Setup trigger

You need to use the Unit - A unit enters (Playable map area) to register your unit into the trigger

You're talking about towers, right ?

I assumed it must be built by your workers or something, therefore when the tower first enters the map (not built yet, but when the worker initially starts to build its base of the structure), the 'towers' or we refer it as unit in the trigger, will be automatically be registered, therefore the system is going on :)

Have fun!
 

Attachments

  • Simple Prevention Movement System.w3x
    15.1 KB · Views: 82
Level 5
Joined
Sep 27, 2011
Messages
141
Thanks defskull i have tried to include your system in my map however it does not stop the units from moving to far and dont know why i will upload what ive got so far so please if you can find whats wrong tell me the units are added to the group in the start spawn units trigger and you are all welcome to play the first wave if you wish. Also tell me what you think thanks guys for all your help.:ogre_haosis:
 

Attachments

  • Mercenary TD.w3x
    67.9 KB · Views: 30
Level 33
Joined
Mar 27, 2008
Messages
8,035
It is because, in your map, each unit has different settings of Area of Effect indicator, therefore, you need to set for each of the unit in a trigger

Like for example, Bandit Lord has different AoE compared to Bandit, therefore a setup for each unit is required

As you can see from my original test map, did you notice the DistanceMax variable ?

That is your restriction radius for a unit

In that test map, I only make it for only 1 unit, therefore it does not suit your map since you want it to vary for each unit (you never mention this in the first post, therefore your information is misleading)

Next time, please be specific...

Don't just keep adding conditions in every post, it will make us helpers, tired.

EDIT:
Or you can reset your original location instead of restricting movement ?
 
Status
Not open for further replies.
Top