Get the average number (between 0 and 100 inclusive) of the all objects within the object's faction that represents the Good/Evil alignment
The creature or object whose faction average you wish to examine.
This will search the module for all members of the object's faction and average out their Good/Evil alignment. The return value is an alignment constant (e.g. ALIGNMENT_EVIL) not a number on the 0-100 scale. Party members are included for player characters. -1 is returned if the object is invalid.
While this works for factions with a single member (identical to GetAlignmentGoodEvil), if there are multiple members to a faction then ALIGNMENT_EVIL is returned if all members are evil and ALIGNMENT_GOOD if at least one member is neutral or good.
// It will make some NPC's go hostile if they are considered to be
// evil on average.
// Of course, it is kinda OOC knowledge. This function is more likely
// to be used in other ways.
// 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 evil!
if(GetFactionAverageGoodEvilAlignment(oPC) == ALIGNMENT_EVIL)
// Get the town guard onto them
object oGuard = GetNearestObjectByTag("TOWN_GUARD");
AdjustReputation(oPC, oGuard, -100);
// Do an attack
author: John Shuell, editor: Jasperre, additional contributor(s): Jasperre, Jeremy Spilinek