|
|
|
@ -142,6 +142,29 @@ void getRestorationPerHourOfSleep (const MWWorld::Ptr& ptr, float& health, float
|
|
|
|
|
magicka = fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
|
void forEachFollowingPackage(MWMechanics::Actors::PtrActorMap& actors, const MWWorld::Ptr& actor, const MWWorld::Ptr& player, T&& func)
|
|
|
|
|
{
|
|
|
|
|
for(auto& iter : actors)
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Ptr &iteratedActor = iter.first;
|
|
|
|
|
if (iteratedActor == player || iteratedActor == actor)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const MWMechanics::CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor);
|
|
|
|
|
if (stats.isDead())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// An actor counts as following if AiFollow is the current AiPackage,
|
|
|
|
|
// or there are only Combat and Wander packages before the AiFollow package
|
|
|
|
|
for (const auto& package : stats.getAiSequence())
|
|
|
|
|
{
|
|
|
|
|
if(!func(iter, package))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace MWMechanics
|
|
|
|
@ -2512,26 +2535,14 @@ namespace MWMechanics
|
|
|
|
|
std::list<MWWorld::Ptr> Actors::getActorsFollowing(const MWWorld::Ptr& actor)
|
|
|
|
|
{
|
|
|
|
|
std::list<MWWorld::Ptr> list;
|
|
|
|
|
for(PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Ptr &iteratedActor = iter->first;
|
|
|
|
|
if (iteratedActor == getPlayer() || iteratedActor == actor)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor);
|
|
|
|
|
if (stats.isDead())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// An actor counts as following if AiFollow is the current AiPackage,
|
|
|
|
|
// or there are only Combat and Wander packages before the AiFollow package
|
|
|
|
|
for (const auto& package : stats.getAiSequence())
|
|
|
|
|
{
|
|
|
|
|
if (package->followTargetThroughDoors() && package->getTarget() == actor)
|
|
|
|
|
list.push_back(iteratedActor);
|
|
|
|
|
else if (package->getTypeId() != AiPackageTypeId::Combat && package->getTypeId() != AiPackageTypeId::Wander)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
forEachFollowingPackage(mActors, actor, getPlayer(), [&] (auto& iter, const std::unique_ptr<AiPackage>& package)
|
|
|
|
|
{
|
|
|
|
|
if (package->followTargetThroughDoors() && package->getTarget() == actor)
|
|
|
|
|
list.push_back(iter.first);
|
|
|
|
|
else if (package->getTypeId() != AiPackageTypeId::Combat && package->getTypeId() != AiPackageTypeId::Wander)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2575,32 +2586,38 @@ namespace MWMechanics
|
|
|
|
|
std::list<int> Actors::getActorsFollowingIndices(const MWWorld::Ptr &actor)
|
|
|
|
|
{
|
|
|
|
|
std::list<int> list;
|
|
|
|
|
for(PtrActorMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
|
|
|
|
forEachFollowingPackage(mActors, actor, getPlayer(), [&] (auto& iter, const std::unique_ptr<AiPackage>& package)
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Ptr &iteratedActor = iter->first;
|
|
|
|
|
if (iteratedActor == getPlayer() || iteratedActor == actor)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
const CreatureStats &stats = iteratedActor.getClass().getCreatureStats(iteratedActor);
|
|
|
|
|
if (stats.isDead())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// An actor counts as following if AiFollow is the current AiPackage,
|
|
|
|
|
// or there are only Combat and Wander packages before the AiFollow package
|
|
|
|
|
for (const auto& package : stats.getAiSequence())
|
|
|
|
|
if (package->followTargetThroughDoors() && package->getTarget() == actor)
|
|
|
|
|
{
|
|
|
|
|
if (package->followTargetThroughDoors() && package->getTarget() == actor)
|
|
|
|
|
{
|
|
|
|
|
list.push_back(static_cast<const AiFollow*>(package.get())->getFollowIndex());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else if (package->getTypeId() != AiPackageTypeId::Combat && package->getTypeId() != AiPackageTypeId::Wander)
|
|
|
|
|
break;
|
|
|
|
|
list.push_back(static_cast<const AiFollow*>(package.get())->getFollowIndex());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (package->getTypeId() != AiPackageTypeId::Combat && package->getTypeId() != AiPackageTypeId::Wander)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::map<int, MWWorld::Ptr> Actors::getActorsFollowingByIndex(const MWWorld::Ptr &actor)
|
|
|
|
|
{
|
|
|
|
|
std::map<int, MWWorld::Ptr> map;
|
|
|
|
|
forEachFollowingPackage(mActors, actor, getPlayer(), [&] (auto& iter, const std::unique_ptr<AiPackage>& package)
|
|
|
|
|
{
|
|
|
|
|
if (package->followTargetThroughDoors() && package->getTarget() == actor)
|
|
|
|
|
{
|
|
|
|
|
int index = static_cast<const AiFollow*>(package.get())->getFollowIndex();
|
|
|
|
|
map[index] = iter.first;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if (package->getTypeId() != AiPackageTypeId::Combat && package->getTypeId() != AiPackageTypeId::Wander)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::list<MWWorld::Ptr> Actors::getActorsFighting(const MWWorld::Ptr& actor) {
|
|
|
|
|
std::list<MWWorld::Ptr> list;
|
|
|
|
|
std::vector<MWWorld::Ptr> neighbors;
|
|
|
|
|