Mercurial > wow > reaction
comparison modules/ReAction_State/ReAction_State.lua @ 67:84721edaa749
Rearranged rule layout slightly
passed nil for OnRefreshBar when it's not actually coming from an event
ApplyStates is now only called by UpdateStates
| author | Flick <flickerstreak@gmail.com> |
|---|---|
| date | Wed, 28 May 2008 17:59:44 +0000 |
| parents | 44d3716aba8d |
| children | fcb5dad031f9 |
comparison
equal
deleted
inserted
replaced
| 66:44d3716aba8d | 67:84721edaa749 |
|---|---|
| 34 end | 34 end |
| 35 | 35 |
| 36 -- PRIVATE -- | 36 -- PRIVATE -- |
| 37 local InitRules, ApplyStates | 37 local InitRules, ApplyStates |
| 38 do | 38 do |
| 39 local ruleformats = { } | 39 -- As far as I can tell the macro clauses are NOT locale-specific. |
| 40 | 40 local ruleformats = { |
| 41 stealth = "stealth", | |
| 42 nostealth = "nostealth", | |
| 43 shadowform = "form:1", | |
| 44 noshadowform = "noform", | |
| 45 pet = "pet", | |
| 46 nopet = "nopet", | |
| 47 harm = "target=target,harm", | |
| 48 help = "target=target,help", | |
| 49 notarget = "target=target,noexists", | |
| 50 focusharm = "target=focus,harm", | |
| 51 focushelp = "target=focus,help", | |
| 52 nofocus = "target=focus,noexists", | |
| 53 raid = "group:raid", | |
| 54 party = "group:party", | |
| 55 solo = "nogroup", | |
| 56 combat = "combat", | |
| 57 nocombat = "nocombat", | |
| 58 } | |
| 59 | |
| 60 -- Have to do these shenanigans instead of hardcoding the stances/forms because | |
| 61 -- the ordering varies if the character is missing a form. For warriors | |
| 62 -- this is rarely a problem (c'mon, who actually skips the level 10 def stance quest?) | |
| 63 -- but for druids it can be. Some people never bother to do the aquatic form quest | |
| 64 -- until well past when they get cat form, and stance 5 can be flight, tree, or moonkin | |
| 65 -- depending on talents. | |
| 41 function InitRules() | 66 function InitRules() |
| 42 local forms = { } | 67 local forms = { } |
| 68 -- sort by icon since it's locale-independent | |
| 43 for i = 1, GetNumShapeshiftForms() do | 69 for i = 1, GetNumShapeshiftForms() do |
| 44 local icon = GetShapeshiftFormInfo(i) | 70 local icon = GetShapeshiftFormInfo(i) |
| 45 forms[icon] = i; | 71 forms[icon] = i; |
| 46 end | 72 end |
| 47 -- sort by icon since it's locale-independent | |
| 48 -- use 9 if not found since 9 is never a valid stance/form | 73 -- use 9 if not found since 9 is never a valid stance/form |
| 49 -- we do these shenanigans instead of hardcoding the stances because | |
| 50 -- the ordering varies if the character is missing a form. For warriors | |
| 51 -- this is rarely a problem but for druids it can be. Some people never bother | |
| 52 -- to do the aquatic form quest, and stance 5 can be either flight or tree/boomkin | |
| 53 -- depending on talents. | |
| 54 local defensive = forms["Interface\\Icons\\Ability_Warrior_DefensiveStance"] or 9 | 74 local defensive = forms["Interface\\Icons\\Ability_Warrior_DefensiveStance"] or 9 |
| 55 local berserker = forms["Interface\\Icons\\Ability_Racial_Avatar"] or 9 | 75 local berserker = forms["Interface\\Icons\\Ability_Racial_Avatar"] or 9 |
| 56 local bear = forms["Interface\\Icons\\Ability_Racial_BearForm"] or 9 -- bear and dire bear share the same icon | 76 local bear = forms["Interface\\Icons\\Ability_Racial_BearForm"] or 9 -- bear and dire bear share the same icon |
| 57 local aquatic = forms["Interface\\Icons\\Ability_Druid_AquaticForm"] or 9 | 77 local aquatic = forms["Interface\\Icons\\Ability_Druid_AquaticForm"] or 9 |
| 58 local cat = forms["Interface\\Icons\\Ability_Druid_CatForm"] or 9 | 78 local cat = forms["Interface\\Icons\\Ability_Druid_CatForm"] or 9 |
| 59 local travel = forms["Interface\\Icons\\Ability_Druid_TravelForm"] or 9 | 79 local travel = forms["Interface\\Icons\\Ability_Druid_TravelForm"] or 9 |
| 60 local treekin = forms["Interface\\Icons\\Ability_Druid_TreeofLife"] or forms["Interface\\Icons\\Spell_Nature_ForceOfNature"] or 9 | 80 local treekin = forms["Interface\\Icons\\Ability_Druid_TreeofLife"] or forms["Interface\\Icons\\Spell_Nature_ForceOfNature"] or 9 |
| 61 local flight = forms["Interface\\Icons\\Ability_Druid_FlightForm"] or 9 -- both flight and swift flight share the same icon | 81 local flight = forms["Interface\\Icons\\Ability_Druid_FlightForm"] or 9 -- flight and swift flight share the same icon |
| 62 | 82 |
| 63 -- As far as I can tell the macro clauses are NOT locale-specific. | |
| 64 ruleformats.battle = "stance:1" | 83 ruleformats.battle = "stance:1" |
| 65 ruleformats.defensive = ("stance:%d"):format(defensive) | 84 ruleformats.defensive = ("stance:%d"):format(defensive) |
| 66 ruleformats.berserker = ("stance:%d"):format(berserker) | 85 ruleformats.berserker = ("stance:%d"):format(berserker) |
| 67 ruleformats.caster = ("form:0/%d/%d/%d"):format(aquatic, travel, flight) | 86 ruleformats.caster = ("form:0/%d/%d/%d"):format(aquatic, travel, flight) |
| 68 ruleformats.bear = ("form:%d"):format(bear) | 87 ruleformats.bear = ("form:%d"):format(bear) |
| 69 ruleformats.cat = ("form:%d"):format(cat) | 88 ruleformats.cat = ("form:%d"):format(cat) |
| 70 ruleformats.treeOrMoonkin = ("form:%d"):format(treekin) | 89 ruleformats.treeOrMoonkin = ("form:%d"):format(treekin) |
| 71 ruleformats.stealth = "stealth" | |
| 72 ruleformats.nostealth = "nostealth" | |
| 73 ruleformats.shadowform = "form:1" | |
| 74 ruleformats.noshadowform = "noform" | |
| 75 ruleformats.pet = "pet" | |
| 76 ruleformats.nopet = "nopet" | |
| 77 ruleformats.harm = "target=target,harm" | |
| 78 ruleformats.help = "target=target,help" | |
| 79 ruleformats.notarget = "target=target,noexists" | |
| 80 ruleformats.focusharm = "target=focus,harm" | |
| 81 ruleformats.focushelp = "target=focus,help" | |
| 82 ruleformats.nofocus = "target=focus,noexists" | |
| 83 ruleformats.raid = "group:raid" | |
| 84 ruleformats.party = "group:party" | |
| 85 ruleformats.solo = "nogroup" | |
| 86 ruleformats.combat = "combat" | |
| 87 ruleformats.nocombat = "nocombat" | |
| 88 end | 90 end |
| 89 | 91 |
| 90 local function BuildRuleString(states) | 92 local function BuildRuleString(states) |
| 91 local s = "" | 93 local s = "" |
| 92 local default | 94 local default |
| 193 -- and this event won't fire until you gain/lose buffs/debuffs, at which point you might | 195 -- and this event won't fire until you gain/lose buffs/debuffs, at which point you might |
| 194 -- be in combat. | 196 -- be in combat. |
| 195 if not InCombatLockdown() then | 197 if not InCombatLockdown() then |
| 196 InitRules() | 198 InitRules() |
| 197 for name, bar in ReAction:IterateBars() do | 199 for name, bar in ReAction:IterateBars() do |
| 198 self:OnRefreshBar("OnRefreshBar",bar,name) | 200 self:OnRefreshBar(nil,bar,name) |
| 199 end | 201 end |
| 200 end | 202 end |
| 201 end | 203 end |
| 202 | 204 |
| 203 function module:OnRefreshBar(event, bar, name) | 205 function module:OnRefreshBar(event, bar, name) |
| 238 | 240 |
| 239 function module:DeleteState( bar, name ) | 241 function module:DeleteState( bar, name ) |
| 240 local states = tfetch(self.db.profile.bars, bar:GetName(), "states") | 242 local states = tfetch(self.db.profile.bars, bar:GetName(), "states") |
| 241 if states[name] then | 243 if states[name] then |
| 242 states[name] = nil | 244 states[name] = nil |
| 243 ApplyStates(bar) | 245 self:UpdateStates(bar) |
| 244 end | 246 end |
| 245 end | 247 end |
| 246 | 248 |
| 247 -- Options -- | 249 -- Options -- |
| 248 | 250 |
