Jump to content

Is there any way to make an NPC never turn hostile towards the player?


Alphaman

Recommended Posts

Hello everyone. I've been searching the internet for over an hour but have not come across any answers whatsoever, so if it's something obvious and I somehow missed it then let me apologise in advance.

 

My question is: is there a way to set up an NPC so it will never turn hostile towards the player? Be it due to retaliation against repeated accidental (or intentional) player attacks or anything else, I am basically looking to make it so an NPC will never, ever see the player as an enemy. Something like Ralof/Hadvar during the beginning of the game, where no matter how much you attack them they'll never turn against you.

 

Would anyone know if this can be achieved through the CK/Tes5Edit? Is there a faction, keyword, or any setting that can be changed to achieve this purpose?

 

Thank you very much for your time

Link to comment

The NPC is in that faction already (in fact it's the only faction this NPC is a part of) and its relationship towards the player is set to Ally, but it didn't do much. Unfortunately after just 3 hits the NPC turned on me and not even sheathing the weapon made it stop combat.

Link to comment

The NPC is in that faction already (in fact it's the only faction this NPC is a part of) and its relationship towards the player is set to Ally, but it didn't do much. Unfortunately after just 3 hits the NPC turned on me and not even sheathing the weapon made it stop combat.

 

I think the two you named and the Greybeards are a little different, but there are also variables (not sure if they are actorvalues or what) you can change for how many friendly hits in or out of combat are ignored by an npc, an ally, and such. The SkyTweak mod is what I use to change them which is why I forget what they are. There is also a variable for how many seconds it takes to "drop" a hit so between that low and allowed hits being high I don't worry about accidental hits.  As I type I remember another setting for not doing damage to allies or friendlies in combat as well. Maybe a combination of those will let you do what you want.

Link to comment

karlpaws, thanks to your reply I started looking into those values and found that iAllyHitNonCombatAllowed is able to solve this issue. So thank you very much karlpaws, and also CPU.

 

I'll leave the steps to take in case anyone else ever has this question. Setting iAllyHitNonCombatAllowed to 1000 in an .esp file (FormID doesn't matter) makes any and all allies ignore an infinite amount of hits even while out of combat, when usually they would attack you after 3. Together with the right morality settings for each specific NPC, they will effectively not attack unless it's caused by appropriate spells like Frenzy. If you want them to ignore even those effects, you'd have to use scripts in order to stop combat with the player immediately after starting it, and that's a big pain in the backside.

Link to comment

Actually you can do this fairly easily. It does require a script but such a script already exists in the vanilla game, all you have to do is attach it to the actor. The script name is:

defaultIgnoreFriendlyHits

 

Just go the actor, select add in the script section, find and select the script then click OK and you're done. The actor will never turn hostile towards friends. Of course, if the actor isn't a friend, then this probably won't work but I've never tried using it on actors who weren't friends with the player so I can't say for sure. I can say that it does work on friends, as I've continuously beat them before and they never turned hostile.

 

 

If you already know how to script, then simply call this function on the actor/object you want to never turn hostile towards friends: IgnoreFriendlyHits(True)

Link to comment

Mods like EFF does this no?

 

They do, but only for followers as far as I know. The NPC I was having this issue with was not a follower so I needed a way which would make any NPCs not attack you even when "provoked". But I also asked this question because I was curious on whether there was a way to make NPCs simply not attack us without using mods, which seems like a really basic feature that skyrim would have natively.

 

---

 

Actually you can do this fairly easily. It does require a script but such a script already exists in the vanilla game, all you have to do is attach it to the actor. The script name is:

defaultIgnoreFriendlyHits

 

Just go the actor, select add in the script section, find and select the script then click OK and you're done. The actor will never turn hostile towards friends. Of course, if the actor isn't a friend, then this probably won't work but I've never tried using it on actors who weren't friends with the player so I can't say for sure. I can say that it does work on friends, as I've continuously beat them before and they never turned hostile.

 

 

If you already know how to script, then simply call this function on the actor/object you want to never turn hostile towards friends: IgnoreFriendlyHits(True)

 

This is very good info as well, thank you very much Swissenergy. Scripting is probably the only area I really haven't touched at all so this will absolutely come in handy. I imagine this script wouldn't place any real load on the papyrus system so I'll definitely keep it in mind if I'm ever in a situation where I want only a few certain allies to never retaliate.

Link to comment

I personally use the script from Bethesda on some custom summonable creatures to prevent hostility if they're accidentally hit a few times and it works perfectly. They never turn hostile, no matter how many times I hit them. The script is tiny and very light.

 

Without scripts, you can setup an AI package that will prevent an NPC from fighting. In fact, there are several ways you can do this.

 

1. Combat override package:

This will cause the NPC to execute a package or packages instead of fight when entering combat, so long as the package(s) is valid. It's a little more complicated to setup if you're not familiar with AI packages and how they work.

 

2. Enabling the flags "Ignore Combat" and "No Combat Alert" on packages:

With these flags enabled on their current package, the NPC will not actually fight or run away from enemies, but they're still "in combat." For example: actors that are in SexLab animations use an AI package with these flags enabled.

Link to comment

So in the latter example, it'd still show a red dot in the compass, they just wouldn't do anything about it? I see how it works. AI packages are something I don't have a lot of experience on, if I look at one I understand what they do but I haven't tried playing around with them yet.

 

Having said that, the situation you described with the summoned creatures is quite similar to my own. In my case, it's a follower which occasionally transforms into a "vampire lord" form. On activation, the follower's actor switches with the vampire lord version of that actor, but being a separate actor it isn't flagged as a follower or anything else. It's simply an ally NPC with an AI package to follow the player just like a follower would, and who attacks anything that's hostile to me since it's a member of the playerfaction. So I imagine it acts pretty much like any summoned creature would.

 

I was just in the middle of disabling my changes to the iAllyHitNonCombatAllowed value and seeing how your script would work, but looking at how similar these cases are I'm sure it'll work perfectly.

 

---

 

EDIT: As expected, when I placeatme'd a new instance of the follower's vampire lord actor your script suggestion worked just as advertised. However I'll stick to using the altered non-combat hits value since it feels right for all allies to not just... murder you. Plus it'd suck if I tried to reset the original vampire lord actor so it'd load the new script and ended up messing things up somehow. Skyrim loves messing things up.

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use