mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-23 15:40:42 +00:00
parent
160a67afe1
commit
028762a7dc
@ -121,6 +121,16 @@ bool AiSequence::isInCombat() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AiSequence::hasPackage(int typeId) const
|
||||||
|
{
|
||||||
|
for (std::list<AiPackage*>::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
||||||
|
{
|
||||||
|
if ((*it)->getTypeId() == typeId)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool AiSequence::isInCombat(const MWWorld::Ptr &actor) const
|
bool AiSequence::isInCombat(const MWWorld::Ptr &actor) const
|
||||||
{
|
{
|
||||||
for(std::list<AiPackage*>::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
for(std::list<AiPackage*>::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
||||||
|
@ -85,6 +85,9 @@ namespace MWMechanics
|
|||||||
/// Is there any combat package?
|
/// Is there any combat package?
|
||||||
bool isInCombat () const;
|
bool isInCombat () const;
|
||||||
|
|
||||||
|
/// Does this AI sequence have the given package type?
|
||||||
|
bool hasPackage(int typeId) const;
|
||||||
|
|
||||||
/// Are we in combat with this particular actor?
|
/// Are we in combat with this particular actor?
|
||||||
bool isInCombat (const MWWorld::Ptr& actor) const;
|
bool isInCombat (const MWWorld::Ptr& actor) const;
|
||||||
|
|
||||||
|
@ -1042,7 +1042,13 @@ namespace MWMechanics
|
|||||||
if (crimeSeen)
|
if (crimeSeen)
|
||||||
reportCrime(player, victim, type, arg);
|
reportCrime(player, victim, type, arg);
|
||||||
else if (type == OT_Assault && !victim.isEmpty())
|
else if (type == OT_Assault && !victim.isEmpty())
|
||||||
|
{
|
||||||
|
if (victim.getClass().isClass(victim, "guard")
|
||||||
|
&& !victim.getClass().getCreatureStats(victim).getAiSequence().hasPackage(AiPackage::TypeIdPursue))
|
||||||
|
reportCrime(player, victim, type, arg);
|
||||||
|
else
|
||||||
startCombat(victim, player); // TODO: combat should be started with an "unaware" flag, which makes the victim flee?
|
startCombat(victim, player); // TODO: combat should be started with an "unaware" flag, which makes the victim flee?
|
||||||
|
}
|
||||||
return crimeSeen;
|
return crimeSeen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,6 +1151,7 @@ namespace MWMechanics
|
|||||||
// once the bounty has been paid.
|
// once the bounty has been paid.
|
||||||
it->getClass().getNpcStats(*it).setCrimeId(id);
|
it->getClass().getNpcStats(*it).setCrimeId(id);
|
||||||
|
|
||||||
|
if (!it->getClass().getCreatureStats(*it).getAiSequence().hasPackage(AiPackage::TypeIdPursue))
|
||||||
it->getClass().getCreatureStats(*it).getAiSequence().stack(AiPursue(player), *it);
|
it->getClass().getCreatureStats(*it).getAiSequence().stack(AiPursue(player), *it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1213,6 +1220,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
// Attacker is in combat with us, but we are not in combat with the attacker yet. Time to fight back.
|
// Attacker is in combat with us, but we are not in combat with the attacker yet. Time to fight back.
|
||||||
// Note: accidental or collateral damage attacks are ignored.
|
// Note: accidental or collateral damage attacks are ignored.
|
||||||
|
if (!victim.getClass().getCreatureStats(victim).getAiSequence().hasPackage(AiPackage::TypeIdPursue))
|
||||||
startCombat(victim, player);
|
startCombat(victim, player);
|
||||||
|
|
||||||
// Set the crime ID, which we will use to calm down participants
|
// Set the crime ID, which we will use to calm down participants
|
||||||
@ -1256,7 +1264,8 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (target.getClass().isNpc() && !attacker.isEmpty() && !seq.isInCombat(attacker)
|
if (target.getClass().isNpc() && !attacker.isEmpty() && !seq.isInCombat(attacker)
|
||||||
&& !isAggressive(target, attacker) && !isFightingNpc)
|
&& !isAggressive(target, attacker) && !isFightingNpc
|
||||||
|
&& !target.getClass().getCreatureStats(target).getAiSequence().hasPackage(AiPackage::TypeIdPursue))
|
||||||
commitCrime(attacker, target, MWBase::MechanicsManager::OT_Assault);
|
commitCrime(attacker, target, MWBase::MechanicsManager::OT_Assault);
|
||||||
|
|
||||||
if (!attacker.isEmpty() && (attacker.getClass().getCreatureStats(attacker).getAiSequence().isInCombat(target)
|
if (!attacker.isEmpty() && (attacker.getClass().getCreatureStats(attacker).getAiSequence().isInCombat(target)
|
||||||
@ -1265,6 +1274,7 @@ namespace MWMechanics
|
|||||||
{
|
{
|
||||||
// Attacker is in combat with us, but we are not in combat with the attacker yet. Time to fight back.
|
// Attacker is in combat with us, but we are not in combat with the attacker yet. Time to fight back.
|
||||||
// Note: accidental or collateral damage attacks are ignored.
|
// Note: accidental or collateral damage attacks are ignored.
|
||||||
|
if (!target.getClass().getCreatureStats(target).getAiSequence().hasPackage(AiPackage::TypeIdPursue))
|
||||||
startCombat(target, attacker);
|
startCombat(target, attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user