Date: 03-16-17 20:42
So it's come to my attention a bug in my mod that I'm not sure how to fix.
I have some items that give stats, for example you put on an amulet that gives + 2 dexterity. If you remove the amulet, it removes 2 dexterity. This is all well and good, until you save the game and quit and restart. What seems to be happening is on a load of a save game, the +2 is being applied again.
So, if you start with base 20 dexterity, put on the amulet, you get 22, if you take it off, you're back to 20. No harm, no foul. This is being triggered by using events readied and unreadied on the object usecode.
If you save the game with 22 dex (20 base + 2 from amulet), you save with 22 dexterity. The next time you load the game, you start with 24 dexterity. (22 from the save, +2 more from the amulet).
I suspect what's happening is when you enter back into the game world, it's re-running the readied usecode, which is in turn causing it to keep going up and up every time you exit.
Does anyone have any thoughts about how to get around this? Is it even possible?
Along the same lines, is there a way to determine the NPC that has the item equipped? Currently I have it hard coded so it only ever works on the Avatar, but it seems like it would be a good idea to work on any equipped NPC's in the party however I can't seem to locate a suitable intrinsic that would return a reference I could use to get the NPC number of the equipped user.