GetFactionAverageLawChaosAlignment(object)
Get the average number (between 0 and 100 inclusive) of the all objects within the object's faction that represents the Law/Chaos alignment
int GetFactionAverageLawChaosAlignment( object oFactionMember );
Parameters
oFactionMember
The creature or object whose faction average you wish to examine.
Description
Returns an integer between 0 and 100 (inclusive) that represents the average law/chaos alignment of oFactionMember's faction.
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
This will search the module for all members of the object's faction and average out their Good/Evil alignment on a scale of 0 (Law) to 100 (Chaos).
This will work exactly the same was as using GetFirst/NextFactionMemeber() and using GetLawChaosValue(), 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
// Check the faction alignment of the PC's party, using a trigger. // It will make a guard say hello if they are very lawful, thus will be // less likely to break the law. // Of course, it is kinda OOC knowledge. This function is more likely // to be used in other ways. void main() { // Get the entering object object oPC = GetEnteringObject(); string sLocal = "DO_ONCE" + ObjectToString(OBJECT_SELF); // Only do this once, only affects PC's if(GetLocalInt(oPC, sLocal) || !GetIsPC(oPC)) return; // Set to not do it again SetLocgalInt(oPC, sLocal, TRUE); // Check alignment - must be very lawful if(GetFactionAverageLawChaosAlignment(oPC) >= 90) { // Get the town guard onto them object oGuard = GetNearestObjectByTag("TOWN_GUARD"); // Get them to talk AssignCommand(oGuard, SpeakString("Good day citizen. Keep an eye out for pick pockets, won't you?")); } }
See Also
author: John Shuell, editor: Jasperre, additional contributor(s): Jeremy Spilinek, Jasperre