ID:1152655
 
(See the best response by Keeth.)
Code:
//Attack code
mob/verb
Attack()
set hidden =1

if(canFight&&move)
if(!swordOn)flick("punch",src)
else flick("Sword Slash1",src)
for(var/mob/M in get_step(src,src.dir))

if(!M.ko)
canFight--
var/off= round(str+rand(-1,1))
if(off<1)off=1

var/def=round((M.lev-lev)*5)
if(def<1)def=1

var/dmg= round(off-def)
if(dmg<1)dmg=1

if(M.passive=="Evasion")
var/R2=100-M.passiveRate
var/sum2=R2+M.passiveRate
var/roll2=rand(1,sum2)
for(var/T2 in passiveList)if(roll2==T2)
dmg=0
show_damage(M,"miss","#f80")

else
if(passive=="Critical"||passive=="Pierce")
var/R=100-passiveRate// subracts the passiveRate from 100 and assigns it to R ex. 100-25=75
var/sum=R+passiveRate // it takes R which is the difference of 100 and passiveRate and assigns it to sum ex. 75+25=100
var/roll=rand(1,sum) // it picks a random number from 1 to the sum
for(var/T in passiveList)
if(roll==T)//assigns T as number from the passiveList; then it tries to find if roll is equal to one of those numbers

if(passive=="Critical")
dmg*=3
donePassive++

if(passive=="Pierce")
dmg=round(str+rand(-1,1))
donePassive++


if(donePassive)
if(passive=="Critical")show_damage(M, dmg, "yellow")
else if(passive=="Pierce")show_damage(M,dmg,"blue")
donePassive--
else show_damage(M, dmg, "#fff")

M.hp-=dmg

if(M.client)
M.Update()
if(M.tab=="vitals")M.statsTab()
if(M.hp<1)M.koCheck()

spawn(hitDelay)
canFight++

mob/proc
koCheck()
if(hp<1)
hp=0
ko=1
move=0
overlays+='ko.dmi'
wounds+=35
Update()
view()<<"[src]: my wounds are [wounds]%"//for debugging
if(wounds>99)Death()

//death code
mob/proc
Death(mob/M)
if(!src||!M)return
if(wounds>99)
if(client)world<<output("[M] has died in the hands of [src]!","playerOut")
view(src)<<output("[src]: [src.mDm]","playerOutput")
ko=0
overlays-='ko.dmi'
//locate and call healling proc
if(istype(src, /mob/Enemies))
loc = locate(0,0,0)
enemyHeal()
spawn(spawnTime*10)
loc = oldSpot
var/D=src.expGive+100
M.exp+=D
if(M.exp>=M.maxExp)M.levelUp()
M<<"Exp +[D]"

//and finally enemy code
mob/Enemies/New()
if(src.enemyType=="Bully")
src.enemyOverlay()
src.lev=rand(1,10)
src.enemyPower()
src.name="Lv-[src.lev] Bully"


spawn(-1) src.CombatAI()

return ..()


Problem description: It's probably really simple but I can't seem to figure it out. What I am trying to do is call the death proc if my enemy has more than 99 wounds but when I do nothing happens. It worked a few days ago.

Edit: M is empty, so it returns.
Explain. Where is it empty and how do I go about fixing it.
Bump.
Best response
//koCheck()
if(wounds>99)Death()

//Death()
Death(mob/M)
if(!src||!M)return

The only time you call Death() here, you don't supply it with an argument (M). Your Death() function DEMANDS src and M be non-null (!src || !M).

Also, you do not have to check if src is non-null ever. If src is null in an object function, then that function stops processing. if(src) and while(src) might as well be if(1) and while(1).

And in the future, try to provide just the relevant blocks of code. All we needed to see here were Death(), and whatever calls Death() (koCheck() in this case). Large blocks of code are discouraging for help as it can be a hassle trying to parse other people's code. Especially when we don't know what we're looking for.