Mercurial > wow > wowdb-profiler
comparison Main.lua @ 113:be3ec607e964
Roll UpdateNPCLocation into UpdateTargetLocation. Mark WIld Pet critters as wild_pet.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Mon, 10 Sep 2012 14:22:16 -0500 |
parents | 5ed405092296 |
children | 6daf570bc198 |
comparison
equal
deleted
inserted
replaced
112:5ed405092296 | 113:be3ec607e964 |
---|---|
270 return unit_type | 270 return unit_type |
271 end | 271 end |
272 end -- do-block | 272 end -- do-block |
273 | 273 |
274 | 274 |
275 local UpdateNPCLocation | |
276 do | |
277 local COORD_MAX = 5 | |
278 | |
279 function UpdateNPCLocation(unit_idnum) | |
280 local npc = NPCEntry(unit_idnum) | |
281 | |
282 if not npc then | |
283 return | |
284 end | |
285 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | |
286 local npc_data = npc.encounter_data[difficulty_token].stats[("level_%d"):format(_G.UnitLevel("target"))] | |
287 local zone_token = ("%s:%d"):format(zone_name, area_id) | |
288 npc_data.locations = npc_data.locations or {} | |
289 | |
290 local zone_data = npc_data.locations[zone_token] | |
291 | |
292 if not zone_data then | |
293 zone_data = {} | |
294 npc_data.locations[zone_token] = zone_data | |
295 end | |
296 | |
297 for location_token in pairs(zone_data) do | |
298 local loc_level, loc_x, loc_y = (":"):split(location_token) | |
299 loc_level = tonumber(loc_level) | |
300 | |
301 if map_level == loc_level and math.abs(x - loc_x) <= COORD_MAX and math.abs(y - loc_y) <= COORD_MAX then | |
302 return | |
303 end | |
304 end | |
305 zone_data[("%s:%s:%s"):format(map_level, x, y)] = true | |
306 end | |
307 end -- do-block | |
308 | |
309 | |
310 local function UpdateDBEntryLocation(entry_type, identifier) | 275 local function UpdateDBEntryLocation(entry_type, identifier) |
311 if not identifier then | 276 if not identifier then |
312 return | 277 return |
313 end | 278 end |
314 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | 279 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() |
609 end | 574 end |
610 end | 575 end |
611 end | 576 end |
612 end | 577 end |
613 | 578 |
614 | 579 do |
615 function WDP:UpdateTargetLocation() | 580 local COORD_MAX = 5 |
616 if currently_drunk or not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or (_G.UnitIsTapped("target") and not _G.UnitIsDead("target")) then | 581 |
617 return | 582 function WDP:UpdateTargetLocation() |
618 end | 583 if currently_drunk or not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or (_G.UnitIsTapped("target") and not _G.UnitIsDead("target")) then |
619 | 584 return |
620 for index = 1, 4 do | 585 end |
621 if not _G.CheckInteractDistance("target", index) then | 586 |
622 return | 587 for index = 1, 4 do |
623 end | 588 if not _G.CheckInteractDistance("target", index) then |
624 end | 589 return |
625 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) | 590 end |
626 | 591 end |
627 if not unit_idnum or unit_type ~= private.UNIT_TYPES.NPC then | 592 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) |
628 return | 593 |
629 end | 594 if not unit_idnum or unit_type ~= private.UNIT_TYPES.NPC then |
630 UpdateNPCLocation(unit_idnum) | 595 return |
631 end | 596 end |
632 | 597 local npc = NPCEntry(unit_idnum) |
598 | |
599 if not npc then | |
600 return | |
601 end | |
602 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData() | |
603 local npc_data = npc.encounter_data[difficulty_token].stats[("level_%d"):format(_G.UnitLevel("target"))] | |
604 local zone_token = ("%s:%d"):format(zone_name, area_id) | |
605 npc_data.locations = npc_data.locations or {} | |
606 | |
607 local zone_data = npc_data.locations[zone_token] | |
608 | |
609 if not zone_data then | |
610 zone_data = {} | |
611 npc_data.locations[zone_token] = zone_data | |
612 end | |
613 | |
614 for location_token in pairs(zone_data) do | |
615 local loc_level, loc_x, loc_y = (":"):split(location_token) | |
616 loc_level = tonumber(loc_level) | |
617 | |
618 if map_level == loc_level and math.abs(x - loc_x) <= COORD_MAX and math.abs(y - loc_y) <= COORD_MAX then | |
619 return | |
620 end | |
621 end | |
622 zone_data[("%s:%s:%s"):format(map_level, x, y)] = true | |
623 end | |
624 end -- do-block | |
633 | 625 |
634 ----------------------------------------------------------------------- | 626 ----------------------------------------------------------------------- |
635 -- Event handlers. | 627 -- Event handlers. |
636 ----------------------------------------------------------------------- | 628 ----------------------------------------------------------------------- |
637 function WDP:BLACK_MARKET_ITEM_UPDATE(event_name) | 629 function WDP:BLACK_MARKET_ITEM_UPDATE(event_name) |
1281 npc.faction = UnitFactionStanding("target") | 1273 npc.faction = UnitFactionStanding("target") |
1282 npc.genders = npc.genders or {} | 1274 npc.genders = npc.genders or {} |
1283 npc.genders[GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true | 1275 npc.genders[GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true |
1284 npc.is_pvp = _G.UnitIsPVP("target") and true or nil | 1276 npc.is_pvp = _G.UnitIsPVP("target") and true or nil |
1285 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")]) | 1277 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")]) |
1278 npc.wild_pet = (_G.UnitCreatureType("target") == "Wild Pet") and true or nil | |
1286 | 1279 |
1287 local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats | 1280 local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats |
1288 local npc_level = ("level_%d"):format(_G.UnitLevel("target")) | 1281 local npc_level = ("level_%d"):format(_G.UnitLevel("target")) |
1289 | 1282 |
1290 if not encounter_data[npc_level] then | 1283 if not encounter_data[npc_level] then |