Aller au contenu

Photo

How to Check to see if a group of NPCs is dead


  • Veuillez vous connecter pour répondre
13 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I want to fire a dialogue after a group of three hostile NPCs have been killed.

I initially used GetIsDead() to set up the checks, but if the NPC decays, then GetIsDead() will not return true (or so it appears).

So now I was thinking of placing an ipoint near the site of the encounter and using local integers on the ipoint to record the deaths of each of the three NPCs. 

An alternative is to use GetIsDead() and if the GetIsDead() == FALSE for any of the three NPCs, then I will make the script execute a return.  At the end of the script will be the coding for the conversation.  This way, the script will only finish if all three are dead, and it does not matter if they decay.  I have used this method successfully in the past.

I am concerned that this second method may be sloppy or prone to bugs which I have not found yet.  Does anyone have any comments or suggestions?

Thanks,

Matt

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Use GetIsObjectValid to check if dead NPCs have already decayed.



In similar scripts, I go through a whole list of possible conditions: dead (dying), invalid (already decayed), and then a bunch of other that deal with particular circumstances.

#3
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Simplest method -



Use an Encounter Trigger to spawn the 3 NPCs.

Put a script in the OnExhausted slot of trigger that fires your convo.



Note that the encounter is not considered "exhausted" until all the bodies have decayed - and possiblly not until there loot is picked up.



Other method - use the Group script functions (# include "ginc_group"). Add them to a group with GroupAddMember() and then use the function GroupOnDeathBeginConversation().



There's other ways to go about it I'm sure, but the Group* functions are VERY useful in many situations.

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

Lugaid of the Red Stripes wrote...

Use GetIsObjectValid to check if dead NPCs have already decayed.

In similar scripts, I go through a whole list of possible conditions: dead (dying), invalid (already decayed), and then a bunch of other that deal with particular circumstances.


Have you had any problems with using this technique? 

By the way, I loved Last of the Danaan.

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

_Knightmare_ wrote...

Simplest method -

Use an Encounter Trigger to spawn the 3 NPCs.
Put a script in the OnExhausted slot of trigger that fires your convo.

Note that the encounter is not considered "exhausted" until all the bodies have decayed - and possiblly not until there loot is picked up.

Other method - use the Group script functions (# include "ginc_group"). Add them to a group with GroupAddMember() and then use the function GroupOnDeathBeginConversation().

There's other ways to go about it I'm sure, but the Group* functions are VERY useful in many situations.


I think that using the ginc_group functions may be the ticket. 


I know that the "ginc" functions can be very useful, but I have not used them because I do not know which ones hold what type of commands.  Is there a tutorial which explains this anywere?

#6
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

M. Rieder wrote...


I think that using the ginc_group functions may be the ticket. 


I know that the "ginc" functions can be very useful, but I have not used them because I do not know which ones hold what type of commands.  Is there a tutorial which explains this anywere?


Go download E.C.’s Super Include and add it to your module. It is a combined script file that has all the "hidden" include functions in it. Open this script and choose functions in Script Assist and read up on it in the bottom message box there.

#7
Shallina

Shallina
  • Members
  • 1 011 messages
For those case when I want to know if a group of NPC are dead I do a counter in the on death script of those NPC.



But using the encounter method is probably the best when it can be used.

#8
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
There have been issues, yes, but mostly with how the engine looks for tags. If you use GetObjectByTag to get the NPC, you can run into issues where the game can't find the object. This happens because the index of area object tags the engine uses isn't always updated in time, especially if there's a lot going on in the area. Out-of-area objects are sometimes also inaccessible using GetObjectByTag. I've found that the best thing to do is to spawn all your NPCs script-hidden during the area on-enter event, and then un-hide them at the appropriate time.



Also, you should always put in some sort of fail-safe. For example, if the player is supposed to fight off 24 mooks, rout all of them once 18 or so have been killed, so the player doesn't have to spend an extra 10 minutes waiting for the last one to be killed off.



If you still have Last of the Danaan installed, you can try looking at one of the numerous 'deathcheck' scripts in there and see how I set them up. I think the ones that start with "plot_marsh" are fairly up-to-date (my technique evolved as I was working through the module).

#9
M. Rieder

M. Rieder
  • Members
  • 2 530 messages

Shallina wrote...

For those case when I want to know if a group of NPC are dead I do a counter in the on death script of those NPC.

But using the encounter method is probably the best when it can be used.


Do you use a localint to store the count?

#10
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

M. Rieder wrote...

Shallina wrote...

For those case when I want to know if a group of NPC are dead I do a counter in the on death script of those NPC.

But using the encounter method is probably the best when it can be used.


Do you use a localint to store the count?


I've used this method as well for a few things. I usually store the local int on either the area or the main PC, depending on the situation. Within the Ondeath I have a conditional to check if nCount is now equal to/greater than value X, if so, do whatever (ie. fire conversation). Remember to re-Get the local int after increasing it with the most recent death before checking its current value.

Of course this method only works if you know exactly how many NPCs there are or deaths you want to count (which you do at 3). Just thought I'd throw that in there for other who happen by here.

Modifié par _Knightmare_, 03 août 2010 - 04:48 .


#11
PJ156

PJ156
  • Members
  • 2 982 messages
I want to do this but lost Kamals script when we lost the old forum (I had it in my useful posts section).

I am planning to do this by putting an on death script on each of three critters. It will go something like.

Add to integer 1

if integer = 3 then start convo.

Thus if any of the three die last it will be thier script that fires the convo.

Any holes in that plan?

PJ

#12
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

PJ156 wrote...

I want to do this but lost Kamals script when we lost the old forum (I had it in my useful posts section).

I am planning to do this by putting an on death script on each of three critters. It will go something like.

Add to integer 1

if integer = 3 then start convo.

Thus if any of the three die last it will be thier script that fires the convo.

Any holes in that plan?

PJ


Only to remember to reget the int value, else it will return the original value.

Get int
Add To Int
Set new int value on whatever
Get int again (to get new/modified value)
If int == 3, Do whatever

#13
PJ156

PJ156
  • Members
  • 2 982 messages
Thank you _Knightmare_

PJ

#14
kamalpoe

kamalpoe
  • Members
  • 711 messages
The script PJ is referring to from me. This requires each npc that's going to die to have a unique tag. It doesn't handle encounters but will handle a large number of placed enemies without issue and does not require the player to be the killer (non party allies can do the killing and it will work). Put this in the OnExit of a trigger the player must walk through.

This isn't the be all end all script for the reasons listed above, but it met my needs. Sample below

--------------------------------
// advance journal on death

#include "ginc_group"

const string GROUP_spiders = "spiders";

void main()
{
object oPC = GetExitingObject();

    GroupAddTag(GROUP_spiders,"spider1");
    GroupAddTag(GROUP_spiders,"spider2");
    GroupAddTag(GROUP_spiders,"spider3");
    if  (GetLocalInt(oPC, "NW_JOURNAL_ENTRYspiders")>= 1)
    {
    GroupOnDeathSetJournalEntry(GROUP_spiders, "spiders",11);   
    }
    else
   {
   GroupOnDeathSetJournalEntry(GROUP_spiders, "spiders",21);
   }


}