diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-11-30 17:54:13 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-11-30 17:54:13 -0500 |
commit | 1024fe8305e5b0a7bb1f660a1cee077172d84534 (patch) | |
tree | 3153bc45fe98809c3d7e81f14710c0a0c6e0a6a2 /src/components.cpp | |
parent | 8c80ad1431512979e364e540a239e806851e4ada (diff) |
quest system
Diffstat (limited to 'src/components.cpp')
-rw-r--r-- | src/components.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/components.cpp b/src/components.cpp index 38fd7a6..eb9fb0e 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -8,6 +8,7 @@ #include <engine.hpp> #include <world.hpp> #include <brice.hpp> +#include <quest.hpp> static std::vector<std::string> randomDialog (readFileA("assets/dialog_en-us")); @@ -158,9 +159,11 @@ void DialogSystem::receive(const MouseClickEvent &mce) ((mce.position.y > pos.y) & (mce.position.y < pos.y + dim.height))) { std::thread([&] { - auto exml = game::engine.getSystem<WorldSystem>()->getXML()->FirstChildElement("Dialog"); + std::string questAssignedText; int newIndex; + auto exml = game::engine.getSystem<WorldSystem>()->getXML()->FirstChildElement("Dialog"); + if (e.has_component<Direction>()) d.talking = true; @@ -182,6 +185,34 @@ void DialogSystem::receive(const MouseClickEvent &mce) game::briceUpdate(); } + auto qxml = exml->FirstChildElement("quest"); + if (qxml != nullptr) { + std::string qname; + auto qsys = game::engine.getSystem<QuestSystem>(); + + do { + // assign quest + qname = qxml->StrAttribute("assign"); + if (!qname.empty()) { + questAssignedText = qname; + qsys->assign(qname, qxml->StrAttribute("desc"), "req"); // gettext() for req + } + + // check / finish quest + else { + qname = qxml->StrAttribute("check"); + if (!(qname.empty() && qsys->hasQuest(qname) && qsys->finish(qname))) { + ui::dialogBox(name.name, "", false, "Finish my quest u nug"); + ui::waitForDialog(); + return; + // oldidx = d.index; + // d.index = qxml->UnsignedAttribute("fail"); + // goto COMMONAIFUNC; + } + } + } while((qxml = qxml->NextSiblingElement())); + } + auto cxml = exml->FirstChildElement("content"); const char *content; if (cxml == nullptr) { @@ -194,6 +225,9 @@ void DialogSystem::receive(const MouseClickEvent &mce) ui::dialogBox(name.name, "", false, content); ui::waitForDialog(); + if (!questAssignedText.empty()) + ui::passiveImportantText(4000, ("Quest assigned:\n\"" + questAssignedText + "\"").c_str()); + if (exml->QueryIntAttribute("nextid", &newIndex) == XML_NO_ERROR) d.index = newIndex; } |