Introduction:
this tutorial will show you how to create a knockback, just like the title says.
titles do not lie, never doubt the title
First off we need to create a spell that triggers the knockback sequence. I like to use
Storm Bolt it has a nice stun so when your target's getting knocked backwards he's not squirming around.
Go into object editor, click the abilities tab, and create new custom abilities. Scroll down the list untill you see Storm Bolt.(there are 2 storm bolts but either is fine) no need to modify anything, you can go back to it later.
Okay, now we need to open up trigger editor and create a few variables. Click the yellow X at the top (between the Redo arrow and the New Catagory tab). Click the green X with the arrow pointing to the left (<-X).
1st Variable: Lets call this variable 'Caster' (the caster of the spell that knocks the unit back) and make the Variable Type 'Unit'.
DO NOT make it an array, it will screw up the whole trigger if you do.
2nt Variable: Lets call this variable 'Target' (the target of the Knockback spell being cast). Make this Variable Type 'Unit' as well.
don't make this variable an array either
3rd Variable: Lets call this variable 'Location' (the point in which the target is getting knocked backwards into) and make this Variable Type 'Point'. once again
DO NOT make it an array.
Okay, now we need to make the trigger that will hold the Knockback. Lets just call it 'Knockback' (short and sweet).
Next, press Ctrl+E, Click the red flag at the top of the editor, or left click the text reading Events, scroll down, and click New Event. (either will do). Scroll down and select 'Generic unit event'. Click 'Unit' then scroll down to 'A unit Starts the effect of an ability.' It should look like this:

Events


Unit - A unit Starts the effect of an ability
Now for the Conditions. We need to have a condition or there's gonna be a knockback for every spell...that may be a problem. So we need to put an Ability Comparison. Create the new Condition, set the ability being cast to our little custom ability, it should now look like this:

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback
Now for the Actions, first off, we need to set the Variables. Lets start off with the Caster variable. Create a new Action, scroll down to 'Set Variable'. Click the red text that reads
Variable and select Caster. Next, select the red text that read
Value and scroll down to 'Event Response - Triggering Unit. It should look like this so far:
Now lets set the 2nt Variable. Create a new Action, scroll down to 'Set Variable'. Click the red text that reads
Variable and select Target. Next, select the red text that read
Value and scroll down to 'Event Response - Target Unit Of Ability Being Cast.' It should look like this so far:

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback

Actions
Now lets set the 3rd Variable. Create a new Action, scroll down to 'Set Variable'. Click the red text that reads
Variable and select Location. Next, select the red text that read
Value and scroll down to 'Unit - Position Of Unit,' then select Caster for the unit, 'Position of Caster.' It should look like this so far:

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback

Actions
Okay, now PAY ATTENTION, this is where it starts getting tricky. Create
another trigger, lets name it 'Push.'
Okay, now find the box with a check in it that says 'Initialy On' next to it.
UNCHECK it, you'll see why it can't be initially on in a second.
Create a new Event, make it a 'Periodic Event,' click the blue text reading 2.00 and set it to 0.04. Why 0.04 you ask? It runs really smoothly and I use it for all my knockingbacking. It should look like this so far:
Knockback

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback

Actions
Push

Events


Time - Every 0.04 seconds of game time
That's why its not initially on, we dont want Push to run every 0.04 seocnds
Okay, now pay
MEGA attention to this Action, its really tricky. Okay, first: create a new Action and scroll down to 'Move Unit (Instantly).' Select the blue text that reads '(Triggering Unit)' and put the Variable 'Target.' Next, click the blue text that reads '(Center Of (Playable Map Area)),' scroll down to 'Point With Polar Offset.' Click the blue text that reads '(Center Of (Playable Map Area))' and select the Variable Location. Click the blue text that reads '256.00.' Click the first blue text that reads '1.00' then scroll down to 'Math - Distance Between Points.' Click the blue text that reads '(Position Of (Triggering Unit))' and use the variable Location then find the blue text that reads 'Position Of (Triggering Unit))' and make it 'Position of (the variable) Target.' Click Ok. Next, find the blue text that reads '1.00' on the right side and type in the number '5.' (we want the trigger to increase by 5 every 0.04 seconds)
trust me. you want that number. Now, click on the blue text that reads '0.00' and scroll down to 'Math - Angle Between Points.' Click the first blue text that reads '(Position Of (Triggering Unit))' and select the Variable Location. Click ok. Click the second blue text that reads '(Position Of (Triggering Unit))' and select 'Position of (the Variable)Target.' Click 'OK' a bunch of times, youre done with that action....finally.
you might need to read that over again a couple times
Here is what it should look like so far:
Knockback

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback

Actions
Push

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


Unit - Move Target instantly to (Location offset by ((Distance between Location and (Position of Target)) + 5.00) towards (Angle from Location to (Position of Target)) degrees)
wow thats alot
Lets go back to the first trigger, Knockback. We need to enable the trigger Push in order for the knockback to work. Create a new action, scroll down to Trigger - Turn On. Click the blue text that reads 'This Trigger' then select the Variable 'Push <gen>.' Here's how it should look so far:
Knockback

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback

Actions
Push

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


Unit - Move Target instantly to (Location offset by ((Distance between Location and (Position of Target)) + 5.00) towards (Angle from Location to (Position of Target)) degrees)
Okay, now we need to make another Action. Create an Action and scroll down to 'Wait (Game-Time).' Click the blue text that reads '2.00' and type in the number '1.' (i use one because i like the result, i think it runs smoothly). Here's how it should look so far:
Knockback

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback

Actions
Push

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


Unit - Move Target instantly to (Location offset by ((Distance between Location and (Position of Target)) + 5.00) towards (Angle from Location to (Position of Target)) degrees)
One more simple action that you
have to put in. Creat a new Action, scroll down to 'Trigger - Turn Off.' Click the blue text that reads 'This Trigger' and select the Variable 'Push <gen>.' Here is what we have so far:
Knockback

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback

Actions
Push

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


Unit - Move Target instantly to (Location offset by ((Distance between Location and (Position of Target)) + 5.00) towards (Angle from Location to (Position of Target)) degrees)
Okay, this next part is not fully nessicary but it can help ALOT, memory leaks. Lets prevent these. (i do not fully understand memory leaks but i know how to stop them). Ok First we put in a Custom Script. Create a new Action in the trigger Knockback, scroll down to Custom Script (its near the top) and click the red text that reads 'Script Code.' Type in these Exact letters (without the quotations) 'call RemoveUnit(udg_Caster)' Ok, that prevents a memory leak for the first variable, we need to do the same for Target and Location.
For Target do the same exact thing as Caster except where it says Caster, type Target. Custom Script: 'call RemoveUnit(udg_Target)'
For Location we have to do something a little different. Caster and Target are both the same type of variables, we based them both off of units. Location is a point, therefore it requires a different custom script. You would think we would type RemovePoint, but no its actually RemoveLocation. Custom Script: 'call RemoveLocation(udg_Location)' Here's what it looks like with custom scripts:
Knockback

Events


Unit - A unit Starts the effect of an ability

Conditions


(Ability being cast) Equal to Knockback

Actions
Push

Events


Time - Every 0.04 seconds of game time

Conditions

Actions


Unit - Move Target instantly to (Location offset by ((Distance between Location and (Position of Target)) + 5.00) towards (Angle from Location to (Position of Target)) degrees)
Okay, that's all you
have to do. But just for the heck of it, im gonna show you some animation effects you might wanna use, like making the target look like he was knocked backwards and not just being pushed.
Special Effect: this is how you make a special effect. Create a new Action, scroll down to 'Create Special Effect On Unit.' Click on the blue text that reads 'overhead' and type in 'origin,'
trust me, you wanna do this. Click on the blue text that reads '(Triggering Unit)' and put the Variable 'Target.' Click on the blue text that reads 'Abilities\Spells\Other\TalkToMe\TalkToMe.mld' then click on the button at the bottom that reads 'Choose Model' and put any effect you want. I, personally, like the ToonBoom effect, when it repeats rapidly in the knockback it creates an admirable piece of genius
Author's Note: I'm sorry that I did not put any screenshots, the fact of the matter is: i dont know how

. I hope is tutorial helps, thanks for reading. GO NUTS
p.s. The reason i don't go into too much detail on why I put things the way I did is because i believe that newer or maybe even more experience map makers could learn more from dissecting my triggers than having everything laid out in front of them
BLOOD ELFS 4 LIFE
