ID:272459
 
How Do I Make It So When I Kill A Monster It Goes To It's Spawn I.E. If I Go Kill A Monster It Would Go Back To It's Original Place On The Map Or Create A New Mob Or Whatever.
mob
proc
DeathCheck()
if(HP<=0)
if(src.ckey)
src.loc=locate(pspawn_x,pspawn_y,pspawn_z)
// Player spawn coordinates
else
src.loc=locate(nspawn_x,nspawn_y,nspawn_z)
// NPC spawn coordinates


Something like this?
In response to Lcooper

Wanna bet that Lunar isnt going to Understand that?

Because if he is asking something that Simple... then he probally wont know how to even call the Proc.

Lets just wait and see what he says .. :D


-SubZeroChaos
It's not a "noob question," and you don't need to feel stupid or embarrased asking it. The subject is actually pretty confusing.

There are two ways to go about respawning:

1. Delete the monster, and spawn a new one in its designated respawning spot.
2. Reset the monster's statistics and move it to its designated respawning spot.

The latter is less resource consuming, but it tends to be harder to implement, so let's go with the first option for now. This is what I'd do:

Give monsters a set of variables storing the x,y,z coordinates for its respawning location. Let's call these respawn_x, respawn_y, respawn_z. Also, let's give them a proc called "GetRespawnLoc," which is responsible for turning our coordinates into an actual location.

mob/monster
var
respawn_x
respawn_y
respawn_z

proc
GetRespawnLoc()
return locate(respawn_x,respawn_y,respawn_z) // the locate() procs takes x,y,z coordinates translates them into a location on the map


Using our new data, respawning is much easier. We need to create an object of the monster's type in its respawning location, and delete the monster afterwars like this:

mob/monster
proc
Respawn()
var/turf/respawn_loc = GetRespawnLoc() // The monster's respawning loc
var/mob/monster/new_monster = new src.type() // A new object of our monster's type (the 'type' variable \
stores an object's type)

new_monster.loc = respawn_loc
spawn() del src


And that's it. Feel free to ask any questions.
In response to SubZeroChaos
SubZeroChaos wrote:

Wanna bet that Lunar isnt going to Understand that?

Because if he is asking something that Simple... then he probally wont know how to even call the Proc.

Lets just wait and see what he says .. :D


-SubZeroChaos

I don't think you need to jump the gun, or make any remarks like that. The forum is made for anyone in need of help or who has questions about a coding issue.