Manually re-added AiCombat portion of actorid changes. This is the only one that really matters, and will not suffer from the infinite recursion because it's not included in AiSequence::fill.

deque
scrawl 11 years ago
parent 36d9ae17cc
commit 18852c09d0

@ -81,7 +81,7 @@ namespace MWMechanics
// NOTE: MIN_DIST_TO_DOOR_SQUARED is defined in obstacle.hpp
AiCombat::AiCombat(const MWWorld::Ptr& actor) :
mTarget(actor),
mTargetActorId(actor.getClass().getCreatureStats(actor).getActorId()),
mTimerAttack(0),
mTimerReact(0),
mTimerCombatMove(0),
@ -153,7 +153,9 @@ namespace MWMechanics
|| actor.getClass().getCreatureStats(actor).getHealth().getCurrent() <= 0)
return true;
if(mTarget.getClass().getCreatureStats(mTarget).isDead())
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId);
if(target.getClass().getCreatureStats(target).isDead())
return true;
//Update every frame
@ -325,7 +327,7 @@ namespace MWMechanics
ESM::Position pos = actor.getRefData().getPosition();
Ogre::Vector3 vActorPos(pos.pos);
Ogre::Vector3 vTargetPos(mTarget.getRefData().getPosition().pos);
Ogre::Vector3 vTargetPos(target.getRefData().getPosition().pos);
Ogre::Vector3 vDirToTarget = vTargetPos - vActorPos;
bool isStuck = false;
@ -396,7 +398,7 @@ namespace MWMechanics
else // remote pathfinding
{
bool preferShortcut = false;
bool inLOS = MWBase::Environment::get().getWorld()->getLOS(actor, mTarget);
bool inLOS = MWBase::Environment::get().getWorld()->getLOS(actor, target);
if(mReadyToAttack) isStuck = false;
@ -432,7 +434,7 @@ namespace MWMechanics
mFollowTarget = false;
buildNewPath(actor); //may fail to build a path, check before use
buildNewPath(actor, target); //may fail to build a path, check before use
//delete visited path node
mPathFinder.checkWaypoint(pos.pos[0],pos.pos[1],pos.pos[2]);
@ -476,9 +478,9 @@ namespace MWMechanics
//less than in time of playing weapon anim from 'start' to 'hit' tags (t_swing)
//then start attacking
float speed1 = actorCls.getSpeed(actor);
float speed2 = mTarget.getClass().getSpeed(mTarget);
if(mTarget.getClass().getMovementSettings(mTarget).mPosition[0] == 0
&& mTarget.getClass().getMovementSettings(mTarget).mPosition[1] == 0)
float speed2 = target.getClass().getSpeed(target);
if(target.getClass().getMovementSettings(target).mPosition[0] == 0
&& target.getClass().getMovementSettings(target).mPosition[1] == 0)
speed2 = 0;
float s1 = distToTarget - weapRange;
@ -570,9 +572,9 @@ namespace MWMechanics
return false;
}
void AiCombat::buildNewPath(const MWWorld::Ptr& actor)
void AiCombat::buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target)
{
Ogre::Vector3 newPathTarget = Ogre::Vector3(mTarget.getRefData().getPosition().pos);
Ogre::Vector3 newPathTarget = Ogre::Vector3(target.getRefData().getPosition().pos);
float dist;
@ -627,9 +629,12 @@ namespace MWMechanics
return 1;
}
const std::string &AiCombat::getTargetId() const
std::string AiCombat::getTargetId() const
{
return mTarget.getRefData().getHandle();
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId);
if (target.isEmpty())
return "";
return target.getRefData().getHandle();
}

@ -31,7 +31,7 @@ namespace MWMechanics
virtual unsigned int getPriority() const;
///Returns target ID
const std::string &getTargetId() const;
std::string getTargetId() const;
private:
PathFinder mPathFinder;
@ -53,7 +53,7 @@ namespace MWMechanics
ESM::Position mLastPos;
MWMechanics::Movement mMovement;
MWWorld::Ptr mTarget;
int mTargetActorId;
const MWWorld::CellStore* mCell;
ObstacleCheck mObstacleCheck;
@ -63,7 +63,7 @@ namespace MWMechanics
MWWorld::CellRefList<ESM::Door>::List::iterator mDoorIter;
MWWorld::CellRefList<ESM::Door>& mDoors;
void buildNewPath(const MWWorld::Ptr& actor);
void buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target);
};
}

Loading…
Cancel
Save