• 🏆 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!

Lightning Zap

Status
Not open for further replies.
Level 3
Joined
Jun 2, 2014
Messages
64
I am trying to make this ability where you can zap a unit with lightning and send then flying back, WITHOUT moving instantly! I would really appreciate it in trigger form!!! I have tried so much Q_Q. I want to be able to see the targeted unit flown back... Of course.
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
The basic idea behind these spells where a unit is moved by trigger is that you move the unit from place to place periodically.
It's done by adding all units that are supposed to be moved into a unit variable array and moving them every 0.03 seconds by for example range 20.
You would need to use custom script for setting unit's X and Y position in game. Also, you would need to make sure these units do not move through some unpathable region.

So with all that said, to have some bug-free knockback system, you would need to trigger yourself such system that fulfills those requirements... which is not that easy to do.
Hence I would actually recommend you to go to download section and download a knockback system from Hive.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The problem being? Units getting smoothly knocked back is just a stringing together of lots of unit position settings. You have to know what movement you want exactly, what the parameters are. Then you split it up using usually a constant timer interval.

For example you want the unit being pushed 100 meters in direction alpha (on the x/y-plane) over 5 seconds and that in a linear fashion (constant speed, no acceleration, direct path). You take a periodic timer with maybe 0.03 interval, divide the 5 seconds by this 0.03 to gain the number of intervals, approximately 167 in this case, so there are 167 steps to the target position. Divide the 100 meters by 167, approx. 0.6 meters per step and that's what you add to the unit's current position each interval (0.6 in direction alpha). After 5 seconds (another timer, or you can also count the steps), stop the periodic timer/halt the movement.

If the movement is to be more complex, you will need more maths.
 
Level 3
Joined
Jun 2, 2014
Messages
64
As Deadlord is saying for me to download a knock back system, my computer's internet explorer or chrome is not working and I cannot be able to get to the computer that does work with others being on it all the time (I am on a tablet). Does Waterknight's way work without that, cause I am confused some?
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
Waterknight wrote the same thing I did. Yes, you can trigger your own knockback system, but it's a bit complicated and requires you to understand the game mechanics - hence why I advised that you download an approved knockback system instead of creating one yourself.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The knockback needs to be done with an instancing system.

1. Create an instance of the knockback in response to the ability being cast.
2. Iterate through all instances of knockback and process them.
3. Destroy instances of knockback after a certain time has passed.

1 is done using your normal indexing/struct systems.
2 is done using a simple for loop through an array. When you process an instance you compute a new location for the unit that is partly towards its target.
3 is usually done either with a tick counter (incremented each time the instance is processed) or with a test (X distance achieved, X distance from caster, within X of target etc).

Since knockback is common you can get ready made systems to do 1, 2 and 3. All you need to do is call a function and pass it the appropriate arguments when your ability is cast.
 
Level 3
Joined
Jun 2, 2014
Messages
64
I decided actually to look at YouTube and this guy showed me a trigger that I used and now it works perfectly! Just type in wc3 knock back trigger in google and u can find the video!!

Thanks for trying the help though!
 
Status
Not open for further replies.
Top