drithius Posted March 21, 2015 Share Posted March 21, 2015 I've been looking to patch Dragbody's CNR RioT Scutum (shield) to include DR and -1 agility. However, I'm having a couple issues: ref rSelf Begin OnEquip set rSelf to GetContainer rSelf.modav DamageThreshold 10 rSelf.modav Agility -1 End Begin OnUnEquip set rSelf to GetContainer rSelf.modav DamageThreshold -10 rSelf.modav Agility 1 End The above has two problems that I'm aware of:1. if a person already has a shield equipped when starting up the patch, they'll be at a permanent stat deficit.2. OnUnEquip doesn't work for an item getting dropped while equipped :( Any pointers? Link to comment Share on other sites More sharing options...
claustromaniac Posted March 21, 2015 Share Posted March 21, 2015 How about something like this... ref rSelf int iStatus Begin OnEquip set rSelf to GetContainer rSelf.modav DamageThreshold 10 rSelf.modav Agility -1 set iStatus to 1 End Begin OnUnEquip if iStatus set rSelf to GetContainer rSelf.modav DamageThreshold -10 rSelf.modav Agility 1 set iStatus to 0 endif End Begin OnDrop if iStatus && rSelf != 0 rSelf.modav DamageThreshold -10 rSelf.modav Agility 1 set iStatus to 0 endif end Link to comment Share on other sites More sharing options...
drithius Posted March 21, 2015 Author Share Posted March 21, 2015 (edited) Hey Claustro. That's really elegant logic and it should work... ...but I've tried all sorts of things and that final IF statement refuses to let anything through. Even if I break it up into two separate IF statements, the characters stats don't revert back to normal when Equipping --> Dropping. I don't see why it's not working! Edited March 21, 2015 by drithius Link to comment Share on other sites More sharing options...
claustromaniac Posted March 21, 2015 Share Posted March 21, 2015 (edited) Hey Claustro. That's really elegant logic and it should work... ...but I've tried all sorts of things and that final IF statement refuses to let anything through. Even if I break it up into two separate IF statements, the characters stats don't revert back to normal when Equipping --> Dropping. I don't see why it's not working!That's really odd :confused:. Hmm... The script must be crashing at some point.. you could try this instead: ref rSelf int iStatus Begin OnEquip set rSelf to GetContainer if rSelf != 0 rSelf.modav DamageThreshold 10 rSelf.modav Agility -1 set iStatus to 1 endif End Begin OnUnEquip if iStatus && rSelf != 0 rSelf.modav DamageThreshold -10 rSelf.modav Agility 1 set iStatus to 0 endif End Begin OnDrop if iStatus && rSelf != 0 rSelf.modav DamageThreshold -10 rSelf.modav Agility 1 set iStatus to 0 endif end Also, if you don't mind your mod requiring NVSE you could use IsFormValid and/or IsReference to ensure that the variable is not invalid. If none of that works there's probably something else messing with the item externally. Edited March 21, 2015 by claustromaniac Link to comment Share on other sites More sharing options...
drithius Posted March 21, 2015 Author Share Posted March 21, 2015 That did it! Thank you, thank you! The added error checking saved the day - I'm just really confused as to why/how since the OnDrop block is identical. So strange. Thank you again, I was really at my wit's end with this. Link to comment Share on other sites More sharing options...
claustromaniac Posted March 21, 2015 Share Posted March 21, 2015 That did it! Thank you, thank you! The added error checking saved the day - I'm just really confused as to why/how since the OnDrop block is identical. So strange. Thank you again, I was really at my wit's end with this. Very glad :cool: Since I was quite sure the script should be working, I just figured the reference variable was - for some alien reason - not storing a valid reference at some point when the script tried to call those ModAV functions in the OnEquip and/or the OnUnequip block. That caused the script to crash, thus preventing the OnDrop block from running altogether. Link to comment Share on other sites More sharing options...
Recommended Posts