Jump to content

Hostile NPC 'Area' - Sort of like a Sparring area


Helemar

Recommended Posts

So, I've spent a good amount of time in the CK, have general knowledge, but have not touched papyrus. Just background info.

 

What I'm trying to do is make an area (let's say 768x768 square) with a custom NPC in it, and when you enter this square area, the NPC goes hostile and starts attacking you, and if you leave said area, the NPC goes back to non-hostile.

 

I haven't found a simple way to do this, and from what I'm guessing I might end up having to do this in papyrus, but does anybody have an insight on how to achieve this without papyrus or furthermore has anyone done this and can point me in the right direction?

 

Thanks.

Link to comment
Share on other sites

Yeah, you'll have to do this in Papyrus I think. Cover the relevant area with a trigger, and attach a script to it, then you'll want to use the OnTriggerEnter() event to make the NPC hostile, and OnTriggerLeave() to make him non-hostile again; a simple way to handle the hostility might be to call SetAttackOnSight(True) on the player when he enters, and SetAttackOnSight(False) when he leaves, however this is only a good idea if there are no other actors around who should not be hostile to the player (this function does exactly what it says on the tin, makes the player fair game for anyone to attack on sight).

 

If you do have other actors about, then call the function SetRelationshipRank(PlayerREF, -4) on your NPC to make him hostile, and SetRelationshipRank(PlayerREF, 0) to make him non-hostile.

 

All of this being said, though, I'm not 100% sure that your NPC will stop attacking in the middle of a fight with either of these methods, especially if you've hit him at some point during the fight. You may need to cast Fury and Calm spells (which, too, can be done via Papyrus). You'll have to do some testing to figure out what works, but hopefully this is enough information to get you started.

Link to comment
Share on other sites

That's actually a perfect starting point. I already had the area covered with a trigger, was hoping there was a way to do it simply with that, but I'll mess around with it and see where it gets me. Figured I'd have to wait like a week for a reply on this.

 

Thanks a bunch. I'll post after I've learned how to use papyrus better and have done some testing.

Edited by Helemar
Link to comment
Share on other sites

  • Recently Browsing   0 members

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