v2.2 Easiest way to react on changed equippment items?
Hey there,
With update 2.2 the function "PlayOnEquippedAnimation" will be removed. This one helped me a lot to update the marker textures at equipment slots, when the equipment got changed in the past :-( So what is the easiest way with the next update 2.2 to react on equipped/unequipped items? I need some event or PreHook callback function to run as any item gets -equipped -unequipped I know there are the functions EquipItem and UnequipItem, but they won't give me all the info I need. I need either the control name of the character control where the item get's equipped/got unequipped, or I need the slotIndex where it gets equipped/got unequipped. And I need this to be executed as I use -drag&drop -double click -right-click/context menu -> "Equip/Unequip" EquipItem will only send the slotIndex of the item from your inventory, which you want to equip. And then it calls the function to get the according free slot where this item could be equipped. Example: double click, drag&drop or right-click and choose "Equip" on a helmet in your inventory will try to equip the helm in the helmet slot. But the function EquipItem will only use the bagId of BAG_BACKPACK and the slotIndex of the helmet in your inventory. Is there any easier way to get the slotIndex or control name where this helmet will "be equipped", or do I need to "search the possible slot(s)" by help of the itemType I want to equip in a callback function of a PreHook to function "EquipItem"? And the same the other way around if you unequip an item. |
EVENT_INVENTORY_SINGLE_SLOT_UPDATE (integer eventCode, integer bagId, integer slotIndex, boolean isNewItem, integer itemSoundCategory, integer updateReason)
check that bagId == BAG_WORN before anything else? not sure if it informs of a newly emptied slot though. edit : inventory item border is also using this : EVENT_ACTIVE_WEAPON_PAIR_CHANGED might be useful. |
I found one other way but I don't really like it:
use the event EVENT_INVENTORY_SINGLE_SLOT_UPDATE and check for bagId == BAG_WORN and updateReason == INVENTORY_UPDATE_REASON_DEFAULT Then use the slotIndex to get the control name from the equipment controls and update the markers. Edit: Haha, thanks Wandamey! Just posted in the same time^^ Tested the unequipping of items: The EVENT_INVENTORY_SINGLE_SLOT_UPDATE will not be called for BAG_WORN then. So you need to PreHook UnequipItem tpoo for those as it seems |
you can keep the count of the number of equipped items you have and if it goes down make a little check up of the paper doll, and a differential diagnosis. Huuuu, i'm mistaken with doctor House sorry.
|
This will notify you when the slot changes with the correct slotId for the slot the item is equipped to or unequipped from.
Lua Code:
|
Thanks circonian
|
If all your wanting is the slot control then try this:
Lua Code:
Edit: Ooops, I should have tested it. If the user does a normal equip/unequip, double click, or drag to equip it fires once. But if they drag the item out of the slot (like to unequip by dragging to the inventory) it fires on the drag & again whenever they drop the item. So that one might not be useful. |
Quote:
Randactyl should take a look in here too ... got floating locks around my doll now :D, but it's refreshed on bag reopening in his case. |
Quote:
Lua Code:
|
Yeah, it was all about the markers next to the equipment slots :-)
I had played around with the WornSlotUpdate callback too (checked the esoui 2.2 code from Ayantr and found it in there), but it didn't alwas/or did fire too ofter sometimes. Upon opening of the inventory I'll update all slots too (same as ItemSaver probably does), but I wanted to update the slots properly as the items get equipped/unequipped already. @Wandamey This is woot. I've tried it for unequipped items and it never reached the part of the source code somehow. Using the same event callback function etc. it just seemd to fire with another update reason or not the BAG_WORN (only BAG_BACKPACK). I'll try it again then, thanks for the info. |
Quote:
no, seriously, check that you don't have something else running at the same time, seems weird that neither circonian's/ayantir's method or this one work exactly as intended. |
All three methods will work: EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnSharedSingleSlotUpdate, & OnWornSlotUpdate.
I'm not sure if you tested it recently or if your comments about it not working properly were based on tests you did in the past, because I can tell you that in the past OnSharedSingleSlotUpdate use to NOT fire for unequipping items and OnWornSlotUpdate use to NOT fire for equipping items. But they changed the way it works and now both fire whether your equipping or unequipping via any method: double-click, drag & drop, or using the context menu. You are correct that OnWornSlotUpdate does fire twice if you drag an item out of an equipment slot & drop it into the inventory slot. It fires once for the drag out of the equipment slot & once for the drop into the inventory slot. Any other method (including dragging items into the slot) only fires it once. However, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnWornSlotUpdate also fire for durability Updates. For EVENT_INVENTORY_SINGLE_SLOT_UPDATE you can't use the updateReason to filter it out because, for example, when you repair an item (and at other times) it fires both reasons INVENTORY_UPDATE_REASON_DURABILITY_CHANGE & INVENTORY_UPDATE_REASON_DEFAULT, but this one does not fire for durability updates, only when the item in the slot changes. Lua Code:
|
I've tested it before the update to 2.2 and I did not test it on PTS (as the download was too slow to finish in time before the update to 2.2 was live :( ).
I need to find the time to test it on 2.2 live now again and I guess I'll change to the SHARED_INVENTORY callback function then. As I'm currently using the normal EVENT_INVENTORY_SINGLE_SLOT_UPDATE callback function to check new looted items, if they apply to some filters and should get a marker symbol then (like marking a new looted intricate item with the intricate texture marker): Could I replace the event callback function with the same new callback function of SHARED_INVENTORY "SingleSlotInventoryUpdate" too in the future, to do these intricate checks etc.? |
Haven't looked too much into it. EVENT_INVENTORY_SINGLE_SLOT_UPDATE seems the most appropriate, since you can filter for BAG_WORN and INVENTORY_UPDATE_REASON_DEFAULT. "SingleSlotInventoryUpdate" doesn't receive updateReason.
As for non-worn inventories, your markers are display stuff, right? If so, you don't need to run code when a slot changes, but only when it's shown. I'd try hooking ZO_PlayerInventorySlot_SetupSlot -- or ZO_Inventory_SetupSlot, or ZO_ItemSlot_SetupSlot, if you want it in other "inventories" like mail, decon etc. but there you'll probably have to check slotType. |
I'am using this for CraftStore:
Lua Code:
This functions are instantly called on every item change. You can also use 'SlotUpdated'. |
Thanks merlight and @AlphaLemming.
I hope I'll get to test the different stuff after the weekend (birthday time :D) |
All times are GMT -6. The time now is 09:14 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI