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

[Solved] Modulo Does not always work on Real Numbers

Status
Not open for further replies.
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 39
Joined
Feb 27, 2007
Messages
4,992
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.
 
Status
Not open for further replies.
Top