ID:1849225
 
(See the best response by Super Saiyan X.)
Code:
deathcheck(atkr)
usr = atkr
if(src.hp <= 0)
world << "[usr] has killed [src]!"
if(usr.isPlayer == 1)
if(usr.lvl <= 10)
usr.exp += src.lvl
usr.gold += src.gold
else
usr.exp+=round(src.lvl*((100-(usr.lvl*0.20))/100))
usr.gold += src.gold
if(src.isPlayer == 1)
src.loc = locate(null)
sleep(50)
src.loc = locate(31, 84, 1)
if(src.name == "Imp")
src.loc = locate(null)
sleep(100)
new/mob/Enemy/Imp(locate(rand(1,100),rand(1,100),1))
del(src)
if(src.name == "Nemesis")
src.loc = locate(null)
sleep(100)
src.loc = locate(44,82,1)
if(src.name == "Alpha")
src.loc = locate(null)
sleep(100)
new/mob/Enemy/Alpha(locate(1,1,1))
del(src)
if(src.name == "Beta")
src.loc = locate(null)
sleep(100)
new/mob/Enemy/Beta(locate(100,1,1))
del(src)
if(src.name == "Delta")
src.loc = locate(null)
sleep(100)
new/mob/Enemy/Delta(locate(1,100,1))
del(src)
if(src.name == "Omega")
src.loc = locate(null)
sleep(100)
new/mob/Enemy/Omega(locate(100,100,1))
del(src)
if(src.name == "Ignis_the_Immolator")
src.loc = locate(null)
sleep(900)
new/mob/Enemy/Ignis_the_Immolator(locate(20,99,1))
del(src)
if(src.name == "Flame_Cerberus")
src.loc = locate(null)
sleep(900)
new/mob/Enemy/Flame_Cerberus(locate(11,99,1))
del(src)
if(src.name == "Pigron_the_Ungrillable")
src.loc = locate(null)
sleep(900)
new/mob/Enemy/Pigron_the_Ungrillable(locate(31,99,1))
del(src)
if(src.name == "Sisemen")
src.loc = locate(null)
sleep(900)
new/mob/Enemy/Sisemen(locate(40,99,1))
del(src)
if(src.name == "Ander")
src.loc = locate(null)
sleep(900)
new/mob/Enemy/Ander(locate(51,99,1))
del(src)
if(src.name == "Corrupt_Spirit_Tiger")
src.loc = locate(null)
sleep(900)
new/mob/Enemy/Corrupt_Spirit_Tiger(locate(51,99,1))
del(src)


Problem description:
For some reason, even though the code looks like it works 100%, everyone starting at Ignis_the_Immolator down don't "respawn" correctly, aside from Sisemen, and there's nothing wrong with the calls to define a new version of them anywhere. (And, just in case Respawns don't normally have a new version of the mob being defined, for my purposes it very much required.)
Best response
It's the underscores in the string. Unless you are actually setting the name of the object to have underscores, underscores from the type definition become spaces when the object is created.
Ohhh ok, thank you very much X.
Does Ander work as well?


I noticed you are checking for "Ignis_The_Immolator" instead of "Ignis the Immolator." By default, his name is name identical to his type path, /mob/Enemy/Ignis_the_Immolator, with the underscores converted to spaces. If you define a name for it, it uses that instead.

You do the same thing for the other ones that don't work.

Edit: I was slow; SSX with the assist.
You shouldn't use usr in your proc at all. Just replace all instances of usr with atkr, and in the proc definition change atkr to mob/atkr so that it's always expected to be a mob type.

That if/else code is kinda dreadful too. All you really need is a single proc, and vars that define the coordinates.

mob/var
respawn_x
respawn_y
respawn_z

mob/proc/Respawn()
var/tp = type // keep track of type
var/turf/T = locate(respawn_x, respawn_y, respawn_z)
loc = null
src = null // let the spawned proc continue while this can die
spawn(900) new tp(T)
// don't need to call del(src) here; if there are no references the mob will disappear


In your deathcheck then, I'd replace the player check:

if(atkr.isPlayer)    // never use ==1 to check true/false
// this stuff really belongs in its own proc
if(lvl <= 10)
atkr.exp += lvl
else
// this is identical to your formula
exp += round(lvl * (1-atkr.lvl*0.002))
if(isPlayer)
loc = null
spawn(50) loc = locate(31, 84, 1)
else
// src is a monster
Respawn()