ID:143277
 
So trying to get damage not to = a negative number here, as it's healing my usr when it's negative.
mob/proc
attack(mob/M as mob in oview(1))
set category = "Combat"
usr << "You attack [M]!"
oview() << "[usr] attacks [M]!"
var/damage = rand(1,10)+rand(1,psionic)-(M.defense)
world << "[damage] damage!"
M.HP -= damage
M.DeathCheck()
CheckExp()


Problem description:

if(damage<0)damage=0

var/damage = max(rand(1,10)+rand(1,psionic)-(M.defense),0)

Maybe.
In response to Dever
Thanx I'll give it a try after i get some grub.

Mike
In response to Dever
Dever wrote:
var/damage = max(rand(1,10)+rand(1,psionic)-(M.defense),0)

Maybe.

This one worked straight away, works better for my purposes since i won't have to get into if/else statements.
thanx m8

mike-
In response to Kichimichi
You shouldn't just copy code and get along with it. Read up on max() in the reference, see how it works, so you learn to use it yourself.

Also, no usr in proc. Ungh.
In response to Kaioken
Kaioken wrote:
You shouldn't just copy code and get along with it. Read up on max() in the reference, see how it works, so you learn to use it yourself.

Also, no usr in proc. Ungh.

You know bro, I have looked it up, I look up most of what I use. If I tend to cut and paste more than a veteran I'm sorry, If I'm not out of the box a great programmer I'm sorry, if I enjoy playing with levels of programming a bit beyond my scope I'm sorry.
I understand max(), I tried finding that function in the mathematical symbol section of the guide, but couldn't that's why I asked for help, now that I was referred to it I get it. I'm not whining for help or bumping my requests, I thank people helping me out, but you know being a curmudgeon is not a virtue in and of itself.

Mike-