Page 1 of 1
simple spawner question
Posted: Fri Oct 10, 2008 1:18 am
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?
Re: simple spawner question
Posted: Fri Oct 10, 2008 10:30 am
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.)
Re: simple spawner question
Posted: Fri Oct 10, 2008 5:30 pm
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.
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.
Re: simple spawner question
Posted: Fri Oct 10, 2008 8:00 pm
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.
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...
Re: simple spawner question
Posted: Fri Oct 10, 2008 9:38 pm
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.
A dialog, while not as accurate, responds much better to being started again and again.
Re: simple spawner question
Posted: Sat Oct 11, 2008 3:02 am
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, .......
Re: simple spawner question
Posted: Sat Oct 11, 2008 10:16 am
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.
So totally random and non-intuitive when a scripted event works and when it doesn't....