comparison Main.lua @ 32:81d7d84df629

Record the player's current standing with a given faction when recording faction gains.
author James D. Callahan III <jcallahan@curse.com>
date Wed, 30 May 2012 14:56:19 -0500
parents 728f1e5dcdc8
children 6422f3b61962
comparison
equal deleted inserted replaced
31:728f1e5dcdc8 32:81d7d84df629
69 ----------------------------------------------------------------------- 69 -----------------------------------------------------------------------
70 local db 70 local db
71 local durability_timer_handle 71 local durability_timer_handle
72 local target_location_timer_handle 72 local target_location_timer_handle
73 local action_data = {} 73 local action_data = {}
74 local faction_names = {} 74 local faction_standings = {}
75 75
76 76
77 ----------------------------------------------------------------------- 77 -----------------------------------------------------------------------
78 -- Helper Functions. 78 -- Helper Functions.
79 ----------------------------------------------------------------------- 79 -----------------------------------------------------------------------
243 end 243 end
244 end 244 end
245 end 245 end
246 246
247 247
248 local function UpdateFactionNames() 248 local UpdateFactionData
249 for faction_index = 1, 1000 do 249 do
250 local faction_name, _, _, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index) 250 local MAX_FACTION_INDEX = 1000
251 251
252 if faction_name and not is_header then 252 local STANDING_NAMES = {
253 faction_names[faction_name] = true 253 "HATED",
254 elseif not faction_name then 254 "HOSTILE",
255 break 255 "UNFRIENDLY",
256 end 256 "NEUTRAL",
257 end 257 "FRIENDLY",
258 end 258 "HONORED",
259 259 "REVERED",
260 "EXALTED",
261 }
262
263 function UpdateFactionData()
264 for faction_index = 1, MAX_FACTION_INDEX do
265 local faction_name, _, current_standing, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index)
266
267 if faction_name and not is_header then
268 faction_standings[faction_name] = STANDING_NAMES[current_standing]
269 elseif not faction_name then
270 break
271 end
272 end
273 end
274 end -- do-block
260 275
261 ----------------------------------------------------------------------- 276 -----------------------------------------------------------------------
262 -- Methods. 277 -- Methods.
263 ----------------------------------------------------------------------- 278 -----------------------------------------------------------------------
264 function WDP:OnInitialize() 279 function WDP:OnInitialize()
427 end 442 end
428 end -- do-block 443 end -- do-block
429 444
430 445
431 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount) 446 function WDP:COMBAT_TEXT_UPDATE(event, message_type, faction_name, amount)
447 if message_type ~= "FACTION" then
448 return
449 end
432 local npc = NPCEntry(action_data.identifier) 450 local npc = NPCEntry(action_data.identifier)
433 451
434 if not npc then 452 if not npc then
435 return 453 return
436 end 454 end
437 local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats 455 local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats
438 encounter_data[action_data.npc_level].reputations = encounter_data[action_data.npc_level].reputations or {} 456 local reputation_data = encounter_data[action_data.npc_level].reputations
439 encounter_data[action_data.npc_level].reputations[faction_name] = amount 457
458 if not reputation_data then
459 reputation_data = {}
460 encounter_data[action_data.npc_level].reputations = reputation_data
461 end
462 UpdateFactionData()
463 reputation_data[("%s:%s"):format(faction_name, faction_standings[faction_name])] = amount
440 end 464 end
441 465
442 466
443 do 467 do
444 local re_gold = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)") 468 local re_gold = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)")
762 end 786 end
763 local npc = NPCEntry(unit_idnum) 787 local npc = NPCEntry(unit_idnum)
764 local _, class_token = _G.UnitClass("target") 788 local _, class_token = _G.UnitClass("target")
765 npc.class = class_token 789 npc.class = class_token
766 790
767 UpdateFactionNames() 791 UpdateFactionData()
768 DatamineTT:ClearLines() 792 DatamineTT:ClearLines()
769 DatamineTT:SetUnit("target") 793 DatamineTT:SetUnit("target")
770 794
771 for line_index = 1, DatamineTT:NumLines() do 795 for line_index = 1, DatamineTT:NumLines() do
772 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] 796 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
774 if not current_line then 798 if not current_line then
775 break 799 break
776 end 800 end
777 local line_text = current_line:GetText() 801 local line_text = current_line:GetText()
778 802
779 if faction_names[line_text] then 803 if faction_standings[line_text] then
780 npc.faction = line_text 804 npc.faction = line_text
781 break 805 break
782 end 806 end
783 end 807 end
784 npc.genders = npc.genders or {} 808 npc.genders = npc.genders or {}
981 1005
982 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id) 1006 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
983 if unit_id ~= "player" then 1007 if unit_id ~= "player" then
984 return 1008 return
985 end 1009 end
986
987 -- if private.SPELL_LABELS_BY_NAME[spell_name] then
988 -- print(("%s: '%s', '%s', '%s', '%s', '%s'"):format(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id))
989 -- end
990 private.tracked_line = nil 1010 private.tracked_line = nil
991 end 1011 end
992 1012
993 function WDP:HandleSpellFailure(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id) 1013 function WDP:HandleSpellFailure(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
994 if unit_id ~= "player" then 1014 if unit_id ~= "player" then