Friendly Hostile Rats/Deer

Hello, I apologize if this thread subject exists somewhere already but I did some searching and could not find my subject at all.
My question is regarding my deer and rats encounters.  Even though I have changed both of their factions to "hostile", these creatures are friendly.  I have double checked to be sure that the factions are set correctly based on my desire to have both the deer and rat encounters hostile to the PC, but they both remain friendly to the PC.  Any help would be very much appreciated.

If you use an encounter trigger to spawn those animals, **make sure that the game uses ones you've modified.**
Step one - add modified rats and deer to palette blueprint (and change their tags)
Step two - create custom encounter trigger and choose the animals from you custom palette
should work

Thanks for reply. I thought I could just change the encounter faction to hostile and that would cause the whole group to become hostile. Well now I realize changing an encounter’s faction does nothing. I suppose you could use that encounter faction as a script target but other then that, nothing I think. Anyway, I had to change the creature’s faction and add it to an encounter. It works fine now all except the deer. Sure, the deer technically becomes labelled as hostile but when attacked the deer simply runs away a bit then stops. I am assuming it has a script that causes a certain behavior. It’s not a big deal. If I really want to make a deer group that acts aggressively and attacks the PC, I can make it out of a different blueprint. I’m a very new builder so I’m just learning these things. Thank you.

Re. deer

there’s an #include file ‘x0_i0_behavior’

It has 2 functions: SetBehaviorState() and GetBehaviorState().
It defines 5 variables:

// Special Behaviors master int

// Special Behavior flags
const int NW_FLAG_BEHAVIOR_SPECIAL   = 0x1;
const int NW_FLAG_BEHAVIOR_CARNIVORE = 0x2; // will always attack regardless of faction
const int NW_FLAG_BEHAVIOR_OMNIVORE  = 0x4; // will only attack if approached
const int NW_FLAG_BEHAVIOR_HERBIVORE = 0x8; // will never attack, will always flee.
  • when a flag is set, usually in the blueprint’s OnSpawn event, AI-scripts that initiate combat will call DetermineSpecialBehavior() instead of DetermineCombatRound().

NOTE: I’m looking at nwn2 scripts, but am sure this is a carry-on from nwn1. I recall that deer are set w/ NW_FLAG_BEHAVIOR_HERBIVORE - if you clear that flag, either by using a modified OnSpawn script or by calling SetBehaviorState(NW_FLAG_BEHAVIOR_HERBIVORE, FALSE), the deer will likely revert to standard combat.

/just a note


That’s right. The deer’s OnSpawn script is nw_c2_herbivore. You can change that to nw_c2_default9 if you want normal behaviour.

1 Like
  1. you can use the creature wizard: TIP 1 wait til you edit the properties to select the model and portrait - because when you select the model it autofills the matching portrait also, TIP 2 when naming the creature, dont call it “Deer” or “Rat” in the wizard - give it a resref name where the first three letters are abbreviations for your module (My module is Time of Atlantis so I use ta_ before everything - this helps you avoid conflicting resrefs and the dreaded BadStreff error. You can then change its name to Deer or whatnot in the properties. The creature wizard will give your creatures all the X2_def_ script events so you dont have any curveballs like above.
  2. If you make template creatures of all the lowest level versions of the critters you want in your mod first, like one level one goblin, one level one rat, one level one deer, one level one wolf - and so on - you can use the amazing left click power of “edit copy” TIP 1 - resref is editable when you edit copy, use this to make your tag and resref the same - TIP2 - in addition to having a 3 character prefix, make the 4th character related to what it is ie: m for monster, i for item, p for placeable, t for trigger, w for waypoint. You have 16 characters in any resref - using the first 4 in this fashion helps avoid BadStreff TIP3 you can always add levels with the levelup wizard under classes but its a little more annoying to remove them, start low and work up - less work means more production. TIP 4 the toolset warns you if you give equipment to a critter and it hasnt feats yadayadayada but if you go in there and give it a bastard sword, it will ask you if you want to give the creature the exotic weapon proficiency - doing this and clicking yes is easier than going to feats and hunting for the checkbox next to weapon prof- exotic.

I’m slightly confused here. Why hasn’t anyone mentioned the fairly standard script that is normally used in these cases? Which one? This that goes in the OnPercieved script slot on the creatures involved -

void main()
    object oPC = GetLastPerceived();


    SetIsTemporaryEnemy(oPC, OBJECT_SELF);
    AssignCommand(OBJECT_SELF, ActionAttack(oPC));
    AssignCommand(OBJECT_SELF, DetermineCombatRound(oPC));


Save it as killer_bunny.

This will make the creatures attack the PC on sight or if heard.


@Tarot_Redhand did you try it with a deer? I think you’ll find that DetermineCombatRound will select the herbivore behaviour (running away) unless the spawn script is changed.

After that, you only need to change the deer to a hostile faction for it to attack on perception.

The temporary enemy approach is more useful when you want an initally neutral NPC to turn hostile during conversation or whatever.

Yes I’ve tried it with deer. I’ve also tried it with dogs and chickens. It works for me.


Just confirmed it in module. Put that script into OnPerceive of a Deer. In game deer charges PC and attacks.


I think it may just be the SetIsTemporaryEnemy() that ensures that the PC is attacked.