Johnny C. Lam [05-05-14 - 18:03]
diff --git a/OvaleAura.lua b/OvaleAura.lua
index b948c2a..7161734 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -365,7 +365,7 @@ function OvaleAura:IsActiveAura(aura, now)
now = now or API_GetTime()
local boolean = false
if aura then
- if aura.serial == self.serial[aura.guid] and aura.stacks > 0 and aura.start <= now and now <= aura.ending then
+ if aura.serial == self.serial[aura.guid] and aura.stacks > 0 and aura.gain <= now and now <= aura.ending then
boolean = true
elseif aura.consumed and IsWithinAuraLag(aura.ending, now) then
boolean = true
@@ -388,7 +388,7 @@ function OvaleAura:GainedAuraOnGUID(guid, atTime, auraId, casterGUID, filter, vi
local aura = GetAura(self.aura, guid, auraId, casterGUID)
local auraIsActive
if aura then
- auraIsActive = (aura.stacks > 0 and aura.start <= atTime and atTime <= aura.ending)
+ auraIsActive = (aura.stacks > 0 and aura.gain <= atTime and atTime <= aura.ending)
else
aura = self_pool:Get()
PutAura(self.aura, guid, auraId, casterGUID, aura)
@@ -892,7 +892,7 @@ statePrototype.IsActiveAura = function(state, aura, now)
local boolean = false
if aura then
if aura.state then
- if aura.serial == state.serial and aura.stacks > 0 and aura.start <= now and now <= aura.ending then
+ if aura.serial == state.serial and aura.stacks > 0 and aura.gain <= now and now <= aura.ending then
boolean = true
elseif aura.consumed and IsWithinAuraLag(aura.ending, now) then
boolean = true
@@ -949,13 +949,14 @@ statePrototype.ApplySpellAuras = function(state, spellId, guid, startCast, endCa
end
-- Reset the aura age relative to the state of the simulator.
aura.serial = state.serial
+ Ovale:Logf("Aura %d is copied into simulator.", auraId)
-- Information that needs to be set below: stacks, start, ending, duration, gain.
end
-- Spell starts channeling before the aura expires, or spellcast ends before the aura expires.
if spellData == "refresh" or stacks > 0 then
-- Adjust stack count.
if spellData == "refresh" then
- Ovale:Logf("Aura %d is refreshed.", auraId)
+ Ovale:Logf("Aura %d is refreshed to %d stack(s).", auraId, aura.stacks)
else -- if stacks > 0 then
local maxstacks = 1
if si and si.maxstacks then
@@ -986,7 +987,7 @@ statePrototype.ApplySpellAuras = function(state, spellId, guid, startCast, endCa
end
aura.ending = aura.start + aura.duration
aura.gain = atTime
- Ovale:Logf("Aura %d now ending at %f", auraId, aura.ending)
+ Ovale:Logf("Aura %d with duration %s now ending at %f", auraId, aura.duration, aura.ending)
elseif stacks == 0 or stacks < 0 then
if stacks == 0 then
aura.stacks = 0
@@ -1105,17 +1106,16 @@ statePrototype.GetAuraWithProperty = function(state, unitId, propertyName, filte
local count = 0
local guid = OvaleGUID:GetGUID(unitId)
local start, ending = math.huge, 0
- local now = state.currentTime
-- Loop through auras not kept in the simulator that match the criteria.
if OvaleAura.aura[guid] then
for auraId, whoseTable in pairs(OvaleAura.aura[guid]) do
for casterGUID in pairs(whoseTable) do
local aura = GetStateAura(state, guid, auraId, self_guid)
- if state:IsActiveAura(aura, now) and not aura.state then
+ if state:IsActiveAura(aura) and not aura.state then
if aura[propertyName] and aura.filter == filter then
count = count + 1
- start = (aura.start < start) and aura.start or start
+ start = (aura.gain < start) and aura.gain or start
ending = (aura.ending > ending) and aura.ending or ending
end
end
@@ -1126,10 +1126,10 @@ statePrototype.GetAuraWithProperty = function(state, unitId, propertyName, filte
if state.aura[guid] then
for auraId, whoseTable in pairs(state.aura[guid]) do
for casterGUID, aura in pairs(whoseTable) do
- if state:IsActiveAura(aura, now) then
+ if state:IsActiveAura(aura) then
if aura[propertyName] and aura.filter == filter then
count = count + 1
- start = (aura.start < start) and aura.start or start
+ start = (aura.gain < start) and aura.gain or start
ending = (aura.ending > ending) and aura.ending or ending
end
end
@@ -1153,10 +1153,10 @@ do
local function CountMatchingActiveAura(aura)
count = count + 1
if aura.ending < endingChangeCount then
- startChangeCount, endingChangeCount = aura.start, aura.ending
+ startChangeCount, endingChangeCount = aura.gain, aura.ending
end
- if aura.start < startFirst then
- startFirst = aura.start
+ if aura.gain < startFirst then
+ startFirst = aura.gain
end
if aura.ending > endingLast then
endingLast = aura.ending
@@ -1175,20 +1175,18 @@ do
startChangeCount, endingChangeCount = math.huge, math.huge
startFirst, endingLast = math.huge, 0
- local now = state.currentTime
-
-- Loop through auras not kept in the simulator that match the criteria.
for guid, auraTable in pairs(OvaleAura.aura) do
if auraTable[auraId] then
if mine then
local aura = GetStateAura(state, guid, auraId, self_guid)
- if state:IsActiveAura(aura, now) and aura.filter == filter and aura.stacks >= minStacks and not aura.state then
+ if state:IsActiveAura(aura) and aura.filter == filter and aura.stacks >= minStacks and not aura.state then
CountMatchingActiveAura(aura)
end
else
for casterGUID in pairs(auraTable[auraId]) do
local aura = GetStateAura(state, guid, auraId, casterGUID)
- if state:IsActiveAura(aura, now) and aura.filter == filter and aura.stacks >= minStacks and not aura.state then
+ if state:IsActiveAura(aura) and aura.filter == filter and aura.stacks >= minStacks and not aura.state then
CountMatchingActiveAura(aura)
end
end
@@ -1201,13 +1199,13 @@ do
if mine then
local aura = auraTable[auraId][self_guid]
if aura then
- if state:IsActiveAura(aura, now) and aura.filter == filter and aura.stacks >= minStacks then
+ if state:IsActiveAura(aura) and aura.filter == filter and aura.stacks >= minStacks then
CountMatchingActiveAura(aura)
end
end
else
for casterGUID, aura in pairs(auraTable[auraId]) do
- if state:IsActiveAura(aura, now) and aura.filter == filter and aura.stacks >= minStacks then
+ if state:IsActiveAura(aura) and aura.filter == filter and aura.stacks >= minStacks then
CountMatchingActiveAura(aura)
end
end
@@ -1215,6 +1213,7 @@ do
end
end
+ Ovale:Logf("AuraCount(%d) is %s, %s, %s, %s, %s", auraId, count, startChangeCount, endingChangeCount, startFirst, endingLast)
return count, startChangeCount, endingChangeCount, startFirst, endingLast
end
end
diff --git a/conditions/BuffAmount.lua b/conditions/BuffAmount.lua
index f3a2eca..39a07c0 100644
--- a/conditions/BuffAmount.lua
+++ b/conditions/BuffAmount.lua
@@ -55,9 +55,9 @@ do
end
local aura = state:GetAura(target, auraId, filter, mine)
if state:IsActiveAura(aura) then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
local value = aura[statName] or 0
- return TestValue(start, ending, value, start, 0, comparator, limit)
+ return TestValue(gain, ending, value, start, 0, comparator, limit)
end
return Compare(0, comparator, limit)
end
diff --git a/conditions/BuffComboPoints.lua b/conditions/BuffComboPoints.lua
index a4689ab..b2b320a 100644
--- a/conditions/BuffComboPoints.lua
+++ b/conditions/BuffComboPoints.lua
@@ -38,9 +38,9 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if state:IsActiveAura(aura) then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
local value = aura and aura.combo or 0
- return TestValue(start, ending, value, start, 0, comparator, limit)
+ return TestValue(gain, ending, value, start, 0, comparator, limit)
end
return Compare(0, comparator, limit)
end
diff --git a/conditions/BuffCountOnAny.lua b/conditions/BuffCountOnAny.lua
index f7aaab1..bee5e35 100644
--- a/conditions/BuffCountOnAny.lua
+++ b/conditions/BuffCountOnAny.lua
@@ -39,7 +39,6 @@ do
local _, filter, mine = ParseCondition(condition)
local count, startChangeCount, endingChangeCount, startFirst, endingLast = state:AuraCount(auraId, filter, mine, condition.stacks)
- Ovale:Logf("BuffCount(%d) is %s, %s, %s, %s, %s", auraId, count, startChangeCount, endingChangeCount, startFirst, endingLast)
if count > 0 and startChangeCount < math.huge then
local origin = startChangeCount
local rate = -1 / (endingChangeCount - startChangeCount)
diff --git a/conditions/BuffDamageMultiplier.lua b/conditions/BuffDamageMultiplier.lua
index 7955e81..265e5c8 100644
--- a/conditions/BuffDamageMultiplier.lua
+++ b/conditions/BuffDamageMultiplier.lua
@@ -38,11 +38,11 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if state:IsActiveAura(aura) then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
local baseDamageMultiplier = aura.snapshot and aura.snapshot.baseDamageMultiplier or 1
local damageMultiplier = aura.damageMultiplier or 1
local value = baseDamageMultiplier * damageMultiplier
- return TestValue(start, ending, value, start, 0, comparator, limit)
+ return TestValue(gain, ending, value, start, 0, comparator, limit)
end
return Compare(1, comparator, limit)
end
diff --git a/conditions/BuffDuration.lua b/conditions/BuffDuration.lua
index e92b08e..5a92882 100644
--- a/conditions/BuffDuration.lua
+++ b/conditions/BuffDuration.lua
@@ -36,9 +36,9 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if state:IsActiveAura(aura) then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
local value = ending - start
- return TestValue(start, ending, value, start, 0, comparator, limit)
+ return TestValue(gain, ending, value, start, 0, comparator, limit)
end
return Compare(0, comparator, limit)
end
diff --git a/conditions/BuffExpires.lua b/conditions/BuffExpires.lua
index 87e3cdc..01a275d 100644
--- a/conditions/BuffExpires.lua
+++ b/conditions/BuffExpires.lua
@@ -61,10 +61,10 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if aura then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
seconds = TimeWithHaste(seconds or 0, condition.haste)
- if ending - seconds <= start then
- return start, math.huge
+ if ending - seconds <= gain then
+ return gain, math.huge
else
return ending - seconds, math.huge
end
@@ -103,12 +103,12 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if aura then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
seconds = TimeWithHaste(seconds or 0, condition.haste)
- if ending - seconds <= start then
+ if ending - seconds <= gain then
return nil
else
- return start, ending - seconds
+ return gain, ending - seconds
end
end
return nil
diff --git a/conditions/BuffRemains.lua b/conditions/BuffRemains.lua
index 406b4c3..6f6747c 100644
--- a/conditions/BuffRemains.lua
+++ b/conditions/BuffRemains.lua
@@ -42,8 +42,8 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if aura then
- local start, ending = aura.start, aura.ending
- return TestValue(start, math.huge, ending - start, start, -1, comparator, limit)
+ local gain, start, ending = aura.gain, aura.start, aura.ending
+ return TestValue(gain, math.huge, 0, ending, -1, comparator, limit)
end
return Compare(0, comparator, limit)
end
diff --git a/conditions/BuffRemainsOnAny.lua b/conditions/BuffRemainsOnAny.lua
index 01830f2..6de1b6b 100644
--- a/conditions/BuffRemainsOnAny.lua
+++ b/conditions/BuffRemainsOnAny.lua
@@ -41,7 +41,7 @@ do
local count, startChangeCount, endingChangeCount, startFirst, endingLast = state:AuraCount(auraId, filter, mine, condition.stacks)
if count > 0 then
local start, ending = startFirst, endingLast
- return TestValue(start, math.huge, ending - start, start, -1, comparator, limit)
+ return TestValue(start, math.huge, 0, ending, -1, comparator, limit)
end
return Compare(0, comparator, limit)
end
diff --git a/conditions/BuffSnapshot.lua b/conditions/BuffSnapshot.lua
index 4aeb7e7..112de7f 100644
--- a/conditions/BuffSnapshot.lua
+++ b/conditions/BuffSnapshot.lua
@@ -24,9 +24,9 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if state:IsActiveAura(aura) then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
local value = aura.snapshot and aura.snapshot[statName] or defaultValue
- return TestValue(start, ending, value, start, 0, comparator, limit)
+ return TestValue(gain, ending, value, start, 0, comparator, limit)
end
return Compare(defaultValue, comparator, limit)
end
@@ -37,12 +37,12 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if state:IsActiveAura(aura) then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
local value = aura.snapshot and aura.snapshot[statName] or defaultValue
if condition.unlimited ~= 1 and value > 100 then
value = 100
end
- return TestValue(start, ending, value, start, 0, comparator, limit)
+ return TestValue(gain, ending, value, start, 0, comparator, limit)
end
return Compare(defaultValue, comparator, limit)
end
diff --git a/conditions/BuffStacks.lua b/conditions/BuffStacks.lua
index 5568b63..f952370 100644
--- a/conditions/BuffStacks.lua
+++ b/conditions/BuffStacks.lua
@@ -44,9 +44,9 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if state:IsActiveAura(aura) then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
local value = aura.stacks or 0
- return TestValue(start, ending, value, start, 0, comparator, limit)
+ return TestValue(gain, ending, value, start, 0, comparator, limit)
end
return Compare(0, comparator, limit)
end
diff --git a/conditions/NextTick.lua b/conditions/NextTick.lua
index 41bbb35..5220432 100644
--- a/conditions/NextTick.lua
+++ b/conditions/NextTick.lua
@@ -39,7 +39,7 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if state:IsActiveAura(aura) then
- local start, ending, tick = aura.start, aura.ending, aura.tick
+ local gain, start, ending, tick = aura.gain, aura.start, aura.ending, aura.tick
if ending < math.huge and tick then
while ending - tick > state.currentTime do
ending = ending - tick
diff --git a/conditions/StaggerRemains.lua b/conditions/StaggerRemains.lua
index ac5001a..29eeba0 100644
--- a/conditions/StaggerRemains.lua
+++ b/conditions/StaggerRemains.lua
@@ -47,10 +47,10 @@ do
aura = state:GetAura(target, LIGHT_STAGGER, "HARMFUL")
end
if state:IsActiveAura(aura) then
- local start, ending = aura.start, aura.ending
+ local gain, start, ending = aura.gain, aura.start, aura.ending
local stagger = API_UnitStagger(target)
local rate = -1 * stagger / (ending - start)
- return TestValue(start, ending, 0, ending, rate, comparator, limit)
+ return TestValue(gain, ending, 0, ending, rate, comparator, limit)
end
return Compare(0, comparator, limit)
end
diff --git a/conditions/Ticks.lua b/conditions/Ticks.lua
index cdbbf41..1972493 100644
--- a/conditions/Ticks.lua
+++ b/conditions/Ticks.lua
@@ -35,7 +35,7 @@ do
local aura = state:GetAura(target, auraId, filter, mine)
local numTicks
if state:IsActiveAura(aura) then
- local start, ending, tick = aura.start, aura.ending, aura.tick
+ local gain, start, ending, tick = aura.gain, aura.start, aura.ending, aura.tick
if tick and tick > 0 then
numTicks = floor((ending - start) / tick + 0.5)
end
diff --git a/conditions/TicksRemain.lua b/conditions/TicksRemain.lua
index 2aace89..aff8032 100644
--- a/conditions/TicksRemain.lua
+++ b/conditions/TicksRemain.lua
@@ -43,9 +43,9 @@ do
local target, filter, mine = ParseCondition(condition)
local aura = state:GetAura(target, auraId, filter, mine)
if aura then
- local start, ending, tick = aura.start, aura.ending, aura.tick
+ local gain, start, ending, tick = aura.gain, aura.start, aura.ending, aura.tick
if tick and tick > 0 then
- return TestValue(start, math.huge, 1, ending, -1/tick, comparator, limit)
+ return TestValue(gain, math.huge, 1, ending, -1/tick, comparator, limit)
end
end
return Compare(0, comparator, limit)