-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrueForm.lua
More file actions
187 lines (166 loc) · 7 KB
/
Copy pathTrueForm.lua
File metadata and controls
187 lines (166 loc) · 7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
local colorRed = CreateColor(0.51, 0.05, 0.03)
local colorYello = CreateColor(1.0, 0.82, 0.0)
--/run SetCVar("ActionButtonUseKeyDown", 0)
--/run SetCVar("ActionButtonUseKeyDown", 1)
--current form: 0 is human, 1 is wolf, 2 is not tracking yet
TrueFormCharacterConfig = {
currentForm = nil,
calmActive = nil,
}
TrueFormConfig = {
firstInstall = nil,
}
local function initializeSavedVariables()
if not TrueFormCharacterConfig.currentForm then
TrueFormCharacterConfig.currentForm = 2
end
if not TrueFormCharacterConfig.calmActive then
TrueFormCharacterConfig.calmActive = false
end
if not TrueFormConfig then
TrueFormConfig = {}
end
if TrueFormConfig.firstInstall == nil then
TrueFormConfig.firstInstall = true
end
end
local function directClickWarning(self, button, down)
if GetCVar("ActionButtonUseKeyDown") == "1" then
print(colorRed:WrapTextInColorCode("TrueForm:"), "To always transform into human form, add ", colorYello:WrapTextInColorCode("/click TrueForm_TurnHuman MouseButton 1"), " to your macros.")
print("To always transform into worgen form, add ", colorYello:WrapTextInColorCode("/click TrueForm_TurnWorgen MouseButton 1"), " instead.")
elseif GetCVar("ActionButtonUseKeyDown") == "0" then
print(colorRed:WrapTextInColorCode("TrueForm:"), "To always transform into human form, add ", colorYello:WrapTextInColorCode("/click TrueForm_TurnHuman"), " to your macros.")
print("To always transform into worgen form, add ", colorYello:WrapTextInColorCode("/click TrueForm_TurnWorgen"), " instead.")
end
end
local function keyUpOrDownWarning(self, button, down)
if down == false and GetCVar("ActionButtonUseKeyDown") == "1" then
print(colorRed:WrapTextInColorCode("TrueForm:"),"Your ActionButtonUse console variable is set to KEY DOWN.")
print("Please use the macro:")
print(colorYello:WrapTextInColorCode(" /click") , colorYello:WrapTextInColorCode(self:GetDebugName()), colorYello:WrapTextInColorCode("MouseButton 1"))
print("instead.")
elseif down and GetCVar("ActionButtonUseKeyDown") == "0" then
print(colorRed:WrapTextInColorCode("TrueForm:"),"Your ActionButtonUse console variable is set to KEY UP.")
print("Please use the macro:")
print(colorYello:WrapTextInColorCode(" /click") , colorYello:WrapTextInColorCode(self:GetDebugName()))
print("instead.")
end
end
function TrueForm_OnLoad(self)
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("UNIT_FORM_CHANGED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:SetScript("OnEvent", TrueForm_EventHandler)
self.turnHuman:RegisterForClicks("AnyUp", "AnyDown")
self.turnHuman:HookScript("OnClick", keyUpOrDownWarning)
self.turnWorgen:RegisterForClicks("AnyUp", "AnyDown")
self.turnWorgen:HookScript("OnClick", keyUpOrDownWarning)
end
local combatHidden = false
local enteredWorld = false
function TrueForm_EventHandler(self, event, unit, ...)
local arg4, arg5, arg6 = ...
if event == "PLAYER_ENTERING_WORLD" then
initializeSavedVariables()
TrueForm.turnHuman:SetAttribute("type", "spell")
TrueForm.turnWorgen:SetAttribute("type", "spell")
TrueForm_HandleButtons(TrueFormCharacterConfig.currentForm)
if TrueFormConfig.firstInstall == true then
TrueForm_FirstInstall()
TrueFormConfig.firstInstall = false
end
enteredWorld = true
TrueForm_CheckForm()
elseif event == "UNIT_FORM_CHANGED" and unit == "player" and enteredWorld == true then
if InCombatLockdown() then return end
TrueForm_CheckForm()
elseif event == "PLAYER_REGEN_DISABLED" then
if TrueForm:IsShown() then
TrueForm:Hide()
combatHidden = true
end
elseif event == "PLAYER_REGEN_ENABLED" then
TrueForm_CheckForm()
if combatHidden == true then
TrueForm:Show()
combatHidden = false
end
end
end
function TrueForm_CheckForm()
if InCombatLockdown() then return end
if C_UnitAuras.WantsAlteredForm("player") == true then
TrueFormCharacterConfig.currentForm = 1
TrueForm_HandleButtons(1)
elseif C_UnitAuras.WantsAlteredForm("player") == false then
TrueFormCharacterConfig.currentForm = 0
TrueForm_HandleButtons(0)
else
TrueForm_HandleButtons(2)
end
end
function TrueForm_HandleButtons(form)
if form == 1 then
TrueForm.visual.human:Hide()
TrueForm.visual.worgen:Show()
TrueForm.visual.text:SetText("WORGEN")
TrueForm.turnHuman:SetAttribute("spell", "68996")
TrueForm.turnWorgen:SetAttribute("spell", " ")
TrueForm.problems:Hide()
elseif form == 0 then
TrueForm.visual.worgen:Hide()
TrueForm.visual.human:Show()
TrueForm.visual.text:SetText("HUMAN")
TrueForm.turnHuman:SetAttribute("spell", " ")
TrueForm.turnWorgen:SetAttribute("spell", "68996")
TrueForm.problems:Hide()
elseif form == 2 then
TrueForm.visual.human:Hide()
TrueForm.visual.worgen:Hide()
TrueForm.visual.text:Hide()
TrueForm.turnHuman:SetAttribute("spell", " ")
TrueForm.turnWorgen:SetAttribute("spell", " ")
TrueForm.problems:Show()
end
end
function TrueForm_GenerateMacros()
if InCombatLockdown() then return end
if GetCVar("ActionButtonUseKeyDown") == "1" then
CreateMacro("TrueForm Human", 236448, "/click TrueForm_TurnHuman MouseButton 1")
CreateMacro("TrueForm Worgen", 463876, "/click TrueForm_TurnWorgen MouseButton 1")
elseif GetCVar("ActionButtonUseKeyDown") == "0" then
CreateMacro("TrueForm Human", 236448, "/click TrueForm_TurnHuman")
CreateMacro("TrueForm Worgen", 463876, "/click TrueForm_TurnWorgen")
end
print(colorRed:WrapTextInColorCode("TrueForm ") .. "example macros successfully generated")
if not MacroFrame then
C_AddOns.LoadAddOn("Blizzard_MacroUI")
MacroFrame_Show()
elseif not MacroFrame:IsShown() then
MacroFrame_Show()
end
end
local closeHooked = true
function TrueForm_AnimateMacros(index)
if not MacroFrame then
C_AddOns.LoadAddOn("Blizzard_MacroUI")
MacroFrame_Show()
elseif not MacroFrame:IsShown() then
MacroFrame_Show()
end
MacroFrame:SetAccountMacros()
MacroFrame:SelectMacro(index)
local frameW, frameH = MacroFrameSelectedMacroButton:GetSize()
TrueForm_MacroAlertAnim:SetSize(frameW + 6, frameH + 6)
TrueForm_MacroAlertAnim:ClearAllPoints()
TrueForm_MacroAlertAnim:SetPoint("CENTER", MacroFrameSelectedMacroButton, "CENTER", 0, -1)
TrueForm_MacroAlertAnim:Show()
TrueForm_MacroAlertAnim.ProcStartAnim:Play()
if not closeHooked then
MacroFrame:HookScript("OnHide", function()
TrueForm_MacroAlertAnim:Hide()
end)
closeHooked = true
end
end