ID:149490
 
mob/monsters
var/monster
var/isattacking = 0
var/monhp
var/monmaxhp

// This seems to be undefined?!?!
var/mob/monster/M

proc
ddamage(M as mob,damage)
M.monhp -= damage
M.death_check(M)
death_check(M as mob)
if(M.monhp < 1)
killmon(M)
killmon(M)
del(M)
var/dropi = rand(0,10)
if(dropi <= 8)
You are declaring a mob/monster as a var, but the type you have posted is mob/monster<font color=red>s</font>.

In your ddamage() and death_check() procs you are using a plain mob named M as input, but are trying to treat M as a mob/monsters. For instance, monhp is defined for a mob/monsters, not a plain mob. This seems to be the larger issue you should fix.

Either way, within a proc, an argument will be used over a var with the same name declared for an object. In other words, the M as mob in your procs will be used, not the var/mob/monster/M. In this case, if you wanted the var/mob/monster/M within those procs, you could use src.M.
here try this


mob/monsters
var
monster
isattacking = 0
monhp = 100
monmaxhp = 100



proc/ddamage(M as mob,damage)
M.monhp -= damage
spawn() death_check()
proc/death_check(M as mob)
if(M.monhp < 1)
spawn() killmon()
del src

var/dropi = rand(0,10)
if(dropi <= 8)

In response to Buzzyboy
Problems noted in yellow...

mob/monsters
var
monster
isattacking = 0
monhp = 100
monmaxhp = 100

proc/ddamage(M as mob,damage)
M.monhp -= damage
spawn() death_check() <font color=yellow> // does not pass your mob to death_check, but death_check expects one</font>
proc/death_check(M as mob)
if(M.monhp < 1)
spawn() killmon()<font color=yellow> // does not pass a mob to killmon, though killmon will obviously need one</font>
del src <font color=yellow> // you've defined this as a global proc, so there is no src. And if there were one, it would end the proc here, so the below would never execute. Lastly, the syntax is del(src)</font>

var/dropi = rand(0,10) <font color=yellow> // indented too far </font>
if(dropi <= 8) <font color=yellow> // incomplete</font>


Here it is cleaned up:

mob
var
isattacking = 0
hp
maxhp

monster
hp = 100
maxhp = 100

proc
ddamage()
hp -= damage
death_check()

death_check()
if(hp < 1)
// death announcement to taste here
if(prob(80))
drop() // define your drop routine here
// or whatever you were trying to do
del(src)
In response to Skysaw
Lastly, the syntax is del(src)


Actually, both work...

del src
and
del(src)

Both work fine.
In response to Kevin Kitsune
Kevin Kitsune wrote:
Lastly, the syntax is del(src)


Actually, both work...

del src
and
del(src)

Both work fine.

Ahh... so they do.

(who was that masked man?)