ID:139015
 
Code:
mob
verb
Punch(mob/M as mob in get_step(src,usr.dir))
set category = "Techniques"
if(src.attacking == 0)
var/colour = "yellow"
var/damage = rand(1,3)
M.health -= damage
src.attacking = 1

if(prob(10))
damage *= rand(10,25)
colour = "red"

Damage(M,damage,colour)
M.health -= damage
M:DeathCheck()
health_bar.Update()
sleep(5)
src.attacking = 0


Problem description:

How do i make it so that when i kill a mob it returns to their original spawn point and not the same as the players respawn point ( 1,1,1 )?
mob/monster
var
spawn_x
spawn_y
spawn_z

goblin
icon='goblin_icon.dmi'
icon_state="goblin"
spawn_x=10//or whatever
spawn_y=10
spawn_z=1
hp=10

mob
verb
Punch(mob/M as mob in get_step(src,usr.dir))
set category = "Techniques"
if(src.attacking == 0)
var/colour = "yellow"
var/damage = rand(1,3)
M.health -= damage
src.attacking = 1

if(prob(10))
damage *= rand(10,25)
colour = "red"

Damage(M,damage,colour)
M.health -= damage
M.DeathCheck()//never use a colon!
M.loc=locate(M.spawn_x,M.spawn_y,M.spawn_z)
//moves them to their spawn loc!
health_bar.Update()
sleep(5)
src.attacking = 0


Just define a var, assign a number to it and locate them to it when they're killed.

Also, never use a colon : in a procedure. Use a period! Hope this helped.
In response to Yusuke13
Thanks! this seems to do it ,
mob
verb
Punch(mob/M as mob in get_step(src,usr.dir))
set category = "Techniques"
if(src.attacking == 0)
var/colour = "yellow"
var/damage = rand(1,3)
M.health -= damage
src.attacking = 1

if(prob(10))
damage *= rand(10,25)
colour = "red"

Damage(M,damage,colour)
M.health -= damage
M.DeathCheck()//never use a colon!
M.loc=locate(5,5,1)
health_bar.Update()
sleep(5)
src.attacking = 0


But there is another problem , Then how will i restore other mobs into their spawns? or simply reuse this mob in another location , will i have to do this M.loc = for every single mob i put on the map ? o.o
In response to SillyChild123
Nah, just set the variable to the monster like I did in my example. Then you just call M.loc=locate(spawn_x,spawn_y,spawn_z)in the deathcheck procedure. If the monster was killed, it will be sent to its spawn location.
In response to Yusuke13
mob/Dummy
var
spawn_x
spawn_y
spawn_z

Dummy
icon='mob.dmi'
icon_state=""
spawn_x=5
spawn_y=5
spawn_z=1
health=100

mob
verb
Punch(mob/M as mob in get_step(src,usr.dir))
set category = "Techniques"
if(src.attacking == 0)
var/colour = "yellow"
var/damage = rand(5,10)
M.health -= damage
src.attacking = 1

if(prob(10))
damage *= rand(10,25)
colour = "red"

Damage(M,damage,colour)
M.health -= damage
M.DeathCheck()
M.loc=locate(M.spawn_x,M.spawn_y,M.spawn_z)
health_bar.Update()
sleep(5)
src.attacking = 0

loading Techniques.dme
Programming\NPC's\NPC's.dm:32:error: M.spawn_x: undefined var
Programming\NPC's\NPC's.dm:32:error: M.spawn_y: undefined var
Programming\NPC's\NPC's.dm:32:error: M.spawn_z: undefined var

Techniques.dmb - 3 errors, 0 warnings (double-click on an error to jump to it)
In response to SillyChild123
Define the vars under the mob tree only.
mob/var
spawn_x
spawn_y
spawn_z
In response to SillyChild123
initial(loc) will return the mobs initial location. As long as you use the map editor to place them on the map, you can use it.