How to Check to see if a group of NPCs is dead
#1
Posté 02 août 2010 - 05:08
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
Posté 02 août 2010 - 05:22
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
Posté 02 août 2010 - 05:30
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
Posté 02 août 2010 - 05:32
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
Posté 02 août 2010 - 05:34
_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
Posté 02 août 2010 - 05:37
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
Posté 02 août 2010 - 07:05
But using the encounter method is probably the best when it can be used.
#8
Posté 03 août 2010 - 04:30
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
Posté 03 août 2010 - 04:41
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
Posté 03 août 2010 - 04:46
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
Posté 03 août 2010 - 08:19
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
Posté 03 août 2010 - 09:09
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
Posté 03 août 2010 - 09:24
PJ
#14
Posté 04 août 2010 - 01:22
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);
}
}





Retour en haut






