mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-25 18:41:33 +00:00
Use the isPlayer variable to do not check if the current actor is player every time
This commit is contained in:
parent
51af729305
commit
126b2fdd42
1 changed files with 7 additions and 5 deletions
|
@ -1298,6 +1298,8 @@ namespace MWMechanics
|
||||||
// AI and magic effects update
|
// AI and magic effects update
|
||||||
for(PtrActorMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
|
for(PtrActorMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
bool isPlayer = iter->first == player;
|
||||||
|
|
||||||
float distSqr = (player.getRefData().getPosition().asVec3() - iter->first.getRefData().getPosition().asVec3()).length2();
|
float distSqr = (player.getRefData().getPosition().asVec3() - iter->first.getRefData().getPosition().asVec3()).length2();
|
||||||
// AI processing is only done within distance of 7168 units to the player. Note the "AI distance" slider doesn't affect this
|
// AI processing is only done within distance of 7168 units to the player. Note the "AI distance" slider doesn't affect this
|
||||||
// (it only does some throttling for targets beyond the "AI distance", so doesn't give any guarantees as to whether AI will be enabled or not)
|
// (it only does some throttling for targets beyond the "AI distance", so doesn't give any guarantees as to whether AI will be enabled or not)
|
||||||
|
@ -1305,7 +1307,7 @@ namespace MWMechanics
|
||||||
// using higher values will make a quest in Bloodmoon harder or impossible to complete (bug #1876)
|
// using higher values will make a quest in Bloodmoon harder or impossible to complete (bug #1876)
|
||||||
bool inProcessingRange = distSqr <= sqrAiProcessingDistance;
|
bool inProcessingRange = distSqr <= sqrAiProcessingDistance;
|
||||||
|
|
||||||
if (iter->first == player)
|
if (isPlayer)
|
||||||
iter->second->getCharacterController()->setAttackingOrSpell(MWBase::Environment::get().getWorld()->getPlayer().getAttackingOrSpell());
|
iter->second->getCharacterController()->setAttackingOrSpell(MWBase::Environment::get().getWorld()->getPlayer().getAttackingOrSpell());
|
||||||
|
|
||||||
// If dead or no longer in combat, no longer store any actors who attempted to hit us. Also remove for the player.
|
// If dead or no longer in combat, no longer store any actors who attempted to hit us. Also remove for the player.
|
||||||
|
@ -1337,14 +1339,14 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
if (timerUpdateAITargets == 0)
|
if (timerUpdateAITargets == 0)
|
||||||
{
|
{
|
||||||
if (iter->first != player)
|
if (!isPlayer)
|
||||||
adjustCommandedActor(iter->first);
|
adjustCommandedActor(iter->first);
|
||||||
|
|
||||||
for(PtrActorMap::iterator it(mActors.begin()); it != mActors.end(); ++it)
|
for(PtrActorMap::iterator it(mActors.begin()); it != mActors.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->first == iter->first || iter->first == player) // player is not AI-controlled
|
if (it->first == iter->first || isPlayer) // player is not AI-controlled
|
||||||
continue;
|
continue;
|
||||||
engageCombat(iter->first, it->first, cachedAllies, it->first == player);
|
engageCombat(iter->first, it->first, cachedAllies, isPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timerUpdateHeadTrack == 0)
|
if (timerUpdateHeadTrack == 0)
|
||||||
|
@ -1353,7 +1355,7 @@ namespace MWMechanics
|
||||||
MWWorld::Ptr headTrackTarget;
|
MWWorld::Ptr headTrackTarget;
|
||||||
|
|
||||||
MWMechanics::CreatureStats& stats = iter->first.getClass().getCreatureStats(iter->first);
|
MWMechanics::CreatureStats& stats = iter->first.getClass().getCreatureStats(iter->first);
|
||||||
bool firstPersonPlayer = iter->first == player && MWBase::Environment::get().getWorld()->isFirstPerson();
|
bool firstPersonPlayer = isPlayer && MWBase::Environment::get().getWorld()->isFirstPerson();
|
||||||
|
|
||||||
// 1. Unconsious actor can not track target
|
// 1. Unconsious actor can not track target
|
||||||
// 2. Actors in combat and pursue mode do not bother to headtrack
|
// 2. Actors in combat and pursue mode do not bother to headtrack
|
||||||
|
|
Loading…
Reference in a new issue