• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Spell] Modulo not showing zero

Status
Not open for further replies.
Level 12
Joined
May 16, 2020
Messages
663
Hi guys,

I want to use Modulo within a loop to only trigger a function at certain intervals. However, the game refuses to give me 0, if for example I divide 0.25 / 0.25 --> rest = 0. As such the "IF Equal to 0.00" part never runs. Any idea what is wrong?

Here the trigger and in-game screenshot:

  • Life Drain Cast Loop
    • Events
      • Time - LD_Timer expires
    • Conditions
    • Actions
      • For each (Integer LD_Integer) from 1 to LD_Index, do (Actions)
        • Loop - Actions
          • Set VariableSet LD_Counter[LD_Integer] = (LD_Counter[LD_Integer] + 0.05)
          • Game - Display to (All players) the text: (String((LD_Counter[LD_Integer] mod 0.25)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (LD_Counter[LD_Integer] mod 0.25) Equal to 0.00
            • Then - Actions
              • Game - Display to (All players) the text: Damage
              • Unit - Cause LD_Caster[LD_Integer] to damage LD_Target[LD_Integer], dealing LD_Drained_HP[LD_Integer] damage of attack type Spells and damage type Magic
              • Unit - Set life of LD_Caster[LD_Integer] to ((Life of LD_Caster[LD_Integer]) + LD_Drained_HP[LD_Integer])
            • Else - Actions
          • XXX
Capture.png
 
Last edited:
It's because you're trying to use equal to compare real numbers. The numbers you enter might look fine to you, being exactly 0.1, 0.15, whatever. Even the game displaying them to you up to 3 decimals might look mighty fine to you, but what's actually happening is something akin to the actual number being 0.15, then about nineteen zeros, then some random number at the end. There is an explanation as to why this is the case, but it's fully technical, and boring. Long story short: don't use equals for reals because it won't work. If it somehow does work once in a blue moon randomly, you're one of the luckiest people left on this planet.
 
Status
Not open for further replies.
Back
Top