Interkarma / daggerfall-unity

Open source recreation of Daggerfall in the Unity engine
http://www.dfworkshop.net
MIT License
2.67k stars 326 forks source link

Mod API: let mods change which static NPCs spawn in and around buildings #2669

Open KABoissonneault opened 1 month ago

KABoissonneault commented 1 month ago

Currently, mods like Roleplay & Realism and Flat Replacer change static NPCs by swapping out their texture and portrait after the NPC is spawned. This causes issues with mods using custom prefabs for specific billboard records (ex: Animated People).

Ex: DFU sees an NPC with archive 334 and record 3 (334_3). DFU checks if a mod (ex: Animated People) has a prefab for 334_3, and spawns that. Another mod (ex: R&R or Flat Replacer) goes and decides that 334_3 should be a 334_6 instead.

The result is that we have an NPC that looks like a 334_6, but has the properties of a 334_3. Any operation that the prefab tries to do will go with the assumption that it's acting on 334_3, but that wouldn't be true anymore.

Best case here, the mod with the prefab would just win and reassign 334_3; worst case we get a weird monster result. Ideally R&R/Flat Replacer should be able change what NPCs get spawned, and then for DFU to spawn the correct 334_6 prefab.

So, we need a new way for mods to change what NPCs get spawned, rather than having them modify the NPC after.