From NWN Lexicon
Jump to navigationJump to search


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

int GetFactionAverageXP(
    object oFactionMember



The object whose faction you wish to examine.


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 as summoned monsters, henchmen and familiars, or if those creatures can be used as the oFactionMember at all.


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.




// If the PC's experience, on average, is over 4000XP (an arbitrary
// 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);

See Also



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