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
|
g_skill = {}
function Msg(outstr,a1,a2,a3)
DEFAULT_CHAT_FRAME:AddMessage(tostring(outstr),a1,a2,a3)
end
function ReadSkills()
g_skill = {}
local skillname,slot
Msg("- Reading Class Skills")
for page = 2,4 do
slot = 1
skillname = GetSkillDetail(page,slot)
repeat
local a1,a2,a3,a4,a5,a6,a7,a8,skillusable = GetSkillDetail(page,slot)
if skillusable then
g_skill[skillname] = { ['page'] = page, ['slot'] = slot }
end
slot = slot + 1
skillname = GetSkillDetail(page,slot)
until skillname == nil
end
end
ReadSkills() -- Read skills into g_skill table at login
function PctH(tgt)
return (UnitHealth(tgt)/UnitMaxHealth(tgt))
end
function ChkBuff(tgt,buffname)
local cnt = 1
local buffcmd = UnitBuff
if UnitCanAttack("player",tgt) then
buffcmd = UnitDebuff
end
local buff = buffcmd(tgt,cnt)
while buff ~= nil do
if string.gsub(buff, "(%()(.)(%))", "%2") == buffname then
return true
end
cnt = cnt + 1
buff = buffcmd(tgt,cnt)
end
return false
end
function BuffList(tgt)
local cnt = 1
local buffcmd = UnitBuff
local buffstr = "/"
if UnitCanAttack("player",tgt) then
buffcmd = UnitDebuff
end
local buff = buffcmd(tgt,cnt)
while buff ~= nil do
buffstr = buffstr..buff.."/"
cnt = cnt + 1
buff = buffcmd(tgt,cnt)
end
return string.gsub(buffstr, "(%()(.)(%))", "%2")
end
function DebuffList(tgt)
local cnt = 1
local buffcmd = UnitDebuff
local buffstr = "/"
if UnitCanAttack("player",tgt) then
buffcmd = UnitBuff
end
local buff = buffcmd(tgt,cnt)
while buff ~= nil do
buffstr = buffstr..buff.."/"
cnt = cnt + 1
buff = buffcmd(tgt,cnt)
end
return string.gsub(buffstr, "(%()(.*)(%))", "%2")
end
function CD(skillname)
local firstskill = GetSkillDetail(2,1)
if (g_skill[firstskill] == nil) or (g_skill[firstskill].page ~= 2) then
ReadSkills()
end
if g_skill[skillname] ~= nil then
local tt,cd = GetSkillCooldown(g_skill[skillname].page,g_skill[skillname].slot)
return cd==0
else
Msg("Skill not available: "..skillname)
return false
end
end
function MyCombat(Skill,arg1)
local spell_name,cast_max,cast_current = UnitCastingTime("player")
local talktome = ((arg1 == "v1") or (arg1 == "v2"))
local action,actioncd
if spell_name ~= nil then
if (arg1 == "v2") then Msg("- ['..spell_name..']",0,1,1) end
return true
end
for x,tbl in ipairs(Skill) do
if string.find(Skill[x].name, "Action:") then
if Skill[x].use then
action = tonumber((string.gsub(Skill[x].name, "(Action:)( *)(.*)", "%3")))
_1,actioncd = GetActionCooldown(action)
if GetActionUsable(action) and (actioncd == 0) then
if talktome then Msg("- "..Skill[x].name) end
UseAction(action)
return true
end
end
elseif string.find(Skill[x].name, "Item:") then
if Skill[x].use then
action = string.gsub(Skill[x].name, "(Item:)( *)(.*)", "%3")
if talktome then Msg("- "..Skill[x].name) end
UseItemByName(action)
return true
end
elseif CD(Skill[x].name) and Skill[x].use then
if talktome then Msg("- "..Skill[x].name) end
CastSpellByName(Skill[x].name)
return true
end
end
if (arg1 == "v2") then Msg("- IDLE") end
return false
end
function DruidWarden(arg1)
local Skill = {}
local i = 0
local tgt = "player"
local friendly = false
local combat = GetPlayerCombatState()
if not UnitCanAttack("player","target") then
tgt = "target"
friendly = true
end
local health = PctH(tgt)
local pbuffs = BuffList("player")
local tbuffs = BuffList("target")
local dbuffs = DebuffList("player")
i=i+1; Skill[i] = { ['name'] = "Rock Protection", ['use'] = (PctH("player") <= .30) }
i=i+1; Skill[i] = { ['name'] = "Elven Amulet", ['use'] = (PctH("player") <= .70) }
i=i+1; Skill[i] = { ['name'] = "Mother Earth's Protection", ['use'] = ((friendly) and (PctH(tgt) <= .30)) }
i=i+1; Skill[i] = { ['name'] = "Savage Blessing", ['use'] = ((not combat) and (friendly) and (not string.find(tbuffs,"Savage Blessing"))) }
i=i+1; Skill[i] = { ['name'] = "Concentration Prayer", ['use'] = ((not combat) and (not string.find(pbuffs,"Concentration Prayer"))) }
i=i+1; Skill[i] = { ['name'] = "Briar Shield", ['use'] = ((not combat) and (not string.find(pbuffs,"Briar Shield"))) }
i=i+1; Skill[i] = { ['name'] = "Antidote", ['use'] = (string.find(dbuffs,"Poisoned")) }
i=i+1; Skill[i] = { ['name'] = "Antidote", ['use'] = (string.find(dbuffs,"Lethal Sting")) }
i=i+1; Skill[i] = { ['name'] = "Antidote", ['use'] = (string.find(dbuffs,"Snake Poison")) }
i=i+1; Skill[i] = { ['name'] = "Purify", ['use'] = (string.find(dbuffs,"Cursed")) }
i=i+1; Skill[i] = { ['name'] = "Curing Seed", ['use'] = ((not friendly) and (health <= .60) and (not string.find(pbuffs,"Curing Seed"))) }
i=i+1; Skill[i] = { ['name'] = "Curing Seed", ['use'] = ((friendly) and (health <= .60) and(not string.find(tbuffs,"Curing Seed"))) }}
i=i+1; Skill[i] = { ['name'] = "Blossoming Life", ['use'] = ((not friendly) and (health <= .80) and (not string.find(pbuffs,"Blossoming Life"))) }
i=i+1; Skill[i] = { ['name'] = "Blossoming Life", ['use'] = ((friendly) and (health <= .80) and (not string.find(tbuffs,"Blossoming Life"))) }
i=i+1; Skill[i] = { ['name'] = "Recover", ['use'] = ((((AbsHP("player")) > 2000) and (not string.find(pbuffs,"Life Guide"))) or ((friendly) and ((PctH(tgt)) <= .50) and (not string.find(tbuffs,"Recover")))) }
i=i+1; Skill[i] = { ['name'] = "Restore Life", ['use'] = ((friendly) and ((PctH(tgt)) <= .60)) }
i=i+1; Skill[i] = { ['name'] = "Weakening Seed", ['use'] = ((not friendly) and (ChkBuff(tgt,"Weakening Seed"))) }
i=i+1; Skill[i] = { ['name'] = "Earth Pulse", ['use'] = (not friendly) }
i=i+1; Skill[i] = { ['name'] = "Briar Entwinement", ['use'] = ((not friendly) and (not string.find(tbuffs,"Briar Entwinement"))) }
i=i+1; Skill[i] = { ['name'] = "Rockslide", ['use'] = ((not friendly) and (not string.find(tbuffs,"Rockslide"))) }
i=i+1; Skill[i] = { ['name'] = "Earth Arrow", ['use'] = (not friendly) }
MyCombat(Skill,arg1)
end
|