Mercurial > wow > wowdb-profiler
comparison Main.lua @ 39:938abe259516
Record _actual_ copper prices from merchants by subtracting all price modifiers (reputation, Goblin racial, Guild perk?).
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Mon, 11 Jun 2012 16:39:27 -0500 |
parents | 934022ee6e52 |
children | 4ae5cde37458 |
comparison
equal
deleted
inserted
replaced
38:934022ee6e52 | 39:938abe259516 |
---|---|
61 local AF = private.ACTION_TYPE_FLAGS | 61 local AF = private.ACTION_TYPE_FLAGS |
62 | 62 |
63 | 63 |
64 local PLAYER_CLASS = _G.select(2, _G.UnitClass("player")) | 64 local PLAYER_CLASS = _G.select(2, _G.UnitClass("player")) |
65 local PLAYER_GUID = _G.UnitGUID("player") | 65 local PLAYER_GUID = _G.UnitGUID("player") |
66 | 66 local PLAYER_RACE = _G.select(2, _G.UnitRace("player")) |
67 | 67 |
68 ----------------------------------------------------------------------- | 68 ----------------------------------------------------------------------- |
69 -- Local variables. | 69 -- Local variables. |
70 ----------------------------------------------------------------------- | 70 ----------------------------------------------------------------------- |
71 local db | 71 local db |
76 | 76 |
77 | 77 |
78 ----------------------------------------------------------------------- | 78 ----------------------------------------------------------------------- |
79 -- Helper Functions. | 79 -- Helper Functions. |
80 ----------------------------------------------------------------------- | 80 ----------------------------------------------------------------------- |
81 local ActualCopperCost | |
82 do | |
83 local BARTERING_SPELL_ID = 83964 | |
84 | |
85 local STANDING_DISCOUNTS = { | |
86 HATED = 0, | |
87 HOSTILE = 0, | |
88 UNFRIENDLY = 0, | |
89 NEUTRAL = 0, | |
90 FRIENDLY = 0.05, | |
91 HONORED = 0.1, | |
92 REVERED = 0.15, | |
93 EXALTED = 0.2, | |
94 } | |
95 | |
96 | |
97 function ActualCopperCost(copper_cost, rep_standing) | |
98 if not copper_cost or copper_cost == 0 then | |
99 return 0 | |
100 end | |
101 local modifier = 1 | |
102 | |
103 if _G.IsSpellKnown(BARTERING_SPELL_ID) then | |
104 modifier = modifier - 0.1 | |
105 end | |
106 | |
107 if rep_standing then | |
108 if PLAYER_RACE == "Goblin" then | |
109 modifier = modifier - STANDING_DISCOUNTS["EXALTED"] | |
110 elseif STANDING_DISCOUNTS[rep_standing] then | |
111 modifier = modifier - STANDING_DISCOUNTS[rep_standing] | |
112 end | |
113 end | |
114 return math.floor(copper_cost / modifier) | |
115 end | |
116 end -- do-block | |
117 | |
118 | |
81 local function InstanceDifficultyToken() | 119 local function InstanceDifficultyToken() |
82 local _, instance_type, instance_difficulty, difficulty_name, _, _, is_dynamic = _G.GetInstanceInfo() | 120 local _, instance_type, instance_difficulty, difficulty_name, _, _, is_dynamic = _G.GetInstanceInfo() |
83 if difficulty_name == "" then | 121 if difficulty_name == "" then |
84 difficulty_name = "NONE" | 122 difficulty_name = "NONE" |
85 end | 123 end |
275 end | 313 end |
276 end | 314 end |
277 end | 315 end |
278 | 316 |
279 | 317 |
318 local UnitFactionStanding | |
280 local UpdateFactionData | 319 local UpdateFactionData |
281 do | 320 do |
282 local MAX_FACTION_INDEX = 1000 | 321 local MAX_FACTION_INDEX = 1000 |
283 | 322 |
284 local STANDING_NAMES = { | 323 local STANDING_NAMES = { |
289 "FRIENDLY", | 328 "FRIENDLY", |
290 "HONORED", | 329 "HONORED", |
291 "REVERED", | 330 "REVERED", |
292 "EXALTED", | 331 "EXALTED", |
293 } | 332 } |
333 | |
334 | |
335 function UnitFactionStanding(unit) | |
336 UpdateFactionData() | |
337 DatamineTT:ClearLines() | |
338 DatamineTT:SetUnit(unit) | |
339 | |
340 for line_index = 1, DatamineTT:NumLines() do | |
341 local faction_name = _G["WDPDatamineTTTextLeft" .. line_index]:GetText() | |
342 | |
343 if faction_name and faction_standings[faction_name] then | |
344 return faction_name, faction_standings[faction_name] | |
345 end | |
346 end | |
347 end | |
348 | |
294 | 349 |
295 function UpdateFactionData() | 350 function UpdateFactionData() |
296 for faction_index = 1, MAX_FACTION_INDEX do | 351 for faction_index = 1, MAX_FACTION_INDEX do |
297 local faction_name, _, current_standing, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index) | 352 local faction_name, _, current_standing, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index) |
298 | 353 |
664 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) | 719 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) |
665 | 720 |
666 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then | 721 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then |
667 return | 722 return |
668 end | 723 end |
724 local _, merchant_standing = UnitFactionStanding("target") | |
669 local merchant = NPCEntry(unit_idnum) | 725 local merchant = NPCEntry(unit_idnum) |
670 merchant.sells = merchant.sells or {} | 726 merchant.sells = merchant.sells or {} |
671 | 727 |
672 local num_items = _G.GetMerchantNumItems() | 728 local num_items = _G.GetMerchantNumItems() |
673 | 729 |
674 for item_index = 1, num_items do | 730 for item_index = 1, num_items do |
675 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index) | 731 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index) |
676 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index)) | 732 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index)) |
677 | 733 |
678 if item_id and item_id > 0 then | 734 if item_id and item_id > 0 then |
679 local price_string = copper_price | 735 local price_string = ActualCopperCost(copper_price, merchant_standing) |
680 | 736 |
681 if extended_cost then | 737 if extended_cost then |
682 local bg_points = 0 | 738 local bg_points = 0 |
683 local personal_points = 0 | 739 local personal_points = 0 |
684 | 740 |
792 return | 848 return |
793 end | 849 end |
794 local npc = NPCEntry(unit_idnum) | 850 local npc = NPCEntry(unit_idnum) |
795 local _, class_token = _G.UnitClass("target") | 851 local _, class_token = _G.UnitClass("target") |
796 npc.class = class_token | 852 npc.class = class_token |
797 | 853 npc.faction = UnitFactionStanding("target") |
798 UpdateFactionData() | |
799 DatamineTT:ClearLines() | |
800 DatamineTT:SetUnit("target") | |
801 | |
802 for line_index = 1, DatamineTT:NumLines() do | |
803 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] | |
804 | |
805 if not current_line then | |
806 break | |
807 end | |
808 local line_text = current_line:GetText() | |
809 | |
810 if faction_standings[line_text] then | |
811 npc.faction = line_text | |
812 break | |
813 end | |
814 end | |
815 npc.genders = npc.genders or {} | 854 npc.genders = npc.genders or {} |
816 npc.genders[GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true | 855 npc.genders[GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true |
817 npc.is_pvp = _G.UnitIsPVP("target") and true or nil | 856 npc.is_pvp = _G.UnitIsPVP("target") and true or nil |
818 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")]) | 857 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")]) |
819 | 858 |