From NWN Lexicon
Jump to navigationJump to search
Red bug icon.png Warning: This function has a known bug and may not work as expected in some situations. See Known Bugs for details.

Returns if the faction averages Law, Chaos or Neutral alignment.

int GetFactionAverageLawChaosAlignment(
    object oFactionMember


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 Law/Chaos alignment. The return value is an alignment constant (e.g. ALIGNMENT_CHAOTIC) not a number on the 0-100 scale. Party members are included for player characters, and for NPC factions all NPCs are included.

-1 is returned if the object is invalid.

Known Bugs

While this works for factions with a single member (identical to GetAlignmentLawChaos), if there are multiple members to a faction then ALIGNMENT_CHAOTIC is returned if all members are chaotic and ALIGNMENT_LAWFUL if at least one member is neutral or lawful.




// Check the faction alignment of the PC's party, using a trigger.
// It will make a guard say hello if they have some consideration of the law, 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) != ALIGNMENT_CHAOTIC)
        // 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