ID:179093
 
I have this
mob/monster
var/tookaction

New()
ailoop()
return ..()

proc/ailoop()
while(1)
sleep(15)

var/mob/M
for(M in oview(1))
if(istype(M, /mob/player))
src.tookaction = 1
attack(M, src)
deathcheck()

if(src.tookaction != 1)
for(M in oview())
src.tookaction = 1
step_to(src, M)
src.tookaction = 0

mob/verb/Attack(mob/M in oview(1))
set category = "Combat"
attack(M, src)
deathcheck()




mob/proc/attack(var/mob/target, var/mob/attacker)
target<<"[attacker] has attacked you"
target.energy-= attacker.strength
attacker<<"You Attacked [target] for [attacker.strength]"

with this deathcheck()

proc/deathcheck(var/mob/attacker, var/mob/target)
if(target.client)//If it's a PC player
if(target.energy <= 0)
target.loc=locate(1,1,1)
target<<"You were destroyed, [attacker] killed you"
attacker<<"You destroyed [target]!"
world<<"[target] was destroyed by [attacker]!"
attacker<<"You destroyed [target]"
del(src)

mob
var/mob/sender
var/mob/reciever

and when either a mob or player attacks in game I get these errors

when mob attacks:
runtime error: Cannot read null.client.
proc name: deathcheck (/proc/deathcheck)
usr: the robot (/mob/monster/robot)
src: null
call stack:
deathcheck(null, null)
the robot (/mob/monster/robot): ailoop()
the robot (/mob/monster/robot): New(the bfloor (3,3,2) (/turf/floor/bfloor))

when player attacks:
runtime error: Cannot read null.client.
proc name: deathcheck (/proc/deathcheck)
usr: Vermolius (/mob/player)
src: null
call stack:
deathcheck(null, null)
Vermolius (/mob/player): Attack(the robot (/mob/monster/robot))

now I know this is a mess but I have no Idea why im getting this error in game

mob/monster
var/tookaction

New()
ailoop()
return ..()

proc/ailoop()
while(1)
sleep(15)

var/mob/M
for(M in oview(1))
if(istype(M, /mob/player))
src.tookaction = 1
attack(M, src)
deathcheck()

if(src.tookaction != 1)
for(M in oview())
src.tookaction = 1
step_to(src, M)
src.tookaction = 0

mob/verb/Attack(mob/M in oview(1))
set category = "Combat"
attack(M, src)
deathcheck()
/* You need to pass the target and attacker to deathcheck, try deatcheck(src, M) instead of just deatcheck.*/
mob/proc/attack(var/mob/target, var/mob/attacker)
target<<"[attacker] has attacked you"
target.energy-= attacker.strength
attacker<<"You Attacked [target] for [attacker.strength]"
/*Try moving your deathcheck here so it checks for player deaths too, since monster attacks go directly to the proc and ignore the verb, If you do move it though, it should be deathcheck(attacker, target), not src, M*/

with this deathcheck()

proc/deathcheck(var/mob/attacker, var/mob/target)
if(target.client)//If it's a PC player
if(target.energy <= 0)
target.loc=locate(1,1,1)
target<<"You were destroyed, [attacker] killed you"
attacker<<"You destroyed [target]!"
world<<"<font color=red>[target]<font color = white> was destroyed by [attacker]!"
attacker<<"You destroyed [target]"
del(src)
/*Add an else to check to see if it's the player who died and do whatever you want here*/


mob
var/mob/sender
var/mob/reciever