GetFactionBestAC

From NWN Lexicon
Jump to: navigation, search



GetFactionBestAC(object, int)

Get the member of a faction (party) who has the highest Armor Class.

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

Parameters

oFactionMember

The object whose faction you wish to examine. (Default: OBJECT_SELF)

bMustBeVisible

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


Description

Returns the object faction (party) member with the highest armor class. If bMustBeVisible is set to TRUE then the returned object must be visible to the object calling the function.

Returns OBJECT_INVALID if oFactionMember's faction is invalid.



Remarks

Another nice Combat Oriented AI function. A possible use is to decide which member of a faction should be dispelled, or have magic cast upon them (compared to a lower AC member which would be easier to hit with a weapon), to lower the AC and damage them.

It can also be used to attack the highest 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 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.


Known Bugs

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


Version

1.64

Example

// Get the highest AC from a (seen) PC faction member, 
// and say "thats some good armor mate, but mine is better", as
// a blacksmith/other fighter/idiot who wants the PC to kill them.
 
void main()
{
    // Get faction to check
    object oPC = GetPCSpeaker();
 
    // Get the highest (Seen) AC member
    object oHighest = GetFactionBestAC(oPC, TRUE);
 
    // Speak to them
    SpeakString("Hey there, " + GetName(oHighest) + ", thats some mighty fine armor, but mine is better!");
}

See Also

functions: 

GetFactionWorstAC



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