- Joined
- Oct 11, 2012
- Messages
- 711
I would like to make an ability that can make the hero instantly move to the back of the target. How can I do that?
Thanks.
Thanks.
I would like to make an ability that can make the hero instantly move to the back of the target. How can I do that?
Thanks.
That won't do. Not only does it leak location, it will also move the caster to random position around the target. Geshishouhu wants fixed location - behind the target.
- Sample Trigger
- Events
- Unit - A unit Starts the effect of an ability
- Conditions
- (Ability being cast) Equal to Whatever Ability
- Actions
- Unit - Move (Casting unit) instantly to (Position of (Targeted unit))
That won't do. Not only does it leak location, it will also move the caster to random position around the target. Geshishouhu wants fixed location - behind the target.
The key lies in understanding the Point With Polar Offset function.
Here's how you do it:
- Ability
- Events
- Unit - A unit Starts the effect of an ability
- Conditions
- (Ability being cast) Equal to Your Ability
- Actions
- Unit - Move (Triggering unit) instantly to ((Position of (Target unit of ability being cast)) offset by 100.00 towards ((Facing of (Target unit of ability being cast)) - 180.00) degrees)
Your Ability should of course be an ability with a unit target (like Storm Bolt) for this to work properly.
I've attatched a map using Storm Bolt as example ability to trigger off of. Study the trigger, learn about the function and implement it with your own ability.
That trigger leaks. You have to save Position of Targeted unit into point variable first and then save the Offset point into another point variable.
For efficiency sake, it may be better to also save targeted unit into variable xD
local real x1
local real y1
local real x2
local real y2
local real dx=x2-x1
local real dy=y2-y1
local real angle=Atan2(dy,dx)
local real distance=SquareRoot(dx*dx+dy*dy)
set x2=x1+distance*Cos(angle)
set y2=y1+distance*Sin(angle)
Alright, thanks. Do you know how to set the hero's facing after the move? I want it to face the target's back. I set the facing angle the same as the target but it didn't work out.
Edit: if the hero and the target were facing each other before the move, then the hero needs to turn around after moving to the target's back. What I want is that the hero faces the target's back after the move, no need to turn around.
Edit: it works, thanks guys!
Edit: should I use the following code instead of using PolarProjectionBJ?
JASS:local real x1 local real y1 local real x2 local real y2 local real dx=x2-x1 local real dy=y2-y1 local real angle=Atan2(dy,dx) local real distance=SquareRoot(dx*dx+dy*dy) set x2=x1+distance*Cos(angle) set y2=y1+distance*Sin(angle)
I hope DIMF can see this, LOL
Why are you setting the distance like that? Shouldn't it be constant. (10010~50 units for melee attack)
The projection seems fine.
It is always easier to make a function you use to return the distance. You can use that function and only have to make it once.
Also use one for the angles. ( i believe it has it in spell below.)
Look at my implosion bomb spell. ( i believe it has it in that one.)
When getting angle like said use the facing angle + or - 180. ( doesn't matter)
To make the unit face the angle of the unit that you base the facing angle off of. Get the units facing angle and face it that way.
Remember to set facing when creating unit otherwise you have about .5 second facing angle delay. ( worst case)
Why are you setting the distance like that? Shouldn't it be constant. (10010~50 units for melee attack)
The projection seems fine.
Ooo sry you are moving unit lol. I'm not thinking much.
Yes move then setfacing.