comparison Equip.lua @ 1:766d8a40a1d6

first commit?
author Nenue
date Tue, 15 Dec 2015 08:07:21 -0500
parents
children
comparison
equal deleted inserted replaced
0:ebbcc148a407 1:766d8a40a1d6
1 -- User: Krakyn
2 -- Created: 12/4/2015 11:20 PM
3 -- Equipment, spec, etc.
4 local T = LibStub("AceAddon-3.0"):GetAddon("Turok")
5 local mod = T:NewModule("Equip", "AceEvent-3.0")
6 --setprinthandler(function (...) T:debug('Equip', nil, ...) end)
7
8 local t18_slots = {
9 [INVSLOT_HEAD] = 124296, -- head
10 [INVSLOT_SHOULDER] = 124307, -- shoulders
11 [INVSLOT_CHEST] = 124284, -- chest
12 [INVSLOT_LEGS] = 124301, -- legs
13 [INVSLOT_HAND] = 124292, -- hands
14 }
15
16
17 local use_slots = {
18 [INVSLOT_FINGER1] = 1,
19 [INVSLOT_FINGER2] = 2,
20 [INVSLOT_TRINKET1] = 3,
21 [INVSLOT_TRINKET2] = 4,
22
23 }
24 function mod:OnEnable()
25 self.equipped = {}
26 self:RegisterEvent('COMBAT_RATING_UPDATE', 'UpdateCombatRatings')
27 self:RegisterEvent('PLAYER_EQUIPMENT_CHANGED', 'UpdateEquipment')
28 self:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED', 'UpdateSpec')
29 end
30
31 function mod:UpdateEquipment (_, slot, hasItem)
32 -- ratings event will handle the rest
33 if not t18_slots[slot] or use_slots[slot] then
34 return
35 end
36 -- debug
37 local link = GetInventoryItemID('player', slot)
38 print('|cFF00FFFFequipment ', slot, hasItem, link)
39 -- /debug
40
41 if t18_slots[slot] then
42 t18_count = 0
43 for slot, itemID in pairs(t18_slots) do
44 if GetInventoryItemID(slot) == itemID then
45 t18_count = t18_count + 1
46 end
47 end
48 if t18 >= 4 then
49 T.stats.aimedshot = s.gcd
50 else
51 T.stats.aimedshot = 2 * T.stats.castingmod
52 end
53 T.statstext =string.format('%.2f', s.aimedshot)
54 end
55
56 if use_slots[slot] then
57 if hasItem then
58 local itemID = GetInventoryItemID('player', slot)
59 self.equipped[slot] = itemID
60 T:GetModule("Spirit").item_watch[itemID] = {GetInventoryItemCooldown('player', slot) }
61 else
62 if self.equipped[slot] then
63 self.equipped[slot] = nil
64 end
65
66 end
67 end
68
69 end
70
71
72 function mod:UpdateCombatRatings()
73 local s = T.stats
74 s.haste = UnitSpellHaste('player')
75 s.focusregen = 4 * (1 + s.haste/100)
76 s.castingmod = 1+ s.haste/1000
77 s.gcd = 1.5 * s.castingmod
78 T.statstext = {
79 haste = string.format('%.2f', s.haste),
80 focusregen = string.format('%.2f', s.focusregen),
81 castingmod = string.format('%.2f', s.castingmod),
82 }
83 local t = T.statstext
84
85 print('|cFF00FFFFCOMBAT_RATING_UPDATE:|r', 'haste:', t.haste, 'regen:', t.focusregen)
86 end
87
88 function mod:UpdateSpec (e, unit)
89 if unit ~= 'player' then
90 return
91 end
92
93 T.stats.focusmax = UnitPowerMax('player')
94 end