ID:145952
 
Code:
//in the death proc
if(M.Bounty)
call(M,/obj/item/dead/proc/CreateDead)(M.loc,M,"head")
else
call(M,/obj/item/dead/proc/CreateDead)(M.loc,M,"corpse")



obj/item/dead
proc
CreateDead(Loc,mob/owner,body)
var/obj/item/o
if(body == "head")
o = new /obj/item/dead/corpse(src.loc)
o.name = addtext(owner.name,"'s head")
o.dir = owner.dir
spawn(rand(200,350))
del(o)
else
o = new /obj/item/dead/head(src.loc)
o.name = addtext(owner.name,"'s corpse")
o.dir = owner.dir
spawn(rand(200,350))
del(o)

corpse
size = 7
desc = "Food for the earth or a trophy for a victor, your chioce"
icon = 'dead.dmi'
icon_state = "corpse"

head
size = 3
desc = "A human head, why on earth would you want that?"
icon = 'dead.dmi'
icon_state = "head"


Problem description:
I am having problems getting my corpse/head system to work. The code I have here is the result of at least an hour of debugging then throwing away code and rewriting so its not very pretty or near working. Sort of like a desperate attempt. Anyways, origianlly this was based of of sariat's corpse demo in which you use new in the death proc to create the corpse and then you define the New()proc for the corpse to tell it to rename it etc... This was all fine and good except when it came to saving and loading my game. When you had a corpse in your inventory logged out then logged back in it would call the New() proc for the corpse and that would cause problems because it would be missing the variable used to create an actual new corpse. So I tried to seperate the use of arguments from the New() proc, but as you can tell I wasnt very successfull. I would appreciate any suggestions anyone has on either this code or how to use the New proc more effectivly. Thank you for your time.
you could try making it so when you pick up the head or corpse, it deletes it and gives you a different item
like you pick up
/obj/items/dead/head/
and you get a
/obj/items/dead2/head/
and it deletes the old one