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
Atreides096
Beginner


Joined: 26 Apr 2004
Posts: 15
Location: USA

PostPosted: Fri May 21, 2004 7:20 pm   

Stopping Math fnctns frm rounding to whole numbers
 
I am currently writing a script that evaluates many of my fighting situations, and then displays to me the average damage I do from certain attacks, and average number of attacks I land from certain skills. However, I cannot find a way to get the math functions to return anything but whole numbers, rounded down.

This isn't an issue for most of the things the script is tracking, but one (backstab) can only hit 1-6 times, so the average number of "hits" rounded down is becomes very inaccurate. My aliases looks like this: (Note I will display the whole alias, however the math in this particular alias is only 1 line, near the top)

#ALIAS {meleedamdis} {
#CLASS {FightEvaluator|MeleeDamageCount}
#math damageaverage {(@totaldamage) / (@totalhits)}
#CLASS 0
#say %ansi( high, white)Since: @damcounttime
#say %ansi( high, yellow)@totalhits Hits Landed
#say %ansi( high, yellow)@totaldamage Damage Done
#say %ansi( high, red)@damageaverage average per hit.
#if {%0} {%0 I have landed @totalhits attacks for a total of @totaldamage damage. My average attack hits for @damageaverage~. Melee Damage Counter last reset: @damcounttime~.}
}

I have tried %eval and %norm as well, with the same results (though %norm displayed the result as (X).0 instead of simply (X), but in the trial run the value should have been (X).31 so it was still rounding.

As always, any suggestions are greatly appreciated. Thanks a lot.
Reply with quote
Guede
Wanderer


Joined: 30 Nov 2003
Posts: 65
Location: United Kingdom

PostPosted: Fri May 21, 2004 8:46 pm   
 
Try using %float in your calculation.

i.e. %float(@totaldamage)/@numhits

-G-

Edited to include example.
Reply with quote
Atreides096
Beginner


Joined: 26 Apr 2004
Posts: 15
Location: USA

PostPosted: Sat May 22, 2004 2:42 am   
 
Thanks for the advice.. unfortunately, %float returns the same thing -- (X).0, a whole number rounded off and then adding a .0, even though it should be like (X).455
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat May 22, 2004 3:45 am   
 
#VAR damageaverage {%eval( @totaldamage/@totalhits).%eval( (( @totaldamage@totalhits) * 100)/@totalhits)}

This is a string, not a number, and should not be used in other calculations.
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