-
Notifications
You must be signed in to change notification settings - Fork 16
/
logic.special.lua
150 lines (132 loc) · 3.71 KB
/
logic.special.lua
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
function BeStride:NoDismountWhileFlying()
-- Check whether we can dismount while flying
-- Returns: boolean
-- Todo: Bitwise Compare
if BeStride:DBGet("settings.mount.nodismountwhileflying") then
return true
else
return false
end
end
function BeStride:IsCombat()
if InCombatLockdown() then
return true
else
return false
end
end
function BeStride:NeedToRepair()
-- Check whether we need to repair
-- Returns: boolean
if BeStride:IsForceRepair() then
return true
end
if BeStride.db.profile.misc ~= nil and BeStride.db.profile.misc.RepairMounts ~= nil and size(BeStride.db.profile.misc.RepairMounts) > 0 and BeStride:UseRepair() then
for i = 0, 17 do
local current, maximum = GetInventoryItemDurability(i)
if current ~= nil and maximum ~= nil and ( (current/maximum) <= BeStride:GetRepairThreshold() ) then
return true
end
end
end
return false
end
function BeStride:IsRepairable()
if not BeStride:DBGetSetting('mount.repair.use') or not self:IsMountable() or IsFlying() or not IsOutdoors() then
return false
end
mounts = BeStride:DBGet("mounts.repair")
local mountCount = {}
table.foreach(mounts,function (key,value) table.insert(mountCount,key) end )
if #mountCount ~= 0 then
local globalDurability,count = 0,0
for i = 0, 17 do
local current, maximum = GetInventoryItemDurability(i)
if current ~= nil and maximum ~= nil then
local durability = (current / maximum)
count = count + 1
globalDurability = globalDurability + durability
if (durability * 100) <= BeStride:DBGet("settings.mount.repair.durability") then
return true
end
end
end
if ((globalDurability/count)*100) <= BeStride:DBGet("settings.mount.repair.globaldurability") then
return true
end
local bagSlots = 0
for i = 0, 4 do
if self.IsMainline() then
local bagSlots = C_Container.GetContainerNumSlots(i)
else
local bagSlots = GetContainerNumSlots(i)
end
for j = 0, bagSlots do
local current, maximum = 0, 0
if self.IsMainline() then
local current, maximum = C_Container.GetContainerItemDurability(i, j)
else
local current, maximum = GetContainerItemDurability(i, j)
end
if current ~= nil and maximum ~= nil and maximum ~= 0 then
if ((current / maximum)*100) <= BeStride:DBGet("settings.mount.repair.inventorydurability") then
return true
end
end
end
end
else
return false
end
end
function BeStride:IsForceRepair()
-- Check whether we force a repair mount
-- Returns: boolean
if BeStride.db.profile.settings["repair"] == nil or BeStride.db.profile.settings["repair"]["force"] == nil then
return false
end
if BeStride.db.profile.settings["repair"]["force"] then
return true
else
return false
end
end
function BeStride:IsUseRepair()
-- Checks whether we check to repair or not
-- Returns: boolean
if BeStride.db.profile.settings["repair"]["use"] then
return true
else
return false
end
end
function BeStride:GetRepairThreshold()
-- Get repair threshold
-- Returns: signed integer
if BeStride.db.profile.settings["repair"]["durability"] then
return BeStride.db.profile.settings["repair"]["durability"]
else
return -1
end
end
function BeStride:IsHerbalismAndCanRobot()
if BeStride:IsHerbalism() and not BeStride:IsCombat() and BeStride:CanRobotSetting() then
if IsUsableSpell(134359) or IsUsableSpell(223814) then
return true
else
return false
end
else
return false
end
end
function BeStride:IsHerbalism()
local prof1,prof2 = self:GetProfessions()
-- 182 = Herbalism
-- ref: http://wowwiki.wikia.com/wiki/API_GetProfessionInfo
if (prof1 and select(7,GetProfessionInfo(prof1)) == 182) or (prof2 and select(7,GetProfessionInfo(prof2)) == 182) then
return true
else
return false
end
end