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

Allow on_grant() method of quests to return true to prevent the quest from being assigned

git-svn-id: http://svn.net-core.org/repos/t-engine4@1181 51575b47-30f0-44d4-a5cc-537603b46e54
parent 580da612
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ function _M:init(q, who)
end
self.status = PENDING
self.objectives = {}
self:check("on_grant", who)
if self:check("on_grant", who) then self.do_not_gain = true end
end
--- Checks if the quest (or sub-objective) is complete
......
......@@ -41,8 +41,11 @@ function _M:grantQuest(quest, args)
assert(quest.name, "no quest name")
assert(quest.desc, "no quest desc")
local q = require(_M.quest_class).new(quest, self)
if q.do_not_gain then return end
self.quests = self.quests or {}
self.quests[quest.id] = require(_M.quest_class).new(quest, self)
self.quests[quest.id] = q
self.quests[quest.id].gained_turn = game.turn
print("[QUEST] given to", self, quest.id)
self:check("on_quest_grant", quest)
......
......@@ -273,6 +273,9 @@ end
on_grant = function(self, who)
local x, y = util.findFreeGrid(who.x, who.y, 10, true, {[engine.Map.ACTOR]=true})
if not x then return true end
self.on_grant = nil
while true do
......@@ -294,8 +297,6 @@ on_grant = function(self, who)
end
-- Spawn actor
local x, y = util.findFreeGrid(who.x, who.y, 10, true, {[engine.Map.ACTOR]=true})
if not x then return end
local npc = mod.class.NPC.new(self.kind.actor)
npc:resolve() npc:resolve(nil, true)
game.zone:addEntity(game.level, npc, "actor", x, y)
......@@ -303,7 +304,7 @@ on_grant = function(self, who)
-- Spawn the portal, far enough from the escort
local gx, gy = getPortalSpot(npc, 150, (game.level.map.w + game.level.map.h) / 2 / 2)
if not gx then return end
if not gx then return true end
local g = mod.class.Grid.new{
show_tooltip=true,
name="Recall Portal: "..npc.name,
......
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