= Questsystem =
== Author ==
[wiki:DamianFrick Damian Frick]
== Description ==
This project aims at implementing a system capable of handling quests.
== Timetable ==
|| '''Date''' || '''What''' ||
|| 15. oct. 2008 || Project design ||
|| 22. oct. 2008 || Start implementation ||
|| 29. oct. 2008 || continue implementation ;) ||
|| 5. nov. 2008 || Tidying and testing, starting implementation of QuestEffectBeacon ||
|| 12. nov. 2008 || Finishing Quests and Effects ||
|| 19. nov. 2008 || Finishing QuestEffectBeacon ||
|| 26. nov. 2008 || Testing, documenting, fail proofing... ||
|| 3. dec. 2008 || Project finished, thinking about something to do... ||
|| 10. dec. 2008 || Buffer, preparing presentation. ||
|| '''17. dec. 2008''' || '''Orxonox Presentation''' ||
== Classtree ==
[[Image(questsystem3.png)]]
== More details ==
The project essentially consists of the Quest entity which is the quest itself (and sub- or helper-entities, such as QuestHint (hints for quest) or QuestDescription (descriptions for quests and hints, to separate content from function)) and the QuestEffect entity which is is the only tool for quests to have an influence on the world. By enabling quests to have QuestEffects their are able to (for example) fail or complete other quests, activate hints give rewards or even trigger quests.
The QuestEffectBeacon is the physical entity which finally makes quests available fot the player in the game, by being able to activate a QuestEffect on a player (under some conditions).
== Creating Quests ==
=== Creating the Quest-Hierarchy ===
You firstly have to create a Quest-Hierarchy in the XML-Levelfile by nesting many quests.
There are two types of Quests you can use, the LocalQuest and the GlobalQuest.
==== LocalQuest ====
A LocalQuest is a Quest which has different states for each player, that means each LocalQuest can be obtained and completed (or failed) by each player parallely.
For generating the questId you can [http://www.google.com/search?q=guid+generator google] or you can use this [http://www.famkruithof.net/uuid/uuidgen generator].
Creating a LocalQuest in XML goes as follows:
{{{
//Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
//The description of the quest.
//A list of n subquest, be aware, each of the tags must have a description and so on and so forth as well.
...
//A list of n QuestHints, see QuestHint for the full XML representation of those.
...
//A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation.
...
//A list of QuestEffects, invoked when the Quest is completed, see QuestEffect for the full XML representation.
...
}}}
==== GlobalQuest ====
GlobalQUests are different, they can be obtained by every player but the changes made to the Quest (i.e. completion of the Quest) affect all owners of the Quest. In short. There are 3 Players, A, B and C. Player A obtains the Quest, a while later player B obtains the Quest and completes it. Since it is a GlobalQuest it is completed for all Players having obtained the Quest which means it is also completed for player A. Player C though, never having obtained the Quest, can now never complete this Quest.
For generating the questId you can [http://www.google.com/search?q=guid+generator google] or you can use this [http://www.famkruithof.net/uuid/uuidgen generator].
Creating a GlobalQuest in XML goes as follows:
{{{
//Where questId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
//The description of the quest.
//A list of n subquest, be aware, each of the tags must have a description and so on and so forth as well.
...
//A list of n QuestHints, see QuestHint for the full XML representation of those.
...
//A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation.
...
//A list of QuestEffects, invoked on all players possessing this quest, when the Quest is completed, see QuestEffect for the full XML representation.
...
//A list of QuestEffects, invoked on the player completing this quest. See QuestEffect for the full XML representation.
...
}}}
As you may see, the difference between a GlobalQuest also lies in the fact of the GlobalQuest having RewardEffects. RewardEffects are only executed on the completing player, while CompleteEffects are executed on all player having obtained the Quest before it is completed, when it is completed.
==== QuestHint ====
QuestHints can be used to give a player useful (or just funnily unuseful) information for Quests he is working on completing. The cannot have any sideeffects but also have an identifier which follows the same form as in the Quests.
Creating a QuestHint in XML goes as follows:
{{{
//Where hintId is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information
}}}
==== QuestDescription ====
Each Quest (and also each QuestHint) mus have a QuestDescription consisting of a title and description, and for Quests also messages for the event the Quest is either failed or completed. Of course these are (as is the title and the description) optional.
Creating a QuestDescription in XML goes as follows:
{{{
}}}
=== Creating Sideeffects ===
Quests can have sideeffects, this means that they can have an influence on the game world. Quests can do that through two distinct devices, QuestEffects and QuestListeners (active and passive).
==== QuestEffect ====
A QuestEffect is the first (and probably most important) divice for Quests to have sideeffects. There are two entities that can have QuestEffects: Quests and QuestEffectBeacons (which will be explained later on).
QuestEffects and for example start a Quest for a player, complete/fail Quests for a player, add a QuestHint or a Reward to a player.
These QuestEffects are implemented so far, but feel free to [wiki:DamianFrick contact me] if you have suggestions for new QuestEffects or if you need help implementing a new one yourself.
===== AddQuest =====
This QuestEffect adds (respectively starts) a Quest (identified by the given questId) to the player.
{{{
//Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added.
}}}
===== FailQuest =====
This QuestEffect fails a Quest (identified by the given questId) for the player.
{{{
//Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added.
}}}
===== CompleteQuest =====
This QuestEffect completes a Quest (identified by the given questId) for the player.
{{{
//Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the Quest that should be added.
}}}
===== AddQuestHint =====
This QuestEffect adds a QuestHint to a Quest (identified by the given questId) of a player.
{{{
//Where id is a GUID, see http://en.wikipedia.org/wiki/Globally_Unique_Identifier#Basic_structure for more information, and identifies the QuestHint that should be added.
}}}
===== AddReward =====
This QuestEffect adds a Rewardable (Rewardable is an Interface which can be implemented by and object that its creator thinks schould be able to be rewarded a player for completing (or failing for that matter) a Quest) to the player. Pickups for example wold be good Rewardables (this is not implemented though).
{{{
//A list of Rewardable objects to be rewarded the player, see the specific Rewardables for their respective XML representations.
...
}}}
==== QuestListener ====
The QuestListener is the second device you can use to create sideeffects. But other than QuestEffects (that are executed (or invoked) eighter as a result of failing or completing a Quest or by a QuestEffectBeacon) QuestListeners are passive. QuestListeners have a certain mode (all, start, complete or fail) and a Quest to which they belong to (resp. to which they react). You then can use QuestListeners to make basically any object aware of when the status of the given Quest changes (the way you defined through the mode) and take any action you may think of.
{{{
// The object that should react to the status change of a Quest.
// Where function is the method of the object that schould be executed. Normally this would be visibility or activity.
// Where someQuestId is the identifier for the Quest the QuestListener is reacting to, and someMode is the kind of status change the QUestListener reacts to (all, start, complete or fail).
}}}
I hope this example has made the QuestListener a little clearer. The QuestListener actually reacts exactly as any Trigger or EventListener would (allthough the QuestListener is really neighter the one nor the other) whcih means you can use it in exactly the same as you would use one of the above, it just reacts to a different thing. Namely to the change ina Quests status.
=== Putting the Quests in the game world ===
As of now we have a way for Quests to initiate new Quests of even complete/fail other Quests. We also have a way of reacting to a status change in Quest. But our Quests have no bound (well, not really at least) to the game world as of yet. For this we have QuestEffectBeacons.
==== QuestEffectBeacon ====
The QuestEffectBeacon is a PositionableEntity (so you can position it anywhere in the game world) and it has the ability to (when triggered trough some circumstance) invoke a specified list of QuestEffects on the player triggering the QuestEffectBeacon.
Creating a QuestEffectBeacon in XML goes as follows:
{{{
//Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
//A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
...
//A PlayerTrigger triggering the execution of the QuestEffectBeacon.
}}}
The QuestEffectBeacon can only be executed a defined number of times (where -1 times stands for an infinite number of times) and the QuestEffects are invoked whenever the method 'execute' is called, which is (indirectly through an EventListener, because I wanted to attach the PlayerTrigger so that his position is always relative to the QuestEffectBeacons position) done by the PlayerTrigger.
A PlayerTrigger is a special sort of Trigger that knows the player that triggered the Trigger and therefore can be asked who triggered him and that way allows theQuestEffects to be executed on the right player. So far only DistanceTrigger is a PlayerTrigger and the target of the DistanceTrigger is a ControllableEntity (or an object that is derived form the ControllableEntity).
== Example Quest ==
To get your head around all of this and see some of the things mentiond here in action you might want to check out the "The Tale Princess Aeryn"-Quest (Levelfile: princessaeryn.oxw) in the level-folder of the media repository.