Set Unit Location X,Y

the_ideal

user title
Reaction score
61
I thought there was a way to set a unit's location by coordinates in GUI. Was I incorrect? I can't seem to find the function. Do I need a custom script? If so, what's the script if my x and y are variables?

Thanks a lot! +rep to helpful stuff
 

the_ideal

user title
Reaction score
61
Thanks.

So is this good? No leaks?

Trigger:
  • Events
    • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap Teleport
    • Actions
      • Set point1 = (Position of (Target unit of ability being cast))
      • Set real_temp = (X of (Position of (Target unit of ability being cast)))
      • Set real_temp2 = (Y of (Position of (Target unit of ability being cast)))
      • Custom script: call SetUnitX(GetTriggerUnit(), udg_realtemp)
      • Custom script: call SetUnitY(GetTriggerUnit(), udg_realtemp2)
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at point1 facing 0.00 degrees
      • Special Effect - Create a special effect attached to the origin of (Triggering unit) using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
      • Unit - Add Thunder Clap (dummy) to (Last created unit)
      • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: call RemoveLocation (udg_point1)
 

Jedi

New Member
Reaction score
63
No, you can't use coordinates in GUI(directly).So you need to remove that X and Y.

Also position of target unit of ability being cast leaks.
 

the_ideal

user title
Reaction score
61
No, you can't use coordinates in GUI(directly).So you need to remove that X and Y.

Also position of target unit of ability being cast leaks.

Sorry, can you clarify? I'm not sure what you mean. I'm trying to avoid using Move Unit Instantly because it interrupts the cooldown of the ability, and I don't want to use a wait.
 

BRUTAL

I'm working
Reaction score
118
Change
Code:
Set point1 = (Position of (Target unit of ability being cast))
Set real_temp = (X of (Position of (Target unit of ability being cast)))
Set real_temp2 = (Y of (Position of (Target unit of ability being cast)))
to
Code:
Set point1 = (Position of (Target unit of ability being cast))
Set real_temp = (X of (point1)
Set real_temp2 = (Y of (point1)
Other then that, it should work fine.
 

the_ideal

user title
Reaction score
61
It gives me two compile errors for the call SetUnitX(GetTriggerUnit(), udg_realtemp) lines... it says "Expected a name."
 

BRUTAL

I'm working
Reaction score
118
You forgot to put the underscores, that are part of the variable names, in the custom scripts.
 

Bogrim

y hello thar
Reaction score
154
A simpler method:
Trigger:
  • Actions
    • Set Temp_Point = (Your position)
    • Custom script: call SetUnitX( GetTriggerUnit(), GetLocationX(udg_Temp_Point) )
    • Custom script: call SetUnitY( GetTriggerUnit(), GetLocationY(udg_Temp_Point) )
    • Custom script: RemoveLocation( udg_Temp_Point )
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
you can do the very same with the GUI function move unit instantly to position.
the only advantage of setting the units X / Y is to keep its current order but as you trigger the movement with an ability being cast there is no need for it.
 

PrisonLove

Hard Realist
Reaction score
78
you can do the very same with the GUI function move unit instantly to position.
the only advantage of setting the units X / Y is to keep its current order but as you trigger the movement with an ability being cast there is no need for it.

He's right, it seems that your making some sort of ability that instantly moves your unit to the target unit (blink strike maybe?). In this case there is no need to preserve the unit's order, since it is moved after the desired order has been issued.

There are only three differences between setting coordinates, and using Move instantly and they are:

1. Setting coordinates preserves the unit's current order, whereas using Move instantly eliminates the order.

2. Setting coordinates can be used without the need for a location, and therefore there would be no leaks, but that requires a bit more effort. Move instantly requires a location, and therefore requires the trigger maker to clean a leak.

3. Setting coordinates ignores pathing, Move unit instantly does not. This is very important as it can cause some unwanted errors, and can even send the unit outside of the map bounds, causing the game to crash!

The way to the spell location's X and Y without the need for the actual location would be:

for a unit targeted spell:


for a point targeted spell:
JASS:


for an instant cast spell (no target):


The preceeding functions would give you the coordinates for all types of spells without the need for using any locations, and therefore you can set coordinates without worrying about leaks. (Note: there are no GUI functions for these, they exist only in JASS)

I just gave you much more information than you wanted/needed to know, but I have nothing else to do at the moment, except maybe play Modern Warfare 2 while I wait for my friend to pick me up so we can go to the gym.

So in conclusion (tl;dr) - You don't have to set coordinates for the spell that you are making, it would be easier to use:
Trigger:
  • Unit - Move Unit Instantly
and then just remove the leak. If you desire to use coordinates, I just gave you three ways to get the x and y values of your spell's location without the need for a location, thus making it leakless.

Sorry for the wall of text.
 

Bogrim

y hello thar
Reaction score
154
you can do the very same with the GUI function move unit instantly to position.
the only advantage of setting the units X / Y is to keep its current order but as you trigger the movement with an ability being cast there is no need for it.
There's a large difference between using set unit X/Y and setunitlocation, Acc. Setting a unit's X/Y also ignores pathing, where setunitlocation will take walkability into account automatically.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
There's a large difference between using set unit X/Y and setunitlocation, Acc. Setting a unit's X/Y also ignores pathing, where setunitlocation will take walkability into account automatically.

yes that is right but i just assume he doesnt really need the custom script for what he wants to do.
 

the_ideal

user title
Reaction score
61
Thanks for all the responses. The problem is, for some reason when I move the unit instantly, the cooldown of the ability doesn't activate. This doesn't make sense because I'm using "starts the effect of an ability." I added a .5 second wait at the beginning, and the cooldown did work, but obviously I don't want to put a wait in there. Why is the cooldown not activating? (my ability is based off channel, and I've tried it with a 0.00 and a 0.01 follow through time)
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
in this case the usage of setUnitX/Y really will help, though using a wait of 0.00 seconds would do so as well.
 

PrisonLove

Hard Realist
Reaction score
78
Try setting follow through time to 0? Or will that make it loop forever? I usually use a follow through time of 1 on all my channel based spells and it never acts up like that.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Try setting follow through time to 0? Or will that make it loop forever? I usually use a follow through time of 1 on all my channel based spells and it never acts up like that.

a time of 0.00 will make it last forever.

sorry for stupid question:
where I change the text below my user name?

you need a certain amount of reputation to do so.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top