Quantcast

spell channeling: fixes

Sidoine De Wispelaere [10-23-10 - 13:06]
spell channeling: fixes
spells that apply a debuff: fixes
hunters: better focus support
haste calculation fixes


git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@317 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Condition.lua
Ovale.lua
defaut/Chasseur.lua
diff --git a/Condition.lua b/Condition.lua
index 901e9cd..b3616ff 100644
--- a/Condition.lua
+++ b/Condition.lua
@@ -266,13 +266,16 @@ local lastEnergyTime

 local function GetManaTime(mana, withBerserker)
 	local _,className = UnitClass("player")
-	if (className == "ROGUE" or (className == "DRUID" and GetShapeshiftForm(true) == 3)) then
-		local current = Ovale.state.mana
-		if current~=lastEnergyValue then
-			lastEnergyValue = current
-			lastEnergyTime = Ovale.currentTime
-		end
-		local rate= 10
+	local current = Ovale.state.mana
+	if current~=lastEnergyValue then
+		lastEnergyValue = current
+		lastEnergyTime = Ovale.currentTime
+	end
+
+	local rate
+
+	if className == "ROGUE" or (className == "DRUID" and GetShapeshiftForm(true) == 3) then
+		rate = 10 * (100 + Ovale.meleeHaste)/100
 		if (className == "ROGUE") then
 			local rush = Ovale:GetAura("player", "HELPFUL", 13750)
 			if rush.stacks>0 then
@@ -284,6 +287,13 @@ local function GetManaTime(mana, withBerserker)
 				mana = mana/2
 			end
 		end
+	elseif className == "HUNTER" then
+		rate = 4.08 * (100 + Ovale.meleeHaste) /100
+	else
+		rate = 0
+	end
+
+	if rate > 0 then
 		local limit = math.ceil((mana - lastEnergyValue) / rate + lastEnergyTime)
 		return limit
 	else
@@ -291,7 +301,7 @@ local function GetManaTime(mana, withBerserker)
 			return Ovale.currentTime-1
 		else
 			return nil
-		end
+		end
 	end
 end

diff --git a/Ovale.lua b/Ovale.lua
index dd3d604..8108a9f 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -484,21 +484,9 @@ function Ovale:HandleProfileChanges()
 	end
 end

-function Ovale:ChercherNomsBuffs()
-	self.MOONKIN_AURA = 24907
-	self.RETRIBUTION_AURA = 7294
-	self.WRATH_OF_AIR_TOTEM = 3738
-	self.WINDFURY_TOTEM = 8512
-	self.ICY_TALONS = 50880
-	self.BLOODLUST = 2825
-	self.HEROISM = 32182
-	self.JUDGMENT_OF_THE_PURE = 54153
-end
-
 function Ovale:FirstInit()
 	self:RemplirActionIndexes()
 	self:RemplirListeTalents()
-	self:ChercherNomsBuffs()
 	self:FillSpellList()

 	local playerClass, englishClass = UnitClass("player")
@@ -639,7 +627,10 @@ function Ovale:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 		--self:Print("event="..event.." source="..nilstring(sourceName).." destName="..nilstring(destName).." " ..GetTime())
 		--Called when a missile reached or missed its target
 		--Update lastSpell accordingly
-		if string.find(event, "SPELL_CAST_SUCCESS") == 1 or string.find(event, "SPELL_DAMAGE")==1
+		--Do not use SPELL_CAST_SUCCESS because it is sent when the missile has not reached the target
+		if
+				string.find(event, "SPELL_AURA_APPLIED")==1
+				or string.find(event, "SPELL_DAMAGE")==1
 				or string.find(event, "SPELL_MISSED") == 1
 				or string.find(event, "SPELL_CAST_FAILED") == 1 then
 			local spellId, spellName = select(9, ...)
@@ -647,8 +638,8 @@ function Ovale:COMBAT_LOG_EVENT_UNFILTERED(event, ...)
 				if v.spellId == spellId then
 					if not v.channeled then
 						table.remove(self.lastSpell, i)
+						--self:Print("LOG_EVENT on supprime "..spellId.." a "..GetTime())
 					end
-					--self:Print("on supprime "..spellId.." a "..GetTime())
 					--self:Print(UnitDebuff("target", "Etreinte de l'ombre"))
 					break
 				end
@@ -727,20 +718,14 @@ function Ovale:UNIT_AURA(event, unit)
 			self.buff[spellId].lastSeen = Ovale.maintenant
 			self.buff[spellId].present = true

-			--TODO: need to be updated to 4.0.0, altought I doubt computing haste is necessary
-			--because there is no longer any risk to clip DOTs
-			if (spellId == self.RETRIBUTION_AURA or spellId == self.MOONKIN_AURA) then
-				hateCommune = 3
-			elseif (spellId == self.WRATH_OF_AIR_TOTEM) then
-				hateSorts = 5
-			elseif (spellId == self.WINDFURY_TOTEM and hateCaC == 0) then
-				hateCaC = 16
-			elseif (spellId == self.ICY_TALONS) then
-				hateCaC = 20
-			elseif (spellId == self.BLOODLUST or spellId == self.HEROISM) then
+			if spellId == 24907 or 2895 then --moonkin aura / wrath of air
+				hateSorts = 5 --add shadow form?
+			elseif spellId == 8515 or spellId == 55610 or spellId == 53290 then --windfury / improved icy talons / hunting party
+				hateCaC = 10
+			elseif spellId == 2825 or 32182 then --bloodlust / heroism
 				hateHero = 30
-			elseif (spellId == self.JUDGMENT_OF_THE_PURE) then
-				hateClasse = 15
+			elseif spellId == 53657 then --judgements of the pure
+				hateClasse = 9
 			end
 			i = i + 1;
 		end
@@ -771,13 +756,11 @@ function Ovale:GLYPH_UPDATED(event)
 end

 function Ovale:RemoveSpellFromList(spellId, lineId)
-	if unit=="player" then
-		for i,v in ipairs(self.lastSpell) do
-			if v.lineId == lineId then
-				table.remove(self.lastSpell, i)
-				--self:Print("on supprime "..name)
-				break
-			end
+	for i,v in ipairs(self.lastSpell) do
+		if v.lineId == lineId then
+			table.remove(self.lastSpell, i)
+			--self:Print("RemoveSpellFromList on supprime "..spellId)
+			break
 		end
 	end
 end
@@ -785,20 +768,26 @@ end
 --Called if the player interrupted early his cast
 --The spell is removed from the lastSpell table
 function Ovale:UNIT_SPELLCAST_INTERRUPTED(event, unit, name, rank, lineId, spellId)
-	self:RemoveSpellFromList(spellId, lineId)
+	if unit == "player" then
+		--self:Print("UNIT_SPELLCAST_INTERRUPTED "..event.." name="..name.." lineId="..lineId.." spellId="..spellId.. " time="..GetTime())
+		self:RemoveSpellFromList(spellId, lineId)
+	end
 end

 function Ovale:UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank, lineId, spellId)
-	--self:Print("UNIT_SPELLCAST_SUCCEEDED "..event.." name="..name.." lineId="..lineId.." spellId="..spellId.. " time="..GetTime())
 	if unit == "player" then
+		--self:Print("UNIT_SPELLCAST_SUCCEEDED "..event.." name="..name.." lineId="..lineId.." spellId="..spellId.. " time="..GetTime())
 		for i,v in ipairs(self.lastSpell) do
 			if v.lineId == lineId then
 				--Already added in UNIT_SPELLCAST_START
 				return
 			end
 		end
-		local now = GetTime()
-		self:AddSpellToList(spellId, lineId, now, now, false)
+		if not UnitChannelInfo("player") then
+			--A UNIT_SPELLCAST_SUCCEEDED is received when channeling a spell, with a different lineId!
+			local now = GetTime()
+			self:AddSpellToList(spellId, lineId, now, now, false)
+		end
 	end
 end

@@ -874,22 +863,29 @@ end

 function Ovale:UNIT_SPELLCAST_CHANNEL_START(event, unit, name, rank, lineId, spellId)
 	if unit=="player" then
+		--self:Print("UNIT_SPELLCAST_CHANNEL_START "..event.." name="..name.." lineId="..lineId.." spellId="..spellId)
 		local _,_,_,_,startTime, endTime = UnitChannelInfo("player")
+		--self:Print("startTime = " ..startTime.." endTime = "..endTime)
 		self:AddSpellToList(spellId, lineId, startTime/1000, endTime/1000, true)
 	end
 end

 function Ovale:UNIT_SPELLCAST_CHANNEL_STOP(event, unit, name, rank, lineId, spellId)
-	self:RemoveSpellFromList(spellId, lineId)
+	if unit == "player" then
+		--self:Print("UNIT_SPELLCAST_CHANNEL_STOP "..event.." name="..name.." lineId="..lineId.." spellId="..spellId)
+		self:RemoveSpellFromList(spellId, lineId)
+	end
 end

 --Called when a spell started its cast
 function Ovale:UNIT_SPELLCAST_START(event, unit, name, rank, lineId, spellId)
 	--self:Print("UNIT_SPELLCAST_START "..event.." name="..name.." lineId="..lineId.." spellId="..spellId)
 	if unit=="player" then
-		local spell, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(spellId)
-		local startTime =  GetTime()
-		self:AddSpellToList(spellId, lineId, startTime, startTime + castTime/1000)
+		local _,_,_,_,startTime,endTime = UnitCastingInfo("player")
+		--local spell, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(spellId)
+		--local startTime =  GetTime()
+		--self:AddSpellToList(spellId, lineId, startTime, startTime + castTime/1000)
+		self:AddSpellToList(spellId, lineId, startTime/1000, endTime/1000)
 	end
 end

@@ -1145,6 +1141,10 @@ function Ovale:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd)
 		end

 		if newSpellInfo then
+			if newSpellInfo.mana then
+				self.state.mana = self.state.mana - newSpellInfo.mana
+			end
+
 			--Points de combo
 			if newSpellInfo.combo then
 				self.state.combo = self.state.combo + newSpellInfo.combo
@@ -1347,6 +1347,7 @@ function Ovale:InitCalculerMeilleureAction()
 				if self.maintenant - v.stop<5 then
 					self:AddSpellToStack(v.spellId, v.start, v.stop, v.stop, v.nocd)
 				else
+					--self:Print("Removing obsolete "..v.spellId)
 					table.remove(self.lastSpell, i)
 				end
 			end
diff --git a/defaut/Chasseur.lua b/defaut/Chasseur.lua
index f62d420..03de69d 100644
--- a/defaut/Chasseur.lua
+++ b/defaut/Chasseur.lua
@@ -2,9 +2,9 @@ Ovale.defaut["HUNTER"] =
 [[
 #Spells
 Define(AIMEDSHOT 19434)
-	SpellInfo(AIMEDSHOT cd=10 resetcounter=ss)
+	SpellInfo(AIMEDSHOT resetcounter=ss)
 Define(ARCANESHOT 3044)
-	SpellInfo(ARCANESHOT cd=6 resetcounter=ss)
+	SpellInfo(ARCANESHOT resetcounter=ss)
 Define(ASPECTOFTHEFOX 82661)
 Define(ASPECTOFTHEHAWK 13165)
 Define(BESTIALWRATH 19574)
@@ -21,6 +21,7 @@ Define(EXPLOSIVESHOT 53301)
 	SpellAddTargetDebuff(EXPLOSIVESHOT EXPLOSIVESHOT=2)
 	SpellAddBuff(EXPLOSIVESHOT LOCKANDLOAD=-1)
 Define(FERVOR 82726)
+	Spellinfo(FERVOR mana=-50)
 Define(FOCUSFIRE 82692)
 Define(KILLCOMMAND 34026)
 	SpellInfo(KILLCOMMAND cd=60 resetcounter=ss)
@@ -37,10 +38,13 @@ Define(SERPENTSTING 1978)
 	SpellInfo(SERPENTSTING resetcounter=ss)
 	SpellAddTargetDebuff(SERPENTSTING SERPENTSTING=15)
 Define(STEADYSHOT 56641)
-	SpellInfo(STEADYSHOT inccounter=ss)
+	SpellInfo(STEADYSHOT inccounter=ss mana=-9)
 Define(SILENCINGSHOT 34490)
 	SpellInfo(SILENCINGSHOT resetcounter=ss)

+#Pet spells
+Define(GROWL 2649)
+
 #Buffs
 Define(LOCKANDLOAD 56453)
 Define(FRENZYEFFECT 19615)
@@ -59,7 +63,7 @@ AddIcon help=main mastery=1
 	if TargetBuffPresent(FRENZYEFFECT stacks=5 target=pet) Spell(FOCUSFIRE)
 	if CheckBoxOn(multi) Spell(MULTISHOT)
 	if TargetDebuffExpires(SERPENTSTING 0 mine=1) and TargetDeadIn(more 8) Spell(SERPENTSTING)
-	if Speed(equal 0 target=pet) Spell(KILLCOMMAND)
+	if TargetInRange(GROWL) Spell(KILLCOMMAND)
 	Spell(ARCANESHOT)
 	Spell(STEADYSHOT)
 }