• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Yet Another AOE Angle Knockback Question

Status
Not open for further replies.
Level 6
Joined
Apr 27, 2006
Messages
186
Lets say I have 2 units, unit A and unit B and they are in a position similar to this:
A
..\
...\
....B
I want unit B to move away from unit A so the units will end up something like this (i.e. a simple knock-back spell)
A
.\
..\
...\
....B
This seemed fairly easily to trigger for me, and this was the trigger I had when I was done:
Move Unit B to Position of Unit B offset by -500 towards unit A.
For some reason unit B only moved closer to unit A, so I thought, ok apparently world editor won't let me use negative distances, logical enough. So then I tried using this trigger code:
Move Unit B to position of Unit B offset by 500 towards angle between unit A and unit B. And this didn't work either.
So I know this seems like a stupid question to ask, but I looked at a few knockback posts in the forums, and I couldn't find it, so how do you move a unit AWAY from another unit?
 
Level 6
Joined
Apr 27, 2006
Messages
186
Weird all right I'll test my map again, thanks for the help. And Paskovish, I honestly lokoed at maybe the top 5 posts with knockback in them (I did a search), and most of them didn't help, they pushed units TOWARDS a point rather than away from it XD.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Simply you must push the unit AWAY from the caster via polar projection or in jass, maths. You basicly have to get the angle to the unit that pushed the moving unit and add 180 degrees to it, then give a POSITIVE distence.

Equaly well you could make it that when the pusher impacts it makes a location as a reference ad it does the above actions but for the location, not the pusher.

Or you could run your distence culculation as the pusher impacts and get a target location and via % you move the pushed unit's X+Y equaly towards the end point.

You could also apply basic physics and via angles and forces generate a slowing down movement away from the pusher.

Do not see why this is so hard, this type was one of my fisrt spells I made. . .
 
Level 6
Joined
Apr 27, 2006
Messages
186
It isn't hard for me and I did exactly what you told me to and it still doesn't work :\.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Let u be the pusher, and u2 be the pushed.

a is the angle, d the distance (replace it with a real), x the new x, y the new y

JASS:
local real a = Atan2( GetUnitY( u2 ) - GetUnitY( u ), GetUnitX( u2 ) - GetUnitX( u ) )
local real x = GetUnitX( u ) + d * Cos( a )
local real y = GetUnitY( u ) + d * Sin( a )
 
Level 6
Joined
Apr 27, 2006
Messages
186
Alright it seems people have been ignoring my posts when I post my long triggers, but this time the trigger is fairly short, please take a look at it and tell me what's wrong, because I'm not bad at math, I'm not bad at programming, and I think it's either a stupid mistake I'm making of some exception in blizzard's faulty WE programming XD (Since there MANY bugs like being unable to change the level of the item ability that increases maximum hitpoints on a unit), anyways here is the trigger's actions:

  • Set TempUnits = (Units within 250.00 of (Position of (Attacked unit)) matching ((((Matching unit) is alive) Equal to True) and (((Point-value of (Matching unit)) Not equal to 90) and (((Owner of (Attacked unit)) is an enemy of (Owner of (Matching unit))) Equal to True))))
  • Unit Group - Pick every unit in TempUnits and do (Actions)
    • Loop - Actions
      • Unit - Cause (Attacked unit) to damage (Picked unit), dealing (100.00 x (Real((Level of Explosive Shot for (Attacked unit))))) damage of attack type Spells and damage type Normal
      • For each (Integer A) from 1 to 100, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain cliff level at (Position of (Picked unit))) Equal to (Terrain cliff level at ((Position of (Picked unit)) offset by -3.00 towards (Angle from (Position of (Attacked unit)) to (Position of (Picked unit))) degrees))
            • Then - Actions
              • Unit - Move (Picked unit) instantly to ((Position of (Attacked unit)) offset by 3.00 towards (180.00 + (Angle from (Position of (Attacked unit)) to (Position of (Picked unit)))) degrees)
            • Else - Actions
  • Custom script: call DestroyGroup (udg_TempUnits)
 
Last edited by a moderator:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Learn maths.

Your move action is faulty.
You need to move the picked unit to the position of picked unit towards the direction the picked unit is to the attacked unit.

  • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 3.00 towards (Angle from (Position of (Attacked unit)) to (Position of (Picked unit))) degrees)
You may want to remove leaks or it WILL lag if used a lot. . .
 
Level 6
Joined
Apr 27, 2006
Messages
186
My bad, thats a different trigger, my math is fine, It's supposed to move away from the attacked unit, but it doesn't work, so ya.
 
Status
Not open for further replies.
Top