home *** CD-ROM | disk | FTP | other *** search
- -----------------------------------------------------------------------
- -- the table where all the functions/methods go to
- -----------------------------------------------------------------------
- %1 = {
- quest,
- name,
- locations,
- iactors,
- triggers,
- conversations,
- cutscenes,
- checklist
- }
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- init function
- -----------------------------------------------------------------------
- function %1:init()
- local questName = "%1"
- -- the quest object stores the C++ object pointer (Quest object)
- self.quest = QuestMgr:createQuest(questName)
- self.name = questName
-
- -- the locations associated with this quest
- self.locations = {
- }
-
- -- the interactor objects associated with this quest
- self.iactors = {
- }
-
- -- the conversations associated with this quest
- self.conversations = {
- }
-
- -- the cutscenes associated with this quest
- self.cutscenes = {
- }
-
- -- the triggers associated with this quest
- --self.quest:addTrigger("trig_%1", "home")
-
- -- the checklist of little tasks associated with this quest
- self.checklist = {
- }
-
- -- associate the locations with the quest
- for key, value in ipairs(self.locations) do
- self.quest:addLocation(value)
- end
- -- associate the interactors with the quest
- for key, value in ipairs(self.iactors) do
- self.quest:addInteractor(value)
- end
- -- associate the conversations with the quest
- for key, value in ipairs(self.conversations) do
- self.quest:addConversation(value)
- end
- -- associate the cutscenes with the quest
- for key, value in ipairs(self.cutscenes) do
- self.quest:addCutscene(value)
- end
- -- associate the list items with the quest
- for key, value in ipairs(self.checklist) do
- self.quest:addTaskToCheckList(value)
- end
-
- -- subscribe the lua functions to call
- self.quest:subscribeLocationEntered(self.name .. ":onLocationEntered")
- self.quest:subscribeLocationLeft(self.name .. ":onLocationLeft")
- self.quest:subscribeInteractorEvent(self.name .. ":onInteractorEvent")
- self.quest:subscribeInteractorEntered(self.name .. ":onMouseEnteredInteractor")
- self.quest:subscribeInteractorLeft(self.name .. ":onMouseLeftInteractor")
- self.quest:subscribeLocationFadingInFinished(self.name .. ":onLocationFadingInFinished")
- self.quest:subscribeConversationEvent(self.name .. ":onConversationEvent")
- self.quest:subscribeConversationFinished(self.name .. ":onConversationFinished")
- self.quest:subscribeCutsceneFinished(self.name .. ":onCutsceneFinished")
- self.quest:subscribeTriggerEvent(self.name .. ":onTriggerEvent")
- self.quest:subscribeCheckListChanged(self.name .. ":updateConfigurationsFromCheckList")
- end
- -----------------------------------------------------------------------
-
- --------------------------------------------------------------------------
- -- sets the quest active and updates the iactor configurations
- --------------------------------------------------------------------------
- function %1:activate()
- _LogInfo(self.name .. ":activate", self.name)
- self.quest:setActive(true)
- self:initializeConfigurations()
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- sets the quest inactive and resets the iactor configurations
- -----------------------------------------------------------------------
- function %1:deactivate()
- _LogInfo("%1:deactivate", "called")
- self.quest:setActive(false)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when an action was performed on an interactor
- -- associated with this quest
- -----------------------------------------------------------------------
- function %1:onInteractorEvent(p_Interactor, p_ActionID, p_InteractedInteractor)
- _LogInfo("%1:onInteractorEvent", p_Interactor)
-
- local questState = self.quest:getState()
- local iactor = GameEntityMgr:getInteractor(p_Interactor)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when the mouse entered an iactor associated
- -- with this quest
- -----------------------------------------------------------------------
- function %1:onMouseEnteredInteractor(p_Interactor)
- _LogInfo("%1:onMouseEnteredInteractor", p_Interactor)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when the mouse left an iactor associated
- -- with this quest
- -----------------------------------------------------------------------
- function %1:onMouseLeftInteractor(p_Interactor)
- _LogInfo("%1:onMouseLeftInteractor", p_Interactor)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when the player entered a location that is associated
- -- with this quest
- -----------------------------------------------------------------------
- function %1:onLocationEntered(p_Location)
- _LogInfo("%1:onLocationEntered", p_Location)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when the player left a location that is associated
- -- with this quest
- -----------------------------------------------------------------------
- function %1:onLocationLeft(p_Location)
- _LogInfo("%1:onLocationLeft", p_Location)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called whenever a location associated with this quest
- -- has finished fading in
- -----------------------------------------------------------------------
- function %1:onLocationFadingInFinished(p_Location)
- _LogInfo("%1:onLocationFadingInFinished", p_Location)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when a cutscene associated with this quest was
- -- finished
- -----------------------------------------------------------------------
- function %1:onCutsceneFinished(p_Cutscene)
- _LogInfo("%1:onCutsceneFinished", p_Cutscene)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when a conversation associated with this quest
- -- was finished
- -----------------------------------------------------------------------
- function %1:onConversationFinished(p_Conversation)
- _LogInfo("%1:onConversationFinished", p_Conversation)
- end
- ----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when a conversation associated with this quest
- -- has fired a special event
- -----------------------------------------------------------------------
- function %1:onConversationEvent(p_Conversation, p_Event)
- _LogInfo("%1:onConversationEvent", p_Conversation .. ":" .. p_Event)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- lua slot called when a trigger associated with this quest
- -- has fired its event
- -----------------------------------------------------------------------
- function %1:onTriggerEvent(p_Trigger)
- _LogInfo("%1:onTriggerEvent", p_Trigger)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- sets the interactor configurations for the iactors associated with
- -- this quest according to the quest's current state
- -----------------------------------------------------------------------
- function %1:initConfigurations()
- _LogInfo("%1:initConfigurations", "")
- local questState = self.quest:getState()
- -- default case, quest just initialized
- if questState == "Initialized" then
- for key, value in ipairs(self.iactors) do
- local configName = self.name .. "_" .. value
- _LogInfo("setting config: '" .. value .. "' to '" .. configName .. "'","")
- if InteractorConfigurationMgr:isConfigurationPresent(configName) then
- local iactor = GameEntityMgr:getInteractor(value)
- iactor:setConfiguration(configName, true)
- else
- _LogWarning("lua", "No such config: " .. configName)
- end
- end
- end
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- check function
- -----------------------------------------------------------------------
- function %1:updateFromCheckList()
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- sets the given checklist element to true after the given amount of
- -- time (in seconds)
- -----------------------------------------------------------------------
- function %1:setDoneDelayed(p_Task, p_Time)
- TimedEventMgr:createTimedEvent("%1.quest:setDone(\"" .. p_Task .. "\")",
- p_Time)
- end
- -----------------------------------------------------------------------
-
- -----------------------------------------------------------------------
- -- Encapsulates picking up an object
- -----------------------------------------------------------------------
- function %1:pickupItem(p_Item, p_Animation, p_Sentence,
- p_BlockTime, p_TaskToSet,
- p_TimeToSetTask)
- player:say(p_Sentence)
- player:blendToPlayOnceAndBack(p_Animation)
- MouseIface:blockInput(p_BlockTime)
- self:setDoneDelayed(p_TaskToSet, p_TimeToSetTask)
- end
- -----------------------------------------------------------------------