GetFactionAverageXP(object)

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

int GetFactionAverageXP(
    object oFactionMember
);

Parameters

oFactionMember

The object whose faction you wish to examine.


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.



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.


Version

1.62

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);
    }
}

See Also

functions: GetFactionAverageLevel
categories: Get Data from Creature Functions | Math Functions | Party Functions | Reputation/Faction Functions


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