-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathThreat.lua
More file actions
executable file
·210 lines (183 loc) · 5.35 KB
/
Copy pathThreat.lua
File metadata and controls
executable file
·210 lines (183 loc) · 5.35 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
--[[
Threat
By: Ollowain.
Credit: Fury.lua by Bhaerau.
]]--
-- Variables
local RevengeReadyUntil = 0;
function Threat_Configuration_Init()
if (not Threat_Configuration) then
Threat_Configuration = { };
end
if (Threat_Configuration["Debug"] == nil) then
Threat_Configuration["Debug"] = false;
end
end
-- Normal Functions
local function Print(msg)
if (not DEFAULT_CHAT_FRAME) then
return;
end
DEFAULT_CHAT_FRAME:AddMessage(msg);
end
local function Debug(msg)
if (Threat_Configuration["Debug"]) then
if (not DEFAULT_CHAT_FRAME) then
return;
end
DEFAULT_CHAT_FRAME:AddMessage(msg);
end
end
--------------------------------------------------
function SpellId(spellname)
local id = 1;
for i = 1, GetNumSpellTabs() do
local _, _, _, numSpells = GetSpellTabInfo(i);
for j = 1, numSpells do
local spellName = GetSpellName(id, BOOKTYPE_SPELL);
if (spellName == spellname) then
return id;
end
id = id + 1;
end
end
return nil;
end
function SpellReady(spellname)
local id = SpellId(spellname);
if (id) then
local start, duration = GetSpellCooldown(id, 0);
if (start == 0 and duration == 0 and ThreatLastSpellCast + 1 <= GetTime()) then
return true;
end
end
return nil;
end
function HasBuff(unit, texturename)
local id = 1;
while (UnitBuff(unit, id)) do
local buffTexture = UnitBuff(unit, id);
if (string.find(buffTexture, texturename)) then
return true;
end
id = id + 1;
end
return nil;
end
function ActiveStance()
for i = 1, 3 do
local _, _, active = GetShapeshiftFormInfo(i);
if (active) then
return i;
end
end
return nil;
end
function HasFiveSunderArmors(unit)
local id = 1;
while (UnitDebuff(unit, id)) do
local debuffTexture, debuffAmount = UnitDebuff(unit, id);
if (string.find(debuffTexture, "Sunder")) then
if (debuffAmount >= 5) then
return true;
else
return nil;
end
end
id = id + 1;
end
return nil;
end
function RevengeAvail()
if GetTime() < RevengeReadyUntil then
return true;
else
return nil;
end
end
function ShieldSlamLearned()
if UnitClass("player") == "Warrior" then
local _, _, _, _, ss = GetTalentInfo(3,17);
if (ss == 1) then
return true;
else
return nil;
end
end
end
function Threat()
if (not UnitIsCivilian("target") and UnitClass("player") == CLASS_WARRIOR_THREAT) then
local rage = UnitMana("player");
if (not ThreatAttack) then
Debug("Starting AutoAttack");
AttackTarget();
end
if (ActiveStance() ~= 2) then
Debug("Changing to def stance");
CastSpellByName(ABILITY_DEFENSIVE_STANCE_THREAT);
end
if (SpellReady(ABILITY_BATTLE_SHOUT_THREAT) and not HasBuff("player", "Ability_Warrior_BattleShout") and rage >= 10) then
Debug("Battle Shout");
CastSpellByName(ABILITY_BATTLE_SHOUT_THREAT);
elseif (SpellReady(ABILITY_SHIELD_SLAM_THREAT) and rage >= 20 and ShieldSlamLearned()) then
Debug("Shield slam");
CastSpellByName(ABILITY_SHIELD_SLAM_THREAT);
elseif (SpellReady(ABILITY_REVENGE_THREAT) and RevengeAvail() and rage >= 5) then
Debug("Revenge");
CastSpellByName(ABILITY_REVENGE_THREAT);
elseif (SpellReady(ABILITY_SUNDER_ARMOR_THREAT) and rage >= 15 and not (HasFiveSunderArmors("target"))) then
Debug("Sunder armor");
CastSpellByName(ABILITY_SUNDER_ARMOR_THREAT);
elseif (SpellReady(ABILITY_HEROIC_STRIKE_THREAT) and rage >= 25) then
Debug("Heroic strike");
CastSpellByName(ABILITY_HEROIC_STRIKE_THREAT);
end
end
end
-- Chat Handlers
function Threat_SlashCommand(msg)
local _, _, command, options = string.find(msg, "([%w%p]+)%s*(.*)$");
if (command) then
command = string.lower(command);
end
if (command == nil or command == "") then
Threat();
elseif (command == "debug") then
if (Threat_Configuration["Debug"]) then
Threat_Configuration["Debug"] = false;
Print(BINDING_HEADER_THREAT .. ": " .. SLASH_THREAT_DEBUG .. " " .. SLASH_THREAT_DISABLED .. ".")
else
Threat_Configuration["Debug"] = true;
Print(BINDING_HEADER_THREAT .. ": " .. SLASH_THREAT_DEBUG .. " " .. SLASH_THREAT_ENABLED .. ".")
end
else
Print(SLASH_THREAT_HELP)
end
end
-- Event Handlers
function Threat_OnLoad()
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("PLAYER_ENTER_COMBAT");
this:RegisterEvent("PLAYER_LEAVE_COMBAT");
this:RegisterEvent("CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES");
ThreatLastSpellCast = GetTime();
ThreatLastStanceCast = GetTime();
SlashCmdList["THREAT"] = Threat_SlashCommand;
SLASH_THREAT1 = "/threat";
end
function Threat_OnEvent(event)
if (event == "VARIABLES_LOADED") then
Threat_Configuration_Init()
elseif (event == "PLAYER_ENTER_COMBAT") then
ThreatAttack = true;
elseif (event == "PLAYER_LEAVE_COMBAT") then
ThreatAttack = nil;
elseif (event == "CHAT_MSG_COMBAT_CREATURE_VS_SELF_MISSES")then
if string.find(arg1,"You block")
or string.find(arg1,"You parry")
or string.find(arg1,"You dodge") then
Debug("Revenge soon ready");
RevengeReadyUntil = GetTime() + 4;
end
end
end