fix veritcal aiming

pull/35/head
mrcheko 9 years ago
parent 293a0f768c
commit e2cd87fcc7

@ -50,7 +50,6 @@ namespace MWMechanics
bool mForceNoShortcut; bool mForceNoShortcut;
ESM::Position mShortcutFailPos; ESM::Position mShortcutFailPos;
MWMechanics::Movement mMovement; MWMechanics::Movement mMovement;
bool mAdjustAiming;
AiCombatStorage(): AiCombatStorage():
mAttackCooldown(0), mAttackCooldown(0),
@ -67,8 +66,7 @@ namespace MWMechanics
mStrength(), mStrength(),
mForceNoShortcut(false), mForceNoShortcut(false),
mShortcutFailPos(), mShortcutFailPos(),
mMovement(), mMovement()
mAdjustAiming(false)
{} {}
void startCombatMove(bool isNpc, bool isDistantCombat, float distToTarget, float rangeAttack); void startCombatMove(bool isNpc, bool isDistantCombat, float distToTarget, float rangeAttack);
@ -255,12 +253,14 @@ namespace MWMechanics
vAimDir = AimDirToMovingTarget(actor, target, lastTargetPos, AI_REACTION_TIME, (weapon ? weapon->mData.mType : 0), storage.mStrength); vAimDir = AimDirToMovingTarget(actor, target, lastTargetPos, AI_REACTION_TIME, (weapon ? weapon->mData.mType : 0), storage.mStrength);
lastTargetPos = vTargetPos; lastTargetPos = vTargetPos;
MWMechanics::Movement& movement = storage.mMovement; storage.mMovement.mRotation[0] = getXAngleToDir(vAimDir);
movement.mRotation[0] = getXAngleToDir(vAimDir); storage.mMovement.mRotation[2] = getZAngleToDir(vAimDir);
movement.mRotation[2] = getZAngleToDir(vAimDir); }
else
{
storage.mMovement.mRotation[0] = getXAngleToDir(vAimDir);
storage.mMovement.mRotation[2] = getZAngleToDir((vTargetPos-vActorPos)); // using vAimDir results in spastic movements since the head is animated
} }
storage.mAdjustAiming = isRangedCombat;
} }
} }
@ -272,11 +272,8 @@ namespace MWMechanics
actorMovementSettings.mPosition[1] = storage.mMovement.mPosition[1]; actorMovementSettings.mPosition[1] = storage.mMovement.mPosition[1];
actorMovementSettings.mPosition[2] = storage.mMovement.mPosition[2]; actorMovementSettings.mPosition[2] = storage.mMovement.mPosition[2];
if (storage.mAdjustAiming) rotateActorOnAxis(actor, 2, actorMovementSettings, storage.mMovement);
{ rotateActorOnAxis(actor, 0, actorMovementSettings, storage.mMovement);
rotateActorOnAxis(actor, 2, actorMovementSettings, storage.mMovement);
rotateActorOnAxis(actor, 0, actorMovementSettings, storage.mMovement);
}
} }
void AiCombat::rotateActorOnAxis(const MWWorld::Ptr& actor, int axis, void AiCombat::rotateActorOnAxis(const MWWorld::Ptr& actor, int axis,

Loading…
Cancel
Save