vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- Manage outfits, whether they're from OutfitDisplayFrame or something else |
2 | FishingBuddy.OutfitManager = {}; |
||
3 | |||
4 | -- Inferred from Draznar's Fishing FAQ |
||
5 | local Accessories = { |
||
6 | [19979] = { ["n"] = "Hook of the Master Angler", ["score"] = 5, }, |
||
7 | [19947] = { ["n"] = "Nat Pagle's Broken Reel", ["score"] = 4, }, |
||
8 | [19972] = { ["n"] = "Lucky Fishing Hat", ["score"] = 5, }, |
||
9 | [7996] = { ["n"] = "Lucky Fishing Hat", ["score"] = 5, }, |
||
10 | [8749] = { ["n"] = "Crochet Hat", ["score"] = 3, }, |
||
11 | [19039] = { ["n"] = "Zorbin's Water Resistant Hat", ["score"] = 3, }, |
||
12 | [3889] = { ["n"] = "Russet Hat", ["score"] = 3, }, |
||
13 | [14584] = { ["n"] = "Dokebi Hat", ["score"] = 2, }, |
||
14 | [4048] = { ["n"] = "Emblazoned Hat", ["score"] = 1, }, |
||
15 | [10250] = { ["n"] = "Masters Hat of the Whale", ["score"] = 1, }, |
||
16 | [9508] = { ["n"] = "Mechbuilder's Overalls", ["score"] = 3, }, |
||
17 | [6263] = { ["n"] = "Blue Overalls", ["score"] = 4, }, |
||
18 | [3342] = { ["n"] = "Captain Sander's Shirt", ["score"] = 4, }, |
||
19 | [5107] = { ["n"] = "Deckhand's Shirt", ["score"] = 2, }, |
||
20 | [6795] = { ["n"] = "White Swashbuckler's Shirt", ["score"] = 1, }, |
||
21 | [2576] = { ["n"] = "White Linen Shirt", ["score"] = 1, }, |
||
22 | [6202] = { ["n"] = "Fingerless Gloves", ["score"] = 3, }, |
||
23 | [792] = { ["n"] = "Knitted Sandals", ["score"] = 4, }, |
||
24 | [1560] = { ["n"] = "Bluegill Sandals", ["score"] = 4, }, |
||
25 | [13402] = { ["n"] = "Timmy's Galoshes", ["score"] = 2, }, |
||
26 | [10658] = { ["n"] = "Quagmire Galoshes", ["score"] = 2, }, |
||
27 | [1678] = { ["n"] = "Black Ogre Kickers", ["score"] = 1, }, |
||
28 | [19969] = { ["n"] = "Nat Pagle's Extreme Anglin' Boots", ["score"] = 5, }, |
||
29 | [15405] = { ["n"] = "Shucking Gloves", ["score"] = 5, }, |
||
30 | [15406] = { ["n"] = "Crustacean Boots", ["score"] = 3, }, |
||
31 | [3287] = { ["n"] = "Tribal Pants", ["score"] = 2, }, |
||
32 | [5310] = { ["n"] = "Sea Dog Britches", ["score"] = 4, }, |
||
33 | } |
||
34 | |||
35 | FishingBuddy.OutfitManager.ItemStylePoints = function(itemno, enchant) |
||
36 | local points = 0; |
||
37 | if ( itemno ) then |
||
38 | itemono = tonumber(itemno); |
||
39 | enchant = tonumber(enchant); |
||
40 | if (Accessories[itemno]) then |
||
41 | points = points + Accessories[itemno].score; |
||
42 | end |
||
43 | if ( enchant == 846 ) then |
||
44 | -- bonus for being enchanted with Fishing +2 |
||
45 | points = points + 2; |
||
46 | end |
||
47 | end |
||
48 | return points; |
||
49 | end |
||
50 | |||
51 | local CheckSwitch = nil; |
||
52 | |||
53 | -- update the watcher when we're done switching outfits |
||
54 | FishingBuddy.OutfitManager.WaitForUpdate = |
||
55 | function(arg1) |
||
56 | local hasPole = FishingBuddy.IsFishingPole(); |
||
57 | if ( hasPole == CheckSwitch ) then |
||
58 | FishingOutfitUpdateFrame:Hide(); |
||
59 | FishingBuddy.FishingMode(); |
||
60 | end |
||
61 | end |
||
62 | |||
63 | FishingBuddy.OutfitManager.CheckSwitch = function(topole) |
||
64 | CheckSwitch = topole; |
||
65 | FishingOutfitUpdateFrame:Show(); |
||
66 | end |
||
67 | |||
68 | FishingBuddy.OutfitManager.Switch = function(outfitname) |
||
69 | if ( OutfitDisplayFrame_OnLoad ) then |
||
70 | FishingBuddy.OutfitFrame.Switch(); |
||
71 | else |
||
72 | local vOut, vCat, vInd = Outfitter_FindOutfitByStatId(Outfitter_cFishingStatName); |
||
73 | if ( vOut ) then |
||
74 | if ( FishingBuddy.IsFishingPole() ) then |
||
75 | Outfitter_RemoveOutfit(vOut); |
||
76 | FishingBuddy.OutfitManager.CheckSwitch(false); |
||
77 | else |
||
78 | vOut.Disabled = nil; |
||
79 | Outfitter_WearOutfit(vOut, vCat); |
||
80 | FishingBuddy.OutfitManager.CheckSwitch(true); |
||
81 | end |
||
82 | Outfitter_Update(true); |
||
83 | end |
||
84 | end |
||
85 | -- if we're now sporting a fishing pole, let's go fishing |
||
86 | FishingBuddy.FishingMode(); |
||
87 | end |
||
88 | |||
89 | FishingBuddy.OutfitManager.HasManager = function() |
||
90 | return ( OutfitDisplayFrame_OnLoad or Outfitter_OnLoad ); |
||
91 | end |
||
92 | |||
93 | FishingBuddy.OutfitManager.Initialize = function() |
||
94 | -- no outfit managers, no outfit switching |
||
95 | if ( not FishingBuddy.OutfitManager.HasManager() ) then |
||
96 | FishingBuddy.SetSetting("InfoBarClickToSwitch", 0); |
||
97 | FishingBuddy.SetSetting("TitanClickToSwitch", 0); |
||
98 | FishingBuddy.SetSetting("MinimapClickToSwitch", 0); |
||
99 | end |
||
100 | if ( (not OutfitDisplayFrame_OnLoad) and Outfitter_OnLoad ) then |
||
101 | -- create the default fishing outfit, if it doesn't exist |
||
102 | if ( gOutfitter_Settings ) then |
||
103 | local vOut, vCat, vInd = Outfitter_FindOutfitByStatId(Outfitter_cFishingStatName); |
||
104 | local vName = "Fishing Buddy"; |
||
105 | if ( not vOut ) then |
||
106 | vOut = Outfitter_GenerateSmartOutfit(vName, Outfitter_cFishingStatName, OutfitterItemList_GetEquippableItems(true)); |
||
107 | if not vOut then |
||
108 | vOut = Outfitter_NewEmptyOutfit(vName); |
||
109 | end |
||
110 | |||
111 | local vCategoryID = Outfitter_AddOutfit(vOut); |
||
112 | end |
||
113 | end |
||
114 | end |
||
115 | end |
||
116 | |||
117 | -- calculate scores based on Outfitter |
||
118 | local function StylePoints(outfit) |
||
119 | local isp = FishingBuddy.OutfitManager.ItemStylePoints; |
||
120 | local points = 0; |
||
121 | if ( outfit )then |
||
122 | for slot in outfit.Items do |
||
123 | points = points + isp(outfit.Items[slot].Code, |
||
124 | outfit.Items[slot].EnchantCode); |
||
125 | end |
||
126 | end |
||
127 | return points; |
||
128 | end |
||
129 | |||
130 | local function BonusPoints(outfit, vStatID) |
||
131 | local points = 0; |
||
132 | if ( outfit )then |
||
133 | for slot in outfit.Items do |
||
134 | if ( outfit.Items[slot][vStatID] ) then |
||
135 | points = points + outfit.Items[slot][vStatID]; |
||
136 | end |
||
137 | -- Enternium Fishing Line |
||
138 | if ( outfit.Items[slot].EnchantCode == 2603 ) then |
||
139 | points = points + 5; |
||
140 | end |
||
141 | end |
||
142 | end |
||
143 | return points; |
||
144 | end |
||
145 | |||
146 | -- Outfitter patches |
||
147 | |||
148 | function Outfitter_FindOutfitByStatId(pStatID) |
||
149 | if not pStatID or pStatID == "" then |
||
150 | return nil; |
||
151 | end |
||
152 | |||
153 | for vCategoryID, vOutfits in gOutfitter_Settings.Outfits do |
||
154 | for vOutfitIndex, vOutfit in vOutfits do |
||
155 | if vOutfit.StatID and vOutfit.StatID == pStatID then |
||
156 | return vOutfit, vCategoryID, vOutfitIndex; |
||
157 | end |
||
158 | end |
||
159 | end |
||
160 | |||
161 | -- return nil, nil, nil; |
||
162 | end |
||
163 | |||
164 | local Saved_OutfitterItem_OnEnter = OutfitterItem_OnEnter; |
||
165 | FishingBuddy.OutfitManager.OutfitterItem_OnEnter = function(pItem) |
||
166 | Saved_OutfitterItem_OnEnter(pItem); |
||
167 | if ( not pItem.isCategoryItem ) then |
||
168 | local vOutfit = Outfitter_GetOutfitFromListItem(pItem); |
||
169 | if ( vOutfit and vOutfit.StatID == Outfitter_cFishingStatName ) then |
||
170 | local vDescription; |
||
171 | local bp = BonusPoints(vOutfit, Outfitter_cFishingStatName); |
||
172 | if ( bp >= 0 ) then |
||
173 | bp = "+"..bp; |
||
174 | else |
||
175 | bp = 0 - bp; |
||
176 | bp = "-"..bp; |
||
177 | end |
||
178 | bp = Outfitter_cFishingStatName.." "..bp; |
||
179 | local sp = StylePoints(vOutfit); |
||
180 | local pstring; |
||
181 | if ( points == 1 ) then |
||
182 | pstring = FishingBuddy.POINT; |
||
183 | else |
||
184 | pstring = FishingBuddy.POINTS; |
||
185 | end |
||
186 | vDescription = string.format(FishingBuddy.CONFIG_OUTFITTER_TEXT, |
||
187 | bp, sp)..pstring; |
||
188 | GameTooltip_AddNewbieTip(vOutfit.Name, 1.0, 1.0, 1.0, vDescription, 1); |
||
189 | end |
||
190 | end |
||
191 | end |
||
192 | OutfitterItem_OnEnter = FishingBuddy.OutfitManager.OutfitterItem_OnEnter; |