• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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