GetFactionWorstAC(object, int)

Get the object faction member with the lowest armor class.

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

Parameters

oFactionMember

The object whose faction you wish to search through (Default: OBJECT_SELF)

bMustBeVisible

Does the returned object have to be visible to the caller? (Default: TRUE)


Description

Returns an object representing the faction (or party) member with the lowest armor class. Will only return the member with the lowest AC that is visible to the object calling the function if bMustBeVisible is set to TRUE (default).

Return OBJECT_INVALID if oFactionMember's faction is invalid.



Remarks

Again, a great function to use in your NPC Combat scripts. This one can sic your creatures on the easiest to hit target, or even use with a henchman spellcaster to determine which member of his master's party needs more protection.

It can also be used to attack the lowest AC, but noting that range is not taken into account and thusly possibly only ranged attackers could use it wisely.

This will work exactly the same was as using GetFirst/NextFactionMemeber() and using GetAC(), to find the lowest, 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.


Known Bugs

This used to cause a crash pre-1.64, and now it should not.


Version

1.64

Example

// Get the lowest AC from a (seen) PC faction member, and remark
// how bad in combat they must do.

void main()
{
    // Get faction to check
    object oPC = GetPCSpeaker();

    // Get the lowest (Seen) AC member
    object oHighest = GetFactionWorstAC(oPC, TRUE);

    // Speak to them
    SpeakString("Ho ho! " + GetName(oHighest) + " looks like a right pin cushion!");
}

See Also

functions: GetFactionBestAC | GetFactionLeastDamagedMember | GetFactionMostDamagedMember
categories: Combat Information Functions | Get Data from Creature Functions | Party Functions | Reputation/Faction Functions | Targeting Functions


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