Quantcast

Add WeaponDamage(hand) script condition and use MH/OH damage in formulas.

Johnny C. Lam [07-07-13 - 04:43]
Add WeaponDamage(hand) script condition and use MH/OH damage in formulas.

The Damage() and LastSpellEstimatedDamage() script conditions now include
MH/OH weapon damage in their calculations as simple linear terms:

    bonusmainhand * MH_WEAPON_DAMAGE
    bonusoffhand * OH_WEAPON_DAMAGE

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@946 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCondition.lua
OvaleData.lua
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index 795f49f..3959fa1 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -1326,10 +1326,10 @@ OvaleCondition.conditions.critdamage = function(condition)
 end

 --- Get the current estimated damage of a spell on the target.
--- The calculated damage takes into account the current attack power, spellpower and combo points (if used).
+-- The calculated damage takes into account the current attack power, spellpower, weapon damage and combo points (if used).
 -- The damage is computed from information for the spell set via SpellInfo(...):
 --
--- damage = base + bonusap * AP + bonuscp * CP + bonusapcp * AP * CP + bonussp * SP
+-- damage = base + bonusmainhand * MH + bonusoffhand * OH + bonusap * AP + bonuscp * CP + bonusapcp * AP * CP + bonussp * SP
 -- @name Damage
 -- @paramsig number
 -- @param id The spell ID.
@@ -1349,8 +1349,12 @@ OvaleCondition.conditions.damage = function(condition)
 	if value then
 		return 0, nil, value, origin, rate
 	else
-		value = OvaleData:GetDamage(spellId, OvalePaperDoll.stat.attackPower, OvalePaperDoll.stat.spellBonusDamage, OvaleState.state.combo)
-		return 0, nil, value * OvaleState:GetDamageMultiplier(spellId), 0, 0
+		local ap = OvalePaperDoll.stat.attackPower
+		local sp = OvalePaperDoll.stat.spellBonusDamage
+		local mh = OvalePaperDoll.stat.mainHandWeaponDamage
+		local oh = OvalePaperDoll.stat.offHandWeaponDamage
+		local dm = OvaleState:GetDamageMultiplier(spellId)
+		return 0, nil, OvaleData:GetDamage(spellId, ap, sp, mh, oh, combo) * dm, 0, 0
 	end
 end

@@ -2016,11 +2020,11 @@ OvaleCondition.conditions.lastspelldamage = function(condition)
 end

 --- Get the estimated damage of the most recent cast of the player's spell on the target.
--- The calculated damage takes into account the values of attack power, spellpower and combo points (if used)
+-- The calculated damage takes into account the values of attack power, spellpower, weapon damage and combo points (if used)
 -- at the time the spell was most recent cast.
 -- The damage is computed from information for the spell set via SpellInfo(...):
 --
--- damage = base + bonusap * AP + bonuscp * CP + bonusapcp * AP * CP + bonussp * SP
+-- damage = base + bonusmainhand * MH + bonusoffhand * OH + bonusap * AP + bonuscp * CP + bonusapcp * AP * CP + bonussp * SP
 -- @name LastSpellEstimatedDamage
 -- @paramsig number
 -- @param id The spell ID.
@@ -2038,9 +2042,11 @@ OvaleCondition.conditions.lastspellestimateddamage = function(condition)
 	local guid = OvaleGUID:GetGUID(GetTarget(condition, "target"))
 	local ap = GetLastSpellInfo(guid, spellId, "attackPower")
 	local sp = GetLastSpellInfo(guid, spellId, "spellBonusDamage")
+	local mh = GetLastSpellInfo(guid, spellId, "mainHandWeaponDamage")
+	local oh = GetLastSpellInfo(guid, spellId, "offHandWeaponDamage")
 	local combo = GetLastSpellInfo(guid, spellId, "comboPoints")
 	local dm = GetLastSpellInfo(guid, condition, "damageMultiplier") or 1
-	return 0, nil, OvaleData:GetDamage(spellId, ap, sp, combo) * dm, 0, 0
+	return 0, nil, OvaleData:GetDamage(spellId, ap, sp, mh, oh, combo) * dm, 0, 0
 end

 --- Get the damage multiplier of the most recent cast of a spell on the target.
@@ -3377,6 +3383,29 @@ OvaleCondition.conditions.weaponenchantexpires = function(condition)
 	end
 end

+--- The average weapon damage of the weapon in the given hand.
+-- @name WeaponDamage
+-- @paramsig number
+-- @param hand Optional. Sets which hand weapon.
+--     Defaults to mainhand.
+--     Valid values: mainhand, offhand.
+-- @return The weapon damage.
+-- @usage
+-- AddFunction MangleDamage {
+--     WeaponDamage() * 5 + 78
+-- }
+
+OvaleCondition.conditions.weapondamage = function(condition)
+	local hand = condition[1]
+	local damage = 0
+	if hand == "offhand" or hand == "off" then
+		damage = OvalePaperDoll.stat.offHandWeaponDamage
+	else -- if hand == "mainhand" or hand == "main" then
+		damage = OvalePaperDoll.stat.mainHandWeaponDamage
+	end
+	return 0, nil, damage, 0, 0
+end
+
 OvaleCondition.defaultTarget = "target"

 --</public-static-properties>
diff --git a/OvaleData.lua b/OvaleData.lua
index f01002d..d06252d 100644
--- a/OvaleData.lua
+++ b/OvaleData.lua
@@ -498,15 +498,23 @@ function OvaleData:GetSpellCD(spellId)
 end

 --Compute the damage of the given spell.
-function OvaleData:GetDamage(spellId, attackpower, spellpower, combo)
+function OvaleData:GetDamage(spellId, attackpower, spellpower, mainHandWeaponDamage, offHandWeaponDamage, combo)
 	local si = self.spellInfo[spellId]
 	if not si then
 		return nil
 	end
 	local damage = si.base or 0
-	combo = combo or 0
 	attackpower = attackpower or 0
 	spellpower = spellpower or 0
+	mainHandWeaponDamage = mainHandWeaponDamage or 0
+	offHandWeaponDamage = offHandWeaponDamage or 0
+	combo = combo or 0
+	if si.bonusmainhand then
+		damage = damage + si.bonusmainhand * mainHandWeaponDamage
+	end
+	if si.bonusoffhand then
+		damage = damage + si.bonusoffhand * offHandWeaponDamage
+	end
 	if si.bonuscp then
 		damage = damage + si.bonuscp * combo
 	end