mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-09 14:41:25 +00:00
Merge branch 'faction_relations' into 'master'
Take in account faction reaction changes See merge request OpenMW/openmw!4015
This commit is contained in:
commit
24fca82f2c
4 changed files with 31 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
#define GAME_MWBASE_DIALOGUEMANAGER_H
|
#define GAME_MWBASE_DIALOGUEMANAGER_H
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -108,11 +109,15 @@ namespace MWBase
|
||||||
/// Changes faction1's opinion of faction2 by \a diff.
|
/// Changes faction1's opinion of faction2 by \a diff.
|
||||||
virtual void modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff) = 0;
|
virtual void modFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int diff) = 0;
|
||||||
|
|
||||||
|
/// Set faction1's opinion of faction2.
|
||||||
virtual void setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute) = 0;
|
virtual void setFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2, int absolute) = 0;
|
||||||
|
|
||||||
/// @return faction1's opinion of faction2
|
/// @return faction1's opinion of faction2
|
||||||
virtual int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const = 0;
|
virtual int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const = 0;
|
||||||
|
|
||||||
|
/// @return all faction's opinion overrides
|
||||||
|
virtual const std::map<ESM::RefId, int>* getFactionReactionOverrides(const ESM::RefId& faction) const = 0;
|
||||||
|
|
||||||
/// Removes the last added topic response for the given actor from the journal
|
/// Removes the last added topic response for the given actor from the journal
|
||||||
virtual void clearInfoActor(const MWWorld::Ptr& actor) const = 0;
|
virtual void clearInfoActor(const MWWorld::Ptr& actor) const = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -738,6 +738,17 @@ namespace MWDialogue
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::map<ESM::RefId, int>* DialogueManager::getFactionReactionOverrides(const ESM::RefId& faction) const
|
||||||
|
{
|
||||||
|
// Make sure the faction exists
|
||||||
|
MWBase::Environment::get().getESMStore()->get<ESM::Faction>().find(faction);
|
||||||
|
|
||||||
|
const auto found = mChangedFactionReaction.find(faction);
|
||||||
|
if (found != mChangedFactionReaction.end())
|
||||||
|
return &found->second;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void DialogueManager::clearInfoActor(const MWWorld::Ptr& actor) const
|
void DialogueManager::clearInfoActor(const MWWorld::Ptr& actor) const
|
||||||
{
|
{
|
||||||
if (actor == mActor && !mLastTopic.empty())
|
if (actor == mActor && !mLastTopic.empty())
|
||||||
|
|
|
@ -126,6 +126,8 @@ namespace MWDialogue
|
||||||
/// @return faction1's opinion of faction2
|
/// @return faction1's opinion of faction2
|
||||||
int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const override;
|
int getFactionReaction(const ESM::RefId& faction1, const ESM::RefId& faction2) const override;
|
||||||
|
|
||||||
|
const std::map<ESM::RefId, int>* getFactionReactionOverrides(const ESM::RefId& faction) const override;
|
||||||
|
|
||||||
/// Removes the last added topic response for the given actor from the journal
|
/// Removes the last added topic response for the given actor from the journal
|
||||||
void clearInfoActor(const MWWorld::Ptr& actor) const override;
|
void clearInfoActor(const MWWorld::Ptr& actor) const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <components/esm3/loadfact.hpp>
|
#include <components/esm3/loadfact.hpp>
|
||||||
#include <components/lua/luastate.hpp>
|
#include <components/lua/luastate.hpp>
|
||||||
|
|
||||||
|
#include "../mwbase/dialoguemanager.hpp"
|
||||||
|
#include "../mwbase/environment.hpp"
|
||||||
|
|
||||||
#include "../mwworld/store.hpp"
|
#include "../mwworld/store.hpp"
|
||||||
|
|
||||||
#include "idcollectionbindings.hpp"
|
#include "idcollectionbindings.hpp"
|
||||||
|
@ -70,6 +73,16 @@ namespace MWLua
|
||||||
sol::table res(lua, sol::create);
|
sol::table res(lua, sol::create);
|
||||||
for (const auto& [factionId, reaction] : rec.mReactions)
|
for (const auto& [factionId, reaction] : rec.mReactions)
|
||||||
res[factionId.serializeText()] = reaction;
|
res[factionId.serializeText()] = reaction;
|
||||||
|
|
||||||
|
const auto* overrides
|
||||||
|
= MWBase::Environment::get().getDialogueManager()->getFactionReactionOverrides(rec.mId);
|
||||||
|
|
||||||
|
if (overrides != nullptr)
|
||||||
|
{
|
||||||
|
for (const auto& [factionId, reaction] : *overrides)
|
||||||
|
res[factionId.serializeText()] = reaction;
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
factionT["attributes"] = sol::readonly_property([&lua](const ESM::Faction& rec) {
|
factionT["attributes"] = sol::readonly_property([&lua](const ESM::Faction& rec) {
|
||||||
|
|
Loading…
Reference in a new issue