[Solved] Modulo Does not always work on Real Numbers

Does anyone know what I'm doing wrong here? I don't understand why this is failing, please note the problem appears to be caused solely by the Modulo condition, as everything works fine when it's gone. Purpose: Use the modulo as a frequency interval for the spell's effect.

  • Curse a Unit
    • Events
      • Player - Player 1 (Red) issues Mouse Down event
    • Conditions
      • (Trigger Mouse Button) Equal to Left Mouse Button
    • Actions
      • Set DOTsActive = (DOTsActive + 1)
      • Set TimeCounter[DOTsActive] = 0.00
      • Set EffectModulo[DOTsActive] = 0.50
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DOTsActive Equal to 1
        • Then - Actions
          • Trigger - Turn on Effect Loop <gen>
        • Else - Actions
  • Effect Loop
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer GenericLoopCount) from 1 to DOTsActive, do (Actions)
        • Loop - Actions
          • Set TimeCounter[GenericLoopCount] = (TimeCounter[GenericLoopCount] + 0.10)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TimeCounter[GenericLoopCount] mod EffectModulo[GenericLoopCount]) Equal to 0.00
            • Then - Actions
              • -------- Make an explosion --------
            • Else - Actions
              • -------- Do nothing --------
 
Level 22
Joined
Feb 27, 2007
Messages
3,784
Operations on real numbers aren't always precise so you are probably simply not getting a modulo remainder of exactly 0. If you change that condition to < 0.10 (or some other small number) I anticipate it will work. This is why it is generally always recommended to use integers for time counters, not reals.
 
Top