mirror of
https://github.com/OpenMW/openmw.git
synced 2025-10-24 09:26:40 +00:00
Allow filters to apply to creatures
This commit is contained in:
parent
c16064e6f3
commit
a645ec0910
3 changed files with 9 additions and 36 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;
|
||||||
|
|
@ -504,7 +500,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 +583,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 +595,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 +667,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…
Reference in a new issue