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,463
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,463
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,463
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,463
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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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