GetFirstFactionMember
GetFirstFactionMember(object, int)
Obtains the first member of the faction that a creature is a member of.
object GetFirstFactionMember(
object oMemberOfFaction,
int bPCOnly = TRUE
);
Parameters
oMemberOfFaction
Creature to determine which faction we want.
bPCOnly
If TRUE then the returned faction member will be a PC, otherwise both NPCs and PCs are included in the search. (Default: TRUE)
Description
Returns the first member of oMemberOfFaction's faction and OBJECT_INVALID if oMemberOfFaction or oMemberOfFaction's faction is invalid. If bPCOnly is set to FALSE it only includes NPCs, NOT both. To get all members of a PC's faction (Henchmen and so forth, as well as PC's themselves) 2 loops of the faction must be done.
Remarks
This function begins to cycle through all oMemberOfFaction's faction by calling GetNextFactionMember(). The cycle begins with oMemberOfFaction; in other words, this function appears to return the calling object; the rest of the party is then retrieved using GeNextFactionMember(). NOTE however that when called on a PC who is in a party, the function seems to return the 'Party Leader' which may not be the calling object (the Party Leader is the PC who first formed the party by inviting another PC to form a party).
If bPCOnly is TRUE the returned faction member will be a PC. If bPCOnly is FALSE, it will only do non-PC faction members.
Never use this on an NPC faction! There would be dozens more objects in even the smallest custom faction compared to a PC party. If used, use with caution!
Version
1.29
Example
// This code shows how you can cycle through all the party
// members of the first PC in the module.
// This will ONLY get PC members - any associates (Henchmen,
// familiars, summoned creatures and so on) will not be got by
// this loop. If the bPCOnly was FALSE in this script, it would ONLY
// get henchmen, familiars and so on for the faction.
void main()
{
// We alway use the SAME object for the GetFirst/Next faction
// member calls - always define it first. Here it is the first PC.
object oPC = GetFirstPC();
// Get the first PC party member
object oPartyMember = GetFirstFactionMember(oPC, TRUE);
// We stop when there are no more valid PC's in the party.
while(GetIsObjectValid(oPartyMember) == TRUE)
{
// Do something to party member
// Get the next PC member of oPC's faction.
// If we put anything but oPC into this, it may be a totally
// unreliable loop!
oPartyMember = GetNextFactionMember(oPC, TRUE);
}
}
See Also
| functions: |
author: Tom Cassiotis, editor: Jasperre, additional contributor(s): Iceberg, Mike Daneman, Matt Andrew