Skip to content

Commit

Permalink
multishot + aimed shot castbar (need to confirm SpellIDs)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Nov 28, 2024
1 parent 7ece420 commit 09e0805
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions ElvUI_Libraries/Core/oUF/elements/castbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,25 @@ local CASTBAR_STAGE_DURATION_INVALID = -1 -- defined in FrameXML/CastingBarFrame
local wipe = wipe
local next = next
local select = select
local GetTime = GetTime
local CreateFrame = CreateFrame
local GetNetStats = GetNetStats
local UnitCastingInfo = UnitCastingInfo
local UnitChannelInfo = UnitChannelInfo
local GetTime = GetTime
local GetUnitEmpowerStageDuration = GetUnitEmpowerStageDuration
local GetUnitEmpowerHoldAtMaxTime = GetUnitEmpowerHoldAtMaxTime

-- GLOBALS: PetCastingBarFrame, PetCastingBarFrame_OnLoad
-- GLOBALS: CastingBarFrame, CastingBarFrame_OnLoad, CastingBarFrame_SetUnit

local tradeskillCurrent, tradeskillTotal, mergeTradeskill = 0, 0, false
local UNIT_SPELLCAST_SENT = function (self, event, unit, target, castID, spellID)
self.Castbar.curTarget = (target and target ~= "") and target or nil
end
local specialCast = { -- ms duration
[2643] = 500, -- Multishot
[14288] = 500, -- Multishot
[14289] = 500, -- Multishot
[14290] = 500, -- Multishot
[19434] = 3000, -- Aimed Shot
}
-- end block

local function resetAttributes(self)
Expand Down Expand Up @@ -224,22 +228,34 @@ local function ShouldShow(element, unit)
return element.__owner.unit == unit
end

local function CastStart(self, real, unit, castGUID)
local function CastStart(self, real, unit, castGUID, spellID, castTime)
if oUF.isRetail and real == 'UNIT_SPELLCAST_START' and not castGUID then return end

local element = self.Castbar
if(not (element.ShouldShow or ShouldShow) (element, unit)) then
return
end

local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo(unit)
local event, numStages, castDuration = 'UNIT_SPELLCAST_START'
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, _
if spellID and real == 'UNIT_SPELLCAST_SENT' then
name, _, texture, castDuration = oUF:GetSpellInfo(spellID)

if castDuration and castDuration ~= 0 then
castTime = castDuration -- prefer a real duration time, otherwise use the static duration
end

castID = castGUID
startTime = GetTime() * 1000
endTime = startTime + castTime
else
name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo(unit)

local numStages, _
local event = 'UNIT_SPELLCAST_START'
if not name then
name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = UnitChannelInfo(unit)
if not name then
name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = UnitChannelInfo(unit)

event = (numStages and numStages > 0) and 'UNIT_SPELLCAST_EMPOWER_START' or 'UNIT_SPELLCAST_CHANNEL_START'
event = (numStages and numStages > 0) and 'UNIT_SPELLCAST_EMPOWER_START' or 'UNIT_SPELLCAST_CHANNEL_START'
end
end

if not name or (isTradeSkill and element.hideTradeSkills) then
Expand Down Expand Up @@ -498,6 +514,17 @@ local function CastInterruptible(self, event, unit)
end
end

-- ElvUI block
local UNIT_SPELLCAST_SENT = function (self, event, unit, target, castID, spellID)
self.Castbar.curTarget = (target and target ~= "") and target or nil

local castTime = specialCast[spellID]
if castTime then
CastStart(self, event, unit, castID, spellID, castTime)
end
end
-- ElvUI block

local function OnUpdateStage(element)
if element.UpdatePipStep then
local maxStage = 0
Expand Down Expand Up @@ -617,7 +644,7 @@ local function Enable(self, unit)
end

-- ElvUI block
self:RegisterEvent('UNIT_SPELLCAST_SENT', UNIT_SPELLCAST_SENT)
self:RegisterEvent('UNIT_SPELLCAST_SENT', UNIT_SPELLCAST_SENT, true)
-- end block

element.holdTime = 0
Expand Down

0 comments on commit 09e0805

Please sign in to comment.