ID:264303
 
Code:
mob
Necromancer
verb
Putrid_Explosion()
set category = "Spells"
set name = "Putrid Explosion"
set desc = "Death Magic-Takes 10 MP, 5 seconds to recharge, 1 seconds to activate."
if(usr.rechargePE)
usr << "You cannot cast this now!"
return
usr.rechargePE=1
spawn(5) usr.rechargePE=0
if(MP>=10)
usr.MP -= 10
sleep(30)
var/mob/M as mob
var/mob/corpse = locate(/obj/corpse) in view(M, 5)
if(corpse)
corpse.icon='Effects.dmi'
corpse.icon_state="Boom"
sleep(10)
var/result=rand(1,3)
if(result==1)
if(M in view(corpse, 3))
M.Health-=24

if(result==2)
if(M in view(corpse, 3))
M.Health-=101

if(result==3)
if(M in view(corpse, 3))
M.Health-=120

view()<<"A Corpse exploded!"
deathcheck(M)
del corpse
else
usr<<"You cannot cast this now!"
return


Problem description:

Ok, I have a bit of a problem..AGAIN cause i suck at coding >_> point aside..This spell is supposed to be set off and everyone within 3 steps of the corpse it was cast on will lose health by a random of 3 numbers, 24, 101, or 120, but it does not take away the health from me, nor surrounding players. I get this runtime error:

runtime error: Cannot read null.Health proc name: deathcheck (/mob/proc/deathcheck) usr: Reno Kujika(Necromancer) (/mob) src: Reno Kujika(Necromancer) (/mob) call stack: Reno Kujika(Necromancer) (/mob): deathcheck(null) Reno Kujika(Necromancer) (/mob): Putrid Explosion()
and i get the message "A Corpse exploded!" but the problem im asking to be helped with is why its not taking surrounding players health..
var/mob/corpse = locate(/obj/corpse) in view(src, 5)
if( !(corpse) )
src << "There isn't a corpse around!"
return
corpse.icon='Effects.dmi'
corpse.icon_state="Boom"
sleep(10)
view(corpse) << "A Corpse has exploded!"
for(var/mob/M in oview(corpse, 3)
switch(rand(1, 3))
if(1)
M.Health -= 24
if(2)
M.Health -= 101
if(3)
M.Health -= 120


That should fix your problem(sorry about any double spacing, my keyboard is being retarded and i didn't comment it =\)



In response to Axerob
Thanks for the help.
And btw:
for(var/mob/M in oview(corpse,3)

u forgot a ")" lol
for(var/mob/M in oview(corpse,3))
In response to Reno Kujika
I'd recommend using viewers() over view() in that situation. That way, it'll send the message to everyone who can see the corpse rather than whoever the corpse can see. No pun intended x.x