Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Angleur.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ local function checkMounted()
end
local firstCast = true
local fishingSpellTable = AngleurRetail_FishingSpellTable

local function updateFishingChannelDuration()
Angleur_UpdateFishingChannelDurationFromUnit("player")
end

function Angleur_LogicVariableHandler(self, event, unit, ...)
local arg4, arg5 = ...
-- Needed for when player zones into dungeon while mounted. Zone changes but no reload, and mount journal change doesn"t register
Expand Down Expand Up @@ -163,6 +168,7 @@ function Angleur_LogicVariableHandler(self, event, unit, ...)
elseif event == "UNIT_SPELLCAST_CHANNEL_START" and not issecretvalue(unit) and unit == "player" then
if issecretvalue(arg5) then return end
if not CheckTable(fishingSpellTable, arg5) then return end
updateFishingChannelDuration()
midFishing = true
EventRegistry:TriggerEvent("Angleur_StartFishing")
Angleur_ActionHandler(Angleur)
Expand Down Expand Up @@ -550,7 +556,8 @@ local function checkConditions(self, slot, assignKey)
return false
end
end
if slot.name ~= 0 and slot.auraActive == false then
local auraBlocksReuse = Angleur_DoesExtraItemAuraBlockReuse(slot)
if slot.name ~= 0 and auraBlocksReuse == false then
if checkUsabilityItem(slot.itemID) == false then return false end
SetOverrideBindingClick_Custom(self, true, assignKey, "Angleur_ToyButton")
self.toyButton:SetAttribute("macrotext", "/cast " .. slot.name)
Expand All @@ -563,7 +570,7 @@ local function checkConditions(self, slot, assignKey)
end
if slot.macroSpellID ~= 0 and C_Spell.DoesSpellExist(slot.macroSpellID) and C_Spell.IsSpellUsable(slot.macroSpellID) then
local spellCooldown = C_Spell.GetSpellCooldown(slot.macroSpellID).duration
if spellCooldown ~= 0 or slot.auraActive == true then return false end
if spellCooldown ~= 0 or auraBlocksReuse == true then return false end
if parseMacroConditions(slot.macroBody) == true then
SetOverrideBindingClick_Custom(self, true, assignKey, "Angleur_ToyButton")
self.toyButton:SetAttribute("macrotext", slot.macroBody)
Expand Down
1 change: 1 addition & 0 deletions Angleur.toc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ angTemplates\embeds.xml

debug.lua
init.lua
items\extra_item_aura_logic.lua
Angleur.lua

toys\toys_retail.lua
Expand Down
11 changes: 9 additions & 2 deletions AngleurMists.lua
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ local function checkMounted()
return false
end
local fishingSpellTable = AngleurMoP_FishingSpellTable

local function updateFishingChannelDuration()
Angleur_UpdateFishingChannelDurationFromUnit("player")
end

function Angleur_LogicVariableHandler(self, event, unit, ...)
local arg4, arg5, arg6 = ...

Expand Down Expand Up @@ -213,6 +218,7 @@ function Angleur_LogicVariableHandler(self, event, unit, ...)
Angleur_ActionHandler(Angleur)
elseif event == "UNIT_SPELLCAST_CHANNEL_START" and unit == "player" then
if not CheckTable(fishingSpellTable, arg5) then return end
updateFishingChannelDuration()
midFishing = true
EventRegistry:TriggerEvent("Angleur_StartFishing")
if AngleurClassicConfig.softInteract.enabled == true and AngleurClassicConfig.softInteract.warningSound == true then
Expand Down Expand Up @@ -653,7 +659,8 @@ local function checkConditions(self, slot, assignKey)
return false
end
end
if slot.name ~= 0 and slot.auraActive == false then
local auraBlocksReuse = Angleur_DoesExtraItemAuraBlockReuse(slot)
if slot.name ~= 0 and auraBlocksReuse == false then
if checkUsabilityItem(slot.itemID) == false then return false end
SetOverrideBindingClick_Custom(self, true, assignKey, "Angleur_ToyButton")
self.toyButton:SetAttribute("macrotext", "/cast " .. slot.name)
Expand All @@ -666,7 +673,7 @@ local function checkConditions(self, slot, assignKey)
end
if slot.macroSpellID ~= 0 and C_Spell.DoesSpellExist(slot.macroSpellID) and IsUsableSpell(slot.macroSpellID) then
local _, spellCooldown = GetSpellCooldown(slot.macroSpellID)
if spellCooldown ~= 0 or slot.auraActive == true then return false end
if spellCooldown ~= 0 or auraBlocksReuse == true then return false end
if parseMacroConditions(slot.macroBody) == true then
SetOverrideBindingClick_Custom(self, true, assignKey, "Angleur_ToyButton")
self.toyButton:SetAttribute("macrotext", slot.macroBody)
Expand Down
11 changes: 9 additions & 2 deletions AngleurTBC.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ local function checkMounted()
return false
end
local fishingSpellTable = AngleurVanilla_FishingSpellTable

local function updateFishingChannelDuration()
Angleur_UpdateFishingChannelDurationFromUnit("player")
end

function Angleur_LogicVariableHandler(self, event, unit, ...)
local arg4, arg5, arg6 = ...
-- Needed for when player zones into dungeon while mounted. Zone changes but no reload, and mount journal change doesn"t register.
Expand Down Expand Up @@ -188,6 +193,7 @@ function Angleur_LogicVariableHandler(self, event, unit, ...)
Angleur_ActionHandler(Angleur)
elseif event == "UNIT_SPELLCAST_CHANNEL_START" and unit == "player" then
if not CheckTable(fishingSpellTable, arg5) then return end
updateFishingChannelDuration()
midFishing = true
EventRegistry:TriggerEvent("Angleur_StartFishing")
if AngleurClassicConfig.softInteract.enabled == true and AngleurClassicConfig.softInteract.warningSound == true then
Expand Down Expand Up @@ -561,7 +567,8 @@ local function checkConditions(self, slot, assignKey)
return false
end
end
if slot.name ~= 0 and slot.auraActive == false then
local auraBlocksReuse = Angleur_DoesExtraItemAuraBlockReuse(slot)
if slot.name ~= 0 and auraBlocksReuse == false then
if checkUsabilityItem(slot.itemID) == false then return false end
SetOverrideBindingClick_Custom(self, true, assignKey, "Angleur_ToyButton")
self.toyButton:SetAttribute("macrotext", "/cast " .. slot.name)
Expand All @@ -574,7 +581,7 @@ local function checkConditions(self, slot, assignKey)
end
if slot.macroSpellID ~= 0 and C_Spell.DoesSpellExist(slot.macroSpellID) and IsUsableSpell(slot.macroSpellID) then
local _, spellCooldown = GetSpellCooldown(slot.macroSpellID)
if spellCooldown ~= 0 or slot.auraActive == true then return false end
if spellCooldown ~= 0 or auraBlocksReuse == true then return false end
if parseMacroConditions(slot.macroBody) == true then
SetOverrideBindingClick_Custom(self, true, assignKey, "Angleur_ToyButton")
self.toyButton:SetAttribute("macrotext", slot.macroBody)
Expand Down
11 changes: 9 additions & 2 deletions AngleurVanilla.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ local function checkMounted()
return false
end
local fishingSpellTable = AngleurVanilla_FishingSpellTable

local function updateFishingChannelDuration()
Angleur_UpdateFishingChannelDurationFromUnit("player")
end

function Angleur_LogicVariableHandler(self, event, unit, ...)
local arg4, arg5, arg6 = ...
-- Needed for when player zones into dungeon while mounted. Zone changes but no reload, and mount journal change doesn"t register.
Expand Down Expand Up @@ -188,6 +193,7 @@ function Angleur_LogicVariableHandler(self, event, unit, ...)
Angleur_ActionHandler(Angleur)
elseif event == "UNIT_SPELLCAST_CHANNEL_START" and unit == "player" then
if not CheckTable(fishingSpellTable, arg5) then return end
updateFishingChannelDuration()
midFishing = true
EventRegistry:TriggerEvent("Angleur_StartFishing")
if AngleurClassicConfig.softInteract.enabled == true and AngleurClassicConfig.softInteract.warningSound == true then
Expand Down Expand Up @@ -560,7 +566,8 @@ local function checkConditions(self, slot, assignKey)
return false
end
end
if slot.name ~= 0 and slot.auraActive == false then
local auraBlocksReuse = Angleur_DoesExtraItemAuraBlockReuse(slot)
if slot.name ~= 0 and auraBlocksReuse == false then
if checkUsabilityItem(slot.itemID) == false then return false end
SetOverrideBindingClick_Custom(self, true, assignKey, "Angleur_ToyButton")
self.toyButton:SetAttribute("macrotext", "/cast " .. slot.name)
Expand All @@ -573,7 +580,7 @@ local function checkConditions(self, slot, assignKey)
end
if slot.macroSpellID ~= 0 and C_Spell.DoesSpellExist(slot.macroSpellID) and IsUsableSpell(slot.macroSpellID) then
local _, spellCooldown = GetSpellCooldown(slot.macroSpellID)
if spellCooldown ~= 0 or slot.auraActive == true then return false end
if spellCooldown ~= 0 or auraBlocksReuse == true then return false end
if parseMacroConditions(slot.macroBody) == true then
SetOverrideBindingClick_Custom(self, true, assignKey, "Angleur_ToyButton")
self.toyButton:SetAttribute("macrotext", slot.macroBody)
Expand Down
1 change: 1 addition & 0 deletions Angleur_Mists.toc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ angTemplates\embeds.xml

debug.lua
init.lua
items\extra_item_aura_logic.lua
AngleurMists.lua

toys\toys_mists.lua
Expand Down
3 changes: 2 additions & 1 deletion Angleur_TBC.toc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ angTemplates\embeds.xml

debug.lua
init.lua
items\extra_item_aura_logic.lua
AngleurTBC.lua

items\items_mists.lua
Expand Down Expand Up @@ -60,4 +61,4 @@ bobberScanner\bobberScanner.lua
AngleurTBC.xml

thanks\thanks.lua
thanks\thanks.xml
thanks\thanks.xml
3 changes: 2 additions & 1 deletion Angleur_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ angTemplates\embeds.xml

debug.lua
init.lua
items\extra_item_aura_logic.lua
AngleurVanilla.lua

items\items_mists.lua
Expand Down Expand Up @@ -59,4 +60,4 @@ bobberScanner\bobberScanner.lua
AngleurVanilla.xml

thanks\thanks.lua
thanks\thanks.xml
thanks\thanks.xml
72 changes: 72 additions & 0 deletions items/extra_item_aura_logic.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Angleur_ExtraItemAuraFallbackRefreshThreshold = 30
Angleur_LastFishingChannelDuration = nil

function Angleur_ClearFishingChannelDuration()
Angleur_LastFishingChannelDuration = nil
end

function Angleur_SetFishingChannelDuration(durationSeconds)
if type(durationSeconds) ~= "number" or durationSeconds <= 0 then
return
end

Angleur_LastFishingChannelDuration = durationSeconds
end

function Angleur_UpdateFishingChannelDurationFromUnit(unit)
local _, _, _, startTimeMs, endTimeMs = UnitChannelInfo(unit or "player")
if not startTimeMs or not endTimeMs then
Angleur_ClearFishingChannelDuration()
return false
end

Angleur_SetFishingChannelDuration((endTimeMs - startTimeMs) / 1000)
return true
end

function Angleur_GetExtraItemAuraRefreshThreshold()
return Angleur_LastFishingChannelDuration or Angleur_ExtraItemAuraFallbackRefreshThreshold
end

function Angleur_GetExtraItemAuraRemainingDuration(auraData, currentTime)
if not auraData then return nil end

local expirationTime = auraData.expirationTime
if not expirationTime or expirationTime == 0 then
return nil
end

return expirationTime - currentTime
end

function Angleur_ShouldBlockExtraItemAuraReuse(auraData, currentTime, refreshThreshold)
if not auraData then
return false
end

local remainingDuration = Angleur_GetExtraItemAuraRemainingDuration(auraData, currentTime)
if remainingDuration == nil then
return true
end

return remainingDuration >= (refreshThreshold or Angleur_GetExtraItemAuraRefreshThreshold())
end

function Angleur_DoesExtraItemAuraBlockReuse(slot)
local spellAuraID
if slot.spellID ~= 0 then
spellAuraID = slot.spellID
elseif slot.macroSpellID ~= 0 then
spellAuraID = slot.macroSpellID
else
return false
end

local spellInfo = C_Spell.GetSpellInfo(spellAuraID)
if not spellInfo or not spellInfo.name then
return false
end

local auraData = C_UnitAuras.GetAuraDataBySpellName("player", spellInfo.name)
return Angleur_ShouldBlockExtraItemAuraReuse(auraData, GetTime())
end