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

Status
Not open for further replies.
Level 6
Joined
Jan 8, 2009
Messages
140
This snippet of a trigger should find the percentage a player is towards the next level. it is run at the bottom of the xp updating trigger. however it is giving me values of 0 every time, as far as I can tell it should be working out but it's probably an obvious overlook on my part. (the else part was only added because I though it might be bugging out using XPBrackets[0] which isn't set.)

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Level Greater than 1
    • Then - Actions
      • Set tmpInt = (XPBrackets[Level] - XPBrackets[(Level - 1)])
      • Game - Display to (All players) for 30.00 seconds the text: (String(tmpInt))
      • Set XPPercent = ((XP - XPBrackets[(Level - 1)]) / tmpInt)
      • Set XPPercent = (XPPercent x 10)
      • Game - Display to (All players) for 30.00 seconds the text: (String(XPPercent))
      • Multiboard - Set the text for Multiboard item in column 2, row 5 to XPBar[XPPercent]
    • Else - Actions
      • Set XPPercent = (XP / XPBrackets[1])
      • Set XPPercent = (XPPercent x 10)
      • Game - Display to (All players) for 30.00 seconds the text: (String(XPPercent))
      • Multiboard - Set the text for Multiboard item in column 2, row 5 to XPBar[XPPercent]
 
Level 16
Joined
Dec 15, 2011
Messages
1,423
Does tmpInt returns a valid value? If it is 0, XPPercent would be infinity (divide by 0) and the game will treat it as 0 in string form or an invalid value. Try and see if there is an error with tmpInt. Convert it to real is what I am thinking.

Oh and please make sure all the values are in real. Real and integer often misinteract.
 
Level 6
Joined
Jan 8, 2009
Messages
140
Check updated post.

Off-topic: 666th post. Scary =))

Yeah I think I just realised the issue, the division results in decimal and it's being converted to 0 which kills the rest of the trigger, i'm changing it now haha.

EDIT: Fixed it up, thanks a lot, doomlord.
 
Last edited:
Status
Not open for further replies.
Top