项目作者: Cultrarius

项目描述 :
Procedurally generated quests and stories for computer games.
高级语言: C++
项目地址: git://github.com/Cultrarius/QuestWeaver.git
创建时间: 2015-08-10T18:00:44Z
项目社区:https://github.com/Cultrarius/QuestWeaver

开源协议:The Unlicense

下载


QuestWeaver

Coverage Status

Procedurally generated quests and stories for computer games.

This project is still in its early stages and under heavy development!

Features

  • Fully portable, serializable quest system, perfect for use in savegames. Supports JSON and a compact binary format.
  • Separates quest logic from quest data (such as titles/descriptions) by using template files.
  • Can output the quest properties as simple text or HTML form to support rich formatting in the game.
  • Uses a complex weighted graph search to create new quests.
    This results in more interesting and coherent quest stories as world actors and entities can be reused when fitting.
  • Supports mod directories to overwrite quest templates after deployment.
  • The game world entities to be used in quests are supplied directly from a game’s custom world model.

Documentation

Have a look at the API documentation!

Usage

The quest system of a game is not an isolated part of the system as it is heavily involved in the current world state and events.
Therefore, the game has to provide the quest system with the necessary information about the game’s state and has to
fulfill change requests made by the quest system (otherwise the state will be inconsistent).

To use the QuestWeaver system, you have to follow these steps:

  • Implement and register custom TemplateFactory classes that read your custom template files
  • Implement a custom WorldModel class
  • Register your wold model and template factories with the QuestWeaver instance
  1. QuestWeaver Init() {
  2. // Create your template factories
  3. unique_ptr<QuestTemplateFactory> questFactory = make_unique<MyQuestTemplateFactory>();
  4. unique_ptr<StoryTemplateFactory> storyFactory = make_unique<MyStoryTemplateFactory>();
  5. // Create Configuration
  6. WeaverConfig config;
  7. config.worldModel = make_unique<MyWorldModel>();
  8. config.dirs.modDirectory = "./Template/";
  9. shared_ptr<WorldListener> myWorldListener = make_shared<MyWorldListener>();
  10. // Create the quest system
  11. QuestWeaver weaver(config);
  12. weaver.RegisterQuestTemplateFactory(move(questFactory));
  13. weaver.RegisterStoryTemplateFactory(move(storyFactory));
  14. weaver.GetWorldModel().AddListener(myWorldListener);
  15. return weaver;
  16. }
  17. // Create new quests
  18. shared_ptr<Quest> newQuest = weaver.CreateNewQuest();

Quests usually want to change the world state as well as their own state (e.g. when a quest succeeds).
To do that, you can tick the quest system in your game loop and it will take care of the rest by ticking each quest
separately.
The WorldListener allows you to change the game state whenever the world model was changed by the quest system.

  1. while (true) {
  2. // game loop ...
  3. weaver.Tick(delta); // updates the world state
  4. }

You can also fully serialize the quest system, e.g. to create a save game or to debug it:

  1. void SerialTest() {
  2. QuestWeaver weaver = Init();
  3. // serialize
  4. stringstream ss; // can also be a file stream
  5. weaver.Serialize(ss, StreamType::JSON);
  6. cout << ss.str() << endl; // or save it to disk
  7. // deserialize - it is important to re-register the template factories and the world model listener!
  8. QuestWeaver deserialized = QuestWeaver::Deserialize(ss, StreamType::JSON, config.dirs);
  9. weaver.RegisterQuestTemplateFactory(move(questFactory));
  10. weaver.RegisterStoryTemplateFactory(move(storyFactory));
  11. weaver.GetWorldModel().AddListener(myWorldListener);
  12. }

Included projects

This project uses the help of some very fine frameworks: