mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Remove redundant isHostile flag (Fixes #1652)
This commit is contained in:
parent
0077296c91
commit
4773d754c6
9 changed files with 11 additions and 38 deletions
|
@ -678,8 +678,8 @@ namespace MWClass
|
||||||
if (ptr != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (ptr != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
{
|
{
|
||||||
// Attacking peaceful NPCs is a crime
|
// Attacking peaceful NPCs is a crime
|
||||||
if (!attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).isHostile() &&
|
if (!attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat(attacker)
|
||||||
!MWBase::Environment::get().getMechanicsManager()->isAggressive(ptr, attacker))
|
&& !MWBase::Environment::get().getMechanicsManager()->isAggressive(ptr, attacker))
|
||||||
MWBase::Environment::get().getMechanicsManager()->commitCrime(attacker, ptr, MWBase::MechanicsManager::OT_Assault);
|
MWBase::Environment::get().getMechanicsManager()->commitCrime(attacker, ptr, MWBase::MechanicsManager::OT_Assault);
|
||||||
|
|
||||||
if (!attacker.isEmpty() && attacker.getClass().getCreatureStats(attacker).getAiSequence().isInCombat(ptr)
|
if (!attacker.isEmpty() && attacker.getClass().getCreatureStats(attacker).getAiSequence().isInCombat(ptr)
|
||||||
|
@ -910,7 +910,7 @@ namespace MWClass
|
||||||
|
|
||||||
if(getCreatureStats(ptr).isDead())
|
if(getCreatureStats(ptr).isDead())
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr, true));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr, true));
|
||||||
if(ptr.getClass().getCreatureStats(ptr).isHostile())
|
if(ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat())
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction("#{sActorInCombat}"));
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::FailedAction("#{sActorInCombat}"));
|
||||||
if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak))
|
if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak))
|
||||||
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
|
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing
|
||||||
|
|
|
@ -191,7 +191,6 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
CreatureStats& creatureStats = actor1.getClass().getCreatureStats(actor1);
|
CreatureStats& creatureStats = actor1.getClass().getCreatureStats(actor1);
|
||||||
|
|
||||||
if (againstPlayer && creatureStats.isHostile()) return; // already fighting against player
|
|
||||||
if (actor2.getClass().getCreatureStats(actor2).isDead()
|
if (actor2.getClass().getCreatureStats(actor2).isDead()
|
||||||
|| actor1.getClass().getCreatureStats(actor1).isDead())
|
|| actor1.getClass().getCreatureStats(actor1).isDead())
|
||||||
return;
|
return;
|
||||||
|
@ -204,7 +203,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
// pure water creatures won't try to fight with the target on the ground
|
// pure water creatures won't try to fight with the target on the ground
|
||||||
// except that creature is already hostile
|
// except that creature is already hostile
|
||||||
if ((againstPlayer || !creatureStats.isHostile())
|
if ((againstPlayer || !creatureStats.getAiSequence().isInCombat())
|
||||||
&& ((actor1.getClass().canSwim(actor1) && !actor1.getClass().canWalk(actor1) // pure water creature
|
&& ((actor1.getClass().canSwim(actor1) && !actor1.getClass().canWalk(actor1) // pure water creature
|
||||||
&& !MWBase::Environment::get().getWorld()->isSwimming(actor2))
|
&& !MWBase::Environment::get().getWorld()->isSwimming(actor2))
|
||||||
|| (!actor1.getClass().canSwim(actor1) && MWBase::Environment::get().getWorld()->isSwimming(actor2)))) // creature can't swim to target
|
|| (!actor1.getClass().canSwim(actor1) && MWBase::Environment::get().getWorld()->isSwimming(actor2)))) // creature can't swim to target
|
||||||
|
@ -222,7 +221,7 @@ namespace MWMechanics
|
||||||
if (!actor1.getClass().isNpc() && actor2.getClass().isClass(actor2, "Guard"))
|
if (!actor1.getClass().isNpc() && actor2.getClass().isClass(actor2, "Guard"))
|
||||||
{
|
{
|
||||||
// if creature is hostile then it is necessarily to start combat
|
// if creature is hostile then it is necessarily to start combat
|
||||||
if (creatureStats.isHostile()) aggressive = true;
|
if (creatureStats.getAiSequence().isInCombat()) aggressive = true;
|
||||||
else aggressive = MWBase::Environment::get().getMechanicsManager()->isAggressive(actor1, actor2);
|
else aggressive = MWBase::Environment::get().getMechanicsManager()->isAggressive(actor1, actor2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -796,7 +795,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
if (torch != inventoryStore.end())
|
if (torch != inventoryStore.end())
|
||||||
{
|
{
|
||||||
if (!ptr.getClass().getCreatureStats (ptr).isHostile())
|
if (!ptr.getClass().getCreatureStats (ptr).getAiSequence().isInCombat())
|
||||||
{
|
{
|
||||||
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
|
// For non-hostile NPCs, unequip whatever is in the left slot in favor of a light.
|
||||||
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
|
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
|
||||||
|
@ -876,7 +875,7 @@ namespace MWMechanics
|
||||||
CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
|
CreatureStats& creatureStats = ptr.getClass().getCreatureStats(ptr);
|
||||||
NpcStats& npcStats = ptr.getClass().getNpcStats(ptr);
|
NpcStats& npcStats = ptr.getClass().getNpcStats(ptr);
|
||||||
|
|
||||||
if (ptr.getClass().isClass(ptr, "Guard") && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue && !creatureStats.isHostile())
|
if (ptr.getClass().isClass(ptr, "Guard") && creatureStats.getAiSequence().getTypeId() != AiPackage::TypeIdPursue && !creatureStats.getAiSequence().isInCombat())
|
||||||
{
|
{
|
||||||
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore();
|
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore();
|
||||||
int cutoff = esmStore.get<ESM::GameSetting>().find("iCrimeThreshold")->getInt();
|
int cutoff = esmStore.get<ESM::GameSetting>().find("iCrimeThreshold")->getInt();
|
||||||
|
@ -909,7 +908,6 @@ namespace MWMechanics
|
||||||
creatureStats.getAiSequence().stopCombat();
|
creatureStats.getAiSequence().stopCombat();
|
||||||
|
|
||||||
// Reset factors to attack
|
// Reset factors to attack
|
||||||
creatureStats.setHostile(false);
|
|
||||||
creatureStats.setAttacked(false);
|
creatureStats.setAttacked(false);
|
||||||
creatureStats.setAlarmed(false);
|
creatureStats.setAlarmed(false);
|
||||||
|
|
||||||
|
@ -1074,7 +1072,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
if(!stats.isDead())
|
if(!stats.isDead())
|
||||||
{
|
{
|
||||||
if (stats.isHostile()) hostilesCount++;
|
if (stats.getAiSequence().isInCombat()) hostilesCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,8 +190,6 @@ namespace MWMechanics
|
||||||
// 2. creature can't swim to target
|
// 2. creature can't swim to target
|
||||||
|| (!actorClass.canSwim(actor) && world->isSwimming(target))))
|
|| (!actorClass.canSwim(actor) && world->isSwimming(target))))
|
||||||
{
|
{
|
||||||
if (target == world->getPlayerPtr())
|
|
||||||
actorClass.getCreatureStats(actor).setHostile(false);
|
|
||||||
actorClass.getCreatureStats(actor).setAttackingOrSpell(false);
|
actorClass.getCreatureStats(actor).setAttackingOrSpell(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace MWMechanics
|
||||||
CreatureStats::CreatureStats()
|
CreatureStats::CreatureStats()
|
||||||
: mLevel (0), mDead (false), mDied (false), mMurdered(false), mFriendlyHits (0),
|
: mLevel (0), mDead (false), mDied (false), mMurdered(false), mFriendlyHits (0),
|
||||||
mTalkedTo (false), mAlarmed (false),
|
mTalkedTo (false), mAlarmed (false),
|
||||||
mAttacked (false), mHostile (false),
|
mAttacked (false),
|
||||||
mAttackingOrSpell(false),
|
mAttackingOrSpell(false),
|
||||||
mIsWerewolf(false),
|
mIsWerewolf(false),
|
||||||
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false),
|
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false),
|
||||||
|
@ -331,16 +331,6 @@ namespace MWMechanics
|
||||||
mAttacked = attacked;
|
mAttacked = attacked;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreatureStats::isHostile() const
|
|
||||||
{
|
|
||||||
return mHostile;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreatureStats::setHostile (bool hostile)
|
|
||||||
{
|
|
||||||
mHostile = hostile;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CreatureStats::getCreatureTargetted() const
|
bool CreatureStats::getCreatureTargetted() const
|
||||||
{
|
{
|
||||||
MWWorld::Ptr targetPtr;
|
MWWorld::Ptr targetPtr;
|
||||||
|
@ -506,7 +496,6 @@ namespace MWMechanics
|
||||||
state.mTalkedTo = mTalkedTo;
|
state.mTalkedTo = mTalkedTo;
|
||||||
state.mAlarmed = mAlarmed;
|
state.mAlarmed = mAlarmed;
|
||||||
state.mAttacked = mAttacked;
|
state.mAttacked = mAttacked;
|
||||||
state.mHostile = mHostile;
|
|
||||||
state.mAttackingOrSpell = mAttackingOrSpell;
|
state.mAttackingOrSpell = mAttackingOrSpell;
|
||||||
// TODO: rewrite. does this really need 3 separate bools?
|
// TODO: rewrite. does this really need 3 separate bools?
|
||||||
state.mKnockdown = mKnockdown;
|
state.mKnockdown = mKnockdown;
|
||||||
|
@ -555,7 +544,6 @@ namespace MWMechanics
|
||||||
mTalkedTo = state.mTalkedTo;
|
mTalkedTo = state.mTalkedTo;
|
||||||
mAlarmed = state.mAlarmed;
|
mAlarmed = state.mAlarmed;
|
||||||
mAttacked = state.mAttacked;
|
mAttacked = state.mAttacked;
|
||||||
mHostile = state.mHostile;
|
|
||||||
mAttackingOrSpell = state.mAttackingOrSpell;
|
mAttackingOrSpell = state.mAttackingOrSpell;
|
||||||
// TODO: rewrite. does this really need 3 separate bools?
|
// TODO: rewrite. does this really need 3 separate bools?
|
||||||
mKnockdown = state.mKnockdown;
|
mKnockdown = state.mKnockdown;
|
||||||
|
|
|
@ -200,9 +200,6 @@ namespace MWMechanics
|
||||||
bool getAttacked() const;
|
bool getAttacked() const;
|
||||||
void setAttacked (bool attacked);
|
void setAttacked (bool attacked);
|
||||||
|
|
||||||
bool isHostile() const;
|
|
||||||
void setHostile (bool hostile);
|
|
||||||
|
|
||||||
bool getCreatureTargetted() const;
|
bool getCreatureTargetted() const;
|
||||||
|
|
||||||
float getEvasion() const;
|
float getEvasion() const;
|
||||||
|
|
|
@ -1176,8 +1176,6 @@ namespace MWMechanics
|
||||||
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
|
||||||
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (target == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
{
|
{
|
||||||
ptr.getClass().getCreatureStats(ptr).setHostile(true);
|
|
||||||
|
|
||||||
// if guard starts combat with player, guards pursuing player should do the same
|
// if guard starts combat with player, guards pursuing player should do the same
|
||||||
if (ptr.getClass().isClass(ptr, "Guard"))
|
if (ptr.getClass().isClass(ptr, "Guard"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -420,7 +420,6 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
const MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
const MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
||||||
std::string currentTargetId;
|
|
||||||
|
|
||||||
bool targetsAreEqual = false;
|
bool targetsAreEqual = false;
|
||||||
MWWorld::Ptr targetPtr;
|
MWWorld::Ptr targetPtr;
|
||||||
|
@ -457,7 +456,6 @@ namespace MWScript
|
||||||
MWWorld::Ptr actor = R()(runtime);
|
MWWorld::Ptr actor = R()(runtime);
|
||||||
MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
|
||||||
creatureStats.getAiSequence().stopCombat();
|
creatureStats.getAiSequence().stopCombat();
|
||||||
creatureStats.setHostile(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ void ESM::CreatureStats::load (ESMReader &esm)
|
||||||
mAttacked = false;
|
mAttacked = false;
|
||||||
esm.getHNOT (mAttacked, "ATKD");
|
esm.getHNOT (mAttacked, "ATKD");
|
||||||
|
|
||||||
mHostile = false;
|
if (esm.isNextSub("HOST"))
|
||||||
esm.getHNOT (mHostile, "HOST");
|
esm.skipHSub(); // Hostile, no longer used
|
||||||
|
|
||||||
mAttackingOrSpell = false;
|
mAttackingOrSpell = false;
|
||||||
esm.getHNOT (mAttackingOrSpell, "ATCK");
|
esm.getHNOT (mAttackingOrSpell, "ATCK");
|
||||||
|
@ -148,9 +148,6 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
|
||||||
if (mAttacked)
|
if (mAttacked)
|
||||||
esm.writeHNT ("ATKD", mAttacked);
|
esm.writeHNT ("ATKD", mAttacked);
|
||||||
|
|
||||||
if (mHostile)
|
|
||||||
esm.writeHNT ("HOST", mHostile);
|
|
||||||
|
|
||||||
if (mAttackingOrSpell)
|
if (mAttackingOrSpell)
|
||||||
esm.writeHNT ("ATCK", mAttackingOrSpell);
|
esm.writeHNT ("ATCK", mAttackingOrSpell);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ namespace ESM
|
||||||
bool mTalkedTo;
|
bool mTalkedTo;
|
||||||
bool mAlarmed;
|
bool mAlarmed;
|
||||||
bool mAttacked;
|
bool mAttacked;
|
||||||
bool mHostile;
|
|
||||||
bool mAttackingOrSpell;
|
bool mAttackingOrSpell;
|
||||||
bool mKnockdown;
|
bool mKnockdown;
|
||||||
bool mKnockdownOneFrame;
|
bool mKnockdownOneFrame;
|
||||||
|
|
Loading…
Reference in a new issue