mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 09:45:34 +00:00
Fix bug where actors in combat with multiple other actors where not regarded as in combat with a specific actor
This commit is contained in:
parent
1636fd66db
commit
90a96cd7d8
3 changed files with 32 additions and 6 deletions
|
@ -1281,12 +1281,8 @@ namespace MWMechanics
|
|||
{
|
||||
const MWWorld::Class &cls = iter->getClass();
|
||||
CreatureStats &stats = cls.getCreatureStats(*iter);
|
||||
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
|
||||
{
|
||||
MWMechanics::AiCombat* package = static_cast<MWMechanics::AiCombat*>(stats.getAiSequence().getActivePackage());
|
||||
if(package->getTarget() == actor)
|
||||
list.push_front(*iter);
|
||||
}
|
||||
if (!stats.isDead() && stats.getAiSequence().isInCombat(actor))
|
||||
list.push_front(*iter);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -72,6 +72,30 @@ bool AiSequence::getCombatTarget(MWWorld::Ptr &targetActor) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool AiSequence::isInCombat() const
|
||||
{
|
||||
for(std::list<AiPackage*>::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
||||
{
|
||||
if ((*it)->getTypeId() == AiPackage::TypeIdCombat)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AiSequence::isInCombat(const MWWorld::Ptr &actor) const
|
||||
{
|
||||
for(std::list<AiPackage*>::const_iterator it = mPackages.begin(); it != mPackages.end(); ++it)
|
||||
{
|
||||
if ((*it)->getTypeId() == AiPackage::TypeIdCombat)
|
||||
{
|
||||
const AiCombat *combat = static_cast<const AiCombat *>(*it);
|
||||
if (combat->getTarget() == actor)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AiSequence::canAddTarget(const ESM::Position& actorPos, float distToTarget) const
|
||||
{
|
||||
bool firstCombatFound = false;
|
||||
|
|
|
@ -63,6 +63,12 @@ namespace MWMechanics
|
|||
/// Return true and assign target if combat package is currently active, return false otherwise
|
||||
bool getCombatTarget (MWWorld::Ptr &targetActor) const;
|
||||
|
||||
/// Is there any combat package?
|
||||
bool isInCombat () const;
|
||||
|
||||
/// Are we in combat with this particular actor?
|
||||
bool isInCombat (const MWWorld::Ptr& actor) const;
|
||||
|
||||
bool canAddTarget(const ESM::Position& actorPos, float distToTarget) const;
|
||||
///< Function assumes that actor can have only 1 target apart player
|
||||
|
||||
|
|
Loading…
Reference in a new issue