1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Modulo Does not always work on Real Numbers

Discussion in 'Triggers & Scripts' started by Veronnis, Aug 14, 2019.

  1. Veronnis

    Veronnis

    Joined:
    Jul 19, 2010
    Messages:
    134
    Resources:
    6
    Models:
    2
    Icons:
    1
    Maps:
    3
    Resources:
    6
    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 --------
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,793
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.
     
  3. Veronnis

    Veronnis

    Joined:
    Jul 19, 2010
    Messages:
    134
    Resources:
    6
    Models:
    2
    Icons:
    1
    Maps:
    3
    Resources:
    6
    I appreciate your response and thought this might be the case. Since the string return was yield 0.00 I thought I would be good, but in reality its probably 0.00001 or something. Thanks for the verification!