-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquest.lua
More file actions
44 lines (35 loc) · 1.07 KB
/
quest.lua
File metadata and controls
44 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
----------------------------
----- Quest class
----------------------------
require('scripts/globals/interaction/container')
Quest = setmetatable({ area = {} }, { __index = Container })
Quest.__index = Quest
Quest.__eq = function(q1, q2)
return q1.area.quest_log == q2.area.quest_log and q1.questId == q2.questId
end
Quest.reward = {}
function Quest:new(area, questId)
local obj = Container:new(Quest.getVarPrefix(area, questId))
setmetatable(obj, self)
obj.area = area
obj.questId = questId
return obj
end
function Quest.getVarPrefix(area, questId)
return string.format("Quest[%d][%d]", area.quest_log, questId)
end
function Quest:getCheckArgs(player)
return { player:getQuestStatus(self.area, self.questId) }
end
-----------------------------
-- Quest operations
function Quest:begin(player)
player:addQuest(self.area, self.questId)
end
function Quest:complete(player)
local didComplete = npcUtil.completeQuest(player, self.area, self.questId, self.reward)
if didComplete then
self:cleanup(player)
end
return didComplete
end