vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | CT_RA_SpellSpell = nil; |
2 | CT_RA_SpellCast = nil; |
||
3 | |||
4 | CT_RA_oldCastSpell = CastSpell; |
||
5 | function CT_RA_newCastSpell(spellId, spellbookTabNum) |
||
6 | -- Call the original function so there's no delay while we process |
||
7 | CT_RA_oldCastSpell(spellId, spellbookTabNum); |
||
8 | |||
9 | -- Load the tooltip with the spell information |
||
10 | CT_RADST:SetSpell(spellId, spellbookTabNum); |
||
11 | |||
12 | local spellName = CT_RADSTTextLeft1:GetText(); |
||
13 | |||
14 | if ( SpellIsTargeting() ) then |
||
15 | -- Spell is waiting for a target |
||
16 | CT_RA_SpellSpell = spellName; |
||
17 | elseif ( UnitExists("target") ) then |
||
18 | -- Spell is being cast on the current target. |
||
19 | -- If ClearTarget() had been called, we'd be waiting target |
||
20 | CT_RA_ProcessSpellCast(spellName, UnitName("target")); |
||
21 | end |
||
22 | end |
||
23 | CastSpell = CT_RA_newCastSpell; |
||
24 | |||
25 | CT_RA_oldCastSpellByName = CastSpellByName; |
||
26 | function CT_RA_newCastSpellByName(spellName, onSelf) |
||
27 | -- Call the original function |
||
28 | CT_RA_oldCastSpellByName(spellName, onSelf) |
||
29 | local _, _, spellName = string.find(spellName, "^([^%(]+)"); |
||
30 | if ( spellName ) then |
||
31 | if ( SpellIsTargeting() ) then |
||
32 | CT_RA_SpellSpell = spellName; |
||
33 | else |
||
34 | CT_RA_ProcessSpellCast(spellName, UnitName("target")); |
||
35 | end |
||
36 | end |
||
37 | end |
||
38 | CastSpellByName = CT_RA_newCastSpellByName; |
||
39 | |||
40 | CT_RA_oldWorldFrameOnMouseDown = WorldFrame:GetScript("OnMouseDown"); |
||
41 | WorldFrame:SetScript("OnMouseDown", function() |
||
42 | -- If we're waiting to target |
||
43 | local targetName; |
||
44 | |||
45 | if ( CT_RA_SpellSpell and UnitName("mouseover") ) then |
||
46 | targetName = UnitName("mouseover"); |
||
47 | elseif ( CT_RA_SpellSpell and GameTooltipTextLeft1:IsVisible() ) then |
||
48 | local _, _, name = string.find(GameTooltipTextLeft1:GetText(), "^Corpse of (.+)$"); |
||
49 | if ( name ) then |
||
50 | targetName = name; |
||
51 | end |
||
52 | end |
||
53 | if ( CT_RA_oldWorldFrameOnMouseDown ) then |
||
54 | CT_RA_oldWorldFrameOnMouseDown(); |
||
55 | end |
||
56 | if ( CT_RA_SpellSpell and targetName ) then |
||
57 | CT_RA_ProcessSpellCast(CT_RA_SpellSpell, targetName); |
||
58 | end |
||
59 | end); |
||
60 | |||
61 | CT_RA_oldUseAction = UseAction; |
||
62 | function CT_RA_newUseAction(a1, a2, a3) |
||
63 | |||
64 | CT_RADST:SetAction(a1); |
||
65 | local spellName = CT_RADSTTextLeft1:GetText(); |
||
66 | CT_RA_SpellSpell = spellName; |
||
67 | |||
68 | -- Call the original function |
||
69 | CT_RA_oldUseAction(a1, a2, a3); |
||
70 | |||
71 | -- Test to see if this is a macro |
||
72 | if ( GetActionText(a1) or not CT_RA_SpellSpell ) then |
||
73 | return; |
||
74 | end |
||
75 | |||
76 | if ( SpellIsTargeting() ) then |
||
77 | -- Spell is waiting for a target |
||
78 | return; |
||
79 | elseif ( a3 ) then |
||
80 | -- Spell is being cast on the player |
||
81 | CT_RA_ProcessSpellCast(spellName, UnitName("player")); |
||
82 | elseif ( UnitExists("target") ) then |
||
83 | -- Spell is being cast on the current target |
||
84 | CT_RA_ProcessSpellCast(spellName, UnitName("target")); |
||
85 | end |
||
86 | end |
||
87 | UseAction = CT_RA_newUseAction; |
||
88 | |||
89 | CT_RA_oldSpellTargetUnit = SpellTargetUnit; |
||
90 | function CT_RA_newSpellTargetUnit(unit) |
||
91 | -- Call the original function |
||
92 | local shallTargetUnit; |
||
93 | if ( SpellIsTargeting() ) then |
||
94 | shallTargetUnit = true; |
||
95 | end |
||
96 | CT_RA_oldSpellTargetUnit(unit); |
||
97 | if ( shallTargetUnit and CT_RA_SpellSpell and not SpellIsTargeting() ) then |
||
98 | CT_RA_ProcessSpellCast(CT_RA_SpellSpell, UnitName(unit)); |
||
99 | CT_RA_SpellSpell = nil; |
||
100 | end |
||
101 | end |
||
102 | SpellTargetUnit = CT_RA_newSpellTargetUnit; |
||
103 | |||
104 | CT_RA_oldSpellStopTargeting = SpellStopTargeting; |
||
105 | function CT_RA_newSpellStopTargeting() |
||
106 | CT_RA_oldSpellStopTargeting(); |
||
107 | CT_RA_SpellSpell = nil; |
||
108 | end |
||
109 | SpellStopTargeting = CT_RA_newSpellStopTargeting; |
||
110 | |||
111 | CT_RA_oldTargetUnit = TargetUnit; |
||
112 | function CT_RA_newTargetUnit(unit) |
||
113 | -- Call the original function |
||
114 | CT_RA_oldTargetUnit(unit); |
||
115 | |||
116 | -- Look to see if we're currently waiting for a target internally |
||
117 | -- If we are, then well glean the target info here. |
||
118 | |||
119 | if ( CT_RA_SpellSpell and UnitExists(unit) ) then |
||
120 | CT_RA_ProcessSpellCast(CT_RA_SpellSpell, UnitName(unit)); |
||
121 | end |
||
122 | end |
||
123 | TargetUnit = CT_RA_newTargetUnit; |
||
124 | |||
125 | function CT_RA_ProcessSpellCast(spellName, targetName) |
||
126 | if ( spellName and targetName ) then |
||
127 | CT_RA_SpellCast = { spellName, targetName }; |
||
128 | end |
||
129 | end |
||
130 | |||
131 | function CT_RADetectSpells_OnLoad() |
||
132 | this:RegisterEvent("SPELLCAST_START"); |
||
133 | this:RegisterEvent("SPELLCAST_STOP"); |
||
134 | this:RegisterEvent("SPELLCAST_FAILED"); |
||
135 | this:RegisterEvent("SPELLCAST_INTERRUPTED"); |
||
136 | end |
||
137 | |||
138 | function CT_RADetectSpells_OnEvent(event) |
||
139 | if ( event == "SPELLCAST_START" ) then |
||
140 | if ( CT_RA_SpellCast and CT_RA_SpellCast[1] == arg1 ) then |
||
141 | CT_RA_SpellStartCast(CT_RA_SpellCast); |
||
142 | end |
||
143 | elseif ( event == "SPELLCAST_INTERRUPTED" or event == "SPELLCAST_STOP" or event == "SPELLCAST_FAILED" ) then |
||
144 | CT_RA_SpellEndCast(); |
||
145 | CT_RA_SpellCast = nil; |
||
146 | CT_RA_SpellSpell = nil; |
||
147 | end |
||
148 | end |