Quests Plugin
From Multiverse
| Contributed by: User:jcanker | Last Tested: 01 Jul 08 | Tested By: jcanker | Tested With: 1.5-Final |
Contents |
Overview
The MARS quest plug-in enables you to define quests, and make mobs give quests to PCs. It is defined by the multiverse.mars.plugins.QuestPlugin class. Although you can use the quest plug-in "as is", in general, you will need to create sub-classes to define your own quests. For example, you may wish to extend the plugin to incorporate group quests, timed quests, or escort quests.
The quest plug-in runs in the mob server process.
By default, use the following configuration scripts (in the /config directory) to customize or extend the quest plug-in:
-
multiverse/config/common/questplugin.py, which registers the quest plugin; -
multiverse/config/sampleworld/mobserver.py(world-specific script) in which you will define the quest and the mobs which serve as the start and end points of the quest; -
multiverse/config/common/events.pyin which events such as "QuestAvailable" and "QuestCompleted" are registered with the event server; -
multiverse/config/common/mvmessages.pyin which quest plugin-related messages are sent via themultiverse.mars.plugins.QuestClient
A quest tutorial is included in the Platform Tutorial.
Types of quests
By default, you can define the following types of quests:
- Collection quest, which requires a PC to acquire a certain quantity of one or more specific items. It is implemented by
MarsCollectionQuest, - Delivery quest, which requires a PC to deliver an item to a specific person or place. Delivery quests are not implemented by their own class; instead they are also implemented by
MarsCollectionQuest. - Kill quest, which requires a PC to kill a specific mob. Implemented by
MarsKillQuest.
Collection quest
Define a collection quest by adding some script statements to multiverse/config/worldname/mobserver.py; for example, here is the code for Sampleworld from multiverse/config/sampleworld/mobserver.py:
collectQuest = MarsCollectionQuest()
collectQuest.setName("Get some skins")
collectQuest.setDesc("Kill a wolf and bring me the skin and bones")
collectQuest.setObjective("Collect 1 Wolf Skin and 1 Wolf Bones")
collectQuest.addQuestPrereq("Welcome Ashore")
collectQuest.addCollectionGoal(MarsCollectionQuest.CollectionGoal("Wolf Skin", 1))
collectQuest.addCollectionGoal(MarsCollectionQuest.CollectionGoal("Wolf Bones", 1))
collectQuest.addReward("Leather Boots")
To make a mob be a quest-giver, add code such as the follwwing to multiverse/config/worldname/mobserver.py; for example, here is the code for Sampleworld from multiverse/config/sampleworld/mobserver.py:
class Npc2Factory (ObjectFactory):
def makeObject(self, loc):
obj = ObjectFactory.makeObject(self, loc)
behav = QuestBehavior()
behav.endsQuest(welcomeQuest)
behav.startsQuest(collectQuest)
behav.endsQuest(collectQuest)
obj.addBehavior(behav)
return obj
If you are creating a new ObjectFactory instead of just adding the appropriate quest-related lines to an existing one, ensure that you are initializing the ObjectFactory as well. More information and examples are provided in the Platform Tutorial.
Ensure that if the collected item is a lootable item from a killed mob that you have configured the mob to include that item in its inventory.
Delivery quest
Delivery quests are implemented in MARS as a variation of the collection quests. Set up a delivery quest the same way you would set up collection quest, except set the collection goal equal to the item(s) and quantity that are to be delivered. Use addDeliveryItem(String) to have that item added to the player's inventory upon accepting the quest. For example, these lines could be added to the quest defined earlier in mv-home/config/worldname/mobserver.py:
toArmsQuest.addCollectionGoal(MarsCollectionQuest.CollectionGoal("Bronze Longsword", 1))
toArmsQuest.addDeliveryItem("Bronze Longsword")
If the player is to deliver more than one of the same item, you must add them individually using addDeliveryItem.
Kill quest
Define a Kill quest with a script such as the following in multiverse/config/sampleworld/mobserver.py:
wolfQuest = MarsKillQuest()
wolfQuest.setName("Kill The Wolves")
wolfQuest.setDesc("Please kill 2 wolves for me.")
wolfQuest.setObjective("Kill 2 Wolves")
wolfQuest.setCashReward(1000)
wolfQuest.addReward("Leather Tunic")
wolfQuest.addKillGoal(MarsKillQuest.KillGoal("Wolf", 2))
To make a mob be a quest-giver, use code such as this in multiverse/config/sampleworld/mobserver.py:
class Npc2Factory (ObjectFactory):
def makeObject(self, loc):
obj = ObjectFactory.makeObject(self, loc)
behav = QuestBehavior()
behav.endsQuest(welcomeQuest)
behav.startsQuest(wolfQuest)
behav.endsQuest(wolfQuest)
obj.addBehavior(behav)
return obj
Quest Chaining
To immediately trigger a new quest upon concluding a current quest in order to create a chain of story-related quests, include quest.addQuestPrereq(String)
as an attribute of the quest when you define it in worldname/mobserver.py. Use the value of the attribute NAME as the reference string. To create a chain quest from the earlier example collection quest:
collectQuest = MarsCollectionQuest()
collectQuest.setName("Get some skins")
collectQuest.setDesc("Kill a wolf and bring me the skin and bones")
collectQuest.setObjective("Collect 1 Wolf Skin and 1 Wolf Bones")
collectQuest.addQuestPrereq("Welcome Ashore")
collectQuest.addCollectionGoal(MarsCollectionQuest.CollectionGoal("Wolf Skin", 1))
collectQuest.addCollectionGoal(MarsCollectionQuest.CollectionGoal("Wolf Bones", 1))
collectQuest.addReward("Leather Boots")
collectQuest.addQuestPrereq("We Need More Armor!")
setChainQuest method which no longer works in 1.5. Use addQuestPrereq instead.