ID:1396839
 
(See the best response by LordAndrew.)
I am having some trouble making a enemy corpse(when it dies the icon stays the same).Heres the enemy slime code:
mob/Enemy
Slime
icon='slime.dmi'
level=1
health=10
maxhealth=10
str=5
pow=5
def=5
exp=21
money=10
New()
src.health=src.maxhealth
src.mana=src.maxmana
spawn()
src.Wander()
return ..()
proc/Wander()
while(src)
if(src.Frozen == 1)
break
else
if(src.Target)
if(get_dist(src,src.Target)>1 && !step_to(src,src.Target,1))
src.Target=null;continue
src.dir=get_dir(src,src.Target)
src.Fight()
if(!ListCheck(src.Target,oview(5)))
src.Target=null
sleep(rand(1,2))
else
sleep(rand(10,15))

if(!src.Target)
for(var/mob/M in oview(4))
if(M.key)
if(step_to(src,M,1))
src.Target=M
sleep(5)
break

proc/Fight()
for(var/mob/M in get_step(src,src.dir))
if(M.key == M.client.key)
var/damage=src.str-M.def
damage=max(1,damage+rand(-1,1))
M.health -= damage
sleep(7)
M <<"<font size=1><b><font color=red>[src] was hit by [M] for [damage] damage!"
M.DamageShow(damage,200,0,0)
M.DeathCheck(src)
It doesn't appear you're setting a dead state anywhere in your code here. I suspect you're handling it in DeathCheck(), which we'll need to see.
here's my deathcheck


DeathCheck(mob/Killer)
if(src.health<=0)
if(src.key)
src<<"<I><small>You have been defeated by [Killer]!"
make_corpse(src)
src.health=src.maxhealth
src.mana=src.maxmana
src.loc=locate(11,5,1)
else
Killer<<"<I><small>You defeated [src]! Gained [src.exp] EXP and $[src.money]"
make_corpse(src)
Killer.exp+=src.exp
Killer.money+=src.money
Killer.LevelUp()
del src <dm>
In response to Tiago7727
I see. What do you have in make_corpse()?

Also, please make sure to wrap your code in <dm> tags so that the forum renders it correctly:

<dm>
your_code_here()
</dm>
proc
make_corpse(mob/m)
var/obj/O= new/obj(locate(m.x,m.y,m.z))
O.name="[m.name]'s remains"
O.icon = icon(m.icon,"[m.icon_state]_dead")
O.icon = icon(m.icon,"[m.icon_state]_dead")
spawn(rand(300,600)) del(O)<dm>
In response to Tiago7727
Best response
A few things:

You're setting O.icon twice, and it appears you're generating an /icon object for it (rather than just directly setting the icon and icon_state, which may be the reason behind why it isn't working). You could also easily just do var obj/o = new (m.loc) rather than verbosely setting its exact coordinates.

Another thing is, do you actually have a state in your icon for [m.icon_state]_dead? If not then it would either turn blank or default to the null state in your icon.

// Try giving this version a whirl.
proc/make_corpse(mob/m)
var obj/o = new (m.loc)
o.name = "[m.name]'s remains"
o.icon = m.icon
o.icon_state = m.icon_state + "_dead"

spawn (rand(300, 600))
del o

Or, if you're feeling adventurous, you could do...

obj/corpse

obj/corpse/New(loc, mob/m)
name = m.name + "'s corpse"
icon = m.icon
icon_state = m.icon_state + "_dead"

spawn (rand(300, 600))
del src

proc/make_corpse(mob/m)
new /obj/corpse(m.loc, m)
you sir are simply awesome thanks for the help