ID:179412
 
I was working on makeing it so when a usr attacks something tthat isnt another user (like a monster or something), it attacks back. I tried useing the combat system (demo i think?) but it didnt agree with my code so i came up with a new one.

mob
verb
Attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
if(M.HP >= 0)
var/Mdamage = M.attack - usr.defence
var/damage = usr.attack-M.defence //assign a random # to a new variable
var/colour = "red"
s_damage(damage,colour,M)
M.HP -= damage //take away the damage from M
M:DeathCheck() //check for death with a proc
if(src.client==null)
if(Mdamage<=0)
usr << "[M]'s attack bounces off harmlessly"
if(Mdamage>=1)
s_damage(Mdamage,colour,usr)
usr.HP-= Mdamage
usr:DeathCheck()
else
usr << "[M] is already dead!"



Thats my code, the part in bold is the part that i had to make the monsters attack back.

=) thanks in advance
__________________________________________________
~dbz73~
Not a DBZ game maker! Don't let the name fool ya!
You're checking the src's client (which isn't defined as the person being attacked), try checking M's client.
In response to Nadrew
=) it works now
dbz73 wrote:


~dbz73~
Not a DBZ game maker! Don't let the name fool ya!

Coulda Fooled me!
j/k

I had problems with src.client before, but then i realized that it had no idea what src was, so I changed it to M



A src is a src, of course, of course,
and no one can define a src of course
That is, of course, unless the src is the famous var/ M!