Encounters attack each other

Hi everyone! I’ve searched around the web for a solution but nobody seems to have the same issue.
In my module I’ve set some random encounter of wild animals that isn’t hostile to PCs, is just a spawn of animals in the wild that walk randomly in the area.
When as a DM I place a hostile creature in the same area that is programmed to attack the party, the creature attack the animals instead.
Does anybody have some ideas about how to avoid this situation?
Thanks to all!

Hostile creatures will attack anything that doesn’t belong to the Hostile faction. You’ll need to create a custom faction for your animals that the Hostile faction is Neutral towards.

See https://nwn.fandom.com/wiki/Faction

The Faction is set through the Advanced tab of the Creature Properties window. I also suggest you get the Guide to Building Vol. I: The Aurora Toolset Manual

https://neverwintervault.org/project/nwn1/other/guide-building-volume-i-–-aurora-toolset-manual

1 Like

Thanks for the reply.
I try what you have suggested following the guide of the toolset. :yum:

I’ve tried every combinations and nothing seems to work properly.
I’ve created a faction “animal” that is set neutral to all the other factions.
But when I run the module both the Defender faction and the Commoner faction attack the Animal faction, ad the player saw the Animal faction as Hostile.

I’ve tried equally to set the Animal faction friendly to the player and itself, and neutral to all the other factions, but nothing seems to work T.T

I’m sure I’m doing something wrong but I don’t know where.

then you have to set all other factions neutral to the Animal faction (also)

It’s what I’ve done, but something make the faction hostile both for Player and for Commoners and Defender factions

Can you post a screenshot of the faction table?

 
and double check that the creature blueprints of the “encounter” really are set to faction Animal

 
and make sure there isn’t a rogue Repute.FAC file in the campaign folder, override, or a .hak

I made the Animal faction as show below and set it up not global.

faction_table

Next, I’ve set up the blueprint of a horse (previously set as Commoner) as Animal, overwriting the proprieties and applying them to all areas.

I’ve checked the faction of the single creatures “horse” that I’ve placed and are all set to Animal.

In the same area, I have an encounter of NPC human where the blueprint is set as Commoner and the encounter itself is set Hostile so the player when entering the area can trigger the encounter.

In the same area, I have some guards placed as creatures with the Defender factions.

The result of all of this is that the guard and the human of the NPC encounter attack the horses immediately when I run the area.

Sorry for the long post, but I’ve preferred to show every step I’ve made.

looks right, although i advise setting your custom faction Global=True

It relates to the “use personal reputation” variable, which doesn’t seem to work as well in Nwn2 as it did in Nwn1. Similarly, if this is a campaign, set UsesPersonalReputations=False in the CampaignEditor plugin … and, in the module properties’ OnModuleLoad script, check that CAMPAIGN_SWITCH_USE_PERSONAL_REPUTATION is set FALSE (or is not set at all).

SetGlobalInt(CAMPAIGN_SWITCH_USE_PERSONAL_REPUTATION, FALSE);

I don’t think that’s the problem but it’s something every builder should be aware of … at least a bit. Using personal reps interferes with expected companion behavior, in my experience. Namely, they won’t attack on their own when creatures go aggro on the PC.

anyway (maybe you want it that way, idk)

The faction table looks good to me. The horse’s tag is “AT_ANI_CAVALLO”, the Encounter NPCs have tags “at_png_pop33” etc, …

 
hm, right now i have the impression that your module might not be running with the custom FactionTable. Because if your module is in fact falling back on using the default factiontable, the Animal faction wouldn’t be represented, meaning it has a reputation of 0 Hostile with all other factions.

hence Commoners and Defenders go aggro on it, and it scries hostile to your PC.

 
you aren’t loading this from a savegame, are you?

The savegame might be a good hint here. I’ve had this problem before and the issue was an autosave trigger. If you load the game for testing purposes from the toolset and then activate an autosave trigger, there will be saved game information in the module folder. Therefore, next time you load the game from the toolset old information will be active.

The module isn’t a campaign but a persistent world I’m building and that will be uploaded on a game server. So there aren’t savegames.
What I’m trying to do is solving a problem that occurs when a DM uses the DM tool for spawning a monster against a party. The creature attack the animal spawned from the encounter instead of the PC.

here’s a script (console) that could help …

// 'testfac'
/*
    Console script based on 'gui_faction_change' in DM-helper.
    https://neverwintervault.org/project/nwn2/other/gui/dm-helper

    - changes or prints current target's Faction
    - only standard factions are supported

    `
    debugmode 1
    rs testfac(%faction%)
    debugmode 0
    `

    where %faction% is an integer:
    0 - set current target to hostile
    1 - set current target to commoner
    2 - set current target to merchant
    3 - set current target to defender

    5 - get faction of current target
*/

const string RESREF_PIG = "c_faction_pig"; // stock faction-pig resref

string GetFactionString(int iFaction, object oTarget);


//
void main(int iFaction)
{
    object oControl = GetControlledCharacter(OBJECT_SELF);

    object oTarget = GetPlayerCurrentTarget(oControl);
    if (GetIsObjectValid(oTarget)
        && GetObjectType(oTarget) == OBJECT_TYPE_CREATURE
        && !GetIsDM(oTarget))
    {
        switch (iFaction)
        {
            case STANDARD_FACTION_HOSTILE:  // 0
            case STANDARD_FACTION_COMMONER: // 1
            case STANDARD_FACTION_MERCHANT: // 2
            case STANDARD_FACTION_DEFENDER: // 3
                if (!GetIsObjectValid(GetFactionLeader(oTarget)))
                {
                    AssignCommand(oTarget, ClearAllActions(TRUE));
                    ChangeToStandardFaction(oTarget, iFaction);
                }
                else
                    SendMessageToPC(oControl, "testfac : Party is invalid for faction change.");

                break;

            default:
            case 5: // get faction of current target
            {
                string sFaction;

                if (!GetIsOwnedByPlayer(oTarget))
                {
                    iFaction = -1;

                    object oPig = CreateObject(OBJECT_TYPE_CREATURE, RESREF_PIG, GetLocation(oTarget));
                    if (GetIsObjectValid(oPig))
                    {
                        SetScriptHidden(oPig, TRUE);

                        for (iFaction = STANDARD_FACTION_HOSTILE; iFaction <= STANDARD_FACTION_DEFENDER; ++iFaction)
                        {
                            ChangeToStandardFaction(oPig, iFaction); // NOTE: Pig resref is faction Commoner.
                            if (GetFactionEqual(oPig, oTarget))
                                break;
                        }

                        SetPlotFlag(oPig, FALSE); // NOTE: Pig resref is Plot.
                        DestroyObject(oPig);
                    }
                    sFaction = GetFactionString(iFaction, oTarget);
                }
                else
                    sFaction = "PC";

                SendMessageToPC(oControl, "testfac : " + GetName(oTarget) + " ( " + GetTag(oTarget) + " ) is faction " + sFaction);
                break;
            }
        }
    }
    else
        SendMessageToPC(oControl, "testfac : Target is invalid for faction scry.");
}


//
string GetFactionString(int iFaction, object oTarget)
{
    string sFaction;
    switch (iFaction)
    {
        case STANDARD_FACTION_HOSTILE:  sFaction = "HOSTILE";  break; // 0
        case STANDARD_FACTION_COMMONER: sFaction = "COMMONER"; break; // 1
        case STANDARD_FACTION_MERCHANT: sFaction = "MERCHANT"; break; // 2
        case STANDARD_FACTION_DEFENDER: sFaction = "DEFENDER"; break; // 3

        default:
            sFaction = "n/a";
            break;
    }

    if (GetIsObjectValid(GetFactionLeader(oTarget)))
        sFaction += " ( PC )";

    return sFaction;
}

if a creature is in the Animal faction, it should scry as “n/a”

 

Edit: script updated to also print the tag of target