ID:141681
 
Code:
//Rough Attack
mob/verb/Attack(mob/M as mob in get_step(src,src.dir))
set category = "Fighting"
var/damage = usr.Str*1.5-M.Def/3
if(usr.canbeattacked)
//M.parryrate()
usr<<output("<font color=red>Battle AI:</font> <font color=white>You attacked [M] for [damage]!</font>","chat")
M<<output("<font color=red>Battle AI:</font> <font color=white>You were attacked by [usr] for [damage]!</font>","chat")
oview(8)<<output("<font color=red>Battle AI:</font> <font color=white>[M] was hit by [usr] for [damage]!</font>","chat")
M.HealthP -= damage
M.deathcheck(usr)
else
usr<<output("<font color=red>Battle AI:</font> <font color=white>You cannot attack this player, he is probally dead.</font>","chat")
return

// Rough Deathcheck
mob/proc/deathcheck()
if(usr.HealthP <= 0)
usr<<output("<font color=red>Death AI:</font> <font color=white>You died and will be respawned in a little bit.</font>","chat")
usr.freeze = 1
usr.icon_state = "Dead"
usr.canbeattacked = 0
sleep(100)
usr.loc = locate(1,1,1)
usr.freeze = 0
usr.icon_state = ""
usr.HealthP = usr.StamP
usr.canbeattacked = 1

//Test dummy
mob
test
name = "Test Dummy"
icon = 'Tall Male.dmi'
HealthP=20
Def=1


Problem description: When I attack the test dummy its HealthP goes to 0 but it isnt dieing.

1. The stuff inside the parentheses after procs are called arguments.
For example, your Attack verb has an argument: (mob/M as mob in get_step(src,src.dir)). M is a mob in one step ahead of src.
You have usr as an argument when calling M.deathcheck(). Pointless.

2. usr abuse. When you're calling M.deathcheck() in the Attack verb, usr is the one who attacked, not M. usr is inherited through verbs/procs. Use src instead, that's what it's for.
//I find it easier to just not include src when accessing 
//variables, just because it's 4 keys less to type.
//For example:
src.Variable
src<<src.Variable
//is the same as
Variable
src<<Variable


3. You don't need to use output() for default outputs. Just set the "chat" output control as the default by checking the Default checkbox in the skin editor.

4. return at the end of a proc is pointless. Procs automatically return . at the end of the proc. "." is a built-in variable for procs containing the default return value.

5. Please, use tabs instead of spaces for indentation. It's a lot easier to read.
In response to Kaiochao
Confused about what you said for 1 & 2,

3. Chat isn't default, OOC is. It is just called chat.

4. Thank you.

5. I know but thats how my higher up wants it. We will probably change it to tabs soon enough though.
In response to Marcmacman
mob/verb/Attack(mob/M as mob in get_step(src,src.dir))
//M is an argument in that case
//if you did not know
set category = "Fighting"
var/damage = usr.Str*1.5-M.Def/3
if(usr.canbeattacked)
//M.parryrate()
usr<<output("<font color=red>Battle AI:</font> <font color=white>You attacked [M] for [damage]!</font>","chat")
M<<output("<font color=red>Battle AI:</font> <font color=white>You were attacked by [usr] for [damage]!</font>","chat")
oview(8)<<output("<font color=red>Battle AI:</font> <font color=white>[M] was hit by [usr] for [damage]!</font>","chat")
M.HealthP -= damage
M.deathcheck(usr)//there you are using an argument
//as you putted something inside the () of the proc name
//and what you type inside that will be recived on
//the proc you called
else
usr<<output("<font color=red>Battle AI:</font> <font color=white>You cannot attack this player, he is probally dead.</font>","chat")
//as Kaiochao said return isnt needed


mob/proc/deathcheck(mob/M)
//as i said the argument will be recived here
//and will be defined as M
//in this case M is the attacker
//by the way, by usr abuse he meant
//usr is null and will give you a run time error
if(src.HealthP <= 0)
src<<output("<font color=red>Death AI:</font> <font color=white>You died and will be respawned in a little bit.</font>","chat")
src.freeze = 1
src.icon_state = "Dead"
src.canbeattacked = 0
sleep(100)
src.loc = locate(1,1,1)
src.freeze = 0
src.icon_state = ""
src.HealthP = src.StamP
src.canbeattacked = 1


I hope you understand my notes and that works for you.

By the way, read this