Skip to content

Commit

Permalink
Add "debuffTYpe" parameter to state:AddAuraToGUID().
Browse files Browse the repository at this point in the history
This change also adds support for "curse=1", "disease=1", "enrage=1",
"magic=1" and "poison=1" SpellInfo() parameters to allow tagging auras as
one of those debuff/dispel types.
  • Loading branch information
johnnylam88 committed Jan 13, 2015
1 parent 9f5c0ea commit ea41dfc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
33 changes: 26 additions & 7 deletions Aura.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ local ipairs = ipairs
local next = next
local pairs = pairs
local strfind = string.find
local strlower = string.lower
local strmatch = string.match
local strsub = string.sub
local tconcat = table.concat
Expand Down Expand Up @@ -138,13 +139,20 @@ do
end

-- Aura debuff types.
local DEBUFF_TYPES = {
local DEBUFF_TYPE = {
Curse = true,
Disease = true,
Enrage = true,
Magic = true,
Poison = true,
}
local SPELLINFO_DEBUFF_TYPE = {}
do
for debuffType in pairs(DEBUFF_TYPE) do
local siDebuffType = strlower(debuffType)
SPELLINFO_DEBUFF_TYPE[siDebuffType] = debuffType
end
end

-- CLEU events triggered by auras being applied, removed, refreshed, or changed in stack size.
local CLEU_AURA_EVENTS = {
Expand Down Expand Up @@ -251,7 +259,7 @@ end

local function GetAuraOnGUID(auraDB, guid, auraId, filter, mine)
local auraFound
if DEBUFF_TYPES[auraId] then
if DEBUFF_TYPE[auraId] then
if mine then
auraFound = GetDebuffType(auraDB, guid, auraId, filter, self_guid)
else
Expand Down Expand Up @@ -1097,7 +1105,7 @@ end

local function GetStateAuraOnGUID(state, guid, auraId, filter, mine)
local auraFound
if DEBUFF_TYPES[auraId] then
if DEBUFF_TYPE[auraId] then
if mine then
auraFound = GetStateDebuffType(state, guid, auraId, filter, self_guid)
else
Expand Down Expand Up @@ -1204,7 +1212,7 @@ statePrototype.ApplySpellAuras = function(state, spellId, guid, atTime, auraList
aura = auraFound
else
-- Add an aura in the simulator and copy the existing aura information over.
aura = state:AddAuraToGUID(guid, auraId, auraFound.source, filter, 0, INFINITY)
aura = state:AddAuraToGUID(guid, auraId, auraFound.source, filter, nil, 0, INFINITY)
for k, v in pairs(auraFound) do
aura[k] = v
end
Expand Down Expand Up @@ -1291,7 +1299,16 @@ statePrototype.ApplySpellAuras = function(state, spellId, guid, atTime, auraList
-- Spellcast causes a new aura.
state:Log("New aura %d at %f on %s", auraId, atTime, guid)
-- Add an aura in the simulator and copy the existing aura information over.
local aura = state:AddAuraToGUID(guid, auraId, self_guid, filter, 0, INFINITY)
local debuffType
if si then
for k, v in pairs(SPELLINFO_DEBUFF_TYPE) do
if si[k] == 1 then
debuffType = v
break
end
end
end
local aura = state:AddAuraToGUID(guid, auraId, self_guid, filter, debuffType, 0, INFINITY)
-- Information that needs to be set below: stacks, start, ending, duration, gain.
aura.stacks = stacks
-- Set start and duration for aura.
Expand Down Expand Up @@ -1350,7 +1367,7 @@ statePrototype.GetAura = function(state, unitId, auraId, filter, mine)
end

-- Add a new aura to the unit specified by GUID.
statePrototype.AddAuraToGUID = function(state, guid, auraId, casterGUID, filter, start, ending, snapshot)
statePrototype.AddAuraToGUID = function(state, guid, auraId, casterGUID, filter, debuffType, start, ending, snapshot)
local aura = self_pool:Get()
aura.state = true
aura.serial = state.serial
Expand All @@ -1362,6 +1379,8 @@ statePrototype.AddAuraToGUID = function(state, guid, auraId, casterGUID, filter,
aura.duration = ending - start
aura.gain = aura.start
aura.stacks = 1
aura.debuffType = debuffType
aura.enrage = (debuffType == "Enrage") or nil
if snapshot then
aura.snapshot = OvalePaperDoll:GetSnapshot(snapshot)
end
Expand All @@ -1379,7 +1398,7 @@ statePrototype.RemoveAuraOnGUID = function(state, guid, auraId, filter, mine, at
aura = auraFound
else
-- Add an aura in the simulator and copy the existing aura information over.
aura = state:AddAuraToGUID(guid, auraId, auraFound.source, filter, 0, INFINITY)
aura = state:AddAuraToGUID(guid, auraId, auraFound.source, filter, nil, 0, INFINITY)
for k, v in pairs(auraFound) do
aura[k] = v
end
Expand Down
2 changes: 1 addition & 1 deletion ComboPoints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ function OvaleComboPoints:ApplySpellAfterCast(state, spellId, targetGUID, startC
-- Add a new Anticipation buff with the updated start, ending, stacks information.
local start = endCast
local ending = start + ANTICIPATION_DURATION
aura = state:AddAuraToGUID(self_guid, ANTICIPATION, self_guid, "HELPFUL", start, ending)
aura = state:AddAuraToGUID(self_guid, ANTICIPATION, self_guid, "HELPFUL", nil, start, ending)
aura.stacks = stacks
end
power = MAX_COMBO_POINTS
Expand Down
6 changes: 3 additions & 3 deletions Eclipse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ end
statePrototype.ApplyEclipseEnergy = function(state, spellId, atTime, snapshot)
OvaleEclipse:StartProfiling("OvaleEclipse_ApplyEclipseEnergy")
if spellId == CELESTIAL_ALIGNMENT then
local aura = state:AddAuraToGUID(self_guid, spellId, self_guid, "HELPFUL", atTime, atTime + 15, snapshot)
local aura = state:AddAuraToGUID(self_guid, spellId, self_guid, "HELPFUL", nil, atTime, atTime + 15, snapshot)
aura.value1 = state:EclipseBonusDamage(atTime, snapshot)
-- Celestial Alignment grants the spell effects of both Lunar and Solar Eclipse and
-- also resets the total Eclipse energy to zero.
Expand Down Expand Up @@ -353,11 +353,11 @@ statePrototype.AddEclipse = function(state, eclipseId, atTime, snapshot)
if eclipseId == LUNAR_ECLIPSE or eclipseId == SOLAR_ECLIPSE then
local eclipseName = (eclipseId == LUNAR_ECLIPSE) and "Lunar" or "Solar"
state:Log(" Adding %s Eclipse (%d) at %f", eclipseName, eclipseId, atTime)
local aura = state:AddAuraToGUID(self_guid, eclipseId, self_guid, "HELPFUL", atTime, INFINITY, snapshot)
local aura = state:AddAuraToGUID(self_guid, eclipseId, self_guid, "HELPFUL", nil, atTime, INFINITY, snapshot)
-- Set the value of the Eclipse aura to the Eclipse's bonus damage.
aura.value1 = state:EclipseBonusDamage(atTime, snapshot)
-- Reaching Eclipse state grants Nature's Grace.
state:AddAuraToGUID(self_guid, NATURES_GRACE, self_guid, "HELPFUL", atTime, atTime + 15, snapshot)
state:AddAuraToGUID(self_guid, NATURES_GRACE, self_guid, "HELPFUL", nil, atTime, atTime + 15, snapshot)
-- Reaching Lunar Eclipse resets the cooldown of Starfall.
if eclipseId == LUNAR_ECLIPSE then
state:ResetSpellCooldown(STARFALL, atTime)
Expand Down

0 comments on commit ea41dfc

Please sign in to comment.