mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-12 22:43:07 +00:00
Exclude deleted actors, prevent copies, and try to avoid a second getActorsSidingWith call
This commit is contained in:
parent
a8ee3dfae8
commit
8ed7a5319d
2 changed files with 6 additions and 5 deletions
|
|
@ -606,8 +606,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
// Get actors allied with actor1. Includes those following or escorting actor1, actors following or escorting
|
// Get actors allied with actor1. Includes those following or escorting actor1, actors following or escorting
|
||||||
// those actors, (recursive) and any actor currently being followed or escorted by actor1
|
// those actors, (recursive) and any actor currently being followed or escorted by actor1
|
||||||
const std::set<MWWorld::Ptr> allies1 = cachedAllies.getActorsSidingWith(actor1);
|
const std::set<MWWorld::Ptr>& allies1 = cachedAllies.getActorsSidingWith(actor1);
|
||||||
const std::set<MWWorld::Ptr> allies2 = cachedAllies.getActorsSidingWith(actor2);
|
|
||||||
|
|
||||||
const auto mechanicsManager = MWBase::Environment::get().getMechanicsManager();
|
const auto mechanicsManager = MWBase::Environment::get().getMechanicsManager();
|
||||||
// If an ally of actor1 has been attacked by actor2 or has attacked actor2, start combat between actor1 and
|
// If an ally of actor1 has been attacked by actor2 or has attacked actor2, start combat between actor1 and
|
||||||
|
|
@ -619,7 +618,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (creatureStats2.matchesActorId(ally.getClass().getCreatureStats(ally).getHitAttemptActorId()))
|
if (creatureStats2.matchesActorId(ally.getClass().getCreatureStats(ally).getHitAttemptActorId()))
|
||||||
{
|
{
|
||||||
mechanicsManager->startCombat(actor1, actor2, &allies2);
|
mechanicsManager->startCombat(actor1, actor2, &cachedAllies.getActorsSidingWith(actor2));
|
||||||
// Also set the same hit attempt actor. Otherwise, if fighting the player, they may stop combat
|
// Also set the same hit attempt actor. Otherwise, if fighting the player, they may stop combat
|
||||||
// if the player gets out of reach, while the ally would continue combat with the player
|
// if the player gets out of reach, while the ally would continue combat with the player
|
||||||
creatureStats1.setHitAttemptActorId(ally.getClass().getCreatureStats(ally).getHitAttemptActorId());
|
creatureStats1.setHitAttemptActorId(ally.getClass().getCreatureStats(ally).getHitAttemptActorId());
|
||||||
|
|
@ -644,6 +643,7 @@ namespace MWMechanics
|
||||||
// Check that actor2 is in combat with actor1
|
// Check that actor2 is in combat with actor1
|
||||||
if (creatureStats2.getAiSequence().isInCombat(actor1))
|
if (creatureStats2.getAiSequence().isInCombat(actor1))
|
||||||
{
|
{
|
||||||
|
const std::set<MWWorld::Ptr>& allies2 = cachedAllies.getActorsSidingWith(actor2);
|
||||||
// Check that an ally of actor2 is also in combat with actor1
|
// Check that an ally of actor2 is also in combat with actor1
|
||||||
for (const MWWorld::Ptr& ally2 : allies2)
|
for (const MWWorld::Ptr& ally2 : allies2)
|
||||||
{
|
{
|
||||||
|
|
@ -741,7 +741,7 @@ namespace MWMechanics
|
||||||
bool LOS = world->getLOS(actor1, actor2) && mechanicsManager->awarenessCheck(actor2, actor1);
|
bool LOS = world->getLOS(actor1, actor2) && mechanicsManager->awarenessCheck(actor2, actor1);
|
||||||
|
|
||||||
if (LOS)
|
if (LOS)
|
||||||
mechanicsManager->startCombat(actor1, actor2, &allies2);
|
mechanicsManager->startCombat(actor1, actor2, &cachedAllies.getActorsSidingWith(actor2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,8 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(targetID, true, false);
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(targetID, true, false);
|
||||||
if (!target.isEmpty() && !target.getClass().getCreatureStats(target).isDead())
|
if (!target.isEmpty() && !target.getBase()->isDeleted()
|
||||||
|
&& !target.getClass().getCreatureStats(target).isDead())
|
||||||
MWBase::Environment::get().getMechanicsManager()->startCombat(actor, target, nullptr);
|
MWBase::Environment::get().getMechanicsManager()->startCombat(actor, target, nullptr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue