comparison Main.lua @ 141:2c2b7d91ca19 1.0.13

Record fishing coordinates based on the direction the character is facing. Minor cleanups.
author James D. Callahan III <jcallahan@curse.com>
date Thu, 27 Sep 2012 08:03:44 -0500
parents f45ff137cf8f
children 15ff29752523
comparison
equal deleted inserted replaced
140:f45ff137cf8f 141:2c2b7d91ca19
21 local LibStub = _G.LibStub 21 local LibStub = _G.LibStub
22 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0") 22 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0")
23 23
24 local deformat = LibStub("LibDeformat-3.0") 24 local deformat = LibStub("LibDeformat-3.0")
25 local LPJ = LibStub("LibPetJournal-2.0") 25 local LPJ = LibStub("LibPetJournal-2.0")
26 local MapData = LibStub("LibMapData-1.0")
26 27
27 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate") 28 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate")
28 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE") 29 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE")
29 30
30 31
318 char_db.bg_blacklist = nil 319 char_db.bg_blacklist = nil
319 end 320 end
320 end 321 end
321 322
322 323
323 local function UpdateDBEntryLocation(entry_type, identifier) 324 local UpdateDBEntryLocation
324 if not identifier then 325 do
325 return 326 local pi = math.pi
326 end 327
327 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() 328 -- Fishing node coordinate code based on code in GatherMate2 with permission from Kagaro.
328 local entry = DBEntry(entry_type, identifier) 329 local function FishingCoordinates(x, y, yard_width, yard_height)
329 entry[difficulty_token] = entry[difficulty_token] or {} 330 local facing = _G.GetPlayerFacing()
330 entry[difficulty_token].locations = entry[difficulty_token].locations or {} 331
331 332 if not facing then
332 local zone_token = ("%s:%d"):format(zone_name, area_id) 333 return x, y
333 local zone_data = entry[difficulty_token].locations[zone_token] 334 end
334 335 local rad = facing + pi
335 if not zone_data then 336 return x + math.sin(rad) * 15 / yard_width, y + math.cos(rad) * 15 / yard_height
336 zone_data = {} 337 end
337 entry[difficulty_token].locations[zone_token] = zone_data 338
338 end 339
339 local location_token = ("%s:%s:%s"):format(map_level, x, y) 340 function UpdateDBEntryLocation(entry_type, identifier)
340 zone_data[location_token] = zone_data[location_token] or true 341 if not identifier then
341 return zone_data 342 return
342 end 343 end
344 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData()
345 local entry = DBEntry(entry_type, identifier)
346 entry[difficulty_token] = entry[difficulty_token] or {}
347 entry[difficulty_token].locations = entry[difficulty_token].locations or {}
348
349 local zone_token = ("%s:%d"):format(zone_name, area_id)
350 local zone_data = entry[difficulty_token].locations[zone_token]
351
352 if not zone_data then
353 zone_data = {}
354 entry[difficulty_token].locations[zone_token] = zone_data
355 end
356
357 -- Special case for Fishing.
358 if current_action.spell_label == "FISHING" then
359 local yard_width, yard_height = MapData:MapArea(area_id, map_level)
360
361 if yard_width > 0 and yard_height > 0 then
362 x, y = FishingCoordinates(x, y, yard_width, yard_height)
363 current_action.x = x
364 current_action.y = y
365 end
366 end
367 local location_token = ("%d:%d:%d"):format(map_level, x, y)
368
369 zone_data[location_token] = zone_data[location_token] or true
370 return zone_data
371 end
372 end -- do-block
343 373
344 374
345 local function HandleItemUse(item_link, bag_index, slot_index) 375 local function HandleItemUse(item_link, bag_index, slot_index)
346 if not item_link then 376 if not item_link then
347 return 377 return
755 785
756 if map_level == loc_level and math.abs(x - loc_x) <= COORD_MAX and math.abs(y - loc_y) <= COORD_MAX then 786 if map_level == loc_level and math.abs(x - loc_x) <= COORD_MAX and math.abs(y - loc_y) <= COORD_MAX then
757 return 787 return
758 end 788 end
759 end 789 end
760 zone_data[("%s:%s:%s"):format(map_level, x, y)] = true 790 zone_data[("%d:%d:%d"):format(map_level, x, y)] = true
761 end 791 end
762 end -- do-block 792 end -- do-block
763 793
764 794
765 ----------------------------------------------------------------------- 795 -----------------------------------------------------------------------
1029 end 1059 end
1030 end -- do-block 1060 end -- do-block
1031 1061
1032 1062
1033 function WDP:CURSOR_UPDATE(event_name) 1063 function WDP:CURSOR_UPDATE(event_name)
1034 if current_action.fishing_target or _G.Minimap:IsMouseOver() or not private.SPELL_FLAGS_BY_LABEL[current_action.spell_label] then 1064 if current_action.fishing_target or _G.Minimap:IsMouseOver() or current_action.spell_label ~= "FISHING" then
1035 return 1065 return
1036 end 1066 end
1037 local text = _G["GameTooltipTextLeft1"]:GetText() 1067 local text = _G["GameTooltipTextLeft1"]:GetText()
1038 1068
1039 if not text or text == "Fishing Bobber" then 1069 if not text or text == "Fishing Bobber" then
1165 end, 1195 end,
1166 [AF.OBJECT] = function() 1196 [AF.OBJECT] = function()
1167 GenericLootUpdate("objects", InstanceDifficultyToken()) 1197 GenericLootUpdate("objects", InstanceDifficultyToken())
1168 end, 1198 end,
1169 [AF.ZONE] = function() 1199 [AF.ZONE] = function()
1170 local location_token = ("%s:%s:%s"):format(current_loot.map_level, current_loot.x, current_loot.y) 1200 local location_token = ("%d:%d:%d"):format(current_loot.map_level, current_loot.x, current_loot.y)
1171 1201
1172 -- This will start life as a boolean true. 1202 -- This will start life as a boolean true.
1173 if _G.type(current_loot.zone_data[location_token]) ~= "table" then 1203 if _G.type(current_loot.zone_data[location_token]) ~= "table" then
1174 current_loot.zone_data[location_token] = { 1204 current_loot.zone_data[location_token] = {
1175 drops = {} 1205 drops = {}