mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-21 13:39:40 +00:00
Adjust combat engagement of following actors (Fixes #1810)
This commit is contained in:
parent
94c2517d67
commit
f8010c09fe
2 changed files with 42 additions and 14 deletions
|
@ -301,20 +301,31 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// start combat if we are in combat with any followers of this actor
|
// start combat if target actor is in combat with one of our followers
|
||||||
const std::list<MWWorld::Ptr>& followers = getActorsFollowing(actor2);
|
const std::list<MWWorld::Ptr>& followers = getActorsFollowing(actor1);
|
||||||
|
const CreatureStats& creatureStats2 = actor2.getClass().getCreatureStats(actor2);
|
||||||
for (std::list<MWWorld::Ptr>::const_iterator it = followers.begin(); it != followers.end(); ++it)
|
for (std::list<MWWorld::Ptr>::const_iterator it = followers.begin(); it != followers.end(); ++it)
|
||||||
{
|
{
|
||||||
if (creatureStats.getAiSequence().isInCombat(*it))
|
// need to check both ways since player doesn't use AI packages
|
||||||
|
if (creatureStats2.getAiSequence().isInCombat(*it)
|
||||||
|
|| it->getClass().getCreatureStats(*it).getAiSequence().isInCombat(actor2))
|
||||||
aggressive = true;
|
aggressive = true;
|
||||||
}
|
}
|
||||||
// start combat if we are in combat with someone this actor is following
|
|
||||||
const CreatureStats& creatureStats2 = actor2.getClass().getCreatureStats(actor2);
|
// start combat if target actor is in combat with someone we are following
|
||||||
for (std::list<MWMechanics::AiPackage*>::const_iterator it = creatureStats2.getAiSequence().begin(); it != creatureStats2.getAiSequence().end(); ++it)
|
for (std::list<MWMechanics::AiPackage*>::const_iterator it = creatureStats.getAiSequence().begin(); it != creatureStats.getAiSequence().end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow &&
|
if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow)
|
||||||
creatureStats.getAiSequence().isInCombat(dynamic_cast<MWMechanics::AiFollow*>(*it)->getTarget()))
|
{
|
||||||
aggressive = true;
|
MWWorld::Ptr followTarget = dynamic_cast<MWMechanics::AiFollow*>(*it)->getTarget();
|
||||||
|
if (followTarget.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// need to check both ways since player doesn't use AI packages
|
||||||
|
if (creatureStats2.getAiSequence().isInCombat(followTarget)
|
||||||
|
|| followTarget.getClass().getCreatureStats(followTarget).getAiSequence().isInCombat(actor2))
|
||||||
|
aggressive = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(aggressive)
|
if(aggressive)
|
||||||
|
@ -1374,11 +1385,19 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = iter->first.getClass();
|
const MWWorld::Class &cls = iter->first.getClass();
|
||||||
CreatureStats &stats = cls.getCreatureStats(iter->first);
|
CreatureStats &stats = cls.getCreatureStats(iter->first);
|
||||||
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdFollow)
|
if (stats.isDead())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (std::list<MWMechanics::AiPackage*>::const_iterator it = stats.getAiSequence().begin(); it != stats.getAiSequence().end(); ++it)
|
||||||
{
|
{
|
||||||
MWMechanics::AiFollow* package = static_cast<MWMechanics::AiFollow*>(stats.getAiSequence().getActivePackage());
|
if ((*it)->getTypeId() == MWMechanics::AiPackage::TypeIdFollow)
|
||||||
if(package->getFollowedActor() == actor.getCellRef().getRefId())
|
{
|
||||||
list.push_front(iter->first);
|
MWWorld::Ptr followTarget = dynamic_cast<MWMechanics::AiFollow*>(*it)->getTarget();
|
||||||
|
if (followTarget.isEmpty())
|
||||||
|
continue;
|
||||||
|
if (followTarget == actor)
|
||||||
|
list.push_back(iter->first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -137,10 +137,19 @@ MWMechanics::AiFollow::AiFollow(const ESM::AiSequence::AiFollow *follow)
|
||||||
|
|
||||||
MWWorld::Ptr MWMechanics::AiFollow::getTarget()
|
MWWorld::Ptr MWMechanics::AiFollow::getTarget()
|
||||||
{
|
{
|
||||||
|
if (mActorId == -2)
|
||||||
|
return MWWorld::Ptr();
|
||||||
|
|
||||||
if (mActorId == -1)
|
if (mActorId == -1)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mActorRefId, false);
|
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mActorRefId, false);
|
||||||
mActorId = target.getClass().getCreatureStats(target).getActorId();
|
if (target.isEmpty())
|
||||||
|
{
|
||||||
|
mActorId = -2;
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mActorId = target.getClass().getCreatureStats(target).getActorId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mActorId != -1)
|
if (mActorId != -1)
|
||||||
|
|
Loading…
Reference in a new issue