Skip to content

Commit

Permalink
Validation fixes / setup swap improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JNSlevin committed May 14, 2024
1 parent 6963511 commit 31a6b91
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 40 deletions.
45 changes: 25 additions & 20 deletions src/WizardsWardrobe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -437,20 +441,16 @@ 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
--? We cant event check if the user is heavy attacking, so we cant even warn the user about it
--? 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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/WizardsWardrobe.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
47 changes: 31 additions & 16 deletions src/WizardsWardrobeSetupValidation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 ) ) ]]
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/WizardsWardrobeUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/modules/WizardsWardrobePrebuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function WWP.CreatePrebuffWindow()
end

if progression:IsChainingAbility() then
abilityId = GetEffectiveAbilityIdForAbilityOnHotbar( abilityId, hotbar )
abilityId = GetEffectiveAbilityIdForAbilityOnHotbar( abilityId, GetActiveHotbarCategory() )
end

ClearCursor()
Expand Down

0 comments on commit 31a6b91

Please sign in to comment.