• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Knockback System [Dardas]

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Allright, i made a knockback system from scratch.
at start it was using custom values
then i learned how to use hashtables from this tutorial:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/

Then, i switched everything to hashtables.

Then, i wanted the spell to look better,
so i added 2 models by rising_dusk.


http://up203.siz.co.il/up2/tjmbhnbyllzz.jpg


The Triggers:

  • Hashtable
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Knockback_Hashtable = (Last created hashtable)
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set u = (Picked unit)
          • Hashtable - Save Handle Ofu as 1 of (Key (Picked unit)) in Knockback_Hashtable
          • Set Knockback_Count = (Knockback_Count + 1)
  • Hashtables 2
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Set u = (Picked unit)
      • Hashtable - Save Handle Ofu as 1 of (Key (Triggering unit)) in Knockback_Hashtable
      • Set Knockback_Count = (Knockback_Count + 1)


The loop that the code goes on

  • Knockback Loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • -------- Theres something you gotta edit, scroll the code down. --------
      • Unit Group - Pick every unit in Knockback_UnitGroup and do (Actions)
        • Loop - Actions
          • Set Knockback_Picked = (Picked unit)
          • Set Knockback_Handle = (Picked unit)
          • Set Knockback_HTInteger = (Load (Key Knockback_Handle) of 1 from Knockback_Hashtable)
          • Set Knockback_PointTarget[Knockback_HTInteger] = (Position of (Picked unit))
          • Set Knockback_Duration[Knockback_HTInteger] = (Knockback_Duration[Knockback_HTInteger] - 0.02)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Knockback_Duration[Knockback_HTInteger] Less than or equal to 0.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Knockback_UnitGroup
              • Custom script: call RemoveLocation(udg_Knockback_Point[udg_Knockback_HTInteger])
              • Custom script: call RemoveLocation(udg_Knockback_PointTarget[udg_Knockback_HTInteger])
              • Skip remaining actions
            • Else - Actions
              • Set Knockback_Point[Knockback_HTInteger] = (Knockback_PointTarget[Knockback_HTInteger] offset by Knockback_Distance[Knockback_HTInteger] towards Knockback_Angle[Knockback_HTInteger] degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Knockback_DestroyTree[Knockback_HTInteger] Equal to True
                • Then - Actions
                  • Destructible - Pick every destructible within 100.00 of Knockback_PointTarget[Knockback_HTInteger] and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Destructible-type of (Picked destructible)) Not equal to Pathing Blocker (Ground)
                          • (Destructible-type of (Picked destructible)) Not equal to Pathing Blocker (Ground) (Large)
                          • (Destructible-type of (Picked destructible)) Not equal to Pathing Blocker (Air)
                          • (Destructible-type of (Picked destructible)) Not equal to Pathing Blocker (Air) (Large)
                          • (Destructible-type of (Picked destructible)) Not equal to Pathing Blocker (Both)
                          • (Destructible-type of (Picked destructible)) Not equal to Pathing Blocker (Both) (Large)
                          • (Destructible-type of (Picked destructible)) Not equal to Line of Sight Blocker
                          • (Destructible-type of (Picked destructible)) Not equal to Line of Sight Blocker (Large)
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Picked destructible) is alive) Equal to True
                              • ((Picked destructible) is invulnerable) Equal to False
                            • Then - Actions
                              • Destructible - Kill (Picked destructible)
                              • Unit - Cause No unit to damage (Picked unit), dealing KnockbackDamage[Knockback_HTInteger] damage of attack type Chaos and damage type Normal
                              • Set Knockback_Duration[Knockback_HTInteger] = (Knockback_Duration[Knockback_HTInteger] - 0.20)
                              • Set Knockback_Distance[Knockback_HTInteger] = (Knockback_Distance[Knockback_HTInteger] - 0.30)
                            • Else - Actions
                        • Else - Actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at Knockback_PointTarget[Knockback_HTInteger] of type Walkability is off) Equal to True
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from Knockback_UnitGroup
                  • Custom script: call RemoveLocation(udg_Knockback_Point[udg_Knockback_HTInteger])
                  • Custom script: call RemoveLocation(udg_Knockback_PointTarget[udg_Knockback_HTInteger])
                  • Skip remaining actions
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Knockback_Loop[Knockback_HTInteger] Equal to True
                • Then - Actions
                  • Unit Group - Pick every unit in (Units within 75.00 of Knockback_PointTarget[Knockback_HTInteger]) and do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ((Picked unit) is in Knockback_UnitGroup) Equal to False
                          • (Picked unit) Not equal to Knockback_Caster[Knockback_HTInteger]
                        • Then - Actions
                          • Set Knockback_Picked2 = (Picked unit)
                          • Set Knockback_Handle = (Picked unit)
                          • Set Knockback_HTInteger = (Load (Key Knockback_Handle) of 1 from Knockback_Hashtable)
                          • Set Knockback_Target[Knockback_HTInteger] = (Picked unit)
                          • Set Knockback_PointCaster[Knockback_HTInteger] = Knockback_PointTarget[Knockback_HTInteger]
                          • Set Knockback_Angle[Knockback_HTInteger] = Knockback_Angle[Knockback_HTInteger]
                          • -------- ------------------------------------------------------------------------------------ --------
                          • -------- Heres what you gotta edit! --------
                          • -------- ------------------------------------------------------------------------------------ --------
                          • Set Knockback_Distance[Knockback_HTInteger] = 7.50
                          • Set Knockback_Duration[Knockback_HTInteger] = (Knockback_Duration[Knockback_HTInteger] + 0.35)
                          • Set Knockback_DestroyTree[Knockback_HTInteger] = False
                          • Set KnockbackDamage[Knockback_HTInteger] = 20.00
                          • Set Knockback_Loop[Knockback_HTInteger] = False
                          • -------- ------------------------------------------------------------------------------------ --------
                          • -------- Stop editing now. --------
                          • -------- ------------------------------------------------------------------------------------ --------
                          • Unit Group - Add (Picked unit) to Knockback_UnitGroup
                        • Else - Actions
                • Else - Actions
              • Set Knockback_Handle = (Picked unit)
              • Set Knockback_HTInteger = (Load (Key Knockback_Handle) of 1 from Knockback_Hashtable)
              • Unit - Move (Picked unit) instantly to Knockback_Point[Knockback_HTInteger]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at Knockback_PointTarget[Knockback_HTInteger] of type Floatability is off) Equal to True
                • Then - Actions
                  • Unit - Create 1 Knockback Dummy Land for Neutral Passive at Knockback_PointTarget[Knockback_HTInteger] facing Knockback_PointCaster[Knockback_HTInteger]
                  • Unit - Add a 0.35 second Generic expiration timer to (Last created unit)
                • Else - Actions
                  • Unit - Create 1 Knockback Dummy Water for Neutral Passive at Knockback_PointTarget[Knockback_HTInteger] facing Knockback_PointCaster[Knockback_HTInteger]
                  • Unit - Add a 0.35 second Generic expiration timer to (Last created unit)
              • Custom script: call RemoveLocation(udg_Knockback_Point[udg_Knockback_HTInteger])
          • Custom script: call RemoveLocation(udg_Knockback_PointTarget[udg_Knockback_HTInteger])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Knockback_UnitGroup) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions


The First sample spells (One Target spell)


  • Knockback Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Knockback
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Knockback_UnitGroup) Less than 1
        • Then - Actions
          • Trigger - Turn on Knockback Loop <gen>
        • Else - Actions
      • -------- This action makes the enemy face you (Trust me, you should keep this.) --------
      • Unit - Make (Target unit of ability being cast) face (Triggering unit) over 0.00 seconds
      • -------- Sets the knockback unit as target unit of ability behing cast. --------
      • Set Knockback_Target[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] = (Target unit of ability being cast)
      • -------- Sets the caster point (In our case triggering unit) --------
      • Set Knockback_PointCaster[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] = (Position of (Triggering unit))
      • -------- Sets the angle the unit will go thru, do not change this unless you know what you'r doing. --------
      • Set Knockback_Angle[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] = (Facing of (Triggering unit))
      • -------- Change this below, it will set the unit's distance movement every 0.02 seconds! --------
      • Set Knockback_Distance[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] = 13.50
      • -------- This will set the unit's duration in the knockback.. MAKE SURE IT CAN BE MULTIPLIED BY 0.02! --------
      • Set Knockback_Duration[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] = (Knockback_Duration[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] + 0.75)
      • -------- If you set DestroyTree as true, it will destroy trees that come near the knock backed unit. --------
      • Set Knockback_DestroyTree[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] = True
      • -------- If you want the knockbacked unit to get damaged in he crushes on a tree, set the damage down. --------
      • -------- if you DONT want him to get damaged, set damage to 0. --------
      • Set KnockbackDamage[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] = 20.00
      • -------- If you set The loop option to true, it will pick any unit that comes near the knockbacked unit, --------
      • -------- and will knockback it too. -- YOU MUST EDIT THE KNOCKBACK LOOP TRIGGER -- --------
      • Set Knockback_Loop[(Load (Key (Target unit of ability being cast)) of 1 from Knockback_Hashtable)] = True
      • -------- Do not change the code below. --------
      • Unit Group - Add (Target unit of ability being cast) to Knockback_UnitGroup


And the other sample spell (Aoe spell)


  • Knockback Aoe Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Knockback Aoe Sample
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Knockback_UnitGroup) Less than 1
        • Then - Actions
          • Trigger - Turn on Knockback Loop <gen>
        • Else - Actions
      • -------- THIS LEAKS, DO NOT USE THIS IN YOUR GAME! --------
      • Unit Group - Pick every unit in (Units within 250.00 of (Position of (Casting unit)) matching ((((Owner of (Matching unit)) is an ally of (Owner of (Casting unit))) Equal to False) and ((Owner of (Casting unit)) Not equal to (Owner of (Matching unit))))) and do (Actions)
        • Loop - Actions
          • -------- This action makes the enemy face you (Trust me, you should keep this.) --------
          • Unit - Make (Picked unit) face (Casting unit) over 0.00 seconds
          • Set Knockback_Caster[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = (Casting unit)
          • -------- Sets the knockback unit as picked unit. --------
          • Set Knockback_Target[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = (Picked unit)
          • -------- Sets the caster point (In our case triggering unit) --------
          • Set Knockback_PointCaster[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = (Position of (Triggering unit))
          • -------- Sets the angle the unit will go thru, do not change this unless you know what you'r doing. --------
          • Set Knockback_Angle[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = (Facing of (Picked unit))
          • -------- Change this below, it will set the unit's distance movement every 0.02 seconds! --------
          • Set Knockback_Distance[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = 13.50
          • -------- This will set the unit's duration. MAKE SURE IT CAN BE MULTIPLIED BY 0.02! --------
          • Set Knockback_Duration[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = (Knockback_Duration[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] + 0.75)
          • -------- If you set DestroyTree as true, it will destroy trees that come near the knock backed unit. --------
          • Set Knockback_DestroyTree[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = True
          • -------- If you want the knockbacked unit to get damaged in he crushes on a tree, set the damage down. --------
          • -------- if you DONT want him to get damaged, set damage to 0. --------
          • Set KnockbackDamage[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = 0.00
          • -------- If you set The loop option to true, it will pick any unit that comes near the knockbacked unit, --------
          • -------- and will knockback it too. -- YOU MUST EDIT THE KNOCKBACK LOOP TRIGGER -- --------
          • Set Knockback_Loop[(Load (Key (Picked unit)) of 1 from Knockback_Hashtable)] = True
          • -------- Do not change the code below. --------
          • Unit Group - Add (Picked unit) to Knockback_UnitGroup



1.Destroying trees (You can set true/false while making your spell.)
2.Making other units get knockbacked if you crush on them.
3.cheaking if terrain is land/water, and by that changing model.

To Do List:
1.Cheak if the unit is going on a height (Raised terrain),
2.And if it does, decrease movement speed.


Give me credits if you use my system.
Give credits to Rising_dusk if you use his models.


Keywords:
Knock,Back,Knockback,Dardas,Bob,System,Push,Spell,Sample,Gui
Contents

Knockback System (Map)

Reviews
19:09, 27th Jul 2010 TriggerHappy: We really don't need anymore of these, oh and in the future you need to upload a preview pic.

Moderator

M

Moderator

19:09, 27th Jul 2010
TriggerHappy:

We really don't need anymore of these, oh and in the future you need to upload a preview pic.
 
Level 11
Joined
Sep 12, 2008
Messages
657
Mnib:
I know, ill do it now.

Triggerhappy:
I did, it just didnt upload it :/
ill put a link if its okay..


Edit: Added picture link (Sorry, i tried again, but it still didnt let me upload to hive..)
Added knockback on attack.
 
Level 11
Joined
Sep 12, 2008
Messages
657
Well.. took me alot of time to make.. but who cares, i can allways use this on my map..
(i made the system because everytime i use someone's elses, some how it turns out not like i wanted.. so here i added all options i need, and i dont need to credit any 1 aswell :p)
 
Top