forked from mirror/openmw-tes3mp
AiCombat: Removed obsolete door back-off code (now handled in AiAvoidDoor)
This commit is contained in:
parent
2e9985c1a3
commit
a6e1d7ffd6
2 changed files with 13 additions and 76 deletions
|
@ -92,11 +92,7 @@ namespace MWMechanics
|
|||
mMovement(),
|
||||
mForceNoShortcut(false),
|
||||
mShortcutFailPos(),
|
||||
mBackOffDoor(false),
|
||||
mCell(NULL),
|
||||
mDoorIter(actor.getCell()->get<ESM::Door>().mList.end()),
|
||||
mDoors(actor.getCell()->get<ESM::Door>()),
|
||||
mDoorCheckDuration(0)
|
||||
mBackOffDoor(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -198,12 +194,6 @@ namespace MWMechanics
|
|||
|
||||
mTimerReact = 0;
|
||||
|
||||
bool cellChange = mCell && (actor.getCell() != mCell);
|
||||
if(!mCell || cellChange)
|
||||
{
|
||||
mCell = actor.getCell();
|
||||
}
|
||||
|
||||
//actual attacking logic
|
||||
//TODO: Some skills affect period of strikes.For berserk-like style period ~ 0.25f
|
||||
float attacksPeriod = 1.0f;
|
||||
|
@ -503,70 +493,23 @@ namespace MWMechanics
|
|||
// coded at 250ms or 1/4 second
|
||||
//
|
||||
// TODO: Add a parameter to vary DURATION_SAME_SPOT?
|
||||
MWWorld::CellStore *cell = actor.getCell();
|
||||
if((distToTarget > rangeAttack || mFollowTarget) &&
|
||||
mObstacleCheck.check(actor, tReaction)) // check if evasive action needed
|
||||
{
|
||||
// first check if we're walking into a door
|
||||
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
|
||||
// but doesn't seem to do that?
|
||||
actor.getClass().getMovementSettings(actor).mPosition[0] = 1;
|
||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0.1f;
|
||||
// change the angle a bit, too
|
||||
if(mPathFinder.isPathConstructed())
|
||||
zTurn(actor, Ogre::Degree(mPathFinder.getZAngleToNext(pos.pos[0] + 1, pos.pos[1])));
|
||||
// probably walking into another NPC TODO: untested in combat situation
|
||||
|
||||
if(mFollowTarget)
|
||||
mFollowTarget = false;
|
||||
// FIXME: can fool actors to stay behind doors, etc.
|
||||
// Related to Bug#1102 and to some degree #1155 as well
|
||||
}
|
||||
}
|
||||
// TODO: diagonal should have same animation as walk forward
|
||||
// but doesn't seem to do that?
|
||||
actor.getClass().getMovementSettings(actor).mPosition[0] = 1;
|
||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0.1f;
|
||||
// change the angle a bit, too
|
||||
if(mPathFinder.isPathConstructed())
|
||||
zTurn(actor, Ogre::Degree(mPathFinder.getZAngleToNext(pos.pos[0] + 1, pos.pos[1])));
|
||||
|
||||
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;
|
||||
}
|
||||
if(mFollowTarget)
|
||||
mFollowTarget = false;
|
||||
// FIXME: can fool actors to stay behind doors, etc.
|
||||
// Related to Bug#1102 and to some degree #1155 as well
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -55,13 +55,7 @@ namespace MWMechanics
|
|||
MWMechanics::Movement mMovement;
|
||||
int mTargetActorId;
|
||||
|
||||
const MWWorld::CellStore* mCell;
|
||||
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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue