Skip to content
Snippets Groups Projects
Commit 1ea97f86 authored by dg's avatar dg
Browse files

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
parent 16e385ef
No related branches found
No related tags found
No related merge requests found
...@@ -132,12 +132,21 @@ function _M:generateList() ...@@ -132,12 +132,21 @@ function _M:generateList()
local list = { chars={} } local list = { chars={} }
local nb = 1 local nb = 1
for i, a in ipairs(self.chat:get(self.cur_id).answers) do 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[#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 list.chars[string.char(string.byte('a')+nb-1)] = #list
nb = nb + 1 nb = nb + 1
end end
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.list = list
self.text = self.chat:replace(self.chat:get(self.cur_id).text) self.text = self.chat:replace(self.chat:get(self.cur_id).text)
......
...@@ -418,3 +418,11 @@ function _M:reward(title, action) ...@@ -418,3 +418,11 @@ function _M:reward(title, action)
end end
game:registerDialog(d) game:registerDialog(d)
end 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
...@@ -30,10 +30,12 @@ newChat{ id="found_staff", ...@@ -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. 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?]], The staff you describe reminds me of an artifact of great power from ancient times. May I see it?]],
answers = { 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.", {"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 player:findInAllInventoriesBy("define_as", "STAFF_ABSORPTION") and player:isQuestStatus("staff-absorption", engine.Quest.COMPLETED, "survived-ukruk") end}, 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*", {"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}, 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. ...@@ -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.]], Anyway, thank you again, @playername@, for your help.]],
answers = { answers = {
{"Thank you, my lord.", action=function(npc, player) {"Thank you, my lord.", action=function(npc, player)
local o, item, inven_id = player:findInAllInventoriesBy("define_as", "STAFF_ABSORPTION") local mem, o, item, inven_id = game.party:findInAllPartyInventoriesBy("define_as", "STAFF_ABSORPTION")
player:removeObject(inven_id, item, true) if mem and o then
o:removed() mem:removeObject(inven_id, item, true)
o:removed()
end
player:setQuestStatus("staff-absorption", engine.Quest.DONE) player:setQuestStatus("staff-absorption", engine.Quest.DONE)
world:gainAchievement("A_DANGEROUS_SECRET", player) world:gainAchievement("A_DANGEROUS_SECRET", player)
......
...@@ -32,6 +32,7 @@ newEntity{ define_as = "STAFF_ABSORPTION", ...@@ -32,6 +32,7 @@ newEntity{ define_as = "STAFF_ABSORPTION",
level_range = {30, 30}, level_range = {30, 30},
display = "\\", color=colors.VIOLET, image = "object/artifact/staff_absorption.png", display = "\\", color=colors.VIOLET, image = "object/artifact/staff_absorption.png",
encumber = 7, encumber = 7,
auto_pickup = 1,
plot = true, quest = true, 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. 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.]], Light around it seems to dim and you can feel its tremendous power simply by touching it.]],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment