ID:145904
 
Code:
mob
monsters
Bug
icon = 'Icons.dmi'
icon_state = "Frozen"
origloc = "10,12,1" //The original location of the mob
respawn = 100 //Respawns after 10 seconds
-----------------------------------------

die(mob/M)
if(src.hp<=0)
blbalbalablablba
src.loc = null
sleep(src.respawn) //Waits respawn amount
src.loc = origloc // Moves the monsters back to his original location


Problem description: Doesn't respawn back

Mysame wrote:
origloc = "10,12,1"

...

src.loc = origloc

So, in effect, here's what you're doing:

src.loc = "10,12,1"

Wrong! loc is not a text string. It's an atom. Use locate() (or, if you're quite insistant on using a text string, download p_utility and use the locate_text() procedure) to get the turf at (10,12,1) and go there.
In response to PirateHead
Yeah well, but origloc = 10,12,1 gives
mobs.dm:16:error: ,: expected }
mobs.dm:4:error: location of top-most unmatched {
> mob
> monsters
> Bug
> icon = 'Icons.dmi'
> icon_state = "Frozen"
> respawn = 100 //Respawns after 10 seconds
New()
..()
origloc = loc

> -----------------------------------------
>
> die(mob/M)
> if(src.hp<=0)
> blbalbalablablba
> src.loc = null
> sleep(src.respawn) //Waits respawn amount
> src.loc = origloc // Moves the monsters back to his original location
>


That should work, who knows. =p
In response to Mysame
try origloc = src.loc = locate(10,12,1)
In response to Derekjeterisgod
You can't set 'origloc' to locate(x,y,z). Although src.loc should be set to that. Origloc cannot be declared to be a dynamic value at compile-time, though.

Do this:
mob/monster
var/origloc
New()
..()
origloc=loc
Respawn()
//Yeah, whatever else goes here
loc=origloc
In response to Jp
Thanks all! It worked!!!
If you want to save your data via text string, something I also prefer because it uses a single variable, use something like this.
proc/Text2Location(T as text)
if(!istext(T)) return T
var/x=text2num(copytext(T,1,findtext(T,",")))
T=copytext(T,findtext(T,",")+1)
var/y=text2num(copytext(T,1,findtext(T,",")))
T=copytext(T,findtext(T,",")+1)
var/z=text2num(copytext(T))
var/turf/T=locate(x,y,z)
return T


It's sort've long, but it works, and saves you a couple of variables.