Jump to content

Better NPC Support for Devious Devices


Recommended Posts

Better NPC Support for Devious Devices

View File


 Better NPC Support for Devious Devices

 

An add-on for Devious Devices to improve support for NPCs.

Latest Version: 0.6 (2022-02-19), this version is for DD 5.x only
Latest Version supporting DD 4.X: 0.2 (2021-01-27)

 

Current functionality:

  • Restore missing effects after NPC is reloaded by the game engine (for example after loading screen).
  • Restore missing effects after NPC's inventory has changed (for example after player giving new equipment to follower).
  • Prevent bound NPCs from using weapons and spells in combat; they will use bound combat if enabled in Devious Devices settings.
  • Allow manipulation of some NPC devices (insert/remove panel gag plug, link/unlink DCUR rubber gloves with D-links).
  • Escape system: If enabled in MCM this allows NPCs to struggle and maybe escape their devices.


Current Limitations:

  • Restoring missing effects may take a few seconds. During that time, devices may flicker as they are being refreshed.
  • Sandboxing packages (especially of followers) might cause NPCs to use furniture even with bound hands, which will look wrong.

 

Compatibility:

  • This mod should work correctly with Devious Devices that are added by other mods.
  • This mod does not replace NPC packages outside of combat, so it should be fully compatible with NPCs that have custom AI like Paradise Halls slaves, Serana, or custom followers.
    The drawback is that their custom AI may occasionally break the bound hands animation (if they are bound), for example when sandboxing.
  • This mod might interfere with bondage furniture mods (DD Contraptions, ZAP). More testing is required.

 

Credits:

  • Everybody working on Devious Devices mods. You are the reason for this mod.
  • Especially Kimy for patiently answering my questions about the inner workings of Devious Devices, allowing me to understand why things are partially working for some NPCs without this mod, but not at all for some other NPCs.
  • Me.

 

License:
Released under CC0 license (included in the archive). My hope is that at some point in the future most of the code might end up in Devious Devices, making this mod unnecessary.

 

Github:

https://github.com/RealHandcuffs/Better-NPC-Support-for-Devious-Devices

 

Changelog:

Spoiler

Version 0.6

  • Do not apply bound idle to sleeping or unconsious NPCs
  • Prevent sleeping or unconscious NPCs from struggling
  • Script changes to allow conversion of mod to .esl

 

Version 0.6 beta 3

  • Fix lockpick escape: NPCs first need to access lock before they can pick it, just like players
  • Apply Devious Devices cooldown difficulty modifier (configured in DD MCM) to NPCs
  • Optimize escape attempt triggering code, especially for "(by device)" case

 

Version 0.6 beta 2

  • NPCs will abide by device cooldowns when trying to escape; they will only use the action with the largest chance of success, though
  • Add new struggle frequency option "(by device)", this will choose struggle frequency automatically according to worn devices
  • Make "(by device)" default struggle frequency for followers (only new games, existing games will continue to use the currently configured value)
  • NPCs can now try to escape by picking the lock of their devices, as long as they have lockpicks in their inventory (they will break on failure)
  • Add MCM setting to enable/disable escape by picking locks, default option is "Current Followers Only"
  • Some small fixes


Version 0.6 beta 1

  • Make bound NPCs behave defensively even if bound combat is enabled
  • Do not make bound NPCs behave defensively if they are followers and player is bound, too
  • Allow non-followers to use bound combat, too, if it is enabled in Devious Devices settings
  • Unequip arrows too when unequipping weapons from bound NPCs
  • Ignore disabled NPCs
  • Various optimizations
  • Build system: Support different files for classic skyrim and special edition
  • Make MCM mod name display work for esl's in special edition (this requires se-only script changes)

 

Version 0.5.1

  • Hotfix: Tighten code to reduce chance of race condition and implement additional code to mitigate the problem

 

Version 0.5

  • Same as 0.5 RC 3, other than version string

 

Version 0.5 RC 3

  • Change how the escape system recognizes NPCs that should not struggle, it now checks if their outfit contains devious devices
  • Block The Whip And Chain actors from escape system in addition to outfit check mentioned above
  • Change build scripts to support Skyrim SE, the scripts are now compiled with SE and a .bsa is built using the SE format
  • Optimize "restore original outfit" code

 

Version 0.5 RC 2

  • Small performance optimization (override DD bound NPC sandbox packages with custom script to prevent unnecessary EvaluateAA call)
  • Clean masters of esp

 

Version 0.5 RC 1

  • Change logic for unlock difficulty, use similar logic like DD does for player
  • Prevent struggling when NPC is being animated by sexlab
  • Internal changes allowing to recalculate helpless/not helples without full fixup

 

Version 0.5 beta 8

  • Interrupt escape attempts when NPCs are hit
  • Prevent struggling NPCs from moving or using furniture

 

Version 0.5 beta 7

  • Change package to contain .bsa archive instead of loose files
  • Add option to fix inconsistent devices of current followers automatically, enabled by default
  • Player teammates will not start to struggle when the player is in combat or sneaking
  • Change layout of MCM menu
  • Add more MCM settings for tweaking struggling behavior
  • Fix enable/disable NPC processing in MCM
  • Various minor fixes and improvements

 

Version 0.5 beta 6

  • Change MCM settings for player notifications to three states: None, summary only, detailed
  • Be much more restrictive about which NPCs are allowed to escape devices if they are not current follower
  • Various fixes, tweaks and internal changes to escape system and handling of devices

 

Version 0.5 beta 5

  • Tweak timing and messages of escape system
  • Fix handling of quest devices by escape system (will now struggle but always fail)
  • More MCM improvements

 

Version 0.5 beta 4

  • First version of escape system, disabled by default, needs to be enabled in MCM
  • Some bugfixes, e.g. race conditions when loading game
  • Change layout of MCM

 

Version 0.5 beta 3

  • Refactoring and small fixes

 

Version 0.5 beta 2

  • Recognize devious plugs, too (they were ignored up to now)
  • Some refactoring and additions to ExternalApi.psc

 

Version 0.5 beta 1

  • Prevent NPCs with equipped devices from becoming bard audience
  • Allow the player to manipulate NPC's panel gags by removing/inserting plug
  • Allow the player to lock NPC's DCUR rubber gloves with D-links
  • Fix unlocking NPC's DCUR locked rubber gloves (DCUR assumes it is only worn by player)

 

Version 0.4

  • Add more information to MCM: Show tracking id and equipped devices of NPC under crosshair.
  • Add DDNF_ExternalApi to support other mods getting or equipping devices.
  • Some more internal changes.

 

Version 0.4 beta 5

  • Further refactoring to improve performance and to make the mod more reactive on changes to NPC inventory by player (container menu).

 

Version 0.4 beta 4

  • Add option to clear all cached data to MCM; this can be used for example after an update to DD that changes keywords of existing devices (not expected).
  • Apply code changes to reduce the chance of race conditions leading to wrong animation sets or orphaned rendered devices.

 

Version 0.4 beta 3

  • Check keywords of all devices, not just the ones with magic effects.
  • Use StorageUtil to speed up analysis of equipped devices by caching information for each "rendered device" that is encountered.

 

Version 0.4 beta 2

  • Add special handling for panel gags.
  • One more very minor performance optimization.

 

Version 0.4 beta 1

  • Add support for unequipping "weapon on back" display armors, currently supports "All Geared Up Derivative".
  • Some minor performance optimizations.

Version 0.3

  • No changes, same as 0.3 beta 5 other than version number.

 

Version 0.3 beta 5

  • Try to prevent bound NPCs from sandboxing (most of this depends on DD NPC slots being enabled and available)
  • Add option to restore original outfit of NPCs after DD replaced it with empty outfit (false by default)

 

Version 0.3 beta 4

  • Slightly increase delay after devices are added/removed to prevent race conditions with DD (could lead to lost animations e.g. after adding gags, or removed devices staying visually applied)


Version 0.3 beta 3

  • Change handling of dummy weapon to prevent bug causing all equipped items to be unequipped

 

Version 0.3 beta 2

  • Improve the fix for corrupt devices (devices sometimes get "bad" when they are stored in a container for a long time)
  • Detect rendered devices being unequipped while NPC is loaded and try to fix the issue
  • Prevent prisoners from using bound combat even if not wearing fetters (use membership in dunPrisonerFaction)

 

Version 0.3 beta 1

  • Add option to fix the NPC under the crosshair to MCM
  • Optimization: Change handling of animations, should now recognize when animations are still applied after loading screen and not re-apply them


Version 0.2

  • Support pahe dwemer slave suit and dwemer pet suit as a soft-dependency (they needed special handling)


Version 0.2 beta 3

  • Some more small optimizations

 

Version 0.2 beta 2

  • Optimizations after testing with Devious Devices 5.1
  • Add flag for papyrus logging to MCM  

 

Version 0.2 beta 1

  • Add a simple MCM with the following options:
    - enabled/disable processing of NPCs (can be used to temporarily disable the mod)
    - frequency of NPC scanner (default: scan for NPCs every 8 seconds)
    - how fast to process NPCs (default: 3 NPCs every 3 seconds)

 

Version 0.1

  • Tweaks to improve weapon handling of bound NPCs.

 

Version 0.1 RC 3

  • Changes to improve compatibility with DDe (and possibly other mods that use non-standard ways of equipping and unequipping devices).

 

Version 0.1 RC 2

  • Optimization: Detect if an added/removed device does not change the existing animations (e.g. when gagging bound NPCs) and skip refreshing animations in that case.
  • Optimization: Refactor detection of keywords on devices, will hopefully reduce the amount of keyword checks for NPCs wearing many devices.
  • Fix: Prevent NPCs with bondage mittens from using shields.

 

Version 0.1 RC 1

  • Use a workaround to force the game to correctly hide body parts according to armor addon item slots (this fixes hands clipping out of elbowbinders).
  • When scanning devices, check for each device if it has an enchantment; if not, assume it has no special functionality (e.g. heavy bondage, different animations).
  • When unequipping and reequipping devices, skip devices that have no enchantment (they have no effect that needs to be restarted).
  • Improve handling of weapons for bound followers: They should no longer try to draw weapons, and they should no longer run with one or both arms sticking out.

 

Version 0.1 Beta 5

  • Detect concurrent modifications to a NPC while the mod is fixing up devices of the NPC and abort the fixup (fail fast).
  • Reduce number of NPCs that can be found by the scanner quest from 8 to 4 (the mod is still able to handle more, it will just take longer to find them).
  • Only allow fixing devices of a particular NPC every 5 seconds real time (slow down). This includes situations where the fixup was aborted.
  • Only allow fixing devices of 3 NPCs over a period of 3 seconds (slow down).
  • Various other small optimizations.
  • Add very minimal logging. It is off by default and can be enabled using "setpqv DDNF_NpcTracker EnablePapyrusLogging true".

 

Version 0.1 Beta 4

  • Optimize all papyrus scripts after using the built-in profiler.
  • Remember devices of NPCs as long as they are being tracked to prevent repeaded inventory scans.
  • Try to be smarter about when to re-apply animations of a NPC (zadBoundCombatScript.EvaluateAA) as doing so is expensive and slow.
  • Allow pausing the mod by using "stopquest DDNF_NpcTracker". Use "startquest DDNF_NpcTracker" to start the mod again.

 

Version 0.1 Beta 3

  • Fix: Factions for combat packages were not cleaned up when NPCs were removed from the reference alias.

 

Version 0.1 Beta 2

  • Fix: Mod can become stuck in certain situations, stopping to work.

 

Version 0.1 Beta 1

  • Refresh effects on NPC after NPC is (re)loaded by game engine.
  • Refresh effects on NPC after NPC inventory changed.
  • Sheathe weapons after bound NPC draws weapon, and try to keep them sheathed.
  • Prevent usage of weapons/spells when NPC is wearing bondage mittens or is bound.
  • Allow bound combat if enabled in DD settings and NPC's feet are free.
  • Try to fix rendered items not being equipped (e.g. compatibility problems with mods like AllGUD).
  • Try to fix the issue that giving a NPC a device is sometimes not registered by the game engine (often when the player has multiple identical devices in inventory).

 

 

Edited by Kharos
update to 0.6
Link to comment

Diagnosing misbehaving NPCs

 

Edit 2021-12-22:

The old way of doing this is no longer necessary, the mod now supports getting the current package directly:

 

  1. Go to the NPC aim at them until you get the "talk" prompt
  2. Open the "Better NPC Spt for DD" MCM page
  3. Debug Settings: Check "Analyze NPC under crosshair"
  4. The menu will show you the FormID of the current package as "Current Package"
  5. Click on it to get a pop-up telling you the plugin that defines the package
Edited by Kharos
Link to comment
16 hours ago, NoppaiKohai said:

Very interesting! Any chance for an SE port? 

I have no personal experience with that. This mod is not very complicated, it's a few quests, factions, keywords, and four scripts. Might be as easy as just loading it in Creation Kit SE, recompiling scripts (is that necessary?), making a small change and saving again.


On the other hand I am not sure if I am somewhere doing something in a script that will not work in SE, or if the sequence of the events is somehow different. Bottom line, somebody would need to test that.

Link to comment

Just installed yesterday and INSTANT SUCCESS!!!

Before installing your mod about 50%-75% of all NPC in devious devices failed to play any DD idles.

Even if DDi settings where on shortest polling interval (0.50) and max number of registered NPC (20).

After installation of your mod 100% of all NPC in DDs show working DDi idles.

Not tested the DCL NPCs yet (they failed idle to 100%)

But HSG and NPC modified by @Corsec's DD patches show to 100% DDi idles.

 

even NPC in armbinders that change idle while sitting and eating/drinking will use the DDi idle again after finishing what ever they are doing.

 

Your mod is a must have with:

 

Thank You!

Makes my game much more immers.... devious!

 

Spoiler

511736442_enb2020_06_2023_27_14_42.jpg.1812030daf208cfdcb652cd7fa5cd2df.jpg

 

652120895_enb2020_06_2023_27_26_88.jpg.151c27f0953ee58e79b73984f5683e91.jpg

 

1568287094_enb2020_06_2023_53_52_29.jpg.19e896fae5298a81e3964bf2b7a9c37f.jpg

 

1896986503_enb2020_06_2023_53_56_53.jpg.83a5b526de836d7fcb5cb94ba7f79155.jpg

 

354813501_enb2020_06_2100_31_54_84.jpg.a21deab272c04afcb8e005d258f53bd4.jpg

 

2031628534_enb2020_06_2100_31_43_61.jpg.d42c84a6f6b6008c9c849d5edfa87bbc.jpg

 

Link to comment
2 hours ago, donttouchmethere said:

Thank You!

Makes my game much more immers.... devious!

Happy to hear that it works ?. If you find any situations where it causes problems with other mods, please tell me here. I am trying to compile a list of possible conflicts.

Link to comment
4 hours ago, Kharos said:

Happy to hear that it works ?. If you find any situations where it causes problems with other mods, please tell me here. I am trying to compile a list of possible conflicts.

Will do!

Thanks to my devious setup I come around a lot (reluctantly) ^^

Your patch was added to a 140 hour game and at the end of the LO atm (below bashed patch).

It feels so much better to have a game where NPCs are properly bound! ?

 

I also have still this one installed:

Optional Patch: DDi sandbox patch by @asdfasdf883 Devious Devices - Integration NPC Sandbox Patch.esp.

Allows NPCs in heavy bondage to idle or follow other NPCs. Drawback: heavy bondage idle failes to work on some NPC on cell load. Most useful in combination with Hydragons Slavegirls & Device Replacer.

 

Not sure if that is still needed now. Guess it is, because your patch refreshes DD idles if I understand it correct and doesn't manipulate the sandbox behavior like DDi does without patch.

Link to comment
2 hours ago, donttouchmethere said:

Not sure if that is still needed now. Guess it is, because you patch refreshes DD idles if I understand it correct and doesn't manipulate the sandbox behavior like DDi does without patch.

My code is not modifying the AI outside of combat (in other words: I am adding combat override packages, but not other packages). I am also not disabling the existing code in DDi that does add packages outside of combat. So most probably this is still required in your case, yes.

Link to comment
Version 0.1 Beta 3
- Fix: Factions for combat packages were not cleaned up when NPCs were removed from the reference alias.

I should have enabled papyrus logging from the beginning ?.

Anyway, should not really cause issues as the factions are only used then the NPCs are in the reference alias, but still better to properly clean up (and not cause papyrus errors).

Link to comment
2 minutes ago, Kharos said:

Version 0.1 Beta 3
- Fix: Factions for combat packages were not cleaned up when NPCs were removed from the reference alias.

I should have enabled papyrus logging from the beginning ?.

Anyway, should not really cause issues as the factions are only used then the NPCs are in the reference alias, but still better to properly clean up (and not cause papyrus errors).

 

If I already have Beta 2 installed in a game, is it safe to overwrite it with Beta 3 before I reload the last savegame?

Link to comment
23 minutes ago, Corsec said:

If I already have Beta 2 installed in a game, is it safe to overwrite it with Beta 3 before I reload the last savegame?

 

Yeah, you can update, I only changed a single script to fix my error (and tested that it works in an existing savegame with beta 2).

Link to comment
15 hours ago, surothedeath said:

what do it mean with sandbox?

NPC Sandbox: Basically the area in which NPC wandering around and idle.

Means in this case the NPC are wandering and searching for idle spots on their own. E.g. NPC wander from town to town, visit a pub, go shopping, use workstations, follow other NPCs, doing their daily routines (out at day/home at night), patrolling the area ...

 

DD NPC Sandbox: NPCs in devious devices can only wander in a limited radius (DDi 4.3) and therefore cannot follow other NPC over longer distances.
The DD Sandbox patch disables this limitation and NPC in devious devices can follow other NPC over longer distances.
This is important for HSG slaves, because they follow their master and wander over long distances. Without the patch the slaves NPC will get stuck while the master NPC continues to wander.

 

Link to comment

Just saw the first DCL "bound girl" NPC after I added Beta 3.

They show device idles too now.

This is pretty amazing! Now that all NPC in devious devices get the DD idles, my game looks a loooot less glitched!

 

If on cell change beta 3 updates the DDs on NPC it even looks like they try to struggle against their bondage faith ?

 

Loading times are not higher, but after the cell change to a cell with many DD NPC there might be a bit lag until all DDs are updated.

I must add that my game already is full of polling mods so this isn't surprising.

 

I'm really happy with what you created and it rises DDi/DCL quality by 100% ?

I couldn't find any NPC so far that could resist your DD NPC support.

 

In my game NPC in DDs are added by DCL, HSG + Corsec patch, Corsec patches for various mods.

All show the correct bondage idles now.

 

EDIT:

Didn't see any bad effects so far, like CTD in crowded areas.

No conflict with PetCollar. Accidentally added a petcollar via MCM to a NPC that was already with a DD collar equipped.

Instead of clusterfuck your mod just refreshed the already worn collar and prevented the equip of a petcollar (that isn't needed anyways, because petcollar effect can be connected to any type of DD collar). This also mean that it might get complicated to exchange devices on NPC.

 

Now it gets really interesting to use any spells/staffs/weapons that add DDs on NPC during battle ⚔️

Link to comment

Great work. Awesome to see those issues fixed.

 

One of my personal experiences is that if you give an NPC a device that has some special scripting on it, it may end up being extremely hard to remove.

 

e.g. if you put a maiden's shield on a follower, it can't be removed.

 

The real problem is that if you give the device to a follower, she puts it on immediately, even if she was simply meant to carry it.

To get her out of that belt requires hacking the StorageUtil properties on the NPC.

 

 

Is there some fix that can be done to stop followers (as opposed to other NPCs) wearing DDs just because they are given them?

e.g. check the current follower faction.

Binding a follower should only be done by mods, using dialogs etc. unless perhaps that follower is a zap slave or similar.

Link to comment
21 hours ago, CovertDemon said:

Would there be plans for making this mod able to prevent shout-capable NPCs from using their shouts in combat%?

I have not yet tested the behaviour of shout capable NPCs. If you have, please tell me what you are seeing.

Link to comment
8 hours ago, Lupine00 said:

The real problem is that if you give the device to a follower, she puts it on immediately, even if she was simply meant to carry it.

To get her out of that belt requires hacking the StorageUtil properties on the NPC.

This is standard behaviour of Devious Devices. If you give a device to a NPC (container menu is open), Devious Devices assumes that you as a player want to equip the device on the NPC [1]. Getting them out should be possible by just taking the device back, as long as you are not bound yourself, you have the key, and removal is not prevented by another device (e.g. belt keeping in plugs) [2].

 

[1]: https://github.com/DeviousDevices/DDi/blob/master/00 Core/scripts/Source/zadEquipScript.psc#L348
[2]: https://github.com/DeviousDevices/DDi/blob/master/00 Core/scripts/Source/zadEquipScript.psc#L400

Link to comment
11 hours ago, Lupine00 said:

The real problem is that if you give the device to a follower, she puts it on immediately, even if she was simply meant to carry it.

You could use Devious Lore to prevent this if you ask your follower to just carry those devices.

Unless you mean you do it already like that and now your followers start to wear those devices.

 

With DEC, followers can find devices anytime and if the PC denies them to equip the devices onto the PC, they will carry those in their inventory without wearing them even if better NPC support is installed.

Link to comment
11 hours ago, donttouchmethere said:

You could use Devious Lore to prevent this if you ask your follower to just carry those devices.

There are two problems.

 

1) Not everyone has Devious Lore

2) Even if you do, it's easy to mis-click just once and accidentally equip the device on the follower unless you prepared in advance.

Link to comment
44 minutes ago, Lupine00 said:

There are two problems.

 

1) Not everyone has Devious Lore

2) Even if you do, it's easy to mis-click just once and accidentally equip the device on the follower unless you prepared in advance.

Isn't that true for all mods/Setups?

Missing something and mis-click?

DDe is nice to remove DDs from NPCs too!

 

But I guess you wanted to make a proposal what to add to the "better NPC support"?

Would be nice if DDi would ask every time you trade a device if it should be added to the NPC or not.

But wouldn't that also happen if a mod adds devices to any NPC in the area?

Like you can see if you have a container open and DCL adds devices to any NPC in the area at the same time.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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