Journal Update
I have to admit that I have learned a lot over the past days. About how some script functions work, and on how to make my work less buggy... so to say.
One of my testers, is playing a spellcaster. Naturally, he doesn't want to lead with him. So he let his companions take the first shots while he was back there shooting arrows and spells. I always play a melee. Fighter, Paladin, Cleric... anything. But I always feel comfortable leading on. So my scripts never failed, or the conversations always got the expected result. But to this tester, not.
it doesn't break his game so far, but because he is a builder he suspects where things went wrong and figured the solution. But first things first.
I used to use the node option to update a journal. What I found out is that this updates the journal for the speaker. Which is fine for the OC, because the companions can never initiate dialogue. Now the problem is, that the speaker, PC or companion has a journal. Yes. Even if it shows the same when we press "j", it's different. I'm thinking, go figure. But still. This leads to the problem.
If I talk to NPC1 with my PC and get a journal entry, then go somewhere to check with gc_journal but talk with my companion the script will return FALSE. Because the companion didn't get the entry, my PC did. Long story short (best expression ever), I have to go back and erase the node option and add the ga_journal to update for all players. Major delay but a very stable method for updating the journal and be safe.
The other thing, was trigger related. I was confussed I guess, because of the many functions for PC. GetPCSpeaker, GetFirstPC etc.
Trouble showed with this one, which was created by Lilacs.
// Get the creature who triggered this event.
object oPC = GetEnteringObject();
// Only fire for (real) PCs.
if ( !GetIsPC(oPC) || GetIsDMPossessed(oPC) )
return;
// Set a local integer.
SetLocalInt(oPC, "shipb", 1);
What went wrong, is that the companion entered, as PC, and got the local int. Then an NPC checked it in a conversation, but another companion was doing the talk and the local int of course returned false. Then I had a talk with KevL who is proving to be quite a mentor in these things
, and he told me
"On to the technical aspects: GetIsPC() does not get isPC ....
it gets "is player controlled" -- that's an unfortunate carry-over from NwN."
Brain all over the wall.
All this led to the conclussion that a script should start with:
object oPC = GetEnteringObject();
if (!GetIsPC(oPC))
return;
That means that it will fire no matter what enters it that is player controlled. But we don't want to leave it like that, for it will add the variable to the EnteringObject, being a companion of anything. Redefining the PC after that solves that.
oPC = GetFirstPC();
Because GetFirstPC(TRUE) - gets only the character(s) that player(s) really entered the Game with. As KevL informed me. So by redefinning, I am certain that the script runs, adding variables and all to the main character.
I guess this is more or less known to be honest. I just had to write these things down as a reminder to myself, and maybe as a hint to others like me who might make the same mistakes. Clicking the box on an NPC that says CanTalkToNonPlayerCreatures is fun. It doesn't teleport our hero where he doesn't want to be. But if one is not careful it leads to problems. Companions are PCs. And therefore everything we add to the PC, or check him for, applies to them as well.
A lot of work to do. Fixing all of these scripts, conversations and journals... I expect to take me weeks. But at least I won't bang my head against the wall in the future when someone tells me "Hey, why isn't this guy completing the quest?", or anything similar
.