Quantcast

Implement ItemInfo() script declaration.

Johnny C. Lam [05-21-13 - 05:10]
Implement ItemInfo() script declaration.

ItemInfo(itemId buff=buffId proc=procName) declares that the item
specified by "itemId" procs the buff named by "buffId" of type "procName".
The buffIds from all ItemInfo lines are collected into spell lists named
"item_proc_<procName>".

This is intended to mirror the SimulationCraft expression
"trinket.proc.<buff>.<expr>".

For example, the following declarations describe the various editions of
the caster DPS trinket "Wushoolay's Final Choice" which procs an intellect
buff called "Wushoolay's Lightning":

  Define(wushoolays_lightning 138786)
    SpellInfo(wushoolays_lightning duration=20)
  ItemList(wushoolays_final_choice 94531 95669 96041 96413 96785)
    ItemInfo(94531 buff=wushoolays_final_choice proc=intellect)
    ItemInfo(95669 buff=wushoolays_final_choice proc=intellect)
    ItemInfo(96041 buff=wushoolays_final_choice proc=intellect)
    ItemInfo(96413 buff=wushoolays_final_choice proc=intellect)
    ItemInfo(96785 buff=wushoolays_final_choice proc=intellect)

And similarly for "Breath of the Hydra":

  Define(breath_of_many_minds 138898)
    SpellInfo(breath_of_many_minds duration=20)
  ItemList(breath_of_the_hydra 94521 95711 96083 96455 96827)
    ItemInfo(94521 buff=breath_of_many_minds proc=intellect)
    ItemInfo(95711 buff=breath_of_many_minds proc=intellect)
    ItemInfo(96083 buff=breath_of_many_minds proc=intellect)
    ItemInfo(96455 buff=breath_of_many_minds proc=intellect)
    ItemInfo(96827 buff=breath_of_many_minds proc=intellect)

It is then possible to use "item_proc_intellect" as a buff name to
represent the intellect proc from either trinket, e.g.,

  # metamorphosis,if=trinket.proc.intellect.react
  if BuffPresent(item_proc_intellect) Spell(metamorphosis)

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@919 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCompile.lua
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index f201ad2..f307278 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -358,6 +358,41 @@ local function ParseSpellList(name, params)
 	end
 end

+local function ParseItemInfo(params)
+	local paramList = ParseParameters(params)
+	local itemId = paramList[1]
+	if itemId then
+		if not TestConditions(paramList) then
+			return ""
+		end
+		for k, v in pairs(paramList) do
+			if k == "proc" then
+				-- Add the buff for this item proc to the spell list "item_proc_<proc>".
+				local buffId = paramList.buff
+				if buffId then
+					local listName = "item_proc_" .. v
+					if not OvaleData.buffSpellList[listName] then
+						OvaleData.buffSpellList[listName] = {}
+					end
+					local i = 1
+					local found = false
+					for _, buff in ipairs(OvaleData.buffSpellList[listName]) do
+						if buff == buffId then
+							found = true
+							break
+						end
+						i = i + 1
+					end
+					if not found then
+						OvaleData.buffSpellList[listName][i] = buffId
+					end
+				end
+			end
+		end
+	end
+	return ""
+end
+
 local function ParseItemList(name, params)
 	OvaleData.itemList[name] = {}
 	local i = 1
@@ -693,6 +728,7 @@ local function CompileDeclarations(text)
 	text = strgsub(text, "SpellDamageBuff%s*%((.-)%)", ParseSpellDamageBuff)
 	text = strgsub(text, "SpellDamageDebuff%s*%((.-)%)", ParseSpellDamageDebuff)
 	text = strgsub(text, "SpellInfo%s*%((.-)%)", ParseSpellInfo)
+	text = strgsub(text, "ItemInfo%s*%((.-)%)", ParseItemInfo)
 	text = strgsub(text, "ScoreSpells%s*%((.-)%)", ParseScoreSpells)
 	text = strgsub(text, "SpellList%s*%(%s*([%w_]+)%s*(.-)%)", ParseSpellList)
 	text = strgsub(text, "ItemList%s*%(%s*([%w_]+)%s*(.-)%)", ParseItemList)