Scripting OnEquipped vs Favorites menu glitch?

Post » Wed Jun 20, 2012 4:14 am

apparently using the favorites menu to switch between weapons bypasses the OnEquipped event, even though OnUnequipped will pass the first time.


for example:

Event OnEquipped(actor akActor)debug.messagebox("equipped")EndEventEvent OnUnequipped(actor akActor)debug.messagebox("unequipped")EndEvent


the code is attached to a weapon.

then in-game, add this weapon to the favorites menu.

equipping this weapon either by conventional inventory menu or favorites menu will fire the "equipped" message

swapping to a bow in the favorites menu or inventory menu will fire "unequipped" message.


however, unequipping the bow in the favorites menu will force-re-equip the weapon wihtout firing the "equipped" message even though this works if done so manually in the inventory menu. there is something about the favorites hotkey that glitches the OnEquipped part of the script, but OnUnequipped is unaffected.

it's as if the OnEquipped part of the code stays active continuously even after firing an OnUnequipped event, since technically the weapon stays "equipped" in the game's cache when switching to a different weapon (hence how it remembers which weapon was previously equipped when unequipping the bow)


i'm wondering if there is either a way to fix this glitch in the hotkey menu, or script the event with something more specific, rather than OnEquipped to check if the weapon is actually being equipped again? or if there is a way to unequip the weapon completely from the hotkey cache so that you have to manually reequip the weapon when unequipping a bow or whatever other weapon force-unequips it?


btw, this glitch even breaks vanilla weapons such as Silver Sword when using hotkey favorites to equip weapons, but i guess no one cared or noticed since i have never heard of this issue until now.
User avatar
Eve(G)
 
Posts: 3546
Joined: Tue Oct 23, 2007 11:45 am

Post » Wed Jun 20, 2012 7:38 am

Ouch! thanks for the heads up.
I have a utility mod in the works called "Inventory and Weight."
One of its functions is to keep track of the player's inventory so that modders can step through them.
Another function is to keep track of each item's weight - so that modders can query the weight of an item.
Another function is to keep track of euipped items - so that modders can do "getEquippedBoots ()" or "getEquippedJeweleries ()"

I'll allow for this bug.
I won't be able to fire the "OnEquipped ()" event to the listeners.
But at least, my internal data will be correct.
Am currenlty play-testing it. It should be released this weekend or early next week.

I already have two other mods working off this utility, so I know that it works:
(Encumbering loot armour and weapons - armour and weapons that are not equipped penalises the player 3 x those item's weight
and Eat and sleep - food weight = satiation gained from eating food)

Of course, SKSE will make this obsolete.
I've not been on the last couple of days and I've not been active in their thread - so I'm not sure when they're planning to release SKSE with the functions above.
User avatar
jesse villaneda
 
Posts: 3359
Joined: Wed Aug 08, 2007 1:37 pm

Post » Wed Jun 20, 2012 7:35 am

Have a failsafe script run alongside your main script that checks for OnUnequip, waits for like .2 then checks equipped item and force unequip/equip. It doesn't look like there is anyway to force equip the left hand though, which would be a problem.
User avatar
Louise Lowe
 
Posts: 3262
Joined: Fri Jul 28, 2006 9:08 am


Return to V - Skyrim