• 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.

[Solved] Math precedence issue

Status
Not open for further replies.
Level 11
Joined
Jan 23, 2015
Messages
788
Can someone tell me what the hell is wrong with this part of my trigger? Everything else works, I didn't uploaded the rest of the trigger cause it will just confuse you even more..

As you can see, I'm trying to detect if the distance between two points is between two reals (example: between 200 and 400)..
The problem is these two conditions which check that, for which I have debug messages and I get this debug message (which is in the else - actions, the then - actions never occur) when the trigger is fired:

example:
542.35 (Distance between the points)
0.00
200.00
542.35 (Distance between the points)
200.00
400.00
542.35 (Distance between the points)
400.00
600.00
542.35 (Distance between the points)
600.00
800.00
542.35 (Distance between the points)
800.00
1000.00

Now, how is it possible that 542.35 is not between 400.00 and 600.00??


  • For each (Integer A) from 1 to HMFullDamage[HMLevel], do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HMDistanceBetween Greater than (HMDistance[HMLevel] + ((HMDistance[HMLevel] x (Real((Integer A)))) - 2.00))
          • HMDistanceBetween Less than or equal to (HMDistance[HMLevel] + ((HMDistance[HMLevel] x (Real((Integer A)))) - 1.00))
        • Then - Actions
          • Set HMDamageIncreases = (HMDamageIncreases + (Integer A))
        • Else - Actions
          • Game - Display to (All players) the text: (String(HMDistanceBetween))
          • Game - Display to (All players) the text: (String((HMDistance[HMLevel] + (HMDistance[HMLevel] x ((Real((Integer A))) - 2.00)))))
          • Game - Display to (All players) the text: (String((HMDistance[HMLevel] + (HMDistance[HMLevel] x ((Real((Integer A))) - 1.00)))))
Values in the case I'm testing:
HMFullDamage[1] = 5
HMLevel = 1
HMDistance[1] = 200.00


Please tell me where the error is, cause I can't find it myself...
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
You just get owned by paranthesis.In your condition there is only 1 "(" before the "Real" word, which is wrong.Inside your if you have 2 "(" before the "Real" word which is true.

Because what you are trying to do is something like this:
Distance[level] + (Distance[level] * (integerA - 2))

But in your condition statement, it is like this:
Distance[level] + (Distance[level] * integerA) - 2
 
Status
Not open for further replies.
Top