Nenue@1: -- User: Krakyn Nenue@1: -- Created: 12/4/2015 11:20 PM Nenue@1: -- Equipment, spec, etc. Nenue@1: local T = LibStub("AceAddon-3.0"):GetAddon("Turok") Nenue@1: local mod = T:NewModule("Equip", "AceEvent-3.0") Nenue@1: --setprinthandler(function (...) T:debug('Equip', nil, ...) end) Nenue@1: Nenue@1: local t18_slots = { Nenue@1: [INVSLOT_HEAD] = 124296, -- head Nenue@1: [INVSLOT_SHOULDER] = 124307, -- shoulders Nenue@1: [INVSLOT_CHEST] = 124284, -- chest Nenue@1: [INVSLOT_LEGS] = 124301, -- legs Nenue@1: [INVSLOT_HAND] = 124292, -- hands Nenue@1: } Nenue@1: Nenue@1: Nenue@1: local use_slots = { Nenue@1: [INVSLOT_FINGER1] = 1, Nenue@1: [INVSLOT_FINGER2] = 2, Nenue@1: [INVSLOT_TRINKET1] = 3, Nenue@1: [INVSLOT_TRINKET2] = 4, Nenue@1: Nenue@1: } Nenue@1: function mod:OnEnable() Nenue@1: self.equipped = {} Nenue@1: self:RegisterEvent('COMBAT_RATING_UPDATE', 'UpdateCombatRatings') Nenue@1: self:RegisterEvent('PLAYER_EQUIPMENT_CHANGED', 'UpdateEquipment') Nenue@1: self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED', 'UpdateSpec') Nenue@1: end Nenue@1: Nenue@1: function mod:UpdateEquipment (_, slot, hasItem) Nenue@1: -- ratings event will handle the rest Nenue@1: if not t18_slots[slot] or use_slots[slot] then Nenue@1: return Nenue@1: end Nenue@1: -- debug Nenue@1: local link = GetInventoryItemID('player', slot) Nenue@1: print('|cFF00FFFFequipment ', slot, hasItem, link) Nenue@1: -- /debug Nenue@1: Nenue@1: if t18_slots[slot] then Nenue@1: t18_count = 0 Nenue@1: for slot, itemID in pairs(t18_slots) do Nenue@1: if GetInventoryItemID(slot) == itemID then Nenue@1: t18_count = t18_count + 1 Nenue@1: end Nenue@1: end Nenue@1: if t18 >= 4 then Nenue@1: T.stats.aimedshot = s.gcd Nenue@1: else Nenue@1: T.stats.aimedshot = 2 * T.stats.castingmod Nenue@1: end Nenue@1: T.statstext =string.format('%.2f', s.aimedshot) Nenue@1: end Nenue@1: Nenue@1: if use_slots[slot] then Nenue@1: if hasItem then Nenue@1: local itemID = GetInventoryItemID('player', slot) Nenue@1: self.equipped[slot] = itemID Nenue@1: T:GetModule("Spirit").item_watch[itemID] = {GetInventoryItemCooldown('player', slot) } Nenue@1: else Nenue@1: if self.equipped[slot] then Nenue@1: self.equipped[slot] = nil Nenue@1: end Nenue@1: Nenue@1: end Nenue@1: end Nenue@1: Nenue@1: end Nenue@1: Nenue@1: Nenue@1: function mod:UpdateCombatRatings() Nenue@1: local s = T.stats Nenue@1: s.haste = UnitSpellHaste('player') Nenue@1: s.focusregen = 4 * (1 + s.haste/100) Nenue@1: s.castingmod = 1+ s.haste/1000 Nenue@1: s.gcd = 1.5 * s.castingmod Nenue@1: T.statstext = { Nenue@1: haste = string.format('%.2f', s.haste), Nenue@1: focusregen = string.format('%.2f', s.focusregen), Nenue@1: castingmod = string.format('%.2f', s.castingmod), Nenue@1: } Nenue@1: local t = T.statstext Nenue@1: Nenue@1: print('|cFF00FFFFCOMBAT_RATING_UPDATE:|r', 'haste:', t.haste, 'regen:', t.focusregen) Nenue@1: end Nenue@1: Nenue@1: function mod:UpdateSpec (e, unit) Nenue@1: if unit ~= 'player' then Nenue@1: return Nenue@1: end Nenue@1: Nenue@1: T.stats.focusmax = UnitPowerMax('player') Nenue@1: end