mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Merge branch 'stupidfilters' into 'master'
Some checks failed
Build and test / Ubuntu (push) Has been cancelled
Build and test / MacOS (push) Has been cancelled
Build and test / Read .env file and expose it as output (push) Has been cancelled
Build and test / Windows (2019) (push) Has been cancelled
Build and test / Windows (2022) (push) Has been cancelled
Some checks failed
Build and test / Ubuntu (push) Has been cancelled
Build and test / MacOS (push) Has been cancelled
Build and test / Read .env file and expose it as output (push) Has been cancelled
Build and test / Windows (2019) (push) Has been cancelled
Build and test / Windows (2022) (push) Has been cancelled
Bring dialogue filters in line with Morrowind.exe Closes #8318 See merge request OpenMW/openmw!4525
This commit is contained in:
commit
863fc8c0e4
3 changed files with 15 additions and 38 deletions
|
@ -265,10 +265,6 @@ bool MWDialogue::Filter::testFunctionLocal(const MWDialogue::SelectWrapper& sele
|
||||||
|
|
||||||
bool MWDialogue::Filter::testSelectStruct(const SelectWrapper& select) const
|
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 (select.getFunction() == ESM::DialogueCondition::Function_Choice && mChoice == -1)
|
||||||
// If not currently in a choice, we reject all conditions that test against choices.
|
// If not currently in a choice, we reject all conditions that test against choices.
|
||||||
return false;
|
return false;
|
||||||
|
@ -305,9 +301,13 @@ bool MWDialogue::Filter::testSelectStructNumeric(const SelectWrapper& select) co
|
||||||
switch (select.getFunction())
|
switch (select.getFunction())
|
||||||
{
|
{
|
||||||
case ESM::DialogueCondition::Function_Global:
|
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 :(
|
// 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:
|
case ESM::DialogueCondition::Function_Local:
|
||||||
{
|
{
|
||||||
|
@ -504,7 +504,8 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
|
||||||
return MWBase::Environment::get().getWorld()->getCurrentWeather();
|
return MWBase::Environment::get().getWorld()->getCurrentWeather();
|
||||||
|
|
||||||
case ESM::DialogueCondition::Function_Reputation:
|
case ESM::DialogueCondition::Function_Reputation:
|
||||||
|
if (!mActor.getClass().isNpc())
|
||||||
|
return 0;
|
||||||
return mActor.getClass().getNpcStats(mActor).getReputation();
|
return mActor.getClass().getNpcStats(mActor).getReputation();
|
||||||
|
|
||||||
case ESM::DialogueCondition::Function_FactionRankDifference:
|
case ESM::DialogueCondition::Function_FactionRankDifference:
|
||||||
|
@ -586,11 +587,11 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
|
||||||
|
|
||||||
case ESM::DialogueCondition::Function_NotClass:
|
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:
|
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:
|
case ESM::DialogueCondition::Function_NotCell:
|
||||||
{
|
{
|
||||||
|
@ -598,12 +599,14 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
|
||||||
return !Misc::StringUtils::ciStartsWith(actorCell, select.getCellName());
|
return !Misc::StringUtils::ciStartsWith(actorCell, select.getCellName());
|
||||||
}
|
}
|
||||||
case ESM::DialogueCondition::Function_SameSex:
|
case ESM::DialogueCondition::Function_SameSex:
|
||||||
|
if (!mActor.getClass().isNpc())
|
||||||
|
return false;
|
||||||
return (player.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female)
|
return (player.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female)
|
||||||
== (mActor.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female);
|
== (mActor.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female);
|
||||||
|
|
||||||
case ESM::DialogueCondition::Function_SameRace:
|
case ESM::DialogueCondition::Function_SameRace:
|
||||||
|
if (!mActor.getClass().isNpc())
|
||||||
|
return false;
|
||||||
return mActor.get<ESM::NPC>()->mBase->mRace == player.get<ESM::NPC>()->mBase->mRace;
|
return mActor.get<ESM::NPC>()->mBase->mRace == player.get<ESM::NPC>()->mBase->mRace;
|
||||||
|
|
||||||
case ESM::DialogueCondition::Function_SameFaction:
|
case ESM::DialogueCondition::Function_SameFaction:
|
||||||
|
@ -668,7 +671,7 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con
|
||||||
|
|
||||||
case ESM::DialogueCondition::Function_Werewolf:
|
case ESM::DialogueCondition::Function_Werewolf:
|
||||||
|
|
||||||
return mActor.getClass().getNpcStats(mActor).isWerewolf();
|
return mActor.getClass().isNpc() && mActor.getClass().getNpcStats(mActor).isWerewolf();
|
||||||
|
|
||||||
default:
|
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
|
bool MWDialogue::SelectWrapper::selectCompare(int value) const
|
||||||
{
|
{
|
||||||
return selectCompareImp(mSelect, value);
|
return selectCompareImp(mSelect, value);
|
||||||
|
|
|
@ -28,9 +28,6 @@ namespace MWDialogue
|
||||||
|
|
||||||
Type getType() const;
|
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(int value) const;
|
||||||
|
|
||||||
bool selectCompare(float value) const;
|
bool selectCompare(float value) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue