ID:263140
 
Code:
mob/var
health = 10
strength = 10
mob
Stat()
statpanel("Stats")
stat("Health: [health]")
stat("Strength: [strength]")
statpanel("Communication")
mob/verb
Attack(mob/M in oview(1))
set category = "Combat"b
var/dmg = rand(1,usr.strength)
usr << "[usr] attacks [M]"
M.health -= dmg
M.DeathCheck()
mob/proc
DeathCheck()
if(usr.health <= 0)
usr << "You die"
usr.health = 10
usr.loc = locate(1,1,1)
mob/var
attacking = 0


Problem description:

well the problem is that you don't die until you walk. you can still do everything like attack and all that but your just fine until you walk. and if you can add in defence and speed that would help to thanks ;)
You're deathcheck just checks the mob, you should check the mob and the user{src.DeathCheck(M)}. And to add weapon delay, just put a sleep(src.weapondelay) in attack. And for defence, you can do sumthing like dmg = rand(0,src.strength-M.defence). Use 0 in the dmg, cuase you wouldn't want low levels being able to hit monsters with high defence. And do if(dmg < 0) dmg=0 after the dmg var.
In response to Evidence
ua all that dose is give me errors....but thanks anyways
No put usr in proc. Ungh.
In response to Archfiend Master
No it doesn't, you just didn't understand him.

We need to define the killer, as well the dying mob. The dying mob is always <code>src</code>, <code>usr</code> on the other hand is wrong in procs, except for pseudo-verbs (Click(), DblClick(), client procs, ...)

mob/verb/Attack()
for(var/mob/enemies/M in get_step(usr,usr.dir)) // get_step() proc returns what is infront of you.
M.hp-=5
M.Deathcheck(usr)

mob/proc/Deathcheck(mob/killer)
src<<"[killer] killed you!"
killer<<"You killed [src]! Yeee!"
src.Move(locate(1,1,1)) // using Move() is better than locating. Move() will trigger that location's turf/area Enter() and Entered().


<code>usr</code> will be send as an argument to Deathcheck(), and from there on he will be the killer. It's really simple.