Remove redundant isHostile flag (Fixes #1652)

deque
scrawl 11 years ago
parent 0077296c91
commit 4773d754c6

@ -678,8 +678,8 @@ namespace MWClass
if (ptr != MWBase::Environment::get().getWorld()->getPlayerPtr())
{
// Attacking peaceful NPCs is a crime
if (!attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).isHostile() &&
!MWBase::Environment::get().getMechanicsManager()->isAggressive(ptr, attacker))
if (!attacker.isEmpty() && !ptr.getClass().getCreatureStats(ptr).getAiSequence().isInCombat(attacker)
&& !MWBase::Environment::get().getMechanicsManager()->isAggressive(ptr, attacker))
MWBase::Environment::get().getMechanicsManager()->commitCrime(attacker, ptr, MWBase::MechanicsManager::OT_Assault);
if (!attacker.isEmpty() && attacker.getClass().getCreatureStats(attacker).getAiSequence().isInCombat(ptr)
@ -910,7 +910,7 @@ namespace MWClass
if(getCreatureStats(ptr).isDead())
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}"));
if(getCreatureStats(actor).getStance(MWMechanics::CreatureStats::Stance_Sneak))
return boost::shared_ptr<MWWorld::Action>(new MWWorld::ActionOpen(ptr)); // stealing

@ -191,7 +191,6 @@ namespace MWMechanics
{
CreatureStats& creatureStats = actor1.getClass().getCreatureStats(actor1);
if (againstPlayer && creatureStats.isHostile()) return; // already fighting against player
if (actor2.getClass().getCreatureStats(actor2).isDead()
|| actor1.getClass().getCreatureStats(actor1).isDead())
return;
@ -204,7 +203,7 @@ namespace MWMechanics
// pure water creatures won't try to fight with the target on the ground
// 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
&& !MWBase::Environment::get().getWorld()->isSwimming(actor2))
|| (!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 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);
}
}
@ -796,7 +795,7 @@ namespace MWMechanics
{
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.
if (heldIter != inventoryStore.end() && heldIter->getTypeName() != typeid(ESM::Light).name())
@ -876,7 +875,7 @@ namespace MWMechanics
CreatureStats& creatureStats = ptr.getClass().getCreatureStats(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();
int cutoff = esmStore.get<ESM::GameSetting>().find("iCrimeThreshold")->getInt();
@ -909,7 +908,6 @@ namespace MWMechanics
creatureStats.getAiSequence().stopCombat();
// Reset factors to attack
creatureStats.setHostile(false);
creatureStats.setAttacked(false);
creatureStats.setAlarmed(false);
@ -1074,7 +1072,7 @@ namespace MWMechanics
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
|| (!actorClass.canSwim(actor) && world->isSwimming(target))))
{
if (target == world->getPlayerPtr())
actorClass.getCreatureStats(actor).setHostile(false);
actorClass.getCreatureStats(actor).setAttackingOrSpell(false);
return true;
}

@ -17,7 +17,7 @@ namespace MWMechanics
CreatureStats::CreatureStats()
: mLevel (0), mDead (false), mDied (false), mMurdered(false), mFriendlyHits (0),
mTalkedTo (false), mAlarmed (false),
mAttacked (false), mHostile (false),
mAttacked (false),
mAttackingOrSpell(false),
mIsWerewolf(false),
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false),
@ -331,16 +331,6 @@ namespace MWMechanics
mAttacked = attacked;
}
bool CreatureStats::isHostile() const
{
return mHostile;
}
void CreatureStats::setHostile (bool hostile)
{
mHostile = hostile;
}
bool CreatureStats::getCreatureTargetted() const
{
MWWorld::Ptr targetPtr;
@ -506,7 +496,6 @@ namespace MWMechanics
state.mTalkedTo = mTalkedTo;
state.mAlarmed = mAlarmed;
state.mAttacked = mAttacked;
state.mHostile = mHostile;
state.mAttackingOrSpell = mAttackingOrSpell;
// TODO: rewrite. does this really need 3 separate bools?
state.mKnockdown = mKnockdown;
@ -555,7 +544,6 @@ namespace MWMechanics
mTalkedTo = state.mTalkedTo;
mAlarmed = state.mAlarmed;
mAttacked = state.mAttacked;
mHostile = state.mHostile;
mAttackingOrSpell = state.mAttackingOrSpell;
// TODO: rewrite. does this really need 3 separate bools?
mKnockdown = state.mKnockdown;

@ -200,9 +200,6 @@ namespace MWMechanics
bool getAttacked() const;
void setAttacked (bool attacked);
bool isHostile() const;
void setHostile (bool hostile);
bool getCreatureTargetted() const;
float getEvasion() const;

@ -1176,8 +1176,6 @@ namespace MWMechanics
ptr.getClass().getCreatureStats(ptr).getAiSequence().stack(MWMechanics::AiCombat(target), ptr);
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 (ptr.getClass().isClass(ptr, "Guard"))
{

@ -420,7 +420,6 @@ namespace MWScript
runtime.pop();
const MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
std::string currentTargetId;
bool targetsAreEqual = false;
MWWorld::Ptr targetPtr;
@ -457,7 +456,6 @@ namespace MWScript
MWWorld::Ptr actor = R()(runtime);
MWMechanics::CreatureStats& creatureStats = actor.getClass().getCreatureStats(actor);
creatureStats.getAiSequence().stopCombat();
creatureStats.setHostile(false);
}
};

@ -36,8 +36,8 @@ void ESM::CreatureStats::load (ESMReader &esm)
mAttacked = false;
esm.getHNOT (mAttacked, "ATKD");
mHostile = false;
esm.getHNOT (mHostile, "HOST");
if (esm.isNextSub("HOST"))
esm.skipHSub(); // Hostile, no longer used
mAttackingOrSpell = false;
esm.getHNOT (mAttackingOrSpell, "ATCK");
@ -148,9 +148,6 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
if (mAttacked)
esm.writeHNT ("ATKD", mAttacked);
if (mHostile)
esm.writeHNT ("HOST", mHostile);
if (mAttackingOrSpell)
esm.writeHNT ("ATCK", mAttackingOrSpell);

@ -43,7 +43,6 @@ namespace ESM
bool mTalkedTo;
bool mAlarmed;
bool mAttacked;
bool mHostile;
bool mAttackingOrSpell;
bool mKnockdown;
bool mKnockdownOneFrame;

Loading…
Cancel
Save