ID:274043
 
i want someone to help me with a monster respawn code... want the monsters to individual remember there location and have there own individual spawn timer. ex: player kills monster(1) & Monster(1) move to Loc=0,0,0 and 100 sec after he dies he respawn.
The ComEdiAn wrote:
i want someone to help me with a monster respawn code... want the monsters to individual remember there location and have there own individual spawn timer. ex: player kills monster(1) & Monster(1) move to Loc=0,0,0 and 100 sec after he dies he respawn.

You can just do a world.Repop() which would just "repopulate the world to its initial state". Meaning that every mob or object in the world that was deleted during runtime, would be recreated.

world
New()
spawn() RepopWorld()
return ..()

proc/RepopWorld()
while(world)
world.Repop()
sleep(600)
In response to Kaigne
Kaigne wrote:
The ComEdiAn wrote:
i want someone to help me with a monster respawn code... want the monsters to individual remember there location and have there own individual spawn timer. ex: player kills monster(1) & Monster(1) move to Loc=0,0,0 and 100 sec after he dies he respawn.

You can just do a world.Repop() which would just "repopulate the world to its initial state". Meaning that every mob or object in the world that was deleted during runtime, would be recreated.

> world
> New()
> spawn() RepopWorld()
> return ..()
>
> proc/RepopWorld()
> while(world)
> world.Repop()
> sleep(600)
>


He clearly said "want the monsters to individual remember there location and have there own individual spawn timer"
In response to A.T.H.K
Then show him your example...

I'm basically showing him a simpler way to respawn stuff. Without necessarily having to keep track of information. If he didn't like or want the method i have shown, he isn't obligated to use it.

Now that I have read it over again it sound like he is leaning towards mob recycling, or creating mobs during runtime.
In response to Kaigne
thanks Kaigne but i already know about world repop i wasnt looking for that
In response to The ComEdiAn
You could do it like this, instead of creating a new mob over and over ..

Once mob is dead density, icon are nulled and obviously stop it from moving also kill off the attack nearest player and any other procs it has (have an isdead check on each proc for the mob\s) ... in the death proc of the mob\s have sleep(mob.timer amount) (set timer amount for each mob ie boss = 100000 minion = 1009 etc) easily done..

Once sleep is finished give it some movement, icon and density run the rand walk/attack procs or how ever you have it set up and Mr mob is off killing people once again.

This should eliminate lag as you aren't deleting each mob and re-creating with saved variable's ..
Pseudo-code:
Monster
var tmp/Initial Position

When Monster is created
Set Initial Position to Current Position

When Monster is killed
Set Current Position to null

Spawn 100 seconds (1000 tenths of a second)
// one of two ways:
Set Current Position to Initial Position

Set all necessary variables to initial value
one by one, like so:

health = max_health

// the other way:
Create a new Monster
of the same type
at Initial Position
In response to Kaiochao
Hiding the monster would be more efficient IMO, saves on deleting and re-creating over and over and over.


"Set Current Position to null" he wants to save this, so just set initial position to current upon dying.
In response to A.T.H.K
"ex: player kills monster(1) & Monster(1) move to Loc=0,0,0 and 100 sec after he dies he respawn."

100 seconds after the monster dies, a new monster appears at the monster's initial position.

I'm assuming he doesn't want a dead monster to re-appear at the monster's initial position, so I provide two ways of accomplishing this:
-creating a new monster at the initial position, or
-repositioning the same monster at its initial position with its essential variables reset.
In both cases, the monster is moved to "Loc=0,0,0" 100 seconds before it is respawned.
In response to Kaiochao
I see what you did the wording caught me off guard - "creating a new monster"
In response to A.T.H.K
I've never encountered lag from my basic NPC respawning proc...
mob/npc
var
respawn_delay = 100
turf/respawn_loc
New()
..()
src.respawn_loc = src.loc

proc/npc_respawn(T,D,L)
spawn(D)
new T(L)