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
ID:179093
Feb 18 2002, 6:18 am
|
|
/*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*/
/*Add an else to check to see if it's the player who died and do whatever you want here*/