GetFactionStrongestMember(object, int)

Get the member of an object's faction who is the strongest.

object GetFactionStrongestMember(
    object oFactionMember = OBJECT_SELF,
    int bMustBeVisible = TRUE
);

Parameters

oFactionMember

An object who is a member of the faction you wish to search through. (Default: OBJECT_SELF)

bMustBeVisible

The member chose must be visible to the calling object. (Default: TRUE)


Description

Returns the strongest member of oFactionMember's faction. If bMustBeVisible is set to TRUE (default) only members who can be seen currently by the calling object will be considered.

Return OBJECT_INVALID if oFactionMember's faction is invalid.



Remarks

This is a useful function because it will get the highest hit dice opponent - useful for AI scripting. Of course, it is probably not based on any kind of range or anything else if there are 2 people with the highest hit dice, and it'll just return the first who joined the party.

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

Try to never use this on an NPC faction unless bMustBeVisible is TRUE, 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

// Get the strongest PC and attack them. For all it matters, this
// could be the On Heartbeat script of a NPC.

void main()
{
    // Get nearest PC
    object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);

    // Get strongest
    object oStrongest = GetFactionStrongestMember(oFactionMember, TRUE);

    // Attack them
    if(GetIsObjectValid(oStrongest))
    {
        ClearAllActions();
        ActionAttack(oStrongest);
    }
}

See Also

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


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