GetIsFriend(), Not restricted to player party members?
ForSerious
Member Posts: 466
One thing I really enjoyed from NWN2 Mask of the Betrayer, was the little XP you would get reworded for unlocking things. I made a little script to do that, then tried to make it multiplayer friendly, so your whole party gets XP, if they're close enough.
My main party determining logic hangs on GetIsFriend(). I changed the game to Hard Core Rules and I stopped getting XP when others in my party unlock things.
Do I have to use GetFirst/NextFactionMember instead?
My main party determining logic hangs on GetIsFriend(). I changed the game to Hard Core Rules and I stopped getting XP when others in my party unlock things.
Do I have to use GetFirst/NextFactionMember instead?
0
Comments
Don't forget that you also need to account for summons, familiars, companion animals and other types of NPC associates, either by deliberately excluding them or deliberately including them.
Incidentally, if you have a module where a summon can also summon, you need to account for that. GetMaster only returns the next-up-the-line creature, not the Player Character.
Here's a short function I came up with called GetTrueMaster which takes care of finding the true master (NPC or PC) in a chain of summons: If this function is called from within a script running on the associate, the associate does not need to be specified in the function call.
This is not intended to work on anything other than a creature which is why the "if" condition is there and comes first.
Using GetMaster on the ultimate master in a chain will return itself, so the "while" will keep looping until it finds that condition and then will return the true master.
It returns all faction members including summons etc, which you can screen using GetAssociateType() or GetIsPC().
Horses are regarded as henchmen, but can be detected using HorseGetIsAMount().
My reading of the lexicon says that you can either filter out all of the NPCs in the party or not filter them out. There is some incorrect text further down in the description of GetFirstFactionMember which says that you can only get one or the other, but the text under Parameters is correct that the filter either restricts the selection to only PCs or allows all members of the party, including NPCs, to be selected.
Selecting only PCs is the default since this would normally be what you want in a function intended to (for example) reward PCs with experience.
Melkior, you have been most helpful!