GetFactionAverageXP

From NWN Lexicon



Contents

[edit] GetFactionAverageXP(object)

Get the average amount of XPs for all members in an objects faction.

int GetFactionAverageXP(
    object oFactionMember
);

[edit] Parameters

oFactionMember

The object whose faction you wish to examine.


[edit] Description

Returns the average number of experience points of the members of the faction (party).

Return value on error: -1

It is unknown if NPC's in a PC's faction affects this function call and the returned result, such sa summoned monsters, henchmen and familiars, or if those creatures can be used as the oFactionMember at all.



[edit] Remarks

Another way of figuring out the overall level of a faction, although more accurate then GetFactionAverageLevel() if you want to know how close they are to one level or another.

This will work exactly the same was as using GetFirst/NextFactionMemeber() and using GetXP(), only is much easier to code and probably better on performance.

Try to never use this on an NPC faction, only a PC's party faction, because NPC factions usually have dozens of NPC's, and thus may cause a lot of high CPU usage with faction calls such as this.


[edit] Version

1.62

[edit] Example

// If the PC's experience, on average, is over 4000XP (an arbitary
// number, between levels) then give the PC speaker 100 gold.
 
void main()
{
    // Get the PC
    object oPC = GetPCSpeaker();
 
    // Get the faction's XP
    int nXP = GetFactionAverageXP(oPC);
 
    // Check the amount
    if(nXP >= 4000)
    {
         // Reward them
         SpeakString("I see we are learning fast. Here is some gold!");
          GiveGoldToCreature(oPC, 100);
    }
}

[edit] See Also

functions: 

GetFactionAverageLevel



 author: John Shuell, editor: Jasperre, additional contributor(s): Jasperre
 

Personal tools
Categories