diff --git a/Condition.lua b/Condition.lua index ae2c9ce..fa174f1 100644 --- a/Condition.lua +++ b/Condition.lua @@ -555,11 +555,11 @@ Ovale.conditions= end, --Compare to eclipse power. <0 lunar, >0 solar Eclipse = function(condition) - if condition.now==1 then + --if condition.now==1 then return compare(Ovale.state.eclipse, condition[1], condition[2]) - else - return compare(Ovale.state.nextEclipse, condition[1], condition[2]) - end + --else + -- return compare(Ovale.state.nextEclipse, condition[1], condition[2]) + --end end, EffectiveMana = function(condition) local limit = GetManaTime(condition[2], true) @@ -663,6 +663,16 @@ Ovale.conditions= end return compare(Ovale.spellDamage[spellId], condition[2], condition[3]) end, + LastSwing = function(condition) + local ret = OvaleSwing:GetLast(condition[1]) + if condition[2] then + ret = ret + condition[2] + end + return ret + end, + lastSwing = function(condition) + return OvaleSwing:GetLast(condition[1]), 0, -1 + end, -- Compare with the player level -- 1 : "less" or "more" -- 2 : the limit @@ -729,6 +739,16 @@ Ovale.conditions= maxHealth = function(condition) return UnitMaxHealth(getTarget(condition.target)) end, + NextSwing = function(condition) + local ret = OvaleSwing:GetNext(condition[1]) + if condition[2] then + ret = ret - condition[2] + end + return ret + end, + nextSwing = function(condition) + return OvaleSwing:GetNext(condition[1]), 0, -1 + end, OtherDebuffExpires = function(condition) Ovale:EnableOtherDebuffs() local otherDebuff = Ovale.otherDebuffs[condition[1]] diff --git a/Ovale.lua b/Ovale.lua index 51fca8f..567028c 100644 --- a/Ovale.lua +++ b/Ovale.lua @@ -1302,45 +1302,6 @@ function Ovale:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd) if newSpellInfo.unholy then self:AddRune(startCast, 2, newSpellInfo.unholy) end - if newSpellInfo.eclipse then - --[[self.state.eclipse = self.state.eclipse + newSpellInfo.eclipse - if self.state.eclipse < -100 then - self.state.eclipse = -100 - elseif self.state.eclipse > 100 then - self.state.eclipse = 100 - end]] - self.state.nextEclipse = self.state.eclipse + newSpellInfo.eclipse - if self.state.nextEclipse < -100 then - self.state.nextEclipse = -100 - elseif self.state.nextEclipse > 100 then - self.state.nextEclipse = 100 - end - self.state.nextEclipseTime = endCast + 0.5 - end - if newSpellInfo.starsurge then - local buffAura = self:GetAura("player", "HELPFUL", 48517) --Solar - if buffAura.stacks>0 then - self:Log("starsurge with solar buff = " .. (- newSpellInfo.starsurge)) - self.state.eclipse = self.state.eclipse - newSpellInfo.starsurge - else - buffAura = self:GetAura("player", "HELPFUL", 48518) --Lunar - if buffAura.stacks>0 then - self:Log("starsurge with lunar buff = " .. newSpellInfo.starsurge) - self.state.eclipse = self.state.eclipse + newSpellInfo.starsurge - elseif self.state.eclipse < 0 then - self:Log("starsurge with eclipse < 0 = " .. (- newSpellInfo.starsurge)) - self.state.eclipse = self.state.eclipse - newSpellInfo.starsurge - else - self:Log("starsurge with eclipse > 0 = " .. newSpellInfo.starsurge) - self.state.eclipse = self.state.eclipse + newSpellInfo.starsurge - end - end - if self.state.eclipse < -100 then - self.state.eclipse = -100 - elseif self.state.eclipse > 100 then - self.state.eclipse = 100 - end - end if newSpellInfo.holy then self.state.holy = self.state.holy + newSpellInfo.holy if self.state.holy < 0 then @@ -1398,6 +1359,46 @@ function Ovale:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd) end end + if newSpellInfo.eclipse then + self.state.eclipse = self.state.eclipse + newSpellInfo.eclipse + if self.state.eclipse < -100 then + self.state.eclipse = -100 + elseif self.state.eclipse > 100 then + self.state.eclipse = 100 + end + --[[self.state.nextEclipse = self.state.eclipse + newSpellInfo.eclipse + if self.state.nextEclipse < -100 then + self.state.nextEclipse = -100 + elseif self.state.nextEclipse > 100 then + self.state.nextEclipse = 100 + end + self.state.nextEclipseTime = endCast + 0.5]] + end + if newSpellInfo.starsurge then + local buffAura = self:GetAura("player", "HELPFUL", 48517) --Solar + if buffAura.stacks>0 then + self:Log("starsurge with solar buff = " .. (- newSpellInfo.starsurge)) + self.state.eclipse = self.state.eclipse - newSpellInfo.starsurge + else + buffAura = self:GetAura("player", "HELPFUL", 48518) --Lunar + if buffAura.stacks>0 then + self:Log("starsurge with lunar buff = " .. newSpellInfo.starsurge) + self.state.eclipse = self.state.eclipse + newSpellInfo.starsurge + elseif self.state.eclipse < 0 then + self:Log("starsurge with eclipse < 0 = " .. (- newSpellInfo.starsurge)) + self.state.eclipse = self.state.eclipse - newSpellInfo.starsurge + else + self:Log("starsurge with eclipse > 0 = " .. newSpellInfo.starsurge) + self.state.eclipse = self.state.eclipse + newSpellInfo.starsurge + end + end + if self.state.eclipse < -100 then + self.state.eclipse = -100 + elseif self.state.eclipse > 100 then + self.state.eclipse = 100 + end + end + --Auras causés par le sort if newSpellInfo.aura then for target, targetInfo in pairs(newSpellInfo.aura) do diff --git a/Ovale.toc b/Ovale.toc index 87632de..7577d92 100644 --- a/Ovale.toc +++ b/Ovale.toc @@ -25,6 +25,7 @@ OvaleFrame.lua OvaleCompile.lua OvaleRecount.lua OvaleSkada.lua +OvaleSwing.lua defaut\Chaman.lua defaut\Chasseur.lua defaut\Demoniste.lua diff --git a/OvaleSwing.lua b/OvaleSwing.lua index 8baaa26..173b6d3 100644 --- a/OvaleSwing.lua +++ b/OvaleSwing.lua @@ -18,31 +18,22 @@ Modifed for Ovale ]] ---[[ Not useful anymore - local autoshotname = GetSpellInfo(75) local resetspells = { - [GetSpellInfo(845)] = true, -- Cleave - [GetSpellInfo(78)] = true, -- Heroic Strike - [GetSpellInfo(6807)] = true, -- Maul - [GetSpellInfo(2973)] = true, -- Raptor Strike } local delayspells = { [GetSpellInfo(1464)] = true, -- Slam } local resetautoshotspells = { } + local _, playerclass = UnitClass('player') local unpack = unpack local math_abs = math.abs local GetTime = GetTime OvaleSwing = LibStub("AceAddon-3.0"):NewAddon("OvaleSwing", "AceEvent-3.0") - -OvaleSwing.swingmode=nil -- nil is none, 0 is meleeing, 1 is autoshooting -OvaleSwing.starttime=0 -OvaleSwing.duration=0 -OvaleSwing.startdelay=0 +OvaleSwing.ohNext = false local BOOKTYPE_SPELL = BOOKTYPE_SPELL @@ -70,89 +61,69 @@ end function OvaleSwing:PLAYER_ENTER_COMBAT() local _,_,offhandlow, offhandhigh = UnitDamage('player') if math_abs(offhandlow - offhandhigh) <= 0.1 or playerclass == "DRUID" then - self.swingmode = 0 -- shouldn't be dual-wielding + self.dual = false + else + self.dual = true end + --print("Enter combat") end function OvaleSwing:PLAYER_LEAVE_COMBAT() - if not self.swingmode or self.swingmode == 0 then - self.swingmode = nil - end + self.ohNext = false + self.ohStartTime = nil + self.ohDuration = nil + self.duration = nil + self.starttime = nil + self.delay = 0 end function OvaleSwing:START_AUTOREPEAT_SPELL() - self.swingmode = 1 end function OvaleSwing:STOP_AUTOREPEAT_SPELL() - if not self.swingmode or self.swingmode == 1 then - self.swingmode = nil - end end --- blizzard screws that global up, double usage in CombatLog.lua and GlobalStrings.lua, so we create it ourselves -local COMBATLOG_FILTER_ME = bit.bor( - COMBATLOG_OBJECT_AFFILIATION_MINE or 0x00000001, - COMBATLOG_OBJECT_REACTION_FRIENDLY or 0x00000010, - COMBATLOG_OBJECT_CONTROL_PLAYER or 0x00000100, - COMBATLOG_OBJECT_TYPE_PLAYER or 0x00000400 - ) - -do - local swordspecproc = false - function OvaleSwing:COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, srcGUID, srcName, srcFlags, dstName, dstGUID, dstFlags, ...) - if (event == "SPELL_EXTRA_ATTACKS") and (select(2, ...) == "Sword Specialization") - and (bit.band(srcFlags, COMBATLOG_FILTER_ME) == COMBATLOG_FILTER_ME) then - swordspecproc = true - elseif (event == "SWING_DAMAGE" or event == "SWING_MISSED") - and (bit.band(srcFlags, COMBATLOG_FILTER_ME) == COMBATLOG_FILTER_ME) - and self.swingmode == 0 then - if (swordspecproc) then - swordspecproc = false - else - self:MeleeSwing() - end +function OvaleSwing:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, eventName, srcGUID, srcName, srcFlags, dstName, dstGUID, dstFlags, ...) + if srcName == UnitName("player") then + if eventName == "SWING_DAMAGE" or eventName == "SWING_MISSED" then + self:MeleeSwing(timestamp) end end end -function OvaleSwing:UNIT_SPELLCAST_START(unit, spell) - if self.swingmode == 0 then - if delayspells[spell] then - self.startdelay = GetTime() - end +function OvaleSwing:UNIT_SPELLCAST_START(event, unit, spell) + if delayspells[spell] and unit=="player" then + self.startdelay = GetTime() + local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(spell) + self.delay = castTime end end -function OvaleSwing:UNIT_SPELLCAST_INTERRUPTED(unit, spell) - if self.swingmode == 0 then - if delayspells[spell] then - self.duration = self.duration + GetTime() - self.startdelay - end +function OvaleSwing:UNIT_SPELLCAST_INTERRUPTED(event, unit, spell) + if unit == "player" and delayspells[spell] and self.startdelay then + self.delay = GetTime() - self.startdelay end end -function OvaleSwing:UNIT_SPELLCAST_SUCCEEDED(unit, spell) - if self.swingmode == 0 then +function OvaleSwing:UNIT_SPELLCAST_SUCCEEDED(event, unit, spell) + if unit == "player" then if resetspells[spell] then - self:MeleeSwing() + self:MeleeSwing(GetTime()) end - if delayspells[spell] then - self.duration = self.duration + + if delayspells[spell] and self.startdelay then + self.delay = GetTime() - self.startdelay end - elseif self.swingmode == 1 then if spell == autoshotname then self:Shoot() end - end - if resetautoshotspells[spell] then - self.swingmode = 1 - self:Shoot() + if resetautoshotspells[spell] then + self:Shoot() + end end end -function OvaleSwing:UNIT_ATTACK(unit) - if unit == 'player' then +function OvaleSwing:UNIT_ATTACK(event, unit) + --[[if unit == 'player' then if not self.swingmode then return elseif self.swingmode == 0 then @@ -160,16 +131,69 @@ function OvaleSwing:UNIT_ATTACK(unit) else self.duration = UnitRangedDamage('player') end - end + end]] end -function OvaleSwing:MeleeSwing() - self.duration = UnitAttackSpeed('player') - self.starttime = GetTime() +function OvaleSwing:MeleeSwing(timestamp) + if self.dual and self.ohNext then + --[[if self.ohDuration then + local prediction = self.ohDuration+self.ohStartTime+self.delay + print("Prediction oh = " .. prediction .. " diff=" .. (timestamp-prediction)) + end]] + self.ohDuration = UnitAttackSpeed('player') + self.ohStartTime = timestamp + --print("MeleeSwing oh = " .. self.ohStartTime) + self.ohNext = false + else + --[[if self.duration then + local prediction = self.duration+self.starttime+self.delay + print("Prediction mh = " .. prediction .. " diff=" .. (timestamp-prediction)) + end]] + self.duration = UnitAttackSpeed('player') + self.starttime = timestamp + --print("MeleeSwing mh = " .. self.starttime) + self.ohNext = true + if self.ohStartTime == nil then + self.ohStartTime = self.starttime - self.duration/2 + self.ohDuration = self.duration + end + end + self.delay = 0 end function OvaleSwing:Shoot() + --[[if self.duration then + print("Prediction = " ..(self.duration+self.starttime)) + end]] self.duration = UnitRangedDamage('player') self.starttime = GetTime() + --print("Shoot " .. self.starttime) +end + +function OvaleSwing:GetLast(which) + if which == "main" then + return self.starttime + elseif which == "off" then + return self.ohStartTime + else + if self.dual and self.ohNext then + return self.starttime + else + return self.ohStartTime + end + end +end + +function OvaleSwing:GetNext(which) + if which == "main" then + return self.duration + self.starttime + self.delay + elseif which == "off" then + return self.ohDuration + self.ohStartTime + self.delay + else + if self.dual and self.ohNext then + return self.ohDuration + self.ohStartTime + self.delay + else + return self.duration + self.starttime + self.delay + end + end end -]] diff --git a/defaut/Chasseur.lua b/defaut/Chasseur.lua index 6b1b868..8ff77d5 100644 --- a/defaut/Chasseur.lua +++ b/defaut/Chasseur.lua @@ -132,10 +132,10 @@ AddIcon help=main mastery=2 if {Mana(more 65) or spell(CHIMERASHOT)>5} and {TargetLifePercent(less 80) and BuffExpires(RAPIDFIRE) and BuffExpires(heroism)} if Mana(more 24) Spell(ARCANESHOT) } - else + unless Glyph(GLYPHOFARCANESHOT) { #/aimed_shot,if=cooldown.chimera_shot.remains>5|focus>=80|buff.rapid_fire.up|buff.bloodlust.up|target.health_pct>80 - if spell(CHIMERASHOT)>5 or Mana(more 79) or BuffPresent(RAPIDFIRE) or BuffPresent(heroism) or TargetLifePercent(more 80) + if {spell(CHIMERASHOT)>5} or Mana(more 79) or BuffPresent(RAPIDFIRE) or BuffPresent(heroism) or TargetLifePercent(more 80) if Mana(more 49) Spell(AIMEDSHOT) } #/steady_shot