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

Create a Simple Knockback

Level 3
Joined
Jun 19, 2008
Messages
18
Introduction:
this tutorial will show you how to create a knockback, just like the title says.

titles do not lie, never doubt the title:razz:

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:hohum: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:

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Knockback
  • Actions
    • Set Caster = (Triggering unit)
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
    • Set Caster = (Triggering unit)
    • Set Target = (Target unit of ability being cast)
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
    • Set Caster = (Triggering unit)
    • Set Target = (Target unit of ability being cast)
    • Set Location = (Position of Caster)
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
    • Set Caster = (Triggering unit)
    • Set Target = (Target unit of ability being cast)
    • Set Location = (Position of Caster)
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
    • Set Caster = (Triggering unit)
    • Set Target = (Target unit of ability being cast)
    • Set Location = (Position of Caster)
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
    • Set Caster = (Triggering unit)
    • Set Target = (Target unit of ability being cast)
    • Set Location = (Position of Caster)
    • Trigger - Turn On Push <gen>
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
    • Set Caster = (Triggering unit)
    • Set Target = (Target unit of ability being cast)
    • Set Location = (Position of Caster)
    • Trigger - Turn On Push <gen>
    • Wait 1.00 game-time seconds
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
    • Set Caster = (Triggering unit)
    • Set Target = (Target unit of ability being cast)
    • Set Location = (Position of Caster)
    • Trigger - Turn On Push <gen>
    • Wait 1.00 game-time seconds
    • Trigger - Turn Off Push <gen>
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
    • Set Caster = (Triggering unit)
    • Set Target = (Target unit of ability being cast)
    • Set Location = (Position of Caster)
    • Trigger - Turn On Push <gen>
    • Wait 1.00 game-time seconds
    • Trigger - Turn Off Push <gen>
    • Custom script: call RemoveUnit(udg_Caster)
    • Custom script: call RemoveUnit(udg_Target)
    • Custom script: call RemoveLocation(udg_Location)
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 :gg:

Author's Note: I'm sorry that I did not put any screenshots, the fact of the matter is: i dont know how:eek:. I hope is tutorial helps, thanks for reading. GO NUTS:thumbs_up:

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 :spell_breaker:
 
Last edited:
Level 22
Joined
Feb 26, 2008
Messages
891
The explanation of this tutorial is actually not that bad.
But you do have some problems.

1. You need to read up on leaks. Your triggers have some.

> Wait 1.00 game-time seconds

What happens after this? Nothing? The way you have it set up, that poor unit will be constantly moved a little bit at a time forever.

Also, it would be nice if you could make this spell MUI.
 
Level 3
Joined
Jun 19, 2008
Messages
18
I thought my trigger had a leak or 2, ill talk to my friend who's pretty good with those and ill try and fix it. Sorry about the wait game time seconds, guess i forgot to type the trigger turn off, i fixed this. About the MUI, im sorry i dont know what that stands for:sad:. Please respond to this and tell me what it is, then ill look into it. Thanks for checking it out.
 
Level 3
Joined
Jun 19, 2008
Messages
18
Okay, I think I fixed all the leaks. About the MUI, this is really the first time I've ever heard of that, I read your response on thehelper.net and i understand what it is, but i dont know how to create it. Also, why would 2 people need to knockback 1 person at once? Actually, if you think about it, getting knocked backwards then, in the middle of your slide, you get knocked another direction, that might create a bug of some sort. Whatever I'll look into making it an MUI.
 
Last edited:
Level 9
Joined
May 5, 2007
Messages
253
no he means so people can use it both at the same time not on the same unit.
also all it does is go into one direction it doesnt go into the facing of the caster can you please fix this?

insted of your move instantly use
  • Unit - Move Target instantly to ((Position of Target) offset by 25.00 towards (Facing of Caster) degrees)
 
Last edited:
Level 22
Joined
Feb 26, 2008
Messages
891
Imagine that, on some side of the board, we have two units fighting. One of these units uses this lovely knockback system on the other.
Now, while the unit is being knocked back, we have two more units fighting on the other side of the board, and one of them uses the same system.
Uh-oh. We have a problem. Variables start to get overwritten because they are set and used in different places and at different times in your triggers. The two separate uses of the ability run into each other due to the limits of the trigger itself.

Does that make it more clear to you?
 
Level 10
Joined
Feb 8, 2008
Messages
432
Thanks Ghan, that clears it up quite a bit. Sorry I really don't know how to make it an MUI. I'm a little bit of a noob map maker so I don't know how to do alot of things in World Editor.

Readers: Sorry guys, guess you'll have to figure out MUI by yourself.

If your a noob map maker dont attempt to teach other players as it could lead to bad habbits for new commers that dont know what their doing is wrong. If you dont know how to make a spell MUI learn about arrays, player numbers and all of that before attempting to help others. I am not saying there is anything wrong with giving the occasional tip but writing a tutorial where you cant make it mui, and its leaking will not help people trying to learn.
 
Level 9
Joined
Apr 5, 2008
Messages
443
i do believe what you meant to put as the leak remove was this
  • Knockback
    • Events
      • bla bla bla
    • Conditions
      • bla bla bal
    • Actions
      • bla bla bla
      • Custom Script: set udg_Caster = null
      • Custom Script: set udg_Target = null
      • Custom Script: set udg_Location = null
that way when you use the ability it doesn't remove the whole group of guys but actually removes leaks.

also a personal preferance of mine is if you play the death animation when he is knocking back so that he flyes back rather than just slide.
 
Level 1
Joined
Jul 8, 2008
Messages
1
By adding arrays and making

Set Caster[Player number of Owner of (Triggering Unit)] : BLA BLA BLA


will make the Spell MUI????????
 
Last edited:
Level 2
Joined
Jun 28, 2007
Messages
9
Imagine that, on some side of the board, we have two units fighting. One of these units uses this lovely knockback system on the other.
Now, while the unit is being knocked back, we have two more units fighting on the other side of the board, and one of them uses the same system.
Uh-oh. We have a problem. Variables start to get overwritten because they are set and used in different places and at different times in your triggers. The two separate uses of the ability run into each other due to the limits of the trigger itself.

Does that make it more clear to you?

Then u have to make Variables for every hero that got that Spell
"Casting = unit of typ("heroname")
"Set variables "heroname" Knockback = Caster"hero.name"
dont know if u get what i mean but i think that shoud work it take 5 minuts longer but wtf it worth it.
 
Level 6
Joined
Jun 15, 2008
Messages
175
Hi, I must say, I love the intiative, I've been looking for something like this for a while :). It's nice and easy to understand, I have not tested it yet.
mrICE and le_dtc, you're both right as far as I know, but there's a more simple way to do it.
I am personally not a master of MUI-spells, but I've understood, that you have to use a continoues loop function, in order for your spell to be able work twice at the same time.
Do this by creating the action "For Each Integer A, Do Multiple Actions", Then whenever you're creating a variable for that specific player, make it for each integer A.
I hope, I made myself clear about this, as it is still very confusing in my own head. If I am wrong in any sense, please do correct me, so we don't all get it wrong.
Sincerely Foopad
 
Level 6
Joined
Jun 15, 2008
Messages
175
I guess that's why I am not making tutorials :p, as I stated, it is still confusing to me, and I only think, I have found heads and tails in this, but I don't know for sure...
Plus Needhelp1 have in mind, that I explained this in 4 sentences, there's made a whole tutorial in a few pages about it. So I think, I did pretty good compared to this :D.
If you still need help, needhelp1, I would suggest reading some off this http://www.hiveworkshop.com/forums/...279/multi-instancible-gui-spell-making-34393/
 
Top