It took me an hour to figure it out, but I managed to at least fix the crash that I could reproduce.
Now that was the function that caused the crash. Looks alright.
It is used to spawn the dog. There is a spawn delay so the dog does not spawn on loading in, and a way to disable the item for when the player is next to a stash.
The way the dog gets spawned in is through an ambush proxy, this way there is a placement radius so the dog does not spawn right below the player. Now the dog is a bit special for some reason, for example you can not get rid of him, I tried lots of stuff, but one can simply not kill the dog! Probably has something to do with its animation and mesh.
This means I can not spawn the dog directly through the proxy like I can do with other friendly NPCs, e.g. the merchant. Instead I spawn an invisible creature that instantly dies. When this creature gets added to the world, it calls the actual function to spawn the dog with its effect on its coordinates.
Even without any attached function on the creature, the game crashes when switching characters. When I cut the proxy out, the crash is gone. It makes no sense for me why this could lead to a game crash. I just assumed that it was my shitty scripting.
[Crash Fix | Lightweight Mod compatibility for DoM]
Put this into the patch folder, overwrite everything and then run the correct “Update script.bat”.
This fixes the crash that I personally could reproduce (switching between multiple characters), so I can not guarantee that this also fixes other potential crashes. I will update the standard mod only if this actually fixes everything.