Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
BobXFett
Novice


Joined: 18 Aug 2001
Posts: 43
Location: USA

PostPosted: Sat Apr 19, 2003 10:31 pm   

Strange math problem with gauges.
 
I've set up some HP gauges and such for my MUD, and they seemed to be working normally for a while, but now they've got this weird problem.

There's a 'wimpy' feature on my MUD, and you set it to a % of your total HP. I want my gauge to change color when it gets to that % so I set up the gauge like this:

Gauge value: @HP
Gauge max: @HPmax
Gauge low: (@HPmax/100)*15

Both those variables are captured from triggers, and their values capture correctly, but I've discovered my gauge doesn't change colors until it is at least 3 below the value that the math should give it.

For example, I have 519 HP on the MUD, and a wimpy of 15, so the gauge should turn red at 77.225% or something like that, which I assume would be rounded to 77. The gauge won't change colors until it's at 74HP or lower, though.

I tried this with a couple other amounts (went up to 16% and down to 14%), and it had the same effect: the gauge actually changed color 3 lower than the math said it should.

I always updated my variables and they were at the correct values, and there are no #MATH triggers that are messing with those variables at all, so I can't figure out what the problem is.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Apr 19, 2003 11:04 pm   
 
zMUD uses integer math, so you'll seldom get exact numbers. However, you'll get closer if you do the multiplication first instead of the division.
@HPmax = 519
(@HPmax/100)*15 = (519/100)*15 = 5*15 = 75
(@HPmax*15)/100 = (519*15)/100 = 7785/100 = 77

LightBulb
Advanced Member
Reply with quote
BobXFett
Novice


Joined: 18 Aug 2001
Posts: 43
Location: USA

PostPosted: Sun Apr 20, 2003 2:46 am   
 
Thanks a bunch, that seems to have fixed it (it's still 1 below the 'low number' but I assume that is by design). I never even thought of doing it the other way around... Math isn't exactly my strong suit ;)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net