Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Author Manaleaf - Sargeras, leaf#1485 if you have any questions.
- function(e,...)
- local timeStamp = GetTime()
- --Returns the current number of Player casted hots on the unit
- local function hotCounter(name)
- local destUnit
- local grpCount = GetNumGroupMembers()
- if UnitInRaid("player") then
- for i = 1, grpCount do
- local name2,realm2 = UnitName("raid"..i)
- if realm2 then name2 = name2 .. "-" .. realm2 end
- if name2 == name then
- destUnit = "raid" .. i
- break
- end
- end
- elseif UnitInParty("player") then
- for i = 1, grpCount do
- local name2,realm2 = UnitName("party"..i)
- if realm2 then name2 = name2 .. "-" .. realm2 end
- if name2 == name then
- destUnit = "party" .. i
- break
- end
- end
- elseif UnitName("player") == name then
- destUnit = "player"
- end
- if not destUnit then
- return -1 --Failure Flag
- end
- local hCount = 0
- for k,v in ipairs(aura_env.hotList) do
- local spellName = GetSpellInfo(v)
- if UnitBuff(destUnit, spellName, nil, "PLAYER") then hCount = hCount + 1 end
- end
- return hCount
- end
- --Debug function
- --local function printTables(t1, t2, t3)
- -- if not(t1[1]) then
- -- print("Empty List")
- -- else
- -- for i = 1, #t1, 1 do
- -- print(t1[i], t2[i], t3[i])
- -- end
- -- print("print has printed.")
- -- end
- --end
- --Inserts a row into a chain of tables.
- local function insert(i, t1, t2, t3)
- tinsert(WA_RDSW_expire, i, t1)
- tinsert(WA_RDSW_guid, i, t2)
- tinsert(WA_RDSW_reduce, i, t3)
- end
- --Removes a row into a chain of tables.
- local function removet(i, t1, t2, t3)
- table.remove(t1, i)
- table.remove(t2, i)
- table.remove(t3, i)
- end
- --Function Registers Living Seeds that are the result of a Regrowth crit as to reduced their contribution to crit healing
- -- by the percentage of bonus crit that makes up Regrowth's chance to crit. (Crit% - baseCrit% / Crit% + regrowth's passive crit%)
- --Living Seeds that are the result of Regrowth crits are stored on 3 tables and timestamped.
- --If timeStamp < current time, entry is removed.
- --If timeStamp >= current time and target is the current target of the heal,
- -- entry is updated (reduction is added to existing total, time stamp is set to new time)
- --If table entry is nil, information is inserted.
- local function regrowth(guid, heal)
- local reduceHeal = heal * 0.5
- local i = 1
- while(i <= #WA_RDSW_expire + 1) do
- --if No Record (insert)
- if not(WA_RDSW_expire[i])then
- insert(i, timeStamp + 15, guid, reduceHeal)
- break;
- --If Record has not expired
- elseif WA_RDSW_expire[i] >= timeStamp then
- --If Record is of target (update)
- if WA_RDSW_guid[i] == guid then
- WA_RDSW_expire[i] = timeStamp + 15
- WA_RDSW_reduce[i] = WA_RDSW_reduce[i] + reduceHeal
- break;
- end
- --If Record is expired (remove)
- elseif WA_RDSW_expire[i] < timeStamp then
- removet(i, WA_RDSW_expire, WA_RDSW_guid, WA_RDSW_reduce)
- i = i - 1
- end
- i = i + 1
- end
- end
- --Function is called when an ally is healed by a living seed whose source is the player.
- --Function accesses a register of tables. (and removes expired entries) if the target if Living seed is boththe Registers Living Seeds that are the result of a Regrowth crit as to reduced their contribution to crit healing
- --by the percentage of bonus crit that makes up Regrowth's chance to crit. (Crit% - baseCrit% / Crit% + regrowth's passive crit%)
- local function livingSeed(guid, heal, overHeal, mstPerc, hCount)
- local statSum = mstPerc + aura_env.vrsPerc
- local baseHeal = heal / ((1 + mstPerc) * (1 + aura_env.vrsPerc))
- local statHeal = heal - baseHeal
- local crtHeal = (baseHeal + 0.5 * statHeal) * ( aura_env.bonusCrt / aura_env.crtPerc) --CONSTANT: 0.5 <- half the contribution of mst and vrs
- local mstHeal = aura_env.bonusMst / (mstPerc * 2) * heal * hCount
- local vrsHeal = aura_env.bonusVrs / ( aura_env.vrsPerc * 2) * heal
- local reduce = 0
- --Table Management
- local i = 1
- while(i <= #WA_RDSW_expire + 1) do
- --If Record has not expired
- if WA_RDSW_expire[i] >= timeStamp then
- --If Record is of target (read, remove and break loop)
- if WA_RDSW_guid[i] == guid then
- reduce = WA_RDSW_reduce[i]
- removet(i, WA_RDSW_expire, WA_RDSW_guid, WA_RDSW_reduce)
- break
- end
- --If Record is expired (remove)
- elseif WA_RDSW_expire[i] < timeStamp then
- removet(i, WA_RDSW_expire, WA_RDSW_guid, WA_RDSW_reduce)
- i = i - 1
- end
- end
- reduce = reduce * (1 - aura_env.bonusCrt / ( aura_env.crtPerc + aura_env.regrowthBaseCrt))
- local statHealSum = crtHeal + mstHeal + vrsHeal
- crtHeal = crtHeal - (crtHeal / statHealSum) * reduce - overHeal
- if crtHeal < 0 then crtHeal = 0 end
- mstHeal = mstHeal - (mstHeal / statHealSum) * reduce - overHeal
- if mstHeal < 0 then mstHeal = 0 end
- vrsHeal = vrsHeal - (vrsHeal / statHealSum) * reduce - overHeal
- if vrsHeal < 0 then vrsHeal = 0 end
- return crtHeal, mstHeal, vrsHeal, 0
- end
- --Function finds the lowest non-zero, non-negative value
- --Still returns 0 if all arguements are 0.
- local function maxButNotZero(n1, n2, n3, n4)
- local max = 1
- if n1 ~= nil and n1 > max then max = n1 end
- if n2 ~= nil and n2 > max then max = n2 end
- if n3 ~= nil and n3 > max then max = n3 end
- if n4 ~= nil and n4 > max then max = n4 end
- return max
- end
- --Allocates stat values
- local function allocate(mstHeal, hstHeal, crtHeal, vrsHeal)
- --Total Raw Healing Score Allocation
- LEAFUI_TTL_MST_HEAL = LEAFUI_TTL_MST_HEAL + mstHeal
- LEAFUI_TTL_HST_HEAL = LEAFUI_TTL_HST_HEAL + hstHeal
- LEAFUI_TTL_CRT_HEAL = LEAFUI_TTL_CRT_HEAL + crtHeal
- LEAFUI_TTL_VRS_HEAL = LEAFUI_TTL_VRS_HEAL + vrsHeal
- --Current Encounter Healing Score Allocation
- LEAFUI_CUR_MST_HEAL = LEAFUI_CUR_MST_HEAL + mstHeal
- LEAFUI_CUR_HST_HEAL = LEAFUI_CUR_HST_HEAL + hstHeal
- LEAFUI_CUR_CRT_HEAL = LEAFUI_CUR_CRT_HEAL + crtHeal
- LEAFUI_CUR_VRS_HEAL = LEAFUI_CUR_VRS_HEAL + vrsHeal
- --Stat Value Score Allocation
- local mstCurVal
- local mstTtlVal
- local hstCurVal
- local hstTtlVal
- local crtCurVal
- local crtTtlVal
- local vrsCurVal
- local vrsTtlVal
- if aura_env.mstRating > 0 then
- mstCurVal = LEAFUI_CUR_MST_HEAL / aura_env.mstRating
- mstTtlVal = LEAFUI_TTL_MST_HEAL / aura_env.mstRating
- else
- mstCurVal = 0
- mstTtlVal = 0
- end
- if aura_env.hstRating > 0 then
- hstCurVal = LEAFUI_CUR_HST_HEAL / aura_env.hstRating
- hstTtlVal = LEAFUI_TTL_HST_HEAL / aura_env.hstRating
- else
- hstCurVal = 0
- hstTtlVal = 0
- end
- if aura_env.crtRating > 0 then
- crtCurVal = LEAFUI_CUR_CRT_HEAL / aura_env.crtRating
- crtTtlVal = LEAFUI_TTL_CRT_HEAL / aura_env.crtRating
- else
- crtCurVal = 0
- crtTtlVal = 0
- end
- if aura_env.vrsRating > 0 then
- vrsCurVal = LEAFUI_CUR_VRS_HEAL / aura_env.vrsRating
- vrsTtlVal = LEAFUI_TTL_VRS_HEAL / aura_env.vrsRating
- else
- vrsCurVal = 0
- vrsTtlVal = 0
- end
- local maxCurHeal = maxButNotZero(mstCurVal, hstCurVal, crtCurVal, vrsCurVal)
- local maxTtlHeal = maxButNotZero(mstTtlVal, hstTtlVal, crtTtlVal, vrsTtlVal)
- if mstCurVal > 0 then
- LEAFUI_CUR_MST = mstCurVal / maxCurHeal
- end
- if hstCurVal > 0 then
- LEAFUI_CUR_HST = hstCurVal / maxCurHeal
- end
- if crtCurVal > 0 then
- LEAFUI_CUR_CRT = crtCurVal / maxCurHeal
- end
- if vrsCurVal > 0 then
- LEAFUI_CUR_VRS = vrsCurVal / maxCurHeal
- end
- if mstTtlVal > 0 then
- LEAFUI_TTL_MST = mstTtlVal / maxTtlHeal
- end
- if hstTtlVal > 0 then
- LEAFUI_TTL_HST = hstTtlVal / maxTtlHeal
- end
- if crtTtlVal > 0 then
- LEAFUI_TTL_CRT = crtTtlVal / maxTtlHeal
- end
- if vrsTtlVal > 0 then
- LEAFUI_TTL_VRS = vrsTtlVal / maxTtlHeal
- end
- end
- --Set and calculates healing and stat weight values
- local function decompHeal(heal, overHeal, name, crtFlag, hstFlag, sName, sklFlag, tGuid)
- local hCount = hotCounter(name)
- local mstPerc = aura_env.mstPerc * hCount
- local hstPerc --Local hstPerc is only applied on hots.
- if hstFlag then
- hstPerc = aura_env.hstPerc
- else hstPerc = 0
- end
- local crtBonus --Local CrtBonus only applies on Crits.
- if crtFlag == true then
- crtBonus = 1 + aura_env.taurenRacial
- else crtBonus = 0
- end
- --Heal Calculation
- local baseHeal
- local baseHeal = heal / ( (1 + mstPerc) * (1 + aura_env.hstPerc) * (1 + aura_env.crtPerc) * (1 + aura_env.vrsPerc) )
- local statHeal = heal - baseHeal - overHeal
- local statSum = mstPerc + aura_env.hstPerc + crtBonus + aura_env.vrsPerc
- local baseHeal = heal / ( (1 + mstPerc) * (1 + aura_env.hstPerc) * (1 + crtBonus) * (1 + aura_env.vrsPerc) )
- local statHeal = heal - baseHeal - overHeal
- local statSum = mstPerc + aura_env.hstPerc + crtBonus + aura_env.vrsPerc
- local mstHeal
- local hstHeal
- local vrsHeal
- local crtHeal
- if statHeal > 0 and statSum > 0 and heal > baseHeal then --Cut out redundant computations if overheal exceeds healing from all secondary stats combined.
- --If Heal is Living Seed
- if sklFlag == 2 then
- crtHeal, mstHeal, vrsHeal, hstHeal = livingSeed(tGuid, heal, overHeal, mstPerc, hCount)
- else
- mstHeal = aura_env.bonusMst * hCount / statSum * statHeal
- hstHeal = aura_env.bonusHst / statSum * statHeal
- vrsHeal = aura_env.bonusVrs / statSum * statHeal
- --if heal is not a crit
- if not(crtFlag) then
- crtHeal = 0
- elseif sklFlag == 1 then --if heal is a crit
- regrowth(tGuid, heal)
- --Unique calc for Regrowth Crit
- crtHeal = ( aura_env.bonusCrt / ( aura_env.crtPerc + aura_env.regrowthBaseCrt)) * ( crtBonus / statSum) * statHeal
- else
- --All non-conditional crit that is successfully applied.
- crtHeal = ( aura_env.bonusCrt / aura_env.crtPerc) * ( crtBonus / statSum) * statHeal
- end
- end
- else
- mstHeal = 0
- hstHeal = 0
- crtHeal = 0
- vrsHeal = 0
- end
- allocate(mstHeal, hstHeal, crtHeal, vrsHeal)
- end
- --Debug function
- --local function printSavedTable(t)
- -- print(t[1])
- -- if not(t[1]) then
- -- print("Empty List")
- -- else
- -- for i = 1, #t, 1 do
- -- print(t[i])
- -- end
- -- print("Saved print has printed.")
- -- end
- --end
- --Sets Encounter data to be printed to file.
- --Para mode: sets print out to stat either "WIPE" if mode - 0 or "KILL" if mode = 1
- local function printToFile(eID, eName, difficulty, raidSize, mode)
- local outcome
- if mode == 0 or mode == 1 then
- if mode == 0 then outcome = "WIPE"
- elseif mode == 1 then outcome = "KILL"
- end
- local outString = "ENCOUNTER: %s eID: %d "
- .. "Time: %s "
- .. "Player: %s"
- .. "Difficulty: %d raidSize: %d "
- .. "Outcome: %s "
- .. "+_"
- .. "MST: %.4f "
- .. "HST: %.4f "
- .. "CRT: %.4f "
- .. "VRS: %.4f "
- .. "_+"
- .. "MST_H: %.2f "
- .. "HST_H: %.2f "
- .. "CRT_H: %.2f "
- .. "VRS_H: %.2f "
- tinsert(Leaf_RDSW, format(outString,
- eName,
- eID,
- aura_env.time,
- UnitName("player"),
- difficulty,
- raidSize,
- outcome,
- LEAFUI_CUR_MST,
- LEAFUI_CUR_HST,
- LEAFUI_CUR_CRT,
- LEAFUI_CUR_VRS,
- LEAFUI_CUR_MST_HEAL,
- LEAFUI_CUR_HST_HEAL,
- LEAFUI_CUR_CRT_HEAL,
- LEAFUI_CUR_VRS_HEAL))
- end
- end
- --Clears the current healing and stat values
- local function clearStats()
- LEAFUI_CUR_MST = 0
- LEAFUI_CUR_HST = 0
- LEAFUI_CUR_CRT = 0
- LEAFUI_CUR_VRS = 0
- LEAFUI_CUR_MST_HEAL = 0
- LEAFUI_CUR_HST_HEAL = 0
- LEAFUI_CUR_CRT_HEAL = 0
- LEAFUI_CUR_VRS_HEAL = 0
- end
- --MAIN--
- if e == "UNIT_STATS" or e == "COMBAT_RATING_UPDATE" then
- aura_env.mstRating = GetCombatRating(CR_MASTERY)
- aura_env.hstRating = GetCombatRating(CR_HASTE_SPELL)
- aura_env.crtRating = GetCombatRating(CR_CRIT_SPELL)
- aura_env.vrsRating = GetCombatRating(CR_VERSATILITY_DAMAGE_DONE)
- aura_env.bonusMst = aura_env.mstRating / aura_env.mstRatingConv / 100
- aura_env.bonusHst = aura_env.hstRating / aura_env.hstRatingConv / 100
- aura_env.bonusCrt = aura_env.crtRating / aura_env.crtRatingConv / 100
- aura_env.bonusVrs = aura_env.vrsRating / aura_env.vrsRatingConv / 100
- aura_env.mstPerc = GetMasteryEffect() / 100--GetCombatRatingBonus(26) / 100 * hCount
- aura_env.hstPerc = UnitSpellHaste("player") / 100
- aura_env.crtPerc = GetCritChance() / 100
- aura_env.vrsPerc = (GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_DONE) + GetVersatilityBonus(CR_VERSATILITY_DAMAGE_DONE)) / 100
- return true
- end
- if e == "ENCOUNTER_START" then
- print("Boss Encounter has begun. Recording")
- aura_env.time = date("%m/%d/%y %H:%M:%S")
- aura_env.encounter = true
- clearStats()
- elseif e == "ENCOUNTER_END" then
- print("Boss Encounter has Ended. Recording to file.")
- printToFile(...)
- aura_env.encounter = false
- elseif e == "COMBAT_LOG_EVENT_UNFILTERED" then
- local heal, overHeal, crtFlag, effHeal, sName, hstFlag, sklFlag, tGuid
- sklFlag = 0
- type = select(2, ...)
- if select(4, ...) == UnitGUID("player") then
- --Hot Spells (haste effected)
- sName = select(13,...)
- if type == "SPELL_PERIODIC_HEAL" then
- if sName == aura_env.spells.rejuvenation
- or sName == aura_env.spells.germination
- or sName == aura_env.spells.lifebloom
- or sName == aura_env.spells.regrowth
- or sName == aura_env.spells.wildgrowth
- or sName == aura_env.spells.springblossoms
- or sName == aura_env.spells.cultivation
- or sName == aura_env.spells.cenarionward
- then hstFlag = true end
- --Direct Healing Spells (Mostly not Haste Effected)
- elseif type == "SPELL_HEAL" then
- sName,_= select(13,...)
- if sName == aura_env.spells.efflorescence then hstFlag = true
- elseif sName == aura_env.spells.regrowth then
- sklFlag = 1
- hstFlag = false
- elseif sName == aura_env.spells.livingseed then
- sklFlag = 2
- hstFlag = false
- elseif sName == aura_env.spells.swiftmend
- or sName == aura_env.spells.healingtouch
- or sName == aura_env.spells.lifebloom
- or sName == aura_env.spells.tranquility
- or sName == aura_env.spells.renewal
- then hstFlag = false end
- end
- if hstFlag ~= nil then --If hstFlag == nil, healing was not done by a spell in the above listing. ie: Ysera's gift is uneffected by secondaries
- tGuid, name,_= select(8,...)
- heal,overHeal,_,crtFlag,_ = select(15,...)
- decompHeal(heal, overHeal, name, crtFlag, hstFlag, sName, sklFlag, tGuid)
- end
- end
- WeakAuras.ScanEvents("LEAFUI_RDSW_UPDATE")
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement