GetFactionEqual

From NWN Lexicon
Jump to navigationJump to search



GetFactionEqual(object, object)

Are both objects in the same faction?

int GetFactionEqual(
    object oFirstObject,
    object oSecondObject = OBJECT_SELF
);

Parameters

oFirstObject

First object to compare.

oSecondObject

Second object to compare against. (Default: OBJECT_SELF)


Description

Returns TRUE if the Faction Ids of the two objects are the same.

Remember, each new PC party has a separate Id, as does each separate faction for NPC's.

It doesn't matter which way round oFirstObject and oSecondObject are used.



Remarks

A great way to tell if another approaching creature is in the same faction as the calling object.

This is best used, in the upmost sense, to make sure NPC's do not attack their actual allies that they should never go hostile to. It is a shame the default AI therefore doesn't use it.

It can also be used by NPC's in a PC's party to, for example, check if they are being attacked by their masters friends, or for example, should help one being over another because they are in their party (faction).


Version

1.62

Example

// Use in a henchman's conversation conditionals script. If the talking
// creature is in our faction, but *not* our master, we will not
// allow them to change anything but we will allow them to talk
// normally to us.

void main()
{
    // Get the PC speaker
    object oPC = GetPCSpeaker();

    // Get our master
    object oMaster = GetMaster(OBJECT_SELF);

    // Check faction and master status
    // * Will return TRUE if they are equal, but not our master
    if(GetFactionEqual(oTarget, OBJECT_SELF) == TRUE &&
       oMaster != oPC)
    {
        // Return TRUE
        return TRUE;
    }
    // Nope, just some guy - who still might be our master, however.
    return FALSE;
}

See Also



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