|
|
|
@ -1460,24 +1460,11 @@ namespace MWMechanics
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Attacking an NPC that is already in combat with any other NPC is not a crime
|
|
|
|
|
AiSequence& seq = statsTarget.getAiSequence();
|
|
|
|
|
bool isFightingNpc = false;
|
|
|
|
|
for (std::list<AiPackage*>::const_iterator it = seq.begin(); it != seq.end(); ++it)
|
|
|
|
|
{
|
|
|
|
|
if ((*it)->getTypeId() == AiPackage::TypeIdCombat)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::Ptr target2 = (*it)->getTarget();
|
|
|
|
|
if (!target2.isEmpty() && target2.getClass().isNpc())
|
|
|
|
|
isFightingNpc = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (target.getClass().isNpc() && !attacker.isEmpty() && !seq.isInCombat(attacker)
|
|
|
|
|
&& !isAggressive(target, attacker) && !isFightingNpc
|
|
|
|
|
&& !target.getClass().getCreatureStats(target).getAiSequence().hasPackage(AiPackage::TypeIdPursue))
|
|
|
|
|
if (canCommitCrimeAgainst(target, attacker))
|
|
|
|
|
commitCrime(attacker, target, MWBase::MechanicsManager::OT_Assault);
|
|
|
|
|
|
|
|
|
|
AiSequence& seq = statsTarget.getAiSequence();
|
|
|
|
|
|
|
|
|
|
if (!attacker.isEmpty() && (attacker.getClass().getCreatureStats(attacker).getAiSequence().isInCombat(target)
|
|
|
|
|
|| attacker == getPlayer())
|
|
|
|
|
&& !seq.isInCombat(attacker))
|
|
|
|
@ -1504,6 +1491,14 @@ namespace MWMechanics
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MechanicsManager::canCommitCrimeAgainst(const MWWorld::Ptr &target, const MWWorld::Ptr &attacker)
|
|
|
|
|
{
|
|
|
|
|
MWMechanics::AiSequence seq = target.getClass().getCreatureStats(target).getAiSequence();
|
|
|
|
|
return target.getClass().isNpc() && !attacker.isEmpty() && !seq.isInCombat(attacker)
|
|
|
|
|
&& !isAggressive(target, attacker) && !seq.isEngagedWithActor()
|
|
|
|
|
&& !target.getClass().getCreatureStats(target).getAiSequence().hasPackage(AiPackage::TypeIdPursue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MechanicsManager::actorKilled(const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker)
|
|
|
|
|
{
|
|
|
|
|
if (attacker.isEmpty() || victim.isEmpty())
|
|
|
|
|