ID:268054
 
I have no idea how to do this but... when a person dies i want their corpse to stay on the ground so you can pick stuff out of their bodies(such as the items they once had) and then eventually start to crumble and disapear could someone show me a peice of code of how to do this? thank you.

- Vash
Vash_616 wrote:
I have no idea how to do this but... when a person dies i want their corpse to stay on the ground so you can pick stuff out of their bodies(such as the items they once had) and then eventually start to crumble and disapear could someone show me a peice of code of how to do this? thank you.

I won't hand you the code in a nicely-bound package, but I will provide you with an idea of how you could go about doing this.

First off, you want people who die to drop a corpse with their loot in it. That's as simple as creating a corpse object, dropping it at the person's location and filling its contents with the person's.

mob/proc/Die()
var/obj/Corpse/C = new(src.loc) // Create the corpse
for(var/obj/O in src.contents)
O.Move(C) // Loop through each item and put it in the fresh corpse


You also said that you want bodies to crumble and disappear. You could accomplish this by having multiple icon states of the corpse in its various stages, and having a seperate thread to handle the countdown of these stages until you choose for the corpse to be deleted.

obj/Corpse
var/lifetime=5 // A var to measure how long it has left before it is deleted

New() // Override the corpse's New() proc
..()
Decay_Loop() // Call our decaying loop

proc/Decay_Loop()
src.lifetime--
if(src.lifetime < 1)
del(src) // Toast the corpse if it's totally decayed
src.icon_state = "[src.lifetime]" // Assuming you numbered your corpse's icon states
spawn(100) // Wait 10 seconds
Decay_Loop() // Keep on rotting!


I hope that's helped give you some insight on what you're trying to do.
In response to Malver
thanks that really helped me get an idea of what i needed to do