KnockBack Ability

freakincage

New Member
Reaction score
1
Alright. Well I'm 99.99% sure this question has been asked somewhere by someone so I am simply asking if anyone can just give me a link to knockback pages, that would be great.

What I'm looking for : Not an ability that knockbacks a unit, but a trigger in which an attacked unit will get slightly knocked back when an attacking unit attacks it.

Idea : If you have ever played Counter Strike Source or any other Counter Strike type map zm : Zombie Mod, you will get my idea. I want various units have an ability in the sense of critical strike, except that instead of a 1-100% chance of critical damage, you will have a 1-100% chance of knocking the unit back alittle.

Got it? Hehe thanks in advance.
 
K

Kerberos

Guest
I can't figure out a way to code this that doesn't have the possibility of glitching if two units attack at about the same time, and I'm not sure such a way exists with the normal WE. So here are two instantaneous ones.

In the conditions, the number that the random number has to be bigger than is what controls the probability. If you want the probability to be variable, then do one of two things: first, you can just set units' custom values to their probabilities of knocking back. If you're already using custom values for something, then I suggest making each unit have a different custom value, and using units' custom values to index arrays that contain stuff that the custom value would otherwise represent (like, say, probability of knocking back).

This is the trigger for if you don't want units' actions interrupted.
Code:
Melee Initialization
    Events
        Unit - A unit Is attacked
    Conditions
        (Random real number between 0.00 and 100.00) Greater than or equal to <probability>
    Actions
        Set RealVariable = (Angle from (Position of (Attacking unit)) to (Position of (Triggering unit)))
        Custom script:   call SetUnitX(GetTriggerUnit(), GetUnitX(GetTriggerUnit()) + [b]50[/b]*Cos(udg_RealVariable * bj_DEGTORAD))
        Custom script:   call SetUnitY(GetTriggerUnit(), GetUnitY(GetTriggerUnit()) + [b]50[/b]*Sin(udg_RealVariable * bj_DEGTORAD))
The bolded numbers are what control how much a unit is knocked back.

This is if you do want them interrupted.
Code:
Melee Initialization
    Events
        Unit - A unit Is attacked
    Conditions
        (Random real number between 0.00 and 100.00) Greater than or equal to <probability>
    Actions
        Set RealVariable = (Angle from (Position of (Attacking unit)) to (Position of (Triggering unit)))
        Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by [b]50.00[/b] towards RealVariable degrees)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top