• 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.

[Trigger] Pushing a unit backwards

Status
Not open for further replies.
Level 4
Joined
Dec 10, 2008
Messages
59
I know the first thing that comes into mind when u view this thread is: "Knockback, go get one from the spells section"

Yes, i had the same thought too when i first thought about this spell. But, correct me if i'm wrong, knockback means u push a unit backwards with increasing distance. However, what i'm looking for is a way to push a unit backwards, with no increase in distance. Meaning, it's like i'm right in front of you, and pushing you to the wall constantly, instead of exerting all the pushing force at one go.

An of course, if you need an overview of how the spell goes, it's like this:

A unit channels a huge circular mass of....power?...in front of him and then the huge circular mass of powaaaaa moves forward with increasing speed. As it moves, any unit within a short distance from the mass of powaaaa will be damaged and gets, well, pushed back.

Thanks in advance for any help!
 
Level 2
Joined
Jan 29, 2009
Messages
21
If you're not familiar with JASS, it may seem daunting, but look through the code for the already posted knockback spells. There's no need to do the grunt work when the foundation is already there.

You simply need to find the areas where the knockback distance is changed, and instead keep that constant. For instance, if you see something like "set x = dx * some variable" or any modification to a variable that is used in the call that moves a unit. Just remove that statement so that the distance knocked back is always the same.

If you need some help understanding the code when you're trying to look through it, feel free to ask.

You could also do it easily in GUI, but its sloppy, inefficient, and leaks very easily. If you're more comfortable with that, ask for it and I'll help with that as well.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
If I understand you correctly, you can still use knockback systems. Instead of moving the 1 unit in the knockback system, you pick all units that are to be effected by it. This includes your mass of power and all units that come in contact with it. When they come in contact with it, add them to the group that's going to be knocked back.

So to clear it up a bit: Every time the mass of power is moved a bit, pick all units in range of it and add them to the group. Then move all units in the group a bit further and repeat the previous step.
 
Level 4
Joined
Dec 10, 2008
Messages
59
If you're not familiar with JASS, it may seem daunting, but look through the code for the already posted knockback spells. There's no need to do the grunt work when the foundation is already there.

You simply need to find the areas where the knockback distance is changed, and instead keep that constant. For instance, if you see something like "set x = dx * some variable" or any modification to a variable that is used in the call that moves a unit. Just remove that statement so that the distance knocked back is always the same.

If you need some help understanding the code when you're trying to look through it, feel free to ask.

You could also do it easily in GUI, but its sloppy, inefficient, and leaks very easily. If you're more comfortable with that, ask for it and I'll help with that as well.

Ugh...i rather not touch JASS yet...I took a look at Dynasti's knockback system. Not that i hate it, i love it, i just don't know how to modify it the way you said it could. (other fields which can be easily modified, yes, i comprehend)

I'd prefer GUI for now...because indeed i'm much more comfortable and familiar with it (at this point in time, surely). So if it doesn't cause you much trouble, i'd like to have a look how it's possibly done in GUI. (just the pushing part will do...to lessen difficulties).


If I understand you correctly, you can still use knockback systems. Instead of moving the 1 unit in the knockback system, you pick all units that are to be effected by it. This includes your mass of power and all units that come in contact with it. When they come in contact with it, add them to the group that's going to be knocked back.

So to clear it up a bit: Every time the mass of power is moved a bit, pick all units in range of it and add them to the group. Then move all units in the group a bit further and repeat the previous step.

provided i myself, in turn, understood you correctly. U're saying adding a group to the knockback? But that also eliminates the purpose of my question:

knocbacking without increasing the distance (from the affecting object).

(once again, i apologize if i misunderstood your statement)
 
Fatty, double post.

And it is possible to make it MUI in GUI, you just need an indexing system. And the periodic time event should be more like 0.03 or maybe 0.04.

What you need is:

Trigger 1:
Events: Unit starts the effects of an ability
Conditions: Ability being cast equal to <Your Ability>
Actions:
Create 1 mass of powaa for owner of triggering unit at (position of triggering unit offset by 200 towards facing angle of triggering unit) facing (facing angle of triggering unit)
Set powaas[Total] = last created unit
if Total equal to 0 then turn on Trigger 2
set Total = Total + 1

Trigger 2:
Events: Every 0.03 seconds
Actions:
For each Integer A from 0 to Total do
Move powaas[Integer A] to position of powaas[Integer A] offset by 10 towards (facing angle of powaas[Integer A].
Set tempGroup = Units within 200 of powaas[Integer A]
Pick every unit in tempGroup and do actions
Move Picked Unit to position of Picked Unit offset by 10 towards (facing angle of powaas[Integer A]
 
Level 4
Joined
Dec 10, 2008
Messages
59
Fatty, double post.

And it is possible to make it MUI in GUI, you just need an indexing system. And the periodic time event should be more like 0.03 or maybe 0.04.

What you need is:

Trigger 1:
Events: Unit starts the effects of an ability
Conditions: Ability being cast equal to <Your Ability>
Actions:
Create 1 mass of powaa for owner of triggering unit at (position of triggering unit offset by 200 towards facing angle of triggering unit) facing (facing angle of triggering unit)
Set powaas[Total] = last created unit
if Total equal to 0 then turn on Trigger 2
set Total = Total + 1

Trigger 2:
Events: Every 0.03 seconds
Actions:
For each Integer A from 0 to Total do
Move powaas[Integer A] to position of powaas[Integer A] offset by 10 towards (facing angle of powaas[Integer A].
Set tempGroup = Units within 200 of powaas[Integer A]
Pick every unit in tempGroup and do actions
Move Picked Unit to position of Picked Unit offset by 10 towards (facing angle of powaas[Integer A]

Hmm...okay, i THINK i get it. (never attempted to use indexing before, it's used to make spell MUI iirc?)

Ok, i haven't test the thing out, but i have a question (considering your method works): how to do i make it so that after it travels X unit distance, it disappears?
 
Level 10
Joined
Jun 1, 2008
Messages
485
ops! sorry. I post it without even see the post below.
but you must increasing total before use it to save variable, or it will make the first array number is 0. and, as you know, it can cause bug. let me explain it below in algorithm way.
Cast
Array Number = 0
Total = (0) + 1 = 1

Cast
Array Number = 1
Total = (1) + 1 = 2

Cast
Array Number = 2
Total = (2) + 1 = 3

Finished (Array number is 1)
Total = (3) - 1 = 2

Cast
Array Number = 2 (Already used!)
Total = (2) + 1 = 3

as far as i know, Paladon Indexing System cause this bug too.

and, what's the point setting this:
set powaas[Integer A] = powaas[Total]
set distance[Integer A] = distance[Total]
it will make glitch if the array numbered [Total] is in use.

well, what you explain is just the basic, This was just information of that.

gonna delete some post above.
 
ops! sorry. I post it without even see the post below.
but you must increasing total before use it to save variable, or it will make the first array number is 0. and, as you know, it can cause bug. let me explain it below in algorithm way.
It doesn't cause any glitch in Jass, why should it cause a glitch in GUI?

as far as i know, Paladon Indexing System cause this bug too.

and, what's the point setting this:
set powaas[Integer A] = powaas[Total]
set distance[Integer A] = distance[Total]
it will make glitch if the array numbered [Total] is in use.

well, what you explain is just the basic, This was just information of that.
No, think about it and you will understand. the array numbered Total cannot be in use at this point.
 
Level 10
Joined
Jun 1, 2008
Messages
485
sorry, you're right. Array number 0 is not cause glitch.

And, It can be used because you reduce total first, then setting variable. Swap it and it will not cause a glitch.

let's say like this:

Unit that have array number 1 is finished pushed.
Let's say total number is 5, meaning there was 5 unit is pushed (Include this finished pushed unit)

Then you set like this

Total = Total - 1 = (5) - 1
set powaas[1] = powaas[4]
set distance[1] = distance[4]

and, as you know, there was a unit that use array number 4. It will mixed then cause a bug.
 
Level 4
Joined
Dec 10, 2008
Messages
59
Okaaaaay......well, it might take some time to understand what u guys posted...but for now i'm exhausted (it's 1:30am in the morning here). Been working my ass off on a few other abilities too....

well, i'll try to dig everything after i get some sleep.

For now many thanks!
 
Level 10
Joined
Jun 1, 2008
Messages
485
redscores, he need a constant moving knockback. yours is periodically decreasing the speed.

En_Fuego, the MUI Methods posted by PurplePoot below you tutorial is not fully MUI. It have limit to 200 unit at same time. If it used by more than 200 unit, it will mixed.

moomoocow1314, let me post the trigger if you still confused. here:
  • Cast Powaa Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to <Your Spell>
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Total Equal to 0
        • Then - Actions
          • Trigger - Turn on Periodic Trigger <gen>
        • Else - Actions
      • Set Point[1] = (Position of (Triggering unit))
      • Unit - Create 1 <Powaa> for (Owner of (Triggering unit)) at Point[1] facing (Facing of (Triggering unit)) degrees
      • Set Powaa[Total] = (Last created unit)
      • Set CountUnit[Total] = 0
      • Set PowaaTraveled[Total] = 0.00
      • Set Total = (Total + 1)
      • Custom script: call RemoveLocation(udg_Point[1])
And for Periodic Trigger
  • Periodic Trigger
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to Total, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Powaa[(Integer A)] Not equal to No unit
            • Then - Actions
              • Set Point[1] = (Position of Powaa[(Integer A)])
              • Set Point[2] = (Point[1] offset by 10.00 towards (Facing of Powaa[(Integer A)]) degrees)
              • Unit - Move Powaa[(Integer A)] instantly to Point[2]
              • Set PowaaTraveled[(Integer A)] = (PowaaTraveled[(Integer A)] + 10.00)
              • Set Temp_Group = (Units within 100.00 of Point[2] matching (((Matching unit) belongs to an enemy of (Owner of Powaa[(Integer A)])) Equal to True))
              • Unit Group - Pick every unit in Temp_Group and do (Actions)
                • Loop - Actions
                  • Unit - Cause Powaa[(Integer A)] to damage (Picked unit), dealing <damage> damage of attack type Spells and damage type Normal
                  • Unit - Pause (Picked unit)
                  • Set KnockbackedUnit[Total2] = (Picked unit)
                  • Set KnockBackTraveled[(Integer A)] = 0.00
                  • Set Total2 = (Total2 + 1)
              • Set CountUnit[(Integer A)] = (CountUnit[(Integer A)] + (Number of units in Temp_Group))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • CountUnit[(Integer A)] Greater than or equal to <Your Max Pushed Unit>
                      • PowaaTraveled[(Integer A)] Greater than or equal to <Max Distance Moved>
                • Then - Actions
                  • Unit - Kill Powaa[(Integer A)]
                  • Set Total = (Total - 1)
                  • Set Powaa[(Integer A)] = Powaa[Total]
                  • Set PowaaTraveled[(Integer A)] = PowaaTraveled[Total]
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Point[1])
              • Custom script: call RemoveLocation(udg_Point[2])
            • Else - Actions
      • For each (Integer A) from 1 to Total2, do (Actions)
        • Loop - Actions
          • Set Point[1] = (Position of KnockbackedUnit[(Integer A)])
          • Set Point[2] = (Point[1] offset by 10.00 towards (Facing of KnockbackedUnit[(Integer A)]) degrees)
          • Unit - Move KnockbackedUnit[(Integer A)] instantly to Point[2]
          • Set KnockBackTraveled[(Integer A)] = (KnockBackTraveled[(Integer A)] + 10.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • KnockBackTraveled[(Integer A)] Greater than or equal to <Max distance of pushed unit>
            • Then - Actions
              • Unit - Unpause (Picked unit)
              • Set Total2 = (Total2 - 1)
              • Set KnockbackedUnit[(Integer A)] = KnockbackedUnit[Total2]
              • Set KnockBackTraveled[(Integer A)] = KnockBackTraveled[Total2]
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Point[1])
          • Custom script: call RemoveLocation(udg_Point[2])
Element of Water have explain the Index system, so i use it here.
And, change the data inside bracket to fit your spell.
If you still confused, then post what you don't know, I'll answer it.

And, to Element of Water, now i know you're right about setting variable like this:
Total = Total - 1 = (5) - 1
set powaas[1] = powaas[4]
set distance[1] = distance[4]
it will prevent the bug i founded first. because it will set the last array to this free array. Brilliant ideas to indexing system.
 
Last edited:
Level 4
Joined
Dec 10, 2008
Messages
59
one question, as i'm about to try it out.

I notice it looks alot like Paladon's indexing system (because it is......wtf rhetorical). But i notice the difference from above is in Paladon's skill maps, he uses an Integer Variable instead of (Integer A).

So...if i were to use integer A, i would only require to change the periodic trigger's integer A with <my integer variable's name>, right?

Can i first set everything in the cast trigger (the initial trigger) to a variable? eg. the facing angle. Moreover, can the pick units within the unit groups be set to a variable like Effected_Unit [<integer variable>]?

I notice u didn't the store the triggering, can i store it? (so meaning, if i store it, based on your post, it'll be Ability_Caster [Total] = Trigger Unit?)

What variable is this: PowaaTravelled? Distance between two points, or a real?

thanks, those are the last bits and piece i need to understand.

EDIT: just tried it with the above triggers...it's...strange. Instead of pushing the units further away, it draws the units backwards towards the caster....hmm, maybe it's because of the unanswered factors.

One more thing before i forget....how do i control the speed at which the mass of powaaaa moves? (sorry if i sound like i'm asking too much >__>)
 
Last edited:
1. You don't need to use your own variable, Integer A does just fine because there are no waits in it.

2. You can store as many variables as you like, just remember to transfer them to the right place in the array when the ball stops

3. You can store the triggering unit, yes.

4. It is a real variable. It measures the total distance travelled from where it started.

5. You can control the speed by changing the 10.00 in this:
  • Set Point[2] = (Point[1] offset by 10.00 towards (Facing of KnockbackedUnit[(Integer A)]) degrees)
and in this:
  • Set KnockBackTraveled[(Integer A)] = (KnockBackTraveled[(Integer A)] + 10.00)
About it drawing units towards the caster - that's probably a mistake on Mage_Goo's part, or maybe you copied the trigger wrong?
 
Level 4
Joined
Dec 10, 2008
Messages
59
1. You don't need to use your own variable, Integer A does just fine because there are no waits in it.

2. You can store as many variables as you like, just remember to transfer them to the right place in the array when the ball stops

3. You can store the triggering unit, yes.

4. It is a real variable. It measures the total distance travelled from where it started.

5. You can control the speed by changing the 10.00 in this:
  • Set Point[2] = (Point[1] offset by 10.00 towards (Facing of KnockbackedUnit[(Integer A)]) degrees)
and in this:
  • Set KnockBackTraveled[(Integer A)] = (KnockBackTraveled[(Integer A)] + 10.00)
About it drawing units towards the caster - that's probably a mistake on Mage_Goo's part, or maybe you copied the trigger wrong?

Thanks for your reply.

As for the errors, i'm pretty damn sure i copied everything correctly....*looks at it again with my panda-like eyes for the 5th time*

For now i'll wait till Mage replies....
 
Level 10
Joined
Jun 1, 2008
Messages
485
ok, i forgot something. What i post above move the unit to its facing angle
You must save the angle of effected unit to real variable.
So, you must add this when start to move unit.
  • Set KnockbackAngle[(Integer A)] = (Facing of Powaa[(Integer A)])
and set point[2] like this
  • Set Point[2] = (Point[1] offset by 10.00 towards KnockbackAngle[(Integer A)] degrees)
Above is to make effected unit to move toward facing of Powaa. So, it like dragged by Powaa.
if you want it pushed beside of Powaa, use this
  • Set KnockbackAngle[(Integer A)] = ((Facing of KnockbackedUnit[(Integer A)]) + 90.00)
or this
  • Set KnockbackAngle[(Integer A)] = ((Facing of KnockbackedUnit[(Integer A)]) - 90.00)
The first make it moved to left of Powaa, and Second make it pushed to right (Or the opposite?) test it, or you can set it depends on the angle between it. Like this:
  • Set Point[3] = (Position of (Picked unit))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Facing of Powaa[(Integer A)]) Greater than or equal to (Angle from Point[2] to Point[3])
    • Then - Actions
      • Set KnockbackAngle[(Integer A)] = ((Facing of KnockbackedUnit[(Integer A)]) - 90.00)
    • Else - Actions
      • Set KnockbackAngle[(Integer A)] = ((Facing of KnockbackedUnit[(Integer A)]) + 90.00)
  • Custom script: call RemoveLocation(udg_Point[3])
 
Level 4
Joined
Dec 10, 2008
Messages
59
ok, i forgot something. What i post above move the unit to its facing angle
You must save the angle of effected unit to real variable.
So, you must add this when start to move unit.
  • Set KnockbackAngle[(Integer A)] = (Facing of Powaa[(Integer A)])
and set point[2] like this
  • Set Point[2] = (Point[1] offset by 10.00 towards KnockbackAngle[(Integer A)] degrees)
Above is to make effected unit to move toward facing of Powaa. So, it like dragged by Powaa.
if you want it pushed beside of Powaa, use this
  • Set KnockbackAngle[(Integer A)] = ((Facing of KnockbackedUnit[(Integer A)]) + 90.00)
or this
  • Set KnockbackAngle[(Integer A)] = ((Facing of KnockbackedUnit[(Integer A)]) - 90.00)
The first make it moved to left of Powaa, and Second make it pushed to right (Or the opposite?) test it, or you can set it depends on the angle between it. Like this:
  • Set Point[3] = (Position of (Picked unit))
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Facing of Powaa[(Integer A)]) Greater than or equal to (Angle from Point[2] to Point[3])
    • Then - Actions
      • Set KnockbackAngle[(Integer A)] = ((Facing of KnockbackedUnit[(Integer A)]) - 90.00)
    • Else - Actions
      • Set KnockbackAngle[(Integer A)] = ((Facing of KnockbackedUnit[(Integer A)]) + 90.00)
  • Custom script: call RemoveLocation(udg_Point[3])

Well thank you. I'll try the new function out as soon as i find time.

EDIT: I don't know how to describe the problem, but here it is:

Instead of moving like it was planned to, it actually stays there on the first cast. On the second cast it moves though. Meaning it's the previous mass of powaaa which is the one "pushing" the second mass....now i'm completely dumbfounded >___>

Oh and i forgot to say when i asked the PowaaTravelled variable, i mean, was it an empty real variable (0.00) or a distance between point real variable (distance between point A and point B)
 
Last edited:
Level 10
Joined
Jun 1, 2008
Messages
485
PowaaTraveled is setting to zero every times it start to used

ok, i mistake some again.
you must start the loop from 0.
So it says:
  • For each (Integer A) from 1 to Total, do (Actions)
    • Loop - Actions
and for the second loop
  • For each (Integer A) from 1 to Total2, do (Actions)
    • Loop - Actions
sorry for that, i forgot it must start from zero.
 
Level 4
Joined
Dec 10, 2008
Messages
59
PowaaTraveled is setting to zero every times it start to used

ok, i mistake some again.
you must start the loop from 0.
So it says:
  • For each (Integer A) from 1 to Total, do (Actions)
    • Loop - Actions
and for the second loop
  • For each (Integer A) from 1 to Total2, do (Actions)
    • Loop - Actions
sorry for that, i forgot it must start from zero.

Hmm...i don't get it D=.

I see no difference from your overall trigger, lol
 
Level 10
Joined
Jun 1, 2008
Messages
485
Oops! my bad, forgot to change it.
here is the correct:
  • For each (Integer A) from 0 to Total, do (Actions)
    • Loop - Actions
and for the second loop
  • For each (Integer A) from 0 to Total2, do (Actions)
    • Loop - Actions
See, it start from zero.
 
Level 4
Joined
Dec 10, 2008
Messages
59
Ok changed it. Nah-uh, still doesn't work.

there's apparently a pattern....on the first cast it's a success, on the second it isn't, the third it is, etc

must have something to do with the "Set Total = (Total + 1)"? I don't know XD

ahh also, i'll try my best to save it to a temp map so that i can attach it here.....i'll try to do so tomorrow or something...though i have a test tomorrow XD
 
Status
Not open for further replies.
Top