Another problem arose through not having a solid GUI system up. So we had to make due with what we had. The structure is as follows:
The player has a MissionHolder and a MissionDispatcher. The MissionHolder is essential a hashtable of Missions and strings as the key, that listens for MissionEvents such as add/completed, etc. A Mission is simply a struct with a name and a status, eg. COMPLETED, FAILED, INPROGRESS, etc.
The real meat and potatoes is in the MissionDispatcher. It listens for a dispatched Mission (which most likely comes from a Dialog from an NPC). The dispatched message (an Event) has the name of the Mission in question. The MissionDispatcher has a reference of already Dispatched Missions, if this mission has not been dispatched, it creates it based off of the Event information. The Event information contains a .MSN filename which is a Mission File that contains all relavent mission data. Now that we have this created Mission, we fire an Event to the MissionHolder, and presto we have an assigned mission.
Well actually there is still a lot more work to be done. This simply assigns a mission, but what the hell is a mission without an objective, and rules to completing that objective? This is were scripting comes in very handy. Thanks to LUA this is done quite easily. In total we have a possible 8 files for a single mission. This sounds like a lot, but with all the possibilities we need responses for all of them. Here is the breakdown of each file and its use:
- mission_check.lua - this file contains a function which takes in an array of mission names, and assigns the correct dialog response. The array of mission names are the queue of missions this particular NPC can give. Based on the status of the current assigned mission, this function will present the correct dialog or action. Ex. If mission A is in progress, the next time the player talks with this NPC he will ask how the mission is going.
- [mission_name]_setup.lua - this file has the array of possible missions to assign. And feeds it to the mission_check.lua.
- [mission_name].dialog - this file is the initial dialog for a mission. If you choose to accept it, it, an event will fire to the MissionDispatcher.
- [mission_name].msn - this file states the mission summary and where to find the mission rules. The mission rules are what needs to happen inorder for this particular mission to be complete.
- [mission_name]_inprogress.dialog - This dialog is for when the mission is in progress. What should the NPC when you have not completed the mission, but talk to him again, maybe give you a clue or something to get you on your way.
- [mission_name]_reward.lua - When the mission is complete, and you come to collect your reward, this script handles it.
- [mission_name]_reward.dialog - The NPC needs to tell you what he is giving you. So we have a dialog for it.
- Can be the rule set, this maybe multiple files.