ID:169194
 
How do I round damage up

Say like I do an attack.

it does like say.... 0.33245

how can I round that up to the nearest whole number?

also:

How do I use prob()?

I read the DM guide but didn't understand it well
mob/verb/test()
var/t=rand(5,10)
world<<t
t=round(t/2,1)
world<<t
if(prob(t))
src<<"You win!"

That'll basically make t a random number from 5 to 10, then divide it by 2, then round it up. Then, it'll check if(%chance) and he'll win.
In response to Ol' Yeller
that was quick

Thanks alot!

[edit]
var/damage = src.CPL
damage = round(damage/12,1)
if(src.doing==0)
src.doing=1
src<<"You throw a fury of punches at [M]"
M<<"[src] throws a fury of punches at you!"
M.CPL -= damage
view() << "[src] attacks [M] for [damage] damage!"
src.doing=0
M.Die()

this is what I use.
but it doesn't work.

when some one attacks with low PL (say 5) it does 0 damage

when some one higher (say at 15) it does 1

did I do something incorrect?
In response to Crzylme
I'm new with coding, but does the order of random range have to go low,high or can it be either?
In response to Steelhouse
good question... not sure.
In response to Crzylme
I guess someone will have to test that out. That someone will be me unless someone else gets back with that answer before I'm at the library again.. which will be 6pm est.
In response to Steelhouse
Looks like the answer is yes, the min/max can be either order. Your problem lies somewhere other than that, and I don't know what. Keep plugging away. I solved a problem once by rewriting the whole portion of code I was using. Try that after cut-pasting to a safe spot or commenting it out temporarily.
In response to Steelhouse
round proc
Format:
round(A)
round(A,B)
Returns:
rounded A
Args:
A: A number.
B: The nearest multiple to round A.
The first format returns the integer portion of A. The second format rounds A to the nearest multiple of B.

Example:
usr << round(1.45) // outputs 1