My brother is beta testing my latest module at the moment and encountered a bug. When looking at it I couldn’t understand the bug at all, so I did what kevL_s has time and again told me to do. I altered the scripts and did a lot of debugging by using SendMessageToPC. What I found had me really baffled. So here’s the situation (I hope you can understand my explanation):
We are at a tavern. When entering the tavern there’s a speakscript firing when entering a trigger just after you’ve got in. In this trigger I set a local int on the player character to 1. At another trigger a bit further in there’s another conversation trigger forcing all but one of the companions to leave the party and wait where they are. You then go upstairs with one of the companions, and after you get back there’s yet another trigger starting a conversation where the rest of the companions rejoin.
Here’s the thing: If the local int is 1 the first conversation should not be triggered again if you go through that trigger, which it does now. However, when you leave the tavern, I have a script on the OnExit of the area where this same local int is set to 0. Thus, if you reenter the tavern a new (or the same, depending on circumstances) conversation should start again when entering the first trigger, because the local int is 0.
Ok, now what I noticed when debugging was this: When speaking with the companions and they rejoin the party, this local int is set to 0 about 4 times (there are 5 companions in total in the party). Why on earth would it do that??! This local int should only be set to 0 when exiting the tavern. I’m using a script that looks like this for the rejoining of the companions. My only guess it must be some hidden code in this that sets this local int to 0…or something. It doesn’t make any sense. Or maybe it does…somehow?
Why I suspect this script is because it is run 4 times, one for each of the companions who rejoins the party, and I get a message ingame 4 times that the local int is set to 0 when this happens.
/******************************************************************
ga_roster_companion
Adds a Companion NPC and sets their XP equal to the PC's if they
are below. This script merges four scripts together so that you
don't have to setup all four script calls in a conversation.
This script also has a convention: the RosterName is the same as
the creature's TAG, resref, etc. They should all be named
the same.
*******************************************************************/
#include "ginc_param_const"
#include "ginc_debug"
#include "ginc_misc"
void main(string sCompanionTag)
{
//FROM: ga_roster_add_object
//Adds a NPC to the global roster of NPCs available to be added to
//a player's party. Roster Name is a 10-character name used to
//reference that NPC in other Roster related functions.
//The NPC will be left in the game world, but will now exist
//in the roster as well.
object oCompanion = GetObjectByTag(sCompanionTag);
int bResult = AddRosterMemberByCharacter(sCompanionTag, oCompanion);
//FROM: ga_roster_selectable
SetIsRosterMemberSelectable(sCompanionTag, 1);
//FROM: ga_roster_party_add
object oPC = GetFirstPC();
AddRosterMemberToParty(sCompanionTag, oPC);
int nXP = GetPCAverageXP();
SetXP(oCompanion, nXP);
ForceRest(oCompanion);
}