forked from jp-ganis/JPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jphealing.lua
executable file
·88 lines (76 loc) · 2.44 KB
/
jphealing.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
--Blacklistplayer functions
--These functions will blacklist a target for a set time.
function jps.UpdateHealerBlacklist(self)
if #jps.HealerBlacklist > 0 then
for i = #jps.HealerBlacklist, 1, -1 do
if GetTime() - jps.HealerBlacklist[i][2] > jps.BlacklistTimer then
if jps.Debug then print("Releasing ", jps.HealerBlacklist[i][1]) end
table.remove(jps.HealerBlacklist,i)
end
end
end
end
function jps.PlayerIsBlacklisted(unit)
local playername
if UnitExists(unit) and UnitIsPlayer(unit) then
playername = GetUnitName(unit)
end
for i = 1, #jps.HealerBlacklist do
if jps.HealerBlacklist[i][1] == playername then
return true
end
end
return false
end
function jps.BlacklistPlayer(unit)
local playername
if UnitExists(unit) and UnitIsPlayer(unit) then
playername = GetUnitName(unit)
end
if playername ~= nil then
local playerexclude = {}
table.insert(playerexclude, playername)
table.insert(playerexclude, GetTime())
table.insert(jps.HealerBlacklist,playerexclude)
if jps.Debug then print("Blacklisting ", playername) end
end
end
---------------------------
-- GROUP Functions in RAID
---------------------------
function jps.canHeal(unit)
if not unit then unit = "target" end
if UnitExists(unit)~=1 then return false end
if UnitIsVisible(unit)~=1 then return false end
if UnitIsPlayer(unit)~=1 then return false end
if UnitIsFriend("player",unit)~=1 then return false end
if not UnitInRange(unit) then return false end
if UnitIsDeadOrGhost(unit)==1 then return false end
return true
end
-- find the subgroup of an unit in RaidStatus --
function jps.findSubGroupUnit(unit)
if GetNumRaidMembers()==0 then return 0 end
local groupUnit = 0
local raidIndex = UnitInRaid(unit) + 0.1
-- UnitInRaid("unit") returns 0 for raid1, 12 for raid13
-- 0-4 > grp1
-- 5-9 > grp2
-- 10-14 > grp3
-- 15-19 > grp4
-- 20-24 > grp5
if raidIndex == nil then groupUnit = 0 -- Pet return nil with UnitInRaid
else groupUnit = math.ceil(raidIndex / 5) -- math.floor(0.5) > 0 math.ceil(0.5) > 1
end
return groupUnit
end
-- counts the number of party members having a significant health pct loss --
function jps.countInRaidStatus(low_health_def)
local units_needing_heals = 0
for unit, unitTable in pairs(jps.RaidStatus) do
if jps.canHeal(unit) and unitTable["hpct"] < low_health_def then
units_needing_heals = units_needing_heals + 1
end
end
return units_needing_heals
end