Trigger help needed

_MB_

New Member
Reaction score
3
I am trying to make my own KnockBack system and i have already make a simple trigger, but there is some where fatal mistake and i can't found it. Can somebody help me? There are the triggers:
Trigger:
  • KnockBack
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in KB_Group_KBedUnits and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 0 to KB_NumberOfUnit, do (Actions)
            • Loop - Actions
              • Set KB_PositionOfUnit[(Integer A)] = (Position of KB_Unit[(Integer A)])
              • Unit - Create 1 KBUnit for Player 1 (Red) at KB_PositionOfUnit[(Integer A)] facing KB_Angle[(Integer A)] degrees
              • Unit - Turn collision for (Last created unit) Off
              • Unit - Hide (Last created unit)
              • Unit - Pause (Last created unit)
              • Unit - Move KB_Unit[(Integer A)] instantly to ((Position of (Last created unit)) offset by KB_EachLength[(Integer A)] towards KB_Angle[(Integer A)] degrees)
              • Unit - Remove (Last created unit) from the game
              • Set KB_ActualKB[(Integer A)] = (KB_ActualKB[(Integer A)] + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • KB_ActualKB[(Integer A)] Equal to KB_NumberOfKBs[(Integer A)]
                • Then - Actions
                  • Unit Group - Remove KB_Unit[(Integer A)] from KB_Group_KBedUnits
                • Else - Actions


Trigger:
  • KnockBack 1
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Attacking unit)) Equal to Footman
          • ((Triggering unit) is in KB_Group_KBedUnits) Equal to False
        • Then - Actions
          • Unit Group - Add (Attacked unit) to KB_Group_KBedUnits
          • Set KB_Unit[KB_NumberOfUnit] = (Attacked unit)
          • Set KB_PositionOfUnit[KB_NumberOfUnit] = (Position of (Attacked unit))
          • Set KB_Angle[KB_NumberOfUnit] = (Facing of (Attacking unit))
          • Set KB_WholeLenght[KB_NumberOfUnit] = 500.00
          • Set KB_NumberOfKBs[KB_NumberOfUnit] = 10
          • Set KB_EachLength[KB_NumberOfUnit] = (KB_WholeLenght[KB_NumberOfUnit] / (Real(KB_NumberOfKBs[KB_NumberOfUnit])))
          • Set KB_NumberOfUnit = (KB_NumberOfUnit + 1)
        • Else - Actions
          • For each (Integer A) from 0 to KB_NumberOfUnit, do (Actions)
            • Loop - Actions
              • Set KB_WholeLenght[(Integer A)] = (KB_WholeLenght[(Integer A)] + 500.00)
              • Set KB_NumberOfKBs[(Integer A)] = (KB_NumberOfKBs[(Integer A)] + 10)
              • Set KB_EachLength[(Integer A)] = (KB_WholeLenght[(Integer A)] / (Real(KB_NumberOfKBs[(Integer A)])))


Trigger:
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set KB_NumberOfUnit = 0
 

Tyrulan

Ultra Cool Member
Reaction score
37
Could you explain the behavior this code is producing?

Also, this code has more than just a few fatal flaws. I would be careful using the "Unit is Attacked" event as it can be triggered my damage over time spells (such as poison) or ranged abilities. If you're attacking unit needs a certain spell (such as a passive ability) to attain knockback add a condition to check the ability. I also noticed your periodic trigger is never enabled/disabled by the calling trigger. Having events fired ever 0.02 seconds will severely cut back on performance. You should add conditions where the periodic disables it self (such as a knckback distance) or is disabled in the calling trigger by adding a "Wait." (Though I would avoid using wait's as much as possible, timers are more equipped for the job.)

If you are able to provide more information about your scenario it will be easier to fix your code.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top