Skyrim Special Edition

Figuring out how to make this mod work was somewhat painful. I wanted to share my findings for the community.

How does trespassing work?

The trespassing mechanic appears to be a hardcoded event triggered by AI packages that include the LockDoors (Procedure) option as selected, thus flagging a location and changing AI behavior for if the player is spotted. There is a non-modifiable value which can be retrieved by the IsTrespassing function. There is no method to set the value, only get the value.

In the vanilla game, this is typically (exclusively?) seen for Sleep packages.

The dialogue is contained in:

  • DialogueGeneric quest > PlayerDialogue > DialogueGenericTrespassingBlocking
  • DialogueGeneric quest > Combat > Trespass
  • DialogueGeneric quest > Combat > TrespassAgainstNC

..and are conditioned to check the IsTrespassing value. A similar structure/naming scheme is also likely used for characters added in DLCs.

Areas that are marked as "Public" in their Cell properties do not invoke the trespassing mechanic, but will still lock the doors.

Contemplating how to use this mechanic...

I thought of creating a new quest that would contain dialogue and use scenes to control behavior, but this just seemed more burdensome. I looked into ways to set the trespassing value, with no luck; no script extender or other reverse-engineered function set contained this. Perhaps it could be done in the future since there are existing get methods.

I did some A/B testing and settled on the existing mechanic.

How this mod utilizes the vanilla trespass mechanic...

It may seem obvious with the information above, but none of this was clear to me when I started. I created the "AreaOffLimitsTrespassingQuest" quest and made an Actor Ref Alias called "CellOwner". The aliases are optional, because sometimes we may enter a cell that is empty. It looks for Actors in the area which is in the same cell as the player, is a playable race, is an actor, and is in their own owned cell. If filled, the "AreaOffLimitsPackageAnyTimeLockWarn" AI package is applied which utilizes the LockDoors procedure.

Unfortunately, the AI package will disrupt whatever the NPC is currently doing. To minimize the disruption, the AI package contains a small radius Sandbox routine. Otherwise, it could unfairly make an NPC move into the area you are even though they likely would not have done so without you entering the off-limits area. GTA cops behave like this, which psychic knowledge of where you generally are - and it's a crappy design R*! Hopefully, a script extender author will implement the ability to set player as trespassing and we can change the implementation. In the meantime, I think this works pretty well.

Areas which are made to be off-limits are done using the "AreaOffLimits" triggerbox. There is a script attached to the base object with all of the needed properties filled. The script for the triggerbox checks to see if the player has entered or exited the triggerbox, which will start and stop the "AreaOffLimitsTrespassingQuest" quest which in turn adds/removes the "AreaOffLimitsPackageAnyTimeLockWarn" AI package from nearby NPCs in the cell owner faction, if any.

Article information

Added on

Edited on

Written by

Korodic

0 comments