ID:174971
 
ok i have here somthing that respawns the objects in the world...but there is a bug, it restores the npc mobs that have been restored too! (and this is the only part of my game that has 'repop' called) so im thinking its somthing ive done wrong?

world/New()
spawn
while(1)
sleep(100)
for(var/obj/clips/L in world)
sleep(310)
Repop(L)
for(var/obj/gherb/L in world)
sleep(520)
Repop(L)

[edit] all i want restored is 'gherb' and the 'clips' but it makes every thing, including mobs and other obj's [/edit]
try repop(L)
I'm not sure, but something I should point out is that you need to put the last two lines after both for() things and not just the second
In response to Koolguy900095
Koolguy900095 wrote:
try repop(L)

hmm diddnt work :(
In response to Wanabe
Also you need something between the two for's
In response to Koolguy900095
Thats what i now have..... ill test it now

world/New()
spawn
while(1)
sleep(100)
for(var/obj/clips/L in world)
sleep(310)
Repop(L)
for(var/obj/gherb/L in world)
sleep(520)
Repop(L)
No still doesnt work. Maybe the problem lies else where?
Wanabe wrote:
ok i have here somthing that respawns the objects in the world...but there is a bug, it restores the npc mobs that have been restored too! (and this is the only part of my game that has 'repop' called) so im thinking its somthing ive done wrong?

world/New()
spawn
while(1)
sleep(100)
for(var/obj/clips/L in world)
for(var/obj/gherb/L in world)
sleep(520)
Repop()


The bolded line has no effect, you should also look up Repop() and read what it does exactly.
In response to Nadrew
oh ok neaver knew that :| Is there a way to just repopulate/create certain things that i want repopulated/created?
In response to Wanabe
easy, use the mobs Del() proc to do this.

example:

mob
monster
Del()
spawn(500)
new/mob/monster(locate(src))
return ..()

Not sure if all that is correct, since I just thought it up, but...I'm not sure about that locate(src) since it'll already be deleted, so it may return null.
In response to Goku72
Goku72 wrote:
easy, use the mobs Del() proc to do this.

example:

> mob
> monster
> Del()
> spawn(500)
> new/mob/monster(locate(src))
> return ..()
>

Not sure if all that is correct, since I just thought it up, but...I'm not sure about that locate(src) since it'll already be deleted, so it may return null.

hey thats a decent idea :) Ill try somthing simalair.

im about to go to some one elses house so ill check the forum out later and test what i had in mind, cyas later.
In response to Goku72
Goku72 wrote:
easy, use the mobs Del() proc to do this.

example:
mob
monster
Del()
spawn(500)
new/mob/monster(locate(src))
return ..()

Not sure if all that is correct, since I just thought it up, but...I'm not sure about that locate(src) since it'll already be deleted, so it may return null.

Actually locate(src) is wrong anyway; you can't use locate() that way. What you're thinking of, I think, is src.loc.

Also, it's much better to just put new type(loc), since the type of the monster may change depending on if it's /mob/monster/slime or /mob/monster/bunny.

You're right that the deletion will screw with this though. The spawn() will end up doing nothing once src is deleted. What you'll have to do is find some other approach, like using a temporary event datum to do this.
event
var/object
var/procpath
var/data
var/endtime

New(time, object, procpath, data)
src.object = object
src.procpath = procpath
src.data = data
endtime = world.time + time
Run()

// handle save/load by storing the amount of time left to fire the event
Read(savefile/F)
..()
endtime += world.time
Run()

Write(savefile/F)
..()
F["endtime"] << (endtime - world.time)

proc/Run()
spawn(endtime - world.time)
// this line is a spawn() timing bug workaround
while(endtime > world.time) sleep(endtime - world.time)
if(ispath(src.object)) new src.object(src.procpath, src.data)
else if(src.object) call(src.object, src.procpath)(src.data)
del(src)
With a system like this, you can delay the spawning of a new monster.
mob/monster
Del()
new/event(rand(300, 600), type, loc)
..()
The event system I wrote up there works two ways:
object.procpath(data)
or...
new object(procpath, data)
The form it takes depends on whether the object is an actual object or a type path. This system is pretty powerful and should serve you well.

If you need to save your world and want events done in this system to save, just do this:
// assuming F is the world/map/etc. savefile
for(var/event/E) F << E
If you use SwapMaps at all this system could be tweaked to work with it by overriding the save/load procs and changing the /event datum to consider itself "attached" to a map.

Lummox JR
In response to Lummox JR
Thank you lummox! that worked