mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-14 01:19:59 +00:00
Merge branch 'stupidfilters' into 'master'
Bring dialogue filters in line with Morrowind.exe Closes #8318 See merge request OpenMW/openmw!4525
This commit is contained in:
commit
ff864e78e6
@ -265,10 +265,6 @@ bool MWDialogue::Filter::testFunctionLocal(const MWDialogue::SelectWrapper& sele
|
||||
|
||||
bool MWDialogue::Filter::testSelectStruct(const SelectWrapper& select) const
|
||||
{
|
||||
if (select.isNpcOnly() && (mActor.getType() != ESM::NPC::sRecordId))
|
||||
// If the actor is a creature, we pass all conditions only applicable to NPCs.
|
||||
return true;
|
||||
|
||||
if (select.getFunction() == ESM::DialogueCondition::Function_Choice && mChoice == -1)
|
||||
// If not currently in a choice, we reject all conditions that test against choices.
|
||||
return false;
|
||||
@ -305,9 +301,13 @@ bool MWDialogue::Filter::testSelectStructNumeric(const SelectWrapper& select) co
|
||||
switch (select.getFunction())
|
||||
{
|
||||
case ESM::DialogueCondition::Function_Global:
|
||||
|
||||
{
|
||||
const auto& world = MWBase::Environment::get().getWorld();
|
||||
if (world->getGlobalVariableType(select.getName()) == ' ')
|
||||
return true; // ignore this filter if the global doesn't exist
|
||||
// internally all globals are float :(
|
||||
return select.selectCompare(MWBase::Environment::get().getWorld()->getGlobalFloat(select.getName()));
|
||||
return select.selectCompare(world->getGlobalFloat(select.getName()));
|
||||
}
|
||||
|
||||
case ESM::DialogueCondition::Function_Local:
|
||||
{
|
||||
@ -504,7 +504,8 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
|
||||
return MWBase::Environment::get().getWorld()->getCurrentWeather();
|
||||
|
||||
case ESM::DialogueCondition::Function_Reputation:
|
||||
|
||||
if (!mActor.getClass().isNpc())
|
||||
return 0;
|
||||
return mActor.getClass().getNpcStats(mActor).getReputation();
|
||||
|
||||
case ESM::DialogueCondition::Function_FactionRankDifference:
|
||||
@ -586,11 +587,11 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
|
||||
|
||||
case ESM::DialogueCondition::Function_NotClass:
|
||||
|
||||
return mActor.get<ESM::NPC>()->mBase->mClass != select.getId();
|
||||
return !mActor.getClass().isNpc() || mActor.get<ESM::NPC>()->mBase->mClass != select.getId();
|
||||
|
||||
case ESM::DialogueCondition::Function_NotRace:
|
||||
|
||||
return mActor.get<ESM::NPC>()->mBase->mRace != select.getId();
|
||||
return !mActor.getClass().isNpc() || mActor.get<ESM::NPC>()->mBase->mRace != select.getId();
|
||||
|
||||
case ESM::DialogueCondition::Function_NotCell:
|
||||
{
|
||||
@ -598,12 +599,14 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
|
||||
return !Misc::StringUtils::ciStartsWith(actorCell, select.getCellName());
|
||||
}
|
||||
case ESM::DialogueCondition::Function_SameSex:
|
||||
|
||||
if (!mActor.getClass().isNpc())
|
||||
return false;
|
||||
return (player.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female)
|
||||
== (mActor.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female);
|
||||
|
||||
case ESM::DialogueCondition::Function_SameRace:
|
||||
|
||||
if (!mActor.getClass().isNpc())
|
||||
return false;
|
||||
return mActor.get<ESM::NPC>()->mBase->mRace == player.get<ESM::NPC>()->mBase->mRace;
|
||||
|
||||
case ESM::DialogueCondition::Function_SameFaction:
|
||||
@ -668,7 +671,7 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
|
||||
|
||||
case ESM::DialogueCondition::Function_Werewolf:
|
||||
|
||||
return mActor.getClass().getNpcStats(mActor).isWerewolf();
|
||||
return mActor.getClass().isNpc() && mActor.getClass().getNpcStats(mActor).isWerewolf();
|
||||
|
||||
default:
|
||||
|
||||
|
@ -247,29 +247,6 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const
|
||||
};
|
||||
}
|
||||
|
||||
bool MWDialogue::SelectWrapper::isNpcOnly() const
|
||||
{
|
||||
switch (mSelect.mFunction)
|
||||
{
|
||||
case ESM::DialogueCondition::Function_NotFaction:
|
||||
case ESM::DialogueCondition::Function_NotClass:
|
||||
case ESM::DialogueCondition::Function_NotRace:
|
||||
case ESM::DialogueCondition::Function_SameSex:
|
||||
case ESM::DialogueCondition::Function_SameRace:
|
||||
case ESM::DialogueCondition::Function_SameFaction:
|
||||
case ESM::DialogueCondition::Function_RankRequirement:
|
||||
case ESM::DialogueCondition::Function_Reputation:
|
||||
case ESM::DialogueCondition::Function_FactionRankDifference:
|
||||
case ESM::DialogueCondition::Function_Werewolf:
|
||||
case ESM::DialogueCondition::Function_PcWerewolfKills:
|
||||
case ESM::DialogueCondition::Function_FacReactionLowest:
|
||||
case ESM::DialogueCondition::Function_FacReactionHighest:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool MWDialogue::SelectWrapper::selectCompare(int value) const
|
||||
{
|
||||
return selectCompareImp(mSelect, value);
|
||||
|
@ -28,9 +28,6 @@ namespace MWDialogue
|
||||
|
||||
Type getType() const;
|
||||
|
||||
bool isNpcOnly() const;
|
||||
///< \attention Do not call any of the select functions for this select struct!
|
||||
|
||||
bool selectCompare(int value) const;
|
||||
|
||||
bool selectCompare(float value) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user