From 31a6b918b6acc2d2762bef9e2b3c463fb7be8ccc Mon Sep 17 00:00:00 2001 From: JN Slevin Date: Tue, 14 May 2024 15:31:52 +0200 Subject: [PATCH] Validation fixes / setup swap improvements --- src/WizardsWardrobe.lua | 45 +++++++++++++----------- src/WizardsWardrobe.txt | 4 +-- src/WizardsWardrobeSetupValidation.lua | 47 +++++++++++++++++--------- src/WizardsWardrobeUtils.lua | 2 +- src/modules/WizardsWardrobePrebuff.lua | 2 +- 5 files changed, 60 insertions(+), 40 deletions(-) diff --git a/src/WizardsWardrobe.lua b/src/WizardsWardrobe.lua index f942baf..9b6adff 100644 --- a/src/WizardsWardrobe.lua +++ b/src/WizardsWardrobe.lua @@ -7,7 +7,7 @@ WW.name = "WizardsWardrobe" WW.simpleName = "Wizard's Wardrobe" WW.displayName = "|c18bed8W|c26c2d1i|c35c6c9z|c43cac2a|c52cebar|c60d1b3d|c6fd5ab'|c7dd9a4s|c8cdd9d |c9ae195W|ca8e58ea|cb7e986r|cc5ed7fd|cd4f077r|ce2f470o|cf1f868b|cfffc61e|r" -WW.version = "1.18.0" +WW.version = "1.18.1" WW.zones = {} WW.currentIndex = 0 WW.IsHeavyAttacking = false @@ -210,13 +210,12 @@ function WW.LoadSkills( setup ) end if not WW.settings.unequipEmpty then if (abilityId == 0 or abilityId == nil) then - logger:Info( "SlotSkill %d %d %d - no skill", hotbarCategory, slotIndex, abilityId ) + logger:Debug( "SlotSkill %d %d %d - no skill", hotbarCategory, slotIndex, abilityId ) return false - else - logger:Warn( "SlotSkill %d %d %d", hotbarCategory, slotIndex, abilityId ) end end - logger:Debug( "SlotSkill %d %d %d", hotbarCategory, slotIndex, abilityId ) + logger:Debug( "SlotSkill %s %s %s (%s)", tostring( hotbarCategory ), tostring( slotIndex ), tostring( abilityId ), + GetAbilityName( abilityId ) ) skillTask:WaitUntil( function() @@ -272,16 +271,17 @@ end function WW.SlotSkill( hotbarCategory, slotIndex, abilityId ) local hotbarData = ACTION_BAR_ASSIGNMENT_MANAGER:GetHotbar( hotbarCategory ) - logger:Verbose( "SlotSkill %d %d %d", hotbarCategory, slotIndex, abilityId ) + logger:Verbose( "SlotSkill %s %s %s (%s) ", tostring( hotbarCategory ), tostring( slotIndex ), tostring( abilityId ), + GetAbilityName( abilityId ) ) -- if using cryptcanon dont slot skill, since cryptcanon does it on its own - if not abilityId then return end + --if not abilityId then return end if abilityId == 195031 then return end if WW.HasCryptCanon() and slotIndex == 8 then return end - if WW.settings.unequipEmpty and abilityId == 0 then + if WW.settings.unequipEmpty and (abilityId == 0 or abilityId == nil) then hotbarData:ClearSlot( slotIndex ) return end @@ -365,9 +365,10 @@ end local runningGearTasks = {} local gearMoveTask = async:Create( WW.name .. "GearMoveTask" ) -local function updateItemLocation( item ) +local function updateItemLocation( index, item ) + local freeSlotMap = WW.GetFreeSlots( BAG_BACKPACK ) if not item.destSlot then - item.destSlot = FindFirstEmptySlotInBag( item.destBag ) + item.destSlot = freeSlotMap[ index ] end if not item.sourceSlot or item.workaround then @@ -383,6 +384,9 @@ local function moveItemToDestination( item ) if item.destBag == BAG_WORN then EquipItem( item.sourceBag, item.sourceSlot, item.destSlot ) else + local isSlotEmpty = GetItemId( item.destBag, item.destSlot ) == 0 + item.destSlot = isSlotEmpty and item.destSlot or FindFirstEmptySlotInBag( item.destBag ) + CallSecureProtected( "RequestMoveItem", item.sourceBag, item.sourceSlot, item.destBag, item.destSlot, 1 ) if WW.IsMythic( item.sourceBag, item.sourceSlot ) then gearMoveTask:Suspend() @@ -437,11 +441,7 @@ function WW.MoveItems( itemTaskList, areAllItemsInInventory, isChangingWeapons ) TogglePlayerWield() end end ):WaitUntil( function() - logger:Info( "TimeStamp = %d, GetTimeStamp = %d, bool: %s", timeStamp, GetTimeStamp(), - tostring( GetTimeStamp() > (timeStamp + 5000) ) ) - - - if GetTimeStamp() > timeStamp + 5000 and not ArePlayerWeaponsSheathed() then + if GetTimeStamp() > timeStamp + 5000 and not ArePlayerWeaponsSheathed() and isChangingWeapons then TogglePlayerWield() end --? If the user is heavy attacking, the setup will not load, and the user will have to do it manually which is horrible but there is no way to fix it @@ -449,8 +449,8 @@ function WW.MoveItems( itemTaskList, areAllItemsInInventory, isChangingWeapons ) --? The event is only a bandaid fix which isnt ideal but for now it works........... --! the above check is only performed if it bugs out and nothing happened after 5 seconds return ArePlayerWeaponsSheathed() or not isChangingWeapons - end ):For( ipairs( itemTaskList ) ):Do( function( _, item ) - updateItemLocation( item ) + end ):For( ipairs( itemTaskList ) ):Do( function( index, item ) + updateItemLocation( index, item ) if not item.sourceSlot or not item.destSlot then return end @@ -470,12 +470,15 @@ function WW.MoveItems( itemTaskList, areAllItemsInInventory, isChangingWeapons ) end ):WaitUntil( function() return ArePlayerWeaponsSheathed() or not isChangingWeapons end ):Then( function() - logger:Debug( "Trying to move %s from %d:%d to %d:%d (%s)", + logger:Debug( "Trying to move %s from %d:%d to %d:%d (%s) [%d]", GetItemLink( item.sourceBag, item.sourceSlot, LINK_STYLE_DEFAULT ), item.sourceBag, item.sourceSlot, item.destBag, - item.destSlot, GetString( "SI_EQUIPSLOT", item.destSlot ) ) + item.destSlot, GetString( "SI_EQUIPSLOT", item.sourceSlot ), #itemTaskList ) moveItemToDestination( item ) + --[[ gearMoveTask:Delay( 500, function() + gearMoveTask:Resume() + end ) ]] end ) end ):Then( function() if not areAllItemsInInventory then @@ -514,6 +517,7 @@ function WW.LoadGear( setup ) WW.Log( GetString( WW_MSG_FULLINV ), WW.LOGTYPES.INFO ) end logger:Warn( "LoadGear " .. setup:GetName() ) + local freeSlotMap = WW.GetFreeSlots( BAG_BACKPACK ) local itemTaskList = {} local inventoryList = WW.GetItemLocation() local areAllItemsInInventory = true @@ -536,7 +540,7 @@ function WW.LoadGear( setup ) end end - for _, gearSlot in ipairs( WW.GEARSLOTS ) do + for index, gearSlot in ipairs( WW.GEARSLOTS ) do local gear = setup:GetGearInSlot( gearSlot ) if gear then @@ -611,6 +615,7 @@ function WW.LoadGear( setup ) else logger:Warn( "Not all items in inventory" ) end + WW.MoveItems( itemTaskList, areAllItemsInInventory, isChangingWeapons ) return true, areAllItemsInInventory, isChangingWeapons --end diff --git a/src/WizardsWardrobe.txt b/src/WizardsWardrobe.txt index e2f4eb1..054586c 100644 --- a/src/WizardsWardrobe.txt +++ b/src/WizardsWardrobe.txt @@ -1,7 +1,7 @@ ## Title: Wizard's Wardrobe ## Author: ownedbynico, |c268074JN_Slevin|r -## Version: 1.18.0 -## AddOnVersion: 1180 +## Version: 1.18.1 +## AddOnVersion: 1181 ## Description: Throw all your setups into the wardrobe and let the wizard equip them exactly when you need it. ## APIVersion: 101041 101042 ## DependsOn: LibAddonMenu-2.0>=35 LibChatMessage>=105 LibDebugLogger>=105 LibAsync>=20304 diff --git a/src/WizardsWardrobeSetupValidation.lua b/src/WizardsWardrobeSetupValidation.lua index 4484209..6a3a5e4 100644 --- a/src/WizardsWardrobeSetupValidation.lua +++ b/src/WizardsWardrobeSetupValidation.lua @@ -146,6 +146,10 @@ function WWV.DidSetupSwapCorrectly( workAround ) else success = false end + elseif WW.settings.unequipEmpty and equippedLink == "" then + success = true + elseif not WW.settings.unequipEmpty then + success = true else failedT[ # failedT + 1 ] = GetString( "SI_EQUIPSLOT", equipSlot ) logger:Verbose( "Equipped %s // saved %s", equippedLink, savedLink ) @@ -214,31 +218,37 @@ function WWV.DidSetupSwapCorrectly( workAround ) equippedSkill = slotData.abilityId else if slotData == ZO_EMPTY_SLOTTABLE_ACTION then - --[[ logger:Debug( "slotData.abilityId =" .. tostring( slotData.abilityId ) ) - if WW.settings.unequipEmpty then - skillSuccess = true - else - if savedBaseId == 0 then - skillSuccess = true - else - failedT[ # failedT + 1 ] = GetAbilityName( savedSkill ) - skillSuccess = false - end - end ]] + else equippedSkill = slotData:GetEffectiveAbilityId() end end end - if equippedSkill ~= 0 and equippedSkill ~= 195031 then - equippedBaseId = WW.GetBaseAbilityId( equippedSkill ) + local areSkillsEqual = WW.AreSkillsEqual( equippedSkill, savedSkill ) + if areSkillsEqual then + skillSuccess = true + else + if WW.settings.unequipEmpty then + if equippedSkill == 0 then + skillSuccess = true + else + failedT[ # failedT + 1 ] = GetAbilityName( savedSkill ) + skillSuccess = false + logger:Warn( "Skills did not swap correctly: %s // %s (empty skill)", + GetAbilityName( equippedSkill ), + GetAbilityName( savedSkill ) ) + end + end end - if savedSkill ~= 195031 then + --[[ if equippedSkill ~= 0 and equippedSkill ~= 195031 then equippedBaseId = WW.GetBaseAbilityId( equippedSkill ) end + if savedSkill ~= 195031 then + savedBaseId = WW.GetBaseAbilityId( savedSkill ) + end ]] - logger:Verbose( "SavedBaseId = %d, name= %s, equippedBaseId = %d, name = %s", savedBaseId, - GetAbilityName( savedBaseId ), equippedBaseId, + logger:Verbose( "SavedBaseId = %s, name= %s, equippedBaseId = %s, name = %s", tostring( savedBaseId ), + GetAbilityName( savedBaseId ), tostring( equippedBaseId ), GetAbilityName( equippedBaseId ) ) --[[ logger:Debug( "SavedSkill = %s, equippedSkill = %s", GetAbilityName( savedSkill ), GetAbilityName( equippedSkill ) ) ]] @@ -292,6 +302,11 @@ function WWV.DidSetupSwapCorrectly( workAround ) logger:Warn( "Skills did not swap correctly" ) end end + if check then + logger:Debug( "Gear swapped correctly" ) + else + logger:Warn( "Gear did not swap correctly" ) + end if not isGearPresent then check = true end if not skillSuccess then check = false end return check, failedT diff --git a/src/WizardsWardrobeUtils.lua b/src/WizardsWardrobeUtils.lua index 6f952f9..3fadf90 100644 --- a/src/WizardsWardrobeUtils.lua +++ b/src/WizardsWardrobeUtils.lua @@ -30,7 +30,7 @@ function WW.GetSlotBoundAbilityId( slotIndex, hotbarIndex ) local actionType = GetSlotType( slotIndex, hotbarIndex ) if actionType == ACTION_TYPE_CRAFTED_ABILITY then - slottedId = GetAbilityIdForCraftedAbilityId( id ) + slottedId = GetAbilityIdForCraftedAbilityId( slottedId ) end return slottedId diff --git a/src/modules/WizardsWardrobePrebuff.lua b/src/modules/WizardsWardrobePrebuff.lua index 053b016..ad5fe7d 100644 --- a/src/modules/WizardsWardrobePrebuff.lua +++ b/src/modules/WizardsWardrobePrebuff.lua @@ -261,7 +261,7 @@ function WWP.CreatePrebuffWindow() end if progression:IsChainingAbility() then - abilityId = GetEffectiveAbilityIdForAbilityOnHotbar( abilityId, hotbar ) + abilityId = GetEffectiveAbilityIdForAbilityOnHotbar( abilityId, GetActiveHotbarCategory() ) end ClearCursor()