AiCombat: Removed obsolete door back-off code (now handled in AiAvoidDoor)

This commit is contained in:
scrawl 2014-05-15 03:07:25 +02:00
parent 2e9985c1a3
commit a6e1d7ffd6
2 changed files with 13 additions and 76 deletions

View file

@ -92,11 +92,7 @@ namespace MWMechanics
mMovement(), mMovement(),
mForceNoShortcut(false), mForceNoShortcut(false),
mShortcutFailPos(), mShortcutFailPos(),
mBackOffDoor(false), mBackOffDoor(false)
mCell(NULL),
mDoorIter(actor.getCell()->get<ESM::Door>().mList.end()),
mDoors(actor.getCell()->get<ESM::Door>()),
mDoorCheckDuration(0)
{ {
} }
@ -198,12 +194,6 @@ namespace MWMechanics
mTimerReact = 0; mTimerReact = 0;
bool cellChange = mCell && (actor.getCell() != mCell);
if(!mCell || cellChange)
{
mCell = actor.getCell();
}
//actual attacking logic //actual attacking logic
//TODO: Some skills affect period of strikes.For berserk-like style period ~ 0.25f //TODO: Some skills affect period of strikes.For berserk-like style period ~ 0.25f
float attacksPeriod = 1.0f; float attacksPeriod = 1.0f;
@ -503,36 +493,11 @@ namespace MWMechanics
// coded at 250ms or 1/4 second // coded at 250ms or 1/4 second
// //
// TODO: Add a parameter to vary DURATION_SAME_SPOT? // TODO: Add a parameter to vary DURATION_SAME_SPOT?
MWWorld::CellStore *cell = actor.getCell();
if((distToTarget > rangeAttack || mFollowTarget) && if((distToTarget > rangeAttack || mFollowTarget) &&
mObstacleCheck.check(actor, tReaction)) // check if evasive action needed mObstacleCheck.check(actor, tReaction)) // check if evasive action needed
{ {
// first check if we're walking into a door // probably walking into another NPC TODO: untested in combat situation
mDoorCheckDuration += 1.0f; // add time taken for obstacle check
if(mDoorCheckDuration >= DOOR_CHECK_INTERVAL && !cell->getCell()->isExterior())
{
mDoorCheckDuration = 0;
// Check all the doors in this cell
mDoors = cell->get<ESM::Door>(); // update
mDoorIter = mDoors.mList.begin();
for (; mDoorIter != mDoors.mList.end(); ++mDoorIter)
{
MWWorld::LiveCellRef<ESM::Door>& ref = *mDoorIter;
float minSqr = 1.3*1.3*MIN_DIST_TO_DOOR_SQUARED; // for legibility
if(vActorPos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)) < minSqr &&
ref.mData.getLocalRotation().rot[2] < 0.4f) // even small opening
{
//std::cout<<"closed door id \""<<ref.mRef.mRefID<<"\""<<std::endl;
mBackOffDoor = true;
mObstacleCheck.clear();
if(mFollowTarget)
mFollowTarget = false;
break;
}
}
}
else // probably walking into another NPC TODO: untested in combat situation
{
// TODO: diagonal should have same animation as walk forward // TODO: diagonal should have same animation as walk forward
// but doesn't seem to do that? // but doesn't seem to do that?
actor.getClass().getMovementSettings(actor).mPosition[0] = 1; actor.getClass().getMovementSettings(actor).mPosition[0] = 1;
@ -546,28 +511,6 @@ namespace MWMechanics
// FIXME: can fool actors to stay behind doors, etc. // FIXME: can fool actors to stay behind doors, etc.
// Related to Bug#1102 and to some degree #1155 as well // Related to Bug#1102 and to some degree #1155 as well
} }
}
if(!cell->getCell()->isExterior() && !mDoors.mList.empty())
{
MWWorld::LiveCellRef<ESM::Door>& ref = *mDoorIter;
float minSqr = 1.6 * 1.6 * MIN_DIST_TO_DOOR_SQUARED; // for legibility
// TODO: add reaction to checking open doors
if(mBackOffDoor &&
vActorPos.squaredDistance(Ogre::Vector3(ref.mRef.mPos.pos)) < minSqr)
{
mMovement.mPosition[1] = -0.2; // back off, but slowly
}
else if(mBackOffDoor &&
mDoorIter != mDoors.mList.end() &&
ref.mData.getLocalRotation().rot[2] >= 1)
{
mDoorIter = mDoors.mList.end();
mBackOffDoor = false;
//std::cout<<"open door id \""<<ref.mRef.mRefID<<"\""<<std::endl;
mMovement.mPosition[1] = 1;
}
}
return false; return false;
} }

View file

@ -55,13 +55,7 @@ namespace MWMechanics
MWMechanics::Movement mMovement; MWMechanics::Movement mMovement;
int mTargetActorId; int mTargetActorId;
const MWWorld::CellStore* mCell;
ObstacleCheck mObstacleCheck; ObstacleCheck mObstacleCheck;
float mDoorCheckDuration;
// TODO: for some reason mDoors.searchViaHandle() returns
// null pointers, workaround by keeping an iterator
MWWorld::CellRefList<ESM::Door>::List::iterator mDoorIter;
MWWorld::CellRefList<ESM::Door>& mDoors;
void buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target); void buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target);
}; };