diff Main.lua @ 97:f6369b88454f

Record quest progress and reward texts.
author James D. Callahan III <jcallahan@curse.com>
date Thu, 30 Aug 2012 15:45:43 -0500
parents e378295b2d6f
children 6b118dd1baf4
line wrap: on
line diff
--- a/Main.lua	Thu Aug 30 14:23:54 2012 -0500
+++ b/Main.lua	Thu Aug 30 15:45:43 2012 -0500
@@ -69,6 +69,7 @@
     QUEST_COMPLETE = true,
     QUEST_DETAIL = true,
     QUEST_LOG_UPDATE = true,
+    QUEST_PROGRESS = true,
     TAXIMAP_OPENED = true,
     TRADE_SKILL_SHOW = true,
     TRAINER_SHOW = true,
@@ -486,6 +487,32 @@
     end
 end -- do-block
 
+
+local ReplaceKeywords
+do
+    local KEYWORD_SUBSTITUTIONS = {
+        class = PLAYER_CLASS,
+        name = PLAYER_NAME,
+        race = PLAYER_RACE,
+    }
+
+
+    function ReplaceKeywords(text)
+        if not text or text == "" then
+            return ""
+        end
+
+        for category, lookup in pairs(KEYWORD_SUBSTITUTIONS) do
+            local category_format = ("<%s>"):format(category)
+            text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format)
+        end
+        return text
+    end
+
+
+end -- do-block
+
+
 -----------------------------------------------------------------------
 -- Methods.
 -----------------------------------------------------------------------
@@ -631,37 +658,15 @@
 end
 
 
-do
-    local KEYWORD_SUBSTITUTIONS = {
-        class = PLAYER_CLASS,
-        name = PLAYER_NAME,
-        race = PLAYER_RACE,
-    }
-
-
-    local function ReplaceKeywords(text)
-        if not text or text == "" then
-            return ""
-        end
-
-        for category, lookup in pairs(KEYWORD_SUBSTITUTIONS) do
-            local category_format = ("<%s>"):format(category)
-            text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format)
-        end
-        return text
+function WDP:RecordQuote(event_name, message, source_name, language_name)
+    if not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then
+        return
     end
-
-
-    function WDP:RecordQuote(event_name, message, source_name, language_name)
-        if not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then
-            return
-        end
-        local npc = NPCEntry(name_to_id_map[source_name])
-        npc.quotes = npc.quotes or {}
-        npc.quotes[event_name] = npc.quotes[event_name] or {}
-        npc.quotes[event_name][ReplaceKeywords(message)] = true
-    end
-end -- do-block
+    local npc = NPCEntry(name_to_id_map[source_name])
+    npc.quotes = npc.quotes or {}
+    npc.quotes[event_name] = npc.quotes[event_name] or {}
+    npc.quotes[event_name][ReplaceKeywords(message)] = true
+end
 
 
 do
@@ -1309,9 +1314,11 @@
 
 
     function WDP:QUEST_COMPLETE(event_name)
+        local quest = UpdateQuestJuncture("end")
+        quest.reward_text = ReplaceKeywords(_G.GetRewardText())
+
         -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it.
         reputation_npc_id = nil
-        UpdateQuestJuncture("end")
     end
 
 
@@ -1356,6 +1363,11 @@
 end
 
 
+function WDP:QUEST_PROGRESS(event_name)
+    DBEntry("quests", _G.GetQuestID()).progress_text = ReplaceKeywords(_G.GetProgressText())
+end
+
+
 function WDP:UNIT_QUEST_LOG_CHANGED(event_name, unit_id)
     if unit_id ~= "player" then
         return