Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Condition.h
- #pragma once
- #include <string>
- enum ConditionType {
- QuestStageDone,
- PlayerLevel,
- SkillLevel,
- DungeonCleared,
- ItemInInventory,
- FindMapLocation,
- ItemActivation,
- NotSet
- };
- class Condition : public RE::BSTEventSink<RE::TESQuestStageEvent> {
- public:
- ConditionType type;
- virtual ~Condition() {};
- virtual void EnableListener(void);
- virtual void OnDataLoaded(void);
- Condition(ConditionType type) : type(type) {};
- };
- class ConditionFactory {
- public:
- virtual Condition* createCondition() = 0;
- virtual ~ConditionFactory() {};
- };
- class QuestStageDoneCondition : public Condition {
- public:
- std::string questId;
- int stage = 200;
- void OnDataLoaded(void) override;
- void EnableListener(void) override;
- void SetCondition(std::string questId, int stage);
- private:
- RE::BSEventNotifyControl ProcessEvent(const RE::TESQuestStageEvent* a_event, RE::BSTEventSource<RE::TESQuestStageEvent>*) override;
- };
- class QuestStageDoneConditionFactory : public ConditionFactory {
- public:
- Condition* createCondition() override;
- };
- // Condition.cpp
- #include "Condition.h"
- #include "log.h"
- #include "CommonFunctions.h"
- #include <SKSE/SKSE.h>
- #include <RE/Skyrim.h>
- #include <functional>
- extern void RegisterPostLoadFunction(Condition* condition);
- class Condition : public RE::BSTEventSink<RE::TESQuestStageEvent> {
- public:
- void EnableListener() {
- // Provide a default implementation or leave it empty if it's meant to be overridden
- }
- void OnDataLoaded() {
- // Provide a default implementation or leave it empty if it's meant to be overridden
- }
- };
- class QuestStageDoneCondition : public Condition {
- public:
- std::string questId;
- int stage = 200;
- void SetCondition(std::string questId, int stage) {
- this->questId = questId;
- this->stage = stage;
- }
- void OnDataLoaded(void){
- std::string questId = this->questId;
- logger::info("{}", questId);
- return;
- // Check that quest hasn't been completed already
- if (CheckQuestStage(this->questId, "Skyrim.esm") >= stage) {
- return;
- }
- // Bind sink for quest stage change event
- }
- void EnableListener(void)
- {
- RegisterPostLoadFunction(this);
- auto* eventSourceHolder = RE::ScriptEventSourceHolder::GetSingleton();
- eventSourceHolder->AddEventSink(this);
- }
- RE::BSEventNotifyControl ProcessEvent(const RE::TESQuestStageEvent* event, RE::BSTEventSource<RE::TESQuestStageEvent>*) override {
- const auto quest = RE::TESForm::LookupByEditorID<RE::TESQuest>(this->questId);
- if (event->formID == quest->formID) {
- logger::debug("si");
- }
- logger::debug("Ciaone.");
- return RE::BSEventNotifyControl::kContinue;
- }
- };
- class QuestStageDoneConditionFactory : ConditionFactory {
- public:
- Condition* createCondition() override {
- return new QuestStageDoneCondition();
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement