GetFactionAverageLawChaosAlignment

From NWN Lexicon
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.

Contents

[edit] 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
);

[edit] Parameters

oFactionMember

The creature or object whose faction average you wish to examine.


[edit] Description

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. -1 is returned if the object is invalid.

[edit] 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.

[edit] Version

1.62

[edit] Example

// 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?"));
    }
}

[edit] See Also

functions: 

GetAlignmentLawChaos



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

Personal tools
Categories