PHP Code:
local function MushroomLog()
local frame = CreateFrame("frame", "WildMushroomLog")
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:RegisterEvent("GROUP_ROSTER_CHANGED")
frame:SetScript("OnEvent", function(self, event, ...)
local Log = {...}
if event == "COMBAT_LOG_EVENT_UNFILTERED" then
if (Log[2] and ( Log[2] == "SPELL_HEAL" or Log[2] == "SPELL_PERIODIC_HEAL" or Log[2] == "SPELL_CAST_SUCCESS" ) )
and (Log[4] and Log[4] == Nova_GUID("player") ) then
if Log[12] then
if Log[12] == 81269 then
if GlyphCheck(145529) then
if GetTime() - tableResetTimer > 0.7 then
local k=#WildMushroomTable
while k >= 1 do
if GetTime() - WildMushroomTable[k].time > 2.2 then
table.remove(WildMushroomTable, k)
end
k = k -1
end
tableResetTimer = GetTime()
end
for i=1, #members do
if Log[8] and Log[8] == members[i].GUID then
for t=1, #WildMushroomTable do
if members[i].GUID == WildMushroomTable[t].GUID then
WildMushroomTable[t] = { Unit = members[i].Unit, HP=members[i].HP, GUID = members[i].GUID , time = GetTime() }
return
end
end
tinsert(WildMushroomTable, { Unit = members[i].Unit, HP=members[i].HP, GUID = members[i].GUID , time = GetTime()} )
return
end
end
end
elseif Log[12] == 774 then
if GetTotemInfo(1)
and select(2, GetTotemInfo(1)) == GetSpellInfo(145205) then
if Log[16] and Log[16] > 0 then
rejuveOverHeal = rejuveOverHeal + Log[16]
end
end
elseif Log[12] == 145205 then
lastMushroomCast = GetTime()
end
end
end
elseif event == "GROUP_ROSTER_CHANGED" then
if #WildMushroomTable > 0 then
table.wipe(WildMushroomTable)
end
end
end)
end
function WildMushrooms()
if not WildMushroomsSetup then
WildMushroomTable = { }
rejuveOverHeal = 0
tableResetTimer = 0
lastMushroomCast = 0
MushroomLog()
WildMushroomsSetup = true
end
if Nova_WildMushroom_Check then
if GetTime() - tableResetTimer > 3 then
local k=#WildMushroomTable
while k >= 1 do
if GetTime() - WildMushroomTable[k].time > 1 then
table.remove(WildMushroomTable, k)
end
k = k -1
end
tableResetTimer = GetTime()
end
if GetTotemInfo(1)
and not UnitAffectingCombat("player")
and #WildMushroomTable == 0 then
DestroyTotem(1)
return false
end
if not GetTotemInfo(1)
and rejuveOverHeal > 0 then
rejuveOverHeal = 0
end
-- We're checking for the perfect AoE Target now
GetDistance()
local PerfectAoETarget = {}
for i=1, #members do
local numNearby, memNearby = UnitsClose(members[i].Unit, 90)
if UnitGroupRolesAssigned(members[i].Unit) == "TANK" then
numNearby = numNearby + 1
end
table.insert(PerfectAoETarget, {NumberNearby = numNearby, HP = members[i].HP, Unit = members[i].Unit, MembersNearby = memNearby} )
end
table.sort(PerfectAoETarget, function(x,y) return x.NumberNearby > y.NumberNearby end)
if #PerfectAoETarget > 0 and PerfectAoETarget[1].NumberNearby >= 2 then
local SimilarFound = false
for k=1, #PerfectAoETarget[1].MembersNearby do
for j=1, #WildMushroomTable do
if UnitIsUnit(PerfectAoETarget[1].MembersNearby[k].Unit, WildMushroomTable[j].Unit) then
if PQR_SpellAvailable(102791)
and UnitAffectingCombat("player")
and GetTotemInfo(1)
and members[1].HP <= Nova_WildMushroomBloom
and Nova_WildMushroomBloomPerc <= 100 * rejuveOverHeal / UnitHealthMax("player") then
SimilarFound = true
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(102791))
end
SimilarFound = true
end
end
end
if not SimilarFound then
if GetTime() - lastMushroomCast > 4
and UnitAffectingCombat("player") then
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(145205), PerfectAoETarget[1].Unit)
tableResetTimer = GetTime()
return true
end
else return false
end
end
local MemFound = false
local FoundTank = false
if not IsInRaid() then
for b=1, #WildMushroomTable do
if members[1].GUID == WildMushroomTable[b].GUID then
MemFound = true
if members[1].HP >= Nova_WildMushroomBloom
and GetTotemInfo(1)
and Nova_WildMushroomBloomPerc <= 100 * rejuveOverHeal / UnitHealthMax("player") then
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(102791))
return true
end
end
end
else
if #Nova_Tanks > 0
and GetTime() - lastMushroomCast > 4
and UnitAffectingCombat("player") then
for l=1, #WildMushroomTable do
if Nova_Tanks[1].GUID == WildMushroomTable[l].GUID then
FoundTank = true
if Nova_Tanks[1].HP <= Nova_WildMushroomBloom
and GetTotemInfo(1)
and Nova_WildMushroomBloomPerc <= 100 * rejuveOverHeal / UnitHealthMax("player") then
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(102791))
return true
end
end
end
if FoundTank == false then
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(145205), Nova_Tanks[1].Unit)
return true
end
elseif GetTime() - lastMushroomCast > 4
and UnitAffectingCombat("player") then
for l=1, #WildMushroomTable do
if Nova_GUID("player") == WildMushroomTable[l].GUID then
FoundPlayer = true
end
if not FoundPlayer then
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(145205), "player")
return true
end
end
end
end
if ( #WildMushroomTable <= 1
or ( not MemFound
and not FoundTank ))
and GetTime() - lastMushroomCast > 4
and UnitAffectingCombat("player")
and PQR_SpellAvailable(145205)
and not IsInRaid() then
if Nova_Tanks[1]
and Nova_Tanks[1].Unit
and Nova_Tanks[1].HP < 80 then
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(145205), Nova_Tanks[1].Unit)
return true
elseif not MemFound
and members[1].HP < 90 then
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(145205), members[1].Unit)
return true
elseif (#WildMushroomTable == 1 and not UnitIsUnit(WildMushroomTable[1].Unit, members[1].Unit))
or #WildMushroomTable == 0 then
SpellCancelQueuedSpell()
CastSpellByName(GetSpellInfo(145205), members[1].Unit)
return true
end
return false
end
return false
end
end
function SoulOfTheForest()
if UnitBuffID("player", 114108) then
if PQR_SpellAvailable(48438)
and Nova_WildGrowth_Check then
GetDistance()
local PerfectAoETarget = {}
for i=1, #members do
table.insert(PerfectAoETarget, {NumberNearby = UnitsClose(members[i].Unit, Nova_WildGrowth), Unit = members[i].Unit} )
end
table.sort(PerfectAoETarget, function(x,y) return x.NumberNearby > y.NumberNearby end)
if PerfectAoETarget[1].NumberNearby >= 2
or AverageHealth(3) <= Nova_WildGrowthSotF then
CastSpellByName(GetSpellInfo(48438), PerfectAoETarget[1].Unit)
return true
end
end
if PQR_SpellAvailable(774)
and Nova_Rejuvenation_Check then
if #Nova_Tanks > 0 then
for y=1, #Nova_Tanks do
if not UnitBuffID(Nova_Tanks[y].Unit, 774, "PLAYER")
and Nova_Tanks[y].HP < 90 then
CastSpellByName(GetSpellInfo(774), Nova_Tanks[y].Unit)
return true
end
end
end
for i=1, #members do
if not UnitBuffID(members[i].Unit, 774, "PLAYER")
and members[i].HP < Nova_RejuvenationSotF then
CastSpellByName(GetSpellInfo(774), members[i].Unit)
return true
end
end
end
return false
end
return false
end
function GenesisFinder()
local rejuveNotes = { }
if UnitAffectingCombat("player")
or UnitAffectingCombat(members[1].Unit) then
for y=1, #members do
if UnitBuffID(members[y].Unit, 774) then
tinsert(rejuveNotes, { Unit = members[y].Unit, HP = members[y].HP, buffTime = (select(7, UnitBuffID(members[y].Unit, 774)) - GetTime())})
end
end
end
local count = 0
for i=1, #rejuveNotes do
if rejuveNotes[i].HP < Nova_Genesis and rejuveNotes[i].buffTime >= 7 then
count = count + 1
end
end
if count >= 2 then
return true
elseif #rejuveNotes > 0 then
if rejuveNotes[1].HP < Nova_GenesisST
and rejuveNotes[1].buffTime >= 7 then
return true
end
end
end
function AddOrRemoveBlacklist(t)
local returnValue, AddOrRemove = nil, nil
if UnitExists(t) then
for i=1, #Nova_BlackList do
if Nova_GUID(t) == Nova_BlackList[i].GUID then
returnValue = UnitName(t)
tremove(Nova_BlackList, i)
AddOrRemove = 1
return AddOrRemove, returnValue
end
end
if UnitPlayerOrPetInRaid(t) then
tinsert(Nova_BlackList, { Unit = t, GUID = Nova_GUID(t) })
returnValue = UnitName(t)
AddOrRemove = 2
return AddOrRemove, returnValue
end
end
return 0
end
Nova_CustomT = { }
Nova_BlackList = { }
--------------------------------------------------------------------------------------------------
-- Copied Functions --
--------------------------------------------------------------------------------------------------
----------------------------------------------
-- Sheuron Healing Functions
----------------------------------------------
SpecialHealUnitList = {
}
local function SpecialHealUnit(t)
for i=1, #SpecialHealUnitList do
if Nova_GUID(t) == SpecialHealUnitList[i] then
return true
end
end
end
function UnitAlreadyTabled(t)
for i=1, #members do
if Nova_GUID(t) == members[i].GUID then
return true
end
end
return false
end
function CalculateHP(t)
incomingheals = UnitGetIncomingHeals(t) and UnitGetIncomingHeals(t) or 0
local PercentWithIncoming = 100 * ( UnitHealth(t) + incomingheals ) / UnitHealthMax(t)
local ActualWithIncoming = ( UnitHealthMax(t) - ( UnitHealth(t) + incomingheals ) )
return PercentWithIncoming, ActualWithIncoming
end
function CanHeal(t)
if (UnitInRange(t)
and UnitCanCooperate("player",t)
and not UnitIsCharmed(t)
and not UnitIsDeadOrGhost(t)
and not PQR_IsOutOfSight(t)
and UnitIsConnected(t)
and UnitDebuffID(t,104451) == nil -- Ice Tomb
and UnitDebuffID(t,76577) == nil -- Smoke Bomb
and UnitDebuffID(t, 121949) == nil -- Parasistic Growth
and UnitDebuffID(t, 122784) == nil -- Reshape Life
and UnitDebuffID(t, 122370) == nil -- Reshape Life 2
and UnitDebuffID(t, 123184) == nil -- Dissonance Field
and UnitDebuffID(t, 123255) == nil -- Dissonance Field 2
and UnitDebuffID(t, 123596) == nil -- Dissonance Field 3
and UnitDebuffID(t, 128353) == nil) -- Dissonance Field 4
or UnitIsUnit("player", t)
then return true else return false end
end
function SheuronEngine(MO, LOWHP, ACTUALHP)
Nova_Tanks = { }
local MouseoverCheck = MO or false
local ActualHP = ACTUALHP or false
local LowHPTarget = LOWHP or 80
lowhpmembers = 0
members = { { Unit = "player", HP = CalculateHP("player"), GUID = Nova_GUID("player"), AHP = select(2, CalculateHP("player")) } }
-- Check if the Player is apart of the Custom Table
for i=1, #Nova_CustomT do
if Nova_GUID("player") == Nova_CustomT[i].GUID then
Nova_CustomT[i] = { Unit = "player", HP = CalculateHP("player"), AHP = select(2, CalculateHP("player")), GUID = Nova_GUID("player") }
end
end
if IsInRaid() then
group = "raid"
elseif IsInGroup() then
group = "party"
end
for i = 1, GetNumGroupMembers() do
local member, memberhp = group..i, CalculateHP(group..i)
local nSkip, nSkipPet = false, false
for r=1, #Nova_BlackList do
if Nova_BlackList[r].GUID == Nova_GUID(member) then
nSkip = true
break
end
end
if not nSkip then
-- Checking all Party/Raid Members for Range/Health
if CanHeal(member) then
-- Checking if Member has threat
if UnitThreatSituation(member) == 3 then memberhp = memberhp - 1 end
-- Checking if Member has Beacon on them
if UnitBuffID(member, 53563) then memberhp = memberhp + 3 end
-- Searing Plasma Check
if UnitDebuffID(member, 109379) then memberhp = memberhp - 9 end
-- Checking if Member is a tank
if UnitGroupRolesAssigned(member) == "TANK" then
memberhp = memberhp - 3
table.insert(Nova_Tanks, { Unit = member, HP = memberhp, AHP = select(2, CalculateHP(member)), GUID = Nova_GUID(member) } )
end
-- If they are in the Custom Table add their info in
for m=1, #Nova_CustomT do
if Nova_GUID(member) == Nova_CustomT[m].GUID then
Nova_CustomT[m] = { Unit = member, HP = memberhp, AHP = select(2, CalculateHP(member)), GUID = Nova_GUID(member) }
end
end
if not UnitIsUnit("player", member) then
table.insert( members,{ Unit = group..i, HP = memberhp, GUID = Nova_GUID(group..i), AHP = select(2, CalculateHP(group..i)) } )
end
end
end
for e=1, #Nova_BlackList do
if Nova_GUID(group..i.."pet") == Nova_BlackList[e].GUID then
nSkipPet = true
break
end
end
if not nSkipPet then
-- Checking Pets in the group
if CanHeal(group..i.."pet") then
local memberpet, memberpethp = nil, nil
if UnitAffectingCombat("player") then
memberpet = group..i.."pet"
memberpethp = CalculateHP(group..i.."pet") * 2
else
memberpet = group..i.."pet"
memberpethp = CalculateHP(group..i.."pet")
end
-- Checking if Pet is apart of the CustomTable
for j=1, #Nova_CustomT do
if Nova_GUID(memberpet) == Nova_CustomT[j].GUID then
Nova_CustomT[j] = { Unit = memberpet, HP = memberpethp, AHP = select(2, CalculateHP(memberpet)), GUID = Nova_GUID(memberpet) }
end
end
table.insert(members, { Unit = memberpet, HP = memberpethp, GUID = Nova_GUID(memberpet), AHP = select(2, CalculateHP(memberpet)) } )
end
end
end
-- This is for special situations, IE world healing or NPC healing in encounters
if UnitExists("target") and CanHeal("target") or SpecialHealUnit("target") then
if not UnitAlreadyTabled("target") then
table.insert(members, { Unit = "tagert", GUID = Nova_GUID("target"), HP = CalculateHP("target"), AHP = select(2, CalculateHP("target")) } )
end
elseif MouseoverCheck and UnitExists("mouseover") and ( CanHeal("mouseover") or SpecialHealUnit("mouseover") ) then
if not UnitAlreadyTabled("mouseover") then
table.insert(members, { Unit = "tagert", GUID = Nova_GUID("mouseover"), HP = CalculateHP("mouseover"), AHP = select(2, CalculateHP("mouseover")) } )
end
elseif UnitExists("focus") and CanHeal("focus") or SpecialHealUnit("focus") then
if not UnitAlreadyTabled("focus") then
table.insert(members, { Unit = "tagert", GUID = Nova_GUID("focus"), HP = CalculateHP("focus"), AHP = select(2, CalculateHP("focus")) } )
end
end
-- So if we pass that ActualHP is true, then we will sort by most health missing. If not, we sort by lowest % of health.
if not ActualHP then
table.sort(members, function(x,y) return x.HP < y.HP end)
if #Nova_Tanks > 0 then
table.sort(Nova_Tanks, function(x,y) return x.HP < y.HP end)
end
elseif ActualHP then
table.sort(members, function(x,y) return x.AHP > y.AHP end)
if #Nova_Tanks > 0 then
table.sort(Nova_Tanks, function(x,y) return x.AHP > y.AHP end)
end
end
-- Setting Low HP Members variable for AoE Healing
for u=1,#members do
if members[u].HP < LowHPTarget then
lowhpmembers = lowhpmembers + 1
end
end
-- Checking Priority Targeting
if UnitExists("target") and (CanHeal("target") or SpecialHealUnit("target")) then
table.sort(members, function(x) if x.GUID == Nova_GUID("target") then return true else return false end end)
elseif UnitExists("mouseover") and ( (CanHeal("mouseover") and GetMouseFocus() ~= WorldFrame ) or SpecialHealUnit("mouseover") ) and MouseoverCheck then
table.sort(members, function(x) if x.GUID == Nova_GUID("mouseover") then return true else return false end end)
end
end
function CheckDistance(unit1,unit2)
local x1,y1 = GetPlayerMapPosition(unit1)
local x2,y2 = GetPlayerMapPosition(unit2)
return sqrt( (x1-x2)^2 + (y1-y2)^2 )
end
function UnitsClose(t, percent)
local PercentToHeal = percent or 85
local n = 0
local NearbyMembers = { }
if distance and distance[1] then
for i=1,#members do
local x = CheckDistance(t,members[i].Unit)
if x ~= 0 and x < distance[1] and members[i].HP < PercentToHeal then n = n + 1; table.insert(NearbyMembers, { Unit = members[i].Unit } ) end
end
end
return n, NearbyMembers
end
function GetDistance()
local playerx,playery = GetPlayerMapPosition("player")
if GetCurrentMapAreaID() ~= xrnMap or GetCurrentMapDungeonLevel() ~= xrnDung then
xrnMap,xrnDung = GetCurrentMapAreaID(), GetCurrentMapDungeonLevel()
mp, distance = {}, {}
end
if #members > 1 and #distance < 10 and playerx ~= 0 and playery ~= 0 then
for i=1,#members do
if CheckInteractDistance(members[i].Unit,2) then
mp[members[i].Unit] = {GetPlayerMapPosition(members[i].Unit)}
elseif UnitInRange(members[i].Unit) and mp[members[i].Unit] then
table.insert(distance,sqrt((mp[members[i].Unit][1] - playerx)^2 + (mp[members[i].Unit][2] - playery)^2))
table.sort(distance)
mp[members[i].Unit] = nil
end
end
end
end
EncryptionSetup = true