simple spawner question

Power to the Player!
Post Reply
olepi
Posts: 145
Joined: Sun Jul 17, 2005 10:00 pm

simple spawner question

Post by olepi »

This is a simple question:

- I want an object that spawns an NPC
- once the NPC is killed, it is respawned
- if the object is interacted with, the NPC does not spawn again, and the object is removed

The object remover is easy, what is the most efficient way of having an object-dependent respawner?
2007 -- 30 years on the Net!
unkala
Posts: 11
Joined: Thu Nov 23, 2006 8:04 am

Re: simple spawner question

Post by unkala »

If you want the NPC to respawn instantly, add the "<NPC> deactives" and then the "<NPC> activates" actions, in that order, to the NPC's death event. Add the conditional "<Scenery Object Interaction X> has not triggered" so the respawn only happens if no one has interacted with your object yet.

This is rather abrupt, though, so you'll probably want a short timer. Make the NPC's death start the timer, again making it conditional on the object not being used yet. Put the deactivation/reactivation on the timer trigger event.

(The reason for deactivating the NPC is to get rid of the corpse. A mob is still active while its corpse is on the ground, and trying to activate an active mob does nothing. Corpses take over a minute to vanish naturally. If you're always going to wait longer than that to respawn, you won't need to do an early manual deactivation.)
sidusar
Posts: 1331
Joined: Tue Dec 21, 2004 4:38 am

Re: simple spawner question

Post by sidusar »

I would do this by making a cyclic timer that goes off every second and activates the NPC every time it goes off. That way the NPC respawns right after the corpse disappears. If you need it to respawn right after death, add an "<NPC> deactives" event to it's death as Unkala said.

Then, make the object interaction deactivate the timer, so that it stops triggering the NPC spawn. (And ofcourse, uncheck the NPC's "autorespawn" so that it doesn't spawn on it's own.)

Unkala's method probably works too though. Whatever suits you best. :)
unkala wrote:This is rather abrupt, though, so you'll probably want a short timer. Make the NPC's death start the timer, again making it conditional on the object not being used yet. Put the deactivation/reactivation on the timer trigger event.
I wouldn't do this though. In my experience, timers that get repeatedly started, triggered, stopped, and started again... well, they get messy. :o

I'd use an (empty) dialog, make the NPC's death start the dialog, and make the end of the dialog trigger the deactivation/reactivation of the NPC. You can make the dialog last as long as you want the NPC to stay dead, thus basicly using it as a timer.
unkala
Posts: 11
Joined: Thu Nov 23, 2006 8:04 am

Re: simple spawner question

Post by unkala »

sidusar wrote:I would do this by making a cyclic timer that goes off every second and activates the NPC every time it goes off. That way the NPC respawns right after the corpse disappears. If you need it to respawn right after death, add an "<NPC> deactives" event to it's death
The issue with that is that the respawn won't always happen one second after the corpse vanishes. It can be anywhere from 0 to 1 seconds, essentially at random, depending on when the NPC dies compared to the timer's beat. And it can be different every time. That's not bad, maybe not even noticeable, at 1 second, but if the OP wants a longer respawn delay, like 5 or 10 seconds, that randomness gets wider.
Unkala's method probably works too though.
It does. I tried it out first. Specifically, I wasn't sure if multiple actions in one event are guaranteed to happen in the order they're listed.
I wouldn't do this though. In my experience, timers that get repeatedly started, triggered, stopped, and started again... well, they get messy. :o
Messy as in hard for the designer to keep track of what he's using for what, or messy as in the game doesn't reset them properly and they start running for the wrong durations, or running but never firing?

Using a dialogue as a substitute timer instead of an actual timer doesn't sound like a good way to avoid confusion...
sidusar
Posts: 1331
Joined: Tue Dec 21, 2004 4:38 am

Re: simple spawner question

Post by sidusar »

unkala wrote:The issue with that is that the respawn won't always happen one second after the corpse vanishes. It can be anywhere from 0 to 1 seconds, essentially at random, depending on when the NPC dies compared to the timer's beat. And it can be different every time. That's not bad, maybe not even noticeable, at 1 second, but if the OP wants a longer respawn delay, like 5 or 10 seconds, that randomness gets wider.
True, that's why it's only usuable for an instant-after-corpse-gone respawn, which is what the OP seemed to want here. :)

If you want a longer respawn delay, you'll have to use the dialog delay and let the scenery interaction deactivate the dialog.
unkala wrote:Messy as in hard for the designer to keep track of what he's using for what, or messy as in the game doesn't reset them properly and they start running for the wrong durations, or running but never firing?
Messy as in the game doesn't handle them well. A non-cyclic timer is often just impossible to fire again after it's triggered once, while a cyclic timer is impossible to stop anymore once it's started. In the best-case scenario they end up running for the wrong duration. :rolleyes:

A dialog, while not as accurate, responds much better to being started again and again.
olepi
Posts: 145
Joined: Sun Jul 17, 2005 10:00 pm

Re: simple spawner question

Post by olepi »

sidusar wrote:I would do this by making a cyclic timer that goes off every second and activates the NPC every time it goes off. That way the NPC respawns right after the corpse disappears. If you need it to respawn right after death, add an "<NPC> deactives" event to it's death as Unkala said.

Then, make the object interaction deactivate the timer, so that it stops triggering the NPC spawn. (And ofcourse, uncheck the NPC's "autorespawn" so that it doesn't spawn on it's own.)
I did it this way at first, but there seems to be a bug. The NPC does stop spawning when the cyclic timer is deactivated. However, it then respawns later, in a different place, and on a much longer timer.

So I'm gonna try some of the other ideas here, thanks! :)

edit: ok, this method works fine.

I set up a route to take, so the mob is going to attack some other NPC's I have standing around. The first invocation works fine, the mob spawns, and runs the route into the NPC's and gets killed. Then the mob respawns, and then runs the route into the NPC's, but HAS NO AGGRO. I can kill him with no aggro either.

So I tried adding some "can attack NPC's" and "can attack player" but then the mob WON'T RUN THE ROUTE.

This seems very buggy to me (been a programmer for 30 years). I just want a mob to spawn, run the route, attack NPC's and get killed, then spawn, run the route, .......
Last edited by olepi on Sat Oct 11, 2008 3:49 am, edited 1 time in total.
2007 -- 30 years on the Net!
sidusar
Posts: 1331
Joined: Tue Dec 21, 2004 4:38 am

Re: simple spawner question

Post by sidusar »

olepi wrote:However, it then respawns later, in a different place, and on a much longer timer.
Did you remember to check the "NoRespawn" box on the NPC?
olepi wrote:This seems very buggy to me (been a programmer for 30 years). I just want a mob to spawn, run the route, attack NPC's and get killed, then spawn, run the route, .......
Everybody who makes Ring scenarios knows exactly what you mean. :p So totally random and non-intuitive when a scripted event works and when it doesn't....
Post Reply

Return to “The Ryzom Ring”