-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFishingSchools.lua
229 lines (202 loc) · 6.3 KB
/
FishingSchools.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
-- Support for schools
local FL = LibStub("LibFishing-1.0");
-- 5.0.4 has a problem with a global "_" (see some for loops below)
local _
local zmto = FishingBuddy.ZoneMarkerTo;
FishingBuddy.Schools = {};
local CLOSEENOUGH = 15; -- fifteen yards
-- Let's store fishing holes like this
-- FishingBuddy_Info["Schools"][ZONE]
-- Store everything to two digits?
local function AddFishingSchool(kind, fishid, mapId, sidx, x, y)
local entry = {};
if ( not mapId ) then
mapId, _ = FishingBuddy.GetCurrentMapIdInfo();
end
if ( not x or not y ) then
_,_,x,y = FL:GetCurrentPlayerPosition();
end
-- Okay, the fishing hole is actually between 10 and 20 yards away
-- roughly in the direction that we're pointing now
-- since most people face the hole directly, it's a good bet anyway
local facing = GetPlayerFacing();
if ( facing ) then
local yx, yy = FL:GetZoneSize(mapId);
if ( yx ) then
facing = facing + math.pi;
-- let's average the distance and say 15 yards
x, y = x * yx, y * yy;
x, y = x + math.cos(facing)*15, y + math.sin(facing)*15;
-- put them back in non-yard adjusted format
x, y = x / yx, y / yy;
end
end
local fszc = FishingBuddy.SZSchoolCounts;
local midx = zmto(mapId, sidx);
if ( fishid ) then
if (not fszc[midx]) then
fszc[midx] = {};
end
if ( fszc[midx][fishid] ) then
fszc[midx][fishid] = fszc[midx][fishid] + 1;
else
fszc[midx][fishid] = 1;
end
end
if ( not FishingBuddy_Info["FishSchools"] ) then
FishingBuddy_Info["FishSchools"] = {};
end
if ( not FishingBuddy_Info["FishSchools"][mapId] ) then
FishingBuddy_Info["FishSchools"][mapId] = {};
else
-- how do we find the same pool?
local C, mapId, x1, y1 = FL:GetCurrentPlayerPosition();
-- if we're in an instance, don't do math
if ( C ) then
for _,hole in pairs(FishingBuddy_Info["FishSchools"][mapId]) do
local d,_,_ = FL:GetWorldDistance(mapId, x, y, hole.x or x, hole.y or y);
if ( d and d < CLOSEENOUGH ) then
hole.x = hole.x or x;
hole.y = hole.y or y;
hole.sidx = hole.sidx or midx;
if ( fishid ) then
if ( hole.count ) then
hole.count = hole.count + 1;
else
hole.count = 1;
end
if ( hole.fish ) then
if ( hole.fish[fishid] ) then
hole.fish[fishid] = hole.fish[fishid] + 1;
return;
end
else
hole.fish = {};
end
hole.fish[fishid] = 1;
end
return;
end
end
end
end
entry.kind = kind;
entry.x = x;
entry.y = y;
entry.sidx = midx;
entry.count = 1;
if ( fishid ) then
entry.fish = {};
entry.fish[fishid] = 1;
end
tinsert(FishingBuddy_Info["FishSchools"][mapId], entry);
FishingBuddy.RunHandlers(FBConstants.ADD_SCHOOL_EVT, kind, fishid, mapId, sidx, x, y);
return true;
end
local function LastCastInPool(poolhint, text)
if (poolhint) then
return true;
else
return FL:IsFishingPool(text or FL:GetLastTooltipText());
end
end
local function CheckFishingPool(fishid, poolhint)
local info = FL:IsFishingPool();
if ( poolhint or info ) then
-- if it definitely was a pool (achievement) but we don't recognize it...
if ( not info ) then
info = FL:IsFishingPool(FL.SCHOOL);
end
if ( AddFishingSchool(info.kind, fishid) and FishingBuddy.GetSettingBool("ShowNewSchools") ) then
FishingBuddy.Print(FBConstants.ADDFISHINFOMSG, info.name, GetRealZoneText());
end
end
end
local function GetSchools(mapId)
if ( not mapId ) then
mapId, _ = FishingBuddy.GetCurrentMapIdInfo();
end
if ( FishingBuddy_Info["FishSchools"] and FishingBuddy_Info["FishSchools"][mapId] ) then
return FishingBuddy_Info["FishSchools"][mapId];
else
return {};
end
end
FishingBuddy.Schools.GetSchools = GetSchools;
-- The ones that have "school" in their names shouldn't be
-- necessary, but do they all translate that way? We'll skip
-- them for now, and just do the ones that aren't schools
local nonschoolfish = {
13422, -- Stonescale Eel Swarm
74857, -- Giant Mantis Shrimp Swarm
74864, -- Reef Octopus Swarm
};
-- In Outland, the names don't match at all, so we have to
-- depend on finding "School" in the pool name
local schoolfish = {
6359, -- Firefin Snapper School
6358, -- Oily Blackmouth School
21153, -- Greater Sagefish School
21071, -- Sagefish School
6522, -- School of Deviate Fish
41805, -- Borean Man O' War School
41800, -- Deep Sea Monster Belly School
41807, -- Dragonfin Angelfish School
41810, -- Fangtooth Herring School
41809, -- Glacial Salmo School
41814, -- Glassfin Minnow School
41802, -- Imperial Manta Ray School
41801, -- Moonglow Cuttlefish School
41806, -- Musselback Sculpin School
41813, -- Nettlefish School
53065, -- Albino Cavefish School
53066, -- Blackbelly Mudfish School
53072, -- Deepsea Sagefish School
53070, -- Fathom Eel School
53064, -- Highland Guppy School
53063, -- Mountain Trout School
52325, -- Volatile Fire (this won't actually work)
74856, -- Jade Lungfish School
74859, -- Emperor Salmon School
74860, -- Redbelly Mandarin School
74861, -- Tiger Gourami School
74863, -- Jewel Danio School
74865, -- Krasarang Paddlefish School
83064, -- Spine Fish School
};
local HyperCompressedOcean = {}
HyperCompressedOcean[168016] = {
["frFR"] = "Océan hyper-comprimé",
["deDE"] = "Hyperkomprimierter Ozean",
["enUS"] = "Hyper-Compressed Ocean",
["enGB"] = "Hyper-Compressed Ocean",
["itIT"] = "Oceano Ultra Compresso",
["koKR"] = "초압축 바다",
["zhCN"] = "Hyper-Compressed Ocean",
["ruRU"] = "Гиперсжатый океан",
["esES"] = "Océano hipercomprimido",
["esMX"] = "Océano hipercomprimido",
["ptBR"] = "Oceano Hipercomprimido",
["spell"] = 295044,
}
FishingBuddy.AddSchoolFish = function()
local loc = GetLocale();
local raw = FishingBuddy.StripRaw;
local fi = FishingBuddy_Info["Fishies"];
if ( fi ) then
for _,id in ipairs(nonschoolfish) do
if ( fi[id] and fi[id][loc] ) then
local name = raw(fi[id][loc]);
FL:AddSchoolName(name);
end
end
end
end
local SchoolEvents = {};
SchoolEvents[FBConstants.ADD_FISHIE_EVT] = function(id, name, mapId, subzone, texture, quantity, quality, level, idx, poolhint)
CheckFishingPool(id, poolhint);
end
SchoolEvents[FBConstants.RESET_FISHDATA_EVT] = function()
FishingBuddy_Info["FishSchools"] = {};
end
FishingBuddy.RegisterHandlers(SchoolEvents);