From 1ea97f867bb91968276b9b58d4da50e2714958dc Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Tue, 22 Jan 2013 00:15:10 +0000 Subject: [PATCH] Added a failsafe to the staff of absorption quest git-svn-id: http://svn.net-core.org/repos/t-engine4@6362 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/dialogs/Chat.lua | 11 ++++++++++- game/modules/tome/class/Party.lua | 8 ++++++++ game/modules/tome/data/chats/last-hope-elder.lua | 14 +++++++++----- .../tome/data/general/objects/quest-artifacts.lua | 1 + 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/game/engines/default/engine/dialogs/Chat.lua b/game/engines/default/engine/dialogs/Chat.lua index e083afef77..07365f0d36 100644 --- a/game/engines/default/engine/dialogs/Chat.lua +++ b/game/engines/default/engine/dialogs/Chat.lua @@ -132,12 +132,21 @@ function _M:generateList() local list = { chars={} } local nb = 1 for i, a in ipairs(self.chat:get(self.cur_id).answers) do - if not a.cond or a.cond(self.npc, self.player) then + if not a.fallback and (not a.cond or a.cond(self.npc, self.player)) then list[#list+1] = { name=string.char(string.byte('a')+nb-1)..") "..self.chat:replace(a[1]), answer=i, color=a.color} list.chars[string.char(string.byte('a')+nb-1)] = #list nb = nb + 1 end end + if #list == 0 then + for i, a in ipairs(self.chat:get(self.cur_id).answers) do + if a.fallback and (not a.cond or a.cond(self.npc, self.player)) then + list[#list+1] = { name=string.char(string.byte('a')+nb-1)..") "..self.chat:replace(a[1]), answer=i, color=a.color} + list.chars[string.char(string.byte('a')+nb-1)] = #list + nb = nb + 1 + end + end + end self.list = list self.text = self.chat:replace(self.chat:get(self.cur_id).text) diff --git a/game/modules/tome/class/Party.lua b/game/modules/tome/class/Party.lua index befa124bbc..8ca078b7dd 100644 --- a/game/modules/tome/class/Party.lua +++ b/game/modules/tome/class/Party.lua @@ -418,3 +418,11 @@ function _M:reward(title, action) end game:registerDialog(d) end + +function _M:findInAllPartyInventoriesBy(prop, value) + local o, item, inven_id + for i, mem in ipairs(game.party.m_list) do + o, item, inven_id = mem:findInAllInventoriesBy(prop, value) + if o then return mem, o, item, inven_id end + end +end diff --git a/game/modules/tome/data/chats/last-hope-elder.lua b/game/modules/tome/data/chats/last-hope-elder.lua index 94f1a17fb7..90a340a1fe 100644 --- a/game/modules/tome/data/chats/last-hope-elder.lua +++ b/game/modules/tome/data/chats/last-hope-elder.lua @@ -30,10 +30,12 @@ newChat{ id="found_staff", text = [[#LIGHT_GREEN#*He remains silent for a while*#WHITE# Indeed you were right to come here. The staff you describe reminds me of an artifact of great power from ancient times. May I see it?]], answers = { - {"Here it is. #LIGHT_GREEN#*Tell him the encounter with the orcs*#LAST# You should keep it. I can feel its power and it would be safer if it were guarded by the armies of the kingdom.", - jump="given_staff", cond=function(npc, player) return player:findInAllInventoriesBy("define_as", "STAFF_ABSORPTION") and player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "survived-ukruk") end}, + {"Here it is. #LIGHT_GREEN#*Tell him about the encounter with the orcs*#LAST# You should keep it. I can feel its power and it would be safer if it were guarded by the armies of the kingdom.", + jump="given_staff", cond=function(npc, player) return game.party:findInAllPartyInventoriesBy("define_as", "STAFF_ABSORPTION") and player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "survived-ukruk") or false end}, {"I am afraid I lost it. #LIGHT_GREEN#*Tell him about the encounter with the orcs*", jump="lost_staff", cond=function(npc, player) return player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "ambush-finish") end}, + {"I had it briefly but have lost it somehow. It could have been some orcs I encountered ...", + jump="lost_staff", fallback=true, cond=function(npc, player) return player:hasQuest("staff-absorption") end}, } } @@ -43,9 +45,11 @@ As for the orcs, it is deeply troubling. We have not seen any for eighty years. Anyway, thank you again, @playername@, for your help.]], answers = { {"Thank you, my lord.", action=function(npc, player) - local o, item, inven_id = player:findInAllInventoriesBy("define_as", "STAFF_ABSORPTION") - player:removeObject(inven_id, item, true) - o:removed() + local mem, o, item, inven_id = game.party:findInAllPartyInventoriesBy("define_as", "STAFF_ABSORPTION") + if mem and o then + mem:removeObject(inven_id, item, true) + o:removed() + end player:setQuestStatus("staff-absorption", engine.Quest.DONE) world:gainAchievement("A_DANGEROUS_SECRET", player) diff --git a/game/modules/tome/data/general/objects/quest-artifacts.lua b/game/modules/tome/data/general/objects/quest-artifacts.lua index 707777a0c4..a7d9d8f3c1 100644 --- a/game/modules/tome/data/general/objects/quest-artifacts.lua +++ b/game/modules/tome/data/general/objects/quest-artifacts.lua @@ -32,6 +32,7 @@ newEntity{ define_as = "STAFF_ABSORPTION", level_range = {30, 30}, display = "\\", color=colors.VIOLET, image = "object/artifact/staff_absorption.png", encumber = 7, + auto_pickup = 1, plot = true, quest = true, desc = [[Carved with runes of power, this staff seems to have been made long ago. Yet it bears no signs of tarnishment. Light around it seems to dim and you can feel its tremendous power simply by touching it.]], -- GitLab