• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Push Ability

Status
Not open for further replies.
Level 2
Joined
Apr 12, 2015
Messages
10
well you need a trigger spell for that, that does something in a loop like:
for each from x to y move unit instantly offset from the casting unit.
dont have the WE open atm cant remeber the complete syntax, but i m sure the next poster does =D
 
Level 2
Joined
Apr 12, 2015
Messages
10
the charge i think works like a buff that gives barathrum 0 collsion/flying movement and increased movespeed till the buff is removen (which happens when u do something else)

the greater bash ability (and over pushing/pulling spells like vacuum, foce staff, blackhol etc) are build like described, at least i have not heard something else yet.
 
Level 11
Joined
Jan 23, 2015
Messages
788
  • TelePush
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Telekinetic Push
    • Actions
      • Set TelePushCaster = (Casting unit)
      • Set TelePushCasterPosition = (Position of TelePushCaster)
      • Set TelePushUnitsAffected = (Units within 700.00 of TelePushCasterPosition matching ((Owner of (Matching unit)) Not equal to (Owner of TelePushCaster)))
      • For each (Integer A) from 1 to 20, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in TelePushUnitsAffected and do (Actions)
            • Loop - Actions
              • Unit - Move (Picked unit) instantly to (TelePushCasterPosition offset by (5.00, 5.00))
what do i type for X and Y ?
 
Level 18
Joined
Oct 17, 2012
Messages
822
No need to worry about having values for x and y. You technically already using x and y values when using a point. Instead, use point with polar offset to determine the direction and speed at which the targets will move in 20 steps.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
The push back is implemented with a periodic timer/trigger that fires between 0.04 and 0.0166 seconds which moves affected units a certain displacement based on the intended velocity. If you do not want the unit's current orders to be interrupted during the knockback you will need to use the JASS only native SetUnitX and SetUnitY as all GUI movement actions issue an implicit stop order.

Since you want the units to stop once they are exactly a certain distance away from the caster you will need additional logic. The most efficient way is to pre-compute the number of ticks the unit needs to be moved for it to end at that distance (simple speed*time stuff you are used to from physics at school). A less efficient but more dynamic away (support other factors affecting unit movement) is to check the distance between unit and caster each tick and if it is larger than the intended amount you then end the effect on the unit.

To manage effects consider some form of instancing system, were each instance of knockback is given a unique index in an array using an indexing system (usually a free list). In this case it could also be possible to use a stack based instancing system (add to top, remove by pulling top and replacing current etc) as each instance is stand alone so instance movement in the array is of no concern.

If using GUI do remember that locations created for the movement calculations will leak unless you use JASS only natives to clean them (RemoveLocation).
 
Level 11
Joined
Jan 23, 2015
Messages
788
  • TelePush
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Telekinetic Push
    • Actions
      • Set TelePushCaster = (Casting unit)
      • Set TelePushCasterPosition = (Position of TelePushCaster)
      • Set TelePushUnitsAffected = (Units within 700.00 of TelePushCasterPosition matching ((Owner of (Matching unit)) Not equal to (Owner of TelePushCaster)))
      • For each (Integer A) from 1 to 20, do (Actions)
        • Loop - Actions
          • Set TelePushStoreDistance = (TelePushStoreDistance - 35.00)
          • Unit Group - Pick every unit in TelePushUnitsAffected and do (Actions)
            • Loop - Actions
              • Unit - Move (Picked unit) instantly to (TelePushCasterPosition offset by TelePushStoreDistance towards 0.00 degrees)
              • Destructible - Pick every destructible within 100.00 of (Position of (Picked unit)) and do (Destructible - Kill (Picked destructible))
              • Custom script: call RemoveLocation (udg_TelePushCasterPosition)
          • Game - Display to (All players) the text: (String(TelePushStoreDistance))
          • Wait 0.01 game-time seconds
      • Set TelePushStoreDistance = 0.00
i'm stuck, when i use the spell, all of the units around the caster move to the center of the map, i really don't know how does this offset thing works.... please help me..
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Move the RemoveLocation() to the bottom.
Just before you move the unit, you must create a new location variable (with the polar offset)
Then move the unit to that location and check for the destructables and immediately after that, you remove that location.
Also... you might want to set the distance at the start of the trigger.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
  • TelePush
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Telekinetic Push
    • Actions
      • Set TelePushCaster = (Casting unit)
      • Set TelePushCasterPosition = (Position of TelePushCaster)
      • Set TelePushStoreDistance = 100?????
      • Set TelePushUnitsAffected = (Units within 700.00 of TelePushCasterPosition matching ((Owner of (Matching unit)) Not equal to (Owner of TelePushCaster)))
      • For each (Integer A) from 1 to 20, do (Actions)
        • Loop - Actions
          • Set TelePushStoreDistance = (TelePushStoreDistance - 35.00)
          • Unit Group - Pick every unit in TelePushUnitsAffected and do (Actions)
            • Loop - Actions
              • Set TempLocation = (TelePushCasterPosition offset by TelePushStoreDistance towards 0.00 degrees)
              • Unit - Move (Picked unit) instantly to TempLocation
              • Destructible - Pick every destructible within 100.00 of TempLocation and do (Destructible - Kill (Picked destructible))
              • Custom script: call RemoveLocation(udg_TempLocation)
          • Game - Display to (All players) the text: (String(TelePushStoreDistance))
          • Wait 0.01 game-time seconds
      • Custom script: call RemoveLocation(udg_TelePushCasterPosition)
      • Set TelePushStoreDistance = 0.00
 
Status
Not open for further replies.
Top