ID:266660
 
I can't seem to figure out whats wrong with my code so I'm posting here.I get this runtime error when the monster attacks.

runtime error: Cannot read null.type
proc name: Death (/mob/proc/Death)
source file: Procs.dm,48
usr: GiantRat (/mob/Monster/GiantRat)
src: Emperor Beld (/mob/Player)
call stack:
Emperor Beld (/mob/Player): Death(null)
GiantRat (/mob/Monster/GiantRat): MonAttack(Emperor Beld (/mob/Player))
GiantRat (/mob/Monster/GiantRat): Bump(Emperor Beld (/mob/Player))

I'm suspecting somethings wrong with my Death proc or how it's called so I'll post them here.
        MonAttack(mob/M)      //new proc called attack
if (src.hittime==0)
src.hittime=1
M.Life -= damage
view(M) << "<b><font color=white>[src]</b> <font color=white>attacks <font color=red>[M]!" //in view of the attacker, show this message...
view(M) << "<b><font color=red>[damage]<font color=white> damage!" //Same here
sleep(attackdelay)
src.hittime=0
M.Death() //call the death proc to the victim
else
..()
that is how it's called and...
proc //Some new procs
Death(mob/M) //Named deathcheck, and when I put M in the coding for this proc, it will mean the mob (not src, but other mob)
if(M.type == /mob/Player) //If the mobs type is that of /mob/PC
PCDeath() //Then do the PCDeathCheck on it
else //Otherwise...
if(M.Life <= 0) //if its HP is less than or equal to 0...
usr.exp += M.exp_give
del(M) //Delete the mob
PCDeath(mob/M)
if(M.Life <= 0)
view(M) << "<font color=white><b>[src] has been killed."
M.loc = locate(3,2,1) //Move it to the starting point
M.Life = MaxLife //Refill the PC's HP

this is my death proc.

if you know whats wrong please help

-Beld

Emperor Beld wrote:
I can't seem to figure out whats wrong with my code so I'm posting here.I get this runtime error when the monster attacks.

runtime error: Cannot read null.type
proc name: Death (/mob/proc/Death)
source file: Procs.dm,48
usr: GiantRat (/mob/Monster/GiantRat)
src: Emperor Beld (/mob/Player)
call stack:
Emperor Beld (/mob/Player): Death(null)
GiantRat (/mob/Monster/GiantRat): MonAttack(Emperor Beld (/mob/Player))
GiantRat (/mob/Monster/GiantRat): Bump(Emperor Beld (/mob/Player))

I'm suspecting somethings wrong with my Death proc or how it's called so I'll post them here.
>       MonAttack(mob/M)      //new proc called attack
> if (src.hittime==0)
> src.hittime=1
> M.Life -= damage
> view(M) << "<b><font color=white>[src]</b> <font color=white>attacks <font color=red>[M]!" //in view of the attacker, show this message...
> view(M) << "<b><font color=red>[damage]<font color=white> damage!" //Same here
> sleep(attackdelay)
> src.hittime=0
> M.Death() //call the death proc to the victim
> else
> ..()
> that is how it's called and...
> proc //Some new procs
> Death(mob/M) //Named deathcheck, and when I put M in the coding for this proc, it will mean the mob (not src, but other mob)
> if(M.type == /mob/Player) //If the mobs type is that of /mob/PC
> PCDeath() //Then do the PCDeathCheck on it
> else //Otherwise...
> if(M.Life <= 0) //if its HP is less than or equal to 0...
> usr.exp += M.exp_give
> del(M) //Delete the mob
> PCDeath(mob/M)
> if(M.Life <= 0)
> view(M) << "<font color=white><b>[src] has been killed."
> M.loc = locate(3,2,1) //Move it to the starting point
> M.Life = MaxLife //Refill the PC's HP
>

this is my death proc.

if you know whats wrong please help

-Beld


Try something like,

mob/proc/Death(mob/M as mob)
if(istype(M,/mob/player))
M.PCDeath()
else
if(M.Life <= 0)
del(M)

Try that out..