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

Need help with knockback system

Status
Not open for further replies.
Level 11
Joined
Jul 17, 2013
Messages
544
Hi im triggering with gui. However i am gargabe at triggers and i need knockback system which knocks back unit away and floates unit into air. I found this system Raging Slam v1.10 it would be perfect but. Developer of this system didnt prevent units going outside of map or into tress. So the problrm of this system is that when unit is pulled back he can stay inside tress or other dooads or even on clifs idk how to fix it. You can also recommend me other systems if u have or know. I was looking for long time and didnt find anything interesting!
 
Level 11
Joined
Jul 17, 2013
Messages
544
Don't know if this will help but I tried to simplify the Knockback 2D system for you.

Open my map and copy the "Knockback 2D" folder. Then open your map and paste it. Inside this folder I have made another folder called "Knockback Example".

Inside "Knockback Example" you will find some triggers I made showing you very simple examples of how to use this system.

Here is one of those triggers. It has instructions plus the variables you'll need to make a knockback happen. I like to reference this trigger whenever I want a knockback effect:
  • Knockback Template
    • Events
    • Conditions
    • Actions
      • -------- There are four required variables when issuing a knockback --------
      • -------- --------
      • -------- 1. Knockback2DAngle -------- this is the direction angle the unit is knocked back (in degrees) --------
      • -------- 2. Knockback2DTime -------- this is how long the unit will be knocked back (in seconds) --------
      • -------- 3. Knockback2DDistance -------- this is how far the unit will be knocked back --------
      • -------- 4. Knockback2DUnit -------- this is the unit being knocked back --------
      • -------- --------
      • -------- When all four variables are set, you can run the Knockback 2D trigger, ignoring conditions --------
      • -------- --------
      • Set CenterPoint = (Position of (Triggering unit))
      • Set TargetPoint = (Position of (Triggering unit))
      • Set Knockback2DAngle = (Angle from CenterPoint to TargetPoint)
      • Custom script: call RemoveLocation(udg_CenterPoint)
      • Custom script: call RemoveLocation(udg_TargetPoint)
      • Set Knockback2DTime = 0.90
      • Set Knockback2DDistance = 500.00
      • Set Knockback2DUnit = (Triggering unit)
      • Trigger - Run Knockback 2D <gen> (checking conditions)

Here is another trigger. This is an example of using the system to knockback a unit whenever it is attacked.
So to do this yourself follow these instructions:
1) Go to our Knockback Template trigger and copy the Actions inside it starting at "Set CenterPoint". You don't have to copy the Comments.
2) Paste the Actions into our desired trigger. In this case it's our Knockback Example Default trigger.
3) Now we have to adjust the variables to match our trigger. Since this is a "A unit is attacked" Event then we will be referencing the Attacked and Attacking units when settings our variables.
4) Set "CenterPoint" to the position of our Attacking Unit.
5) Set "TargetPoint" to the position of our Attacked Unit.
6) Don't change Knockback2DAngle
7) Set Knockback2DTime to how long you want the knockback to last
8) Set Knockback2DDistance to how far the knockbacked unit should move
9) Set Knockback2DUnit to the unit that you want to get knocked back
10) Finally Run the Knockback 2D trigger which will cause the Unit to get Knockedback based on these Settings
  • Knockback Example Default
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set CenterPoint = (Position of (Attacking unit))
      • Set TargetPoint = (Position of (Attacked unit))
      • Set Knockback2DAngle = (Angle from CenterPoint to TargetPoint)
      • Custom script: call RemoveLocation(udg_CenterPoint)
      • Custom script: call RemoveLocation(udg_TargetPoint)
      • Set Knockback2DTime = 0.90
      • Set Knockback2DDistance = 500.00
      • Set Knockback2DUnit = (Attacked unit)
      • Trigger - Run Knockback 2D <gen> (checking conditions)

You'll also notice that I have a bunch of disabled triggers like "Knockback Example No Bounce".
By default the Knockback2D system will destroy trees, cause units to bounce off of terrain, and allow the units to move while being knocked back. However, you can change these settings before you declare a knockback. The disabled triggers I made are meant to show you how to disable/enable these settings.

Note: For the "standard" knockback effect that I assume you want check out the "Knockback Example Combine" trigger. It pauses the knocked back unit, doesn't destroy trees, and doesn't cause units to bounce.

@Bribe
Do you mind if I edit your GUI Knockback System? I wanted to add a flying height feature for emil23 here. Also, and maybe this is the wrong place to bring this up, I wanted to know what the current height related features do in your System. In reference to this stuff:
This was in the Knockback 2D trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Knockback2DHeight Not equal to 0.00
    • Then - Actions
      • Set K2DHeight[UDex] = Knockback2DHeight
      • Custom script: if UnitAddAbility(udg_Knockback2DUnit, 'Amrf') then
      • Custom script: call UnitRemoveAbility(udg_Knockback2DUnit, 'Amrf')
      • Custom script: endif
      • Animation - Change Knockback2DUnit flying height to ((Default flying height of Knockback2DUnit) + Knockback2DHeight) at ((Knockback2DHeight - (Default flying height of Knockback2DUnit)) / (Knockback2DGravity x Knockback2DTime))
      • Set K2DHeightThreshold[UDex] = ((1.00 - Knockback2DGravity) x Knockback2DTime)
      • Set Knockback2DHeight = 0.00
    • Else - Actions
      • Set K2DHeight[UDex] = 0.00
I found this in the Knockback 2D Destroy trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • K2DHeight[UDex] Not equal to 0.00
    • Then - Actions
      • Animation - Change Knockback2DUnit flying height to (Default flying height of Knockback2DUnit) at 0.00
    • Else - Actions
And I found this in the code:
vJASS:
if udg_K2DTimeLeft[i] < udg_K2DHeightThreshold[i] and udg_K2DHeightThreshold[i] != 0.00 then
    call SetUnitFlyHeight(u, GetUnitDefaultFlyHeight(u), GetUnitFlyHeight(u) - GetUnitDefaultFlyHeight(u)/udg_K2DHeightThreshold[i])
    set udg_K2DHeightThreshold[i] = 0.00
endif
//AND
if udg_K2DHeight[i] != 0.00 then
    set udg_Knockback2DHeight = GetUnitFlyHeight(u) - GetUnitDefaultFlyHeight(u)
endif
I'm not too sure how to make use of it or if it really does anything but after deleting it I can't see any differences.
Fak, you spend probly a lot of time doing it. I forgot to say that i alreday have good knockback, its in jass thought i was too afraid to brother with jass but there was no need to be scared. Actually copying jass was easier for me than coppying gui all i had to change is spell id
 
Status
Not open for further replies.
Top