Skip to content

Commit

Permalink
Merge pull request #617 from Xian55/feature/improve-castinghandler-v4
Browse files Browse the repository at this point in the history
Addon: [1.7.60] - Improved CastingHandler spell detection and wands
  • Loading branch information
Xian55 authored Aug 17, 2024
2 parents 88c1be3 + adc5143 commit 9c8da07
Show file tree
Hide file tree
Showing 12 changed files with 385 additions and 127 deletions.
1 change: 1 addition & 0 deletions Addons/DataToColor/DataToColor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ DataToColor.targetChanged = true

DataToColor.autoFollow = false
DataToColor.moving = false
DataToColor.channeling = false

DataToColor.playerGUID = UnitGUID(DataToColor.C.unitPlayer)
DataToColor.petGUID = UnitGUID(DataToColor.C.unitPet)
Expand Down
2 changes: 1 addition & 1 deletion Addons/DataToColor/DataToColor.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Title: DataToColor
## Author: FreeHongKongMMO
## Notes: Displays data as colors
## Version: 1.7.59
## Version: 1.7.60
## RequiredDeps:
## OptionalDeps: Ace3, LibRangeCheck, LibClassicCasterino
## SavedVariables:
Expand Down
12 changes: 12 additions & 0 deletions Addons/DataToColor/EventHandlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ function DataToColor:RegisterEvents()
DataToColor:RegisterEvent("UNIT_SPELLCAST_SENT", 'OnUnitSpellCastSent')
DataToColor:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", 'OnUnitSpellCastSucceeded')
DataToColor:RegisterEvent("UNIT_SPELLCAST_FAILED", 'OnUnitSpellCastFailed')
DataToColor:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", 'OnUnitSpellCastChannelStart')
DataToColor:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", 'OnUnitSpellCastChannelStop')
--DataToColor:RegisterEvent("UNIT_SPELLCAST_FAILED_QUIET", 'OnUnitSpellCastFailed')
DataToColor:RegisterEvent('LOOT_READY', 'OnLootReady')
DataToColor:RegisterEvent('LOOT_CLOSED', 'OnLootClosed')
Expand Down Expand Up @@ -481,6 +483,16 @@ function DataToColor:OnUnitSpellCastFailed(event, unit, castGUID, spellId)
DataToColor.lastCastSpellId = spellId
end

function DataToColor:OnUnitSpellCastChannelStart(event, unit, castGUID, spellID)
if unit ~= DataToColor.C.unitPlayer then return end
DataToColor.channeling = true
end

function DataToColor:OnUnitSpellCastChannelStop(event, unit, castGUID, spellID)
if unit ~= DataToColor.C.unitPlayer then return end
DataToColor.channeling = false
end

function DataToColor:SoM_OnCastSuccess(event, unitTarget, castGuid, spellId)
if unitTarget ~= DataToColor.C.unitPlayer then return end
som_spellId = spellId or 0
Expand Down
3 changes: 2 additions & 1 deletion Addons/DataToColor/Query.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ function DataToColor:Bits3()
(UnitIsPlayer(DataToColor.C.unitSoftInteract) and 2 or 0) ^ 3 +
(UnitIsTapDenied(DataToColor.C.unitSoftInteract) and 2 or 0) ^ 4 +
(UnitAffectingCombat(DataToColor.C.unitSoftInteract) and 2 or 0) ^ 5 +
(DataToColor:IsUnitHostile(DataToColor.C.unitPlayer, DataToColor.C.unitSoftInteract) and 2 or 0) ^ 6
(DataToColor:IsUnitHostile(DataToColor.C.unitPlayer, DataToColor.C.unitSoftInteract) and 2 or 0) ^ 6 +
((DataToColor.channeling and 2 or 0)) ^ 7
)
end

Expand Down
2 changes: 2 additions & 0 deletions Core/AddonComponent/AddonBits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,6 @@ public void Update(IAddonDataProvider reader)
public bool SoftInteract_Combat() => v3[Mask._5];

public bool SoftInteract_Hostile() => v3[Mask._6];

public bool Channeling() => v3[Mask._7];
}
25 changes: 25 additions & 0 deletions Core/GoalsComponent/CastResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

namespace Core.Goals;

public enum CastResult
{
Success,
CurrentActionNotDetected,
UIFeedbackNotDetected,
TokenInterrupted,
UIError
}

public static class CastResult_Extension
{
public static string ToStringF(this CastResult value) => value switch
{
CastResult.Success => nameof(CastResult.Success),
CastResult.CurrentActionNotDetected => nameof(CastResult.CurrentActionNotDetected),
CastResult.UIFeedbackNotDetected => nameof(CastResult.UIFeedbackNotDetected),
CastResult.TokenInterrupted => nameof(CastResult.TokenInterrupted),
CastResult.UIError => nameof(CastResult.UIError),
_ => throw new ArgumentNullException(nameof(value)),
};
}
Loading

0 comments on commit 9c8da07

Please sign in to comment.