ID:273521
 
Well I know there is all together a way to do this by using world.Repop() but I'd rather do this inside the Del() so clients are not spammed with monsters around their location all at once. What I have is this:

mob
var
aggressive
Monsters
New()
..()
spawn() src.Monster_AI()
density = 1
Earth
icon = 'Monsters.dmi'
Non_Aggressive
race = "Animal"
New()
..()
exp = rand(150,300)
zenni = rand(50,100)
Del()
var/mob/Monsters/M = src.type
M = src
M.loc = initial(src.loc)
world<<M
..()
Rabbit
icon_state = "Rabbit"
strength = 1
defense = 1
powerlevel = 100
maxpowerlevel = 100


What I'm wondering is when they are deleted (dead by the client) give it a specific time to pass by using spawn() and have them respawn, I did this without spawn() because I needed to see right away that it works, however it does not. If anyone could help that would be much appreciated. Also thank you in advance!
var/mob/Monsters/M = src.type
Should be new src.type
M = src
Shouldn't happen at all

Though deleting and re-creating mobs like that isn't very efficient
The M = src line is what's breaking it. It makes no sense to have it there at all.
In response to Nadrew
That just creates a runtime error, however it works but not the way intended, I want it to spawn on the map where it was originally placed.

runtime error: Cannot modify /mob/Monsters/Earth/Non_Aggressive/Rabbit.loc.
proc name: Del (/mob/Monsters/Earth/Non_Aggressive/Del)
source file: Monsters.dm,19
usr: 0
src: Rabbit (/mob/Monsters/Earth/Non_Aggressive/Rabbit)
call stack:
Rabbit (/mob/Monsters/Earth/Non_Aggressive/Rabbit): Del()
Yash (/mob/player/saiyan): DeathCheck(null)
Kamehameha (/obj/Battle/Blast/Beam/Kamehameha): Bump(Rabbit (/mob/Monsters/Earth/Non_Aggressive/Rabbit))
Kamehameha (/obj/Battle/Blast/Beam/Kamehameha): Move(Dragonball Z: Sagas Unleashed (125,131,1) (/turf/Earth/grass), 8)
Kamehameha (/obj/Battle/Blast/Beam/Kamehameha): Move(Dragonball Z: Sagas Unleashed (125,131,1) (/turf/Earth/grass), 8)
In response to Yash 69
Yash 69 wrote:
That just creates a runtime error

You didn't do what I posted then
In response to Yash 69
Why not make a var called originalloc and then when the enemy is created, set it's loc to originalloc. Then, when they die, you can move them off the map and after a set time limit bring them back to their originalloc?
Yash 69 wrote:
Well I know there is all together a way to do this by using world.Repop() but I'd rather do this inside the Del() so clients are not spammed with monsters around their location all at once. What I have is this:

mob
> var
> aggressive
> Monsters
> New()
> ..()
> spawn() src.Monster_AI()
> density = 1
> Earth
> icon = 'Monsters.dmi'
> Non_Aggressive
> race = "Animal"
> New()
> ..()
> exp = rand(150,300)
> zenni = rand(50,100)
> Del()
> var/mob/Monsters/M = src.type
> M = src
> M.loc = initial(src.loc)
> world<<M
> ..()
> Rabbit
> icon_state = "Rabbit"
> strength = 1
> defense = 1
> powerlevel = 100
> maxpowerlevel = 100

What I'm wondering is when they are deleted (dead by the client) give it a specific time to pass by using spawn() and have them respawn, I did this without spawn() because I needed to see right away that it works, however it does not. If anyone could help that would be much appreciated. Also thank you in advance!

obj
spawner
var
spawn_type=/mob/monster/Bleh //Define the type path that you wish to spawn
spawn_max=1 //Only produce 1 every 600 ticks
spawn_time=600 //600 ticks equals one minute
list
spawned=list() //Gotta keep track of our babies!
proc
Spawn()
while(src.spawned.Remove(null))
spawn(src.spawn_time)
if(src.spawn_max<src.spawned.len)
var/mob/monster/M=new src.spawn_type(src.loc)
M.owner=src
src.spawned.Add(M)

mob
monster
var
obj
spawner
owner
Del()
spawn()
src.owner.Spawn() //Call the owners Spawn() to make the same monster respawn in a given time
return ..()