Knock back units in front of caster

Mr_Joke

New Member
Reaction score
1
So I tried to make a knockback spell that knocks back units in front of the caster but the problem is the units are only knocked back if the caster faces a certain angle (180 to 360 degrees) and not knocked back if the caster faces 0 to 180 degrees.

Here are the conditions that check if the unit should be knocked back or not:

Code:
        Set KnockbackUnitsPre[(Player number of (Owner of (Triggering unit)))] = (Units within 500.00 of KnockbackOrigin[(Player number of (Owner of (Triggering unit)))] matching ((Matching unit) Not equal to (Triggering unit)))
        Unit Group - Pick every unit in KnockbackUnitsPre[(Player number of (Owner of (Triggering unit)))] and do (Actions)
            Loop - Actions
                Set KnockbackUnitLoc[(Player number of (Owner of (Picked unit)))] = (Position of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Facing of (Triggering unit)) + 45.00) Greater than or equal to (Angle from KnockbackOrigin[(Player number of (Owner of (Triggering unit)))] to KnockbackUnitLoc[(Player number of (Owner of (Picked unit)))])
                        ((Facing of (Triggering unit)) - 45.00) Less than or equal to (Angle from KnockbackOrigin[(Player number of (Owner of (Triggering unit)))] to KnockbackUnitLoc[(Player number of (Owner of (Picked unit)))])

KnockbackOrigin is the location of the caster.

Thank you in advance.
 

vypur85

Hibernate
Reaction score
803
Facing of unit checks angles between 0 to 360 degrees.
Angle between points check angles between -180 to 180 degrees.

To solve the problem, you can try convert negative angles into positives.
For example,
If (YourAngle Less than 0.00) then (Set YourAngle = YourAngle + 360.00)

YourAngle being your angle between points.
 
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