|
|
|
@ -295,148 +295,9 @@ void CharacterController::updatePtr(const MWWorld::Ptr &ptr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CharacterController::update(float duration, Movement &movement)
|
|
|
|
|
bool CharacterController::updateNpcState()
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
|
|
|
|
|
|
|
|
|
if(!cls.isActor())
|
|
|
|
|
{
|
|
|
|
|
if(mAnimQueue.size() > 1)
|
|
|
|
|
{
|
|
|
|
|
if(mAnimation->isPlaying(mAnimQueue.front().first) == false)
|
|
|
|
|
{
|
|
|
|
|
mAnimation->disable(mAnimQueue.front().first);
|
|
|
|
|
mAnimQueue.pop_front();
|
|
|
|
|
|
|
|
|
|
mAnimation->play(mAnimQueue.front().first, Priority_Default,
|
|
|
|
|
MWRender::Animation::Group_All, false,
|
|
|
|
|
1.0f, "start", "stop", 0.0f, mAnimQueue.front().second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(!cls.getCreatureStats(mPtr).isDead())
|
|
|
|
|
{
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
|
|
bool onground = world->isOnGround(mPtr);
|
|
|
|
|
bool inwater = world->isSwimming(mPtr);
|
|
|
|
|
bool isrunning = cls.getStance(mPtr, MWWorld::Class::Run);
|
|
|
|
|
bool sneak = cls.getStance(mPtr, MWWorld::Class::Sneak);
|
|
|
|
|
Ogre::Vector3 vec = cls.getMovementVector(mPtr);
|
|
|
|
|
Ogre::Vector3 rot = cls.getRotationVector(mPtr);
|
|
|
|
|
mMovementSpeed = cls.getSpeed(mPtr);
|
|
|
|
|
|
|
|
|
|
// advance athletics
|
|
|
|
|
if(vec.squaredLength() > 0 && mPtr.getRefData().getHandle() == "player")
|
|
|
|
|
{
|
|
|
|
|
if(inwater)
|
|
|
|
|
{
|
|
|
|
|
mSecondsOfSwimming += duration;
|
|
|
|
|
while(mSecondsOfSwimming > 1)
|
|
|
|
|
{
|
|
|
|
|
cls.skillUsageSucceeded(mPtr, ESM::Skill::Athletics, 1);
|
|
|
|
|
mSecondsOfSwimming -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(isrunning)
|
|
|
|
|
{
|
|
|
|
|
mSecondsOfRunning += duration;
|
|
|
|
|
while(mSecondsOfRunning > 1)
|
|
|
|
|
{
|
|
|
|
|
cls.skillUsageSucceeded(mPtr, ESM::Skill::Athletics, 0);
|
|
|
|
|
mSecondsOfRunning -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: The state should be set to Jump, and X/Y movement should be disallowed except
|
|
|
|
|
* for the initial thrust (which would be carried by "physics" until landing). */
|
|
|
|
|
if(!onground)
|
|
|
|
|
vec.z = 0.0f;
|
|
|
|
|
else if(vec.z > 0.0f)
|
|
|
|
|
{
|
|
|
|
|
float z = cls.getJump(mPtr);
|
|
|
|
|
|
|
|
|
|
if(vec.x == 0 && vec.y == 0)
|
|
|
|
|
vec.z *= z;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: this would be more correct if we were going into a jumping state,
|
|
|
|
|
* rather than normal walking/idle states. */
|
|
|
|
|
//Ogre::Vector3 lat = Ogre::Vector3(vec.x, vec.y, 0.0f).normalisedCopy();
|
|
|
|
|
//vec *= Ogre::Vector3(lat.x, lat.y, 1.0f) * z * 0.707f;
|
|
|
|
|
vec.z *= z * 0.707f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//decrease fatigue by fFatigueJumpBase + (1 - normalizedEncumbrance) * fFatigueJumpMult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vec.x *= mMovementSpeed;
|
|
|
|
|
vec.y *= mMovementSpeed;
|
|
|
|
|
|
|
|
|
|
CharacterState movestate = CharState_None;
|
|
|
|
|
CharacterState idlestate = CharState_SpecialIdle;
|
|
|
|
|
bool forcestateupdate = false;
|
|
|
|
|
|
|
|
|
|
if(std::abs(vec.x/2.0f) > std::abs(vec.y))
|
|
|
|
|
{
|
|
|
|
|
if(vec.x > 0.0f)
|
|
|
|
|
movestate = (inwater ? (isrunning ? CharState_SwimRunRight : CharState_SwimWalkRight)
|
|
|
|
|
: (sneak ? CharState_SneakRight
|
|
|
|
|
: (isrunning ? CharState_RunRight : CharState_WalkRight)));
|
|
|
|
|
else if(vec.x < 0.0f)
|
|
|
|
|
movestate = (inwater ? (isrunning ? CharState_SwimRunLeft : CharState_SwimWalkLeft)
|
|
|
|
|
: (sneak ? CharState_SneakLeft
|
|
|
|
|
: (isrunning ? CharState_RunLeft : CharState_WalkLeft)));
|
|
|
|
|
}
|
|
|
|
|
else if(vec.y != 0.0f)
|
|
|
|
|
{
|
|
|
|
|
if(vec.y > 0.0f)
|
|
|
|
|
movestate = (inwater ? (isrunning ? CharState_SwimRunForward : CharState_SwimWalkForward)
|
|
|
|
|
: (sneak ? CharState_SneakForward
|
|
|
|
|
: (isrunning ? CharState_RunForward : CharState_WalkForward)));
|
|
|
|
|
else if(vec.y < 0.0f)
|
|
|
|
|
movestate = (inwater ? (isrunning ? CharState_SwimRunBack : CharState_SwimWalkBack)
|
|
|
|
|
: (sneak ? CharState_SneakBack
|
|
|
|
|
: (isrunning ? CharState_RunBack : CharState_WalkBack)));
|
|
|
|
|
}
|
|
|
|
|
else if(rot.z != 0.0f && !inwater && !sneak)
|
|
|
|
|
{
|
|
|
|
|
if(rot.z > 0.0f)
|
|
|
|
|
movestate = CharState_TurnRight;
|
|
|
|
|
else if(rot.z < 0.0f)
|
|
|
|
|
movestate = CharState_TurnLeft;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(movestate != CharState_None)
|
|
|
|
|
clearAnimQueue();
|
|
|
|
|
|
|
|
|
|
if(mAnimQueue.size() == 0)
|
|
|
|
|
idlestate = (inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle));
|
|
|
|
|
else if(mAnimQueue.size() > 1)
|
|
|
|
|
{
|
|
|
|
|
if(mAnimation->isPlaying(mAnimQueue.front().first) == false)
|
|
|
|
|
{
|
|
|
|
|
mAnimation->disable(mAnimQueue.front().first);
|
|
|
|
|
mAnimQueue.pop_front();
|
|
|
|
|
|
|
|
|
|
mAnimation->play(mAnimQueue.front().first, Priority_Default,
|
|
|
|
|
MWRender::Animation::Group_All, false,
|
|
|
|
|
1.0f, "start", "stop", 0.0f, mAnimQueue.front().second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vec *= duration;
|
|
|
|
|
movement.mPosition[0] += vec.x;
|
|
|
|
|
movement.mPosition[1] += vec.y;
|
|
|
|
|
movement.mPosition[2] += vec.z;
|
|
|
|
|
rot *= duration;
|
|
|
|
|
movement.mRotation[0] += rot.x;
|
|
|
|
|
movement.mRotation[1] += rot.y;
|
|
|
|
|
movement.mRotation[2] += rot.z;
|
|
|
|
|
|
|
|
|
|
if(mPtr.getTypeName() == typeid(ESM::NPC).name())
|
|
|
|
|
{
|
|
|
|
|
NpcStats &stats = cls.getNpcStats(mPtr);
|
|
|
|
|
WeaponType weaptype = WeapType_None;
|
|
|
|
|
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
|
|
|
@ -493,6 +354,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|
|
|
|
else
|
|
|
|
|
weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
|
|
|
|
|
|
|
|
|
bool forcestateupdate = false;
|
|
|
|
|
if(mUpdateWeapon)
|
|
|
|
|
{
|
|
|
|
|
forcestateupdate = (mWeaponType != weaptype);
|
|
|
|
@ -540,8 +402,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
bool isWeapon = (weapon != inv.end() && weapon->getTypeName() == typeid(ESM::Weapon).name());
|
|
|
|
|
float weapSpeed = 1.0f;
|
|
|
|
|
if(isWeapon)
|
|
|
|
@ -584,13 +445,17 @@ void CharacterController::update(float duration, Movement &movement)
|
|
|
|
|
mUpperBodyState = UpperCharState_MaxAttackToMinHit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(mUpperBodyState == UpperCharState_EquipingWeap && !animPlaying)
|
|
|
|
|
if(!animPlaying)
|
|
|
|
|
{
|
|
|
|
|
if(mUpperBodyState == UpperCharState_EquipingWeap ||
|
|
|
|
|
mUpperBodyState == UpperCharState_LargeFollowStartToLargeFollowStop)
|
|
|
|
|
mUpperBodyState = UpperCharState_WeapEquiped;
|
|
|
|
|
else if(mUpperBodyState == UpperCharState_UnEquipingWeap && !animPlaying)
|
|
|
|
|
else if(mUpperBodyState == UpperCharState_UnEquipingWeap)
|
|
|
|
|
mUpperBodyState = UpperCharState_Nothing;
|
|
|
|
|
else if(animPlaying)
|
|
|
|
|
}
|
|
|
|
|
else if(complete >= 1.0f)
|
|
|
|
|
{
|
|
|
|
|
if(mUpperBodyState == UpperCharState_StartToMinAttack && complete == 1.0f)
|
|
|
|
|
if(mUpperBodyState == UpperCharState_StartToMinAttack)
|
|
|
|
|
{
|
|
|
|
|
mAnimation->disable(mCurrentWeapon);
|
|
|
|
|
mAnimation->play(mCurrentWeapon, Priority_Weapon,
|
|
|
|
@ -599,7 +464,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|
|
|
|
0.0f, 0);
|
|
|
|
|
mUpperBodyState = UpperCharState_MinAttackToMaxAttack;
|
|
|
|
|
}
|
|
|
|
|
else if(mUpperBodyState == UpperCharState_MaxAttackToMinHit && complete == 1.0f)
|
|
|
|
|
else if(mUpperBodyState == UpperCharState_MaxAttackToMinHit)
|
|
|
|
|
{
|
|
|
|
|
mAnimation->disable(mCurrentWeapon);
|
|
|
|
|
mAnimation->play(mCurrentWeapon, Priority_Weapon,
|
|
|
|
@ -608,22 +473,22 @@ void CharacterController::update(float duration, Movement &movement)
|
|
|
|
|
0.0f, 0);
|
|
|
|
|
mUpperBodyState = UpperCharState_MinHitToHit;
|
|
|
|
|
}
|
|
|
|
|
else if(mUpperBodyState == UpperCharState_MinHitToHit && complete == 1.0f)
|
|
|
|
|
else if(mUpperBodyState == UpperCharState_MinHitToHit)
|
|
|
|
|
{
|
|
|
|
|
mAnimation->disable(mCurrentWeapon);
|
|
|
|
|
mAnimation->play(mCurrentWeapon, Priority_Weapon,
|
|
|
|
|
MWRender::Animation::Group_UpperBody, false,
|
|
|
|
|
MWRender::Animation::Group_UpperBody, true,
|
|
|
|
|
weapSpeed, mAttackType+" large follow start", mAttackType+" large follow stop",
|
|
|
|
|
0.0f, 0);
|
|
|
|
|
mUpperBodyState = UpperCharState_LargeFollowStartToLargeFollowStop;
|
|
|
|
|
}
|
|
|
|
|
else if(mUpperBodyState == UpperCharState_LargeFollowStartToLargeFollowStop && complete == 1.0f)
|
|
|
|
|
else if(mUpperBodyState == UpperCharState_LargeFollowStartToLargeFollowStop)
|
|
|
|
|
{
|
|
|
|
|
mAnimation->disable(mCurrentWeapon);
|
|
|
|
|
mUpperBodyState = UpperCharState_WeapEquiped;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
|
|
|
|
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name())
|
|
|
|
@ -635,7 +500,152 @@ void CharacterController::update(float duration, Movement &movement)
|
|
|
|
|
}
|
|
|
|
|
else if(mAnimation->isPlaying("torch"))
|
|
|
|
|
mAnimation->disable("torch");
|
|
|
|
|
|
|
|
|
|
return forcestateupdate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CharacterController::update(float duration, Movement &movement)
|
|
|
|
|
{
|
|
|
|
|
const MWWorld::Class &cls = MWWorld::Class::get(mPtr);
|
|
|
|
|
|
|
|
|
|
if(!cls.isActor())
|
|
|
|
|
{
|
|
|
|
|
if(mAnimQueue.size() > 1)
|
|
|
|
|
{
|
|
|
|
|
if(mAnimation->isPlaying(mAnimQueue.front().first) == false)
|
|
|
|
|
{
|
|
|
|
|
mAnimation->disable(mAnimQueue.front().first);
|
|
|
|
|
mAnimQueue.pop_front();
|
|
|
|
|
|
|
|
|
|
mAnimation->play(mAnimQueue.front().first, Priority_Default,
|
|
|
|
|
MWRender::Animation::Group_All, false,
|
|
|
|
|
1.0f, "start", "stop", 0.0f, mAnimQueue.front().second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(!cls.getCreatureStats(mPtr).isDead())
|
|
|
|
|
{
|
|
|
|
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
|
|
|
|
|
|
|
|
bool onground = world->isOnGround(mPtr);
|
|
|
|
|
bool inwater = world->isSwimming(mPtr);
|
|
|
|
|
bool isrunning = cls.getStance(mPtr, MWWorld::Class::Run);
|
|
|
|
|
bool sneak = cls.getStance(mPtr, MWWorld::Class::Sneak);
|
|
|
|
|
Ogre::Vector3 vec = cls.getMovementVector(mPtr);
|
|
|
|
|
Ogre::Vector3 rot = cls.getRotationVector(mPtr);
|
|
|
|
|
mMovementSpeed = cls.getSpeed(mPtr);
|
|
|
|
|
|
|
|
|
|
// advance athletics
|
|
|
|
|
if(vec.squaredLength() > 0 && mPtr.getRefData().getHandle() == "player")
|
|
|
|
|
{
|
|
|
|
|
if(inwater)
|
|
|
|
|
{
|
|
|
|
|
mSecondsOfSwimming += duration;
|
|
|
|
|
while(mSecondsOfSwimming > 1)
|
|
|
|
|
{
|
|
|
|
|
cls.skillUsageSucceeded(mPtr, ESM::Skill::Athletics, 1);
|
|
|
|
|
mSecondsOfSwimming -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(isrunning)
|
|
|
|
|
{
|
|
|
|
|
mSecondsOfRunning += duration;
|
|
|
|
|
while(mSecondsOfRunning > 1)
|
|
|
|
|
{
|
|
|
|
|
cls.skillUsageSucceeded(mPtr, ESM::Skill::Athletics, 0);
|
|
|
|
|
mSecondsOfRunning -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: The state should be set to Jump, and X/Y movement should be disallowed except
|
|
|
|
|
* for the initial thrust (which would be carried by "physics" until landing). */
|
|
|
|
|
if(!onground)
|
|
|
|
|
vec.z = 0.0f;
|
|
|
|
|
else if(vec.z > 0.0f)
|
|
|
|
|
{
|
|
|
|
|
float z = cls.getJump(mPtr);
|
|
|
|
|
|
|
|
|
|
if(vec.x == 0 && vec.y == 0)
|
|
|
|
|
vec.z *= z;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* FIXME: this would be more correct if we were going into a jumping state,
|
|
|
|
|
* rather than normal walking/idle states. */
|
|
|
|
|
//Ogre::Vector3 lat = Ogre::Vector3(vec.x, vec.y, 0.0f).normalisedCopy();
|
|
|
|
|
//vec *= Ogre::Vector3(lat.x, lat.y, 1.0f) * z * 0.707f;
|
|
|
|
|
vec.z *= z * 0.707f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//decrease fatigue by fFatigueJumpBase + (1 - normalizedEncumbrance) * fFatigueJumpMult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vec.x *= mMovementSpeed;
|
|
|
|
|
vec.y *= mMovementSpeed;
|
|
|
|
|
|
|
|
|
|
CharacterState movestate = CharState_None;
|
|
|
|
|
CharacterState idlestate = CharState_SpecialIdle;
|
|
|
|
|
bool forcestateupdate = false;
|
|
|
|
|
|
|
|
|
|
if(std::abs(vec.x/2.0f) > std::abs(vec.y))
|
|
|
|
|
{
|
|
|
|
|
if(vec.x > 0.0f)
|
|
|
|
|
movestate = (inwater ? (isrunning ? CharState_SwimRunRight : CharState_SwimWalkRight)
|
|
|
|
|
: (sneak ? CharState_SneakRight
|
|
|
|
|
: (isrunning ? CharState_RunRight : CharState_WalkRight)));
|
|
|
|
|
else if(vec.x < 0.0f)
|
|
|
|
|
movestate = (inwater ? (isrunning ? CharState_SwimRunLeft : CharState_SwimWalkLeft)
|
|
|
|
|
: (sneak ? CharState_SneakLeft
|
|
|
|
|
: (isrunning ? CharState_RunLeft : CharState_WalkLeft)));
|
|
|
|
|
}
|
|
|
|
|
else if(vec.y != 0.0f)
|
|
|
|
|
{
|
|
|
|
|
if(vec.y > 0.0f)
|
|
|
|
|
movestate = (inwater ? (isrunning ? CharState_SwimRunForward : CharState_SwimWalkForward)
|
|
|
|
|
: (sneak ? CharState_SneakForward
|
|
|
|
|
: (isrunning ? CharState_RunForward : CharState_WalkForward)));
|
|
|
|
|
else if(vec.y < 0.0f)
|
|
|
|
|
movestate = (inwater ? (isrunning ? CharState_SwimRunBack : CharState_SwimWalkBack)
|
|
|
|
|
: (sneak ? CharState_SneakBack
|
|
|
|
|
: (isrunning ? CharState_RunBack : CharState_WalkBack)));
|
|
|
|
|
}
|
|
|
|
|
else if(rot.z != 0.0f && !inwater && !sneak)
|
|
|
|
|
{
|
|
|
|
|
if(rot.z > 0.0f)
|
|
|
|
|
movestate = CharState_TurnRight;
|
|
|
|
|
else if(rot.z < 0.0f)
|
|
|
|
|
movestate = CharState_TurnLeft;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(movestate != CharState_None)
|
|
|
|
|
clearAnimQueue();
|
|
|
|
|
|
|
|
|
|
if(mAnimQueue.size() == 0)
|
|
|
|
|
idlestate = (inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle));
|
|
|
|
|
else if(mAnimQueue.size() > 1)
|
|
|
|
|
{
|
|
|
|
|
if(mAnimation->isPlaying(mAnimQueue.front().first) == false)
|
|
|
|
|
{
|
|
|
|
|
mAnimation->disable(mAnimQueue.front().first);
|
|
|
|
|
mAnimQueue.pop_front();
|
|
|
|
|
|
|
|
|
|
mAnimation->play(mAnimQueue.front().first, Priority_Default,
|
|
|
|
|
MWRender::Animation::Group_All, false,
|
|
|
|
|
1.0f, "start", "stop", 0.0f, mAnimQueue.front().second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vec *= duration;
|
|
|
|
|
movement.mPosition[0] += vec.x;
|
|
|
|
|
movement.mPosition[1] += vec.y;
|
|
|
|
|
movement.mPosition[2] += vec.z;
|
|
|
|
|
rot *= duration;
|
|
|
|
|
movement.mRotation[0] += rot.x;
|
|
|
|
|
movement.mRotation[1] += rot.y;
|
|
|
|
|
movement.mRotation[2] += rot.z;
|
|
|
|
|
|
|
|
|
|
if(mPtr.getTypeName() == typeid(ESM::NPC).name())
|
|
|
|
|
forcestateupdate = updateNpcState();
|
|
|
|
|
|
|
|
|
|
refreshCurrentAnims(idlestate, movestate, forcestateupdate);
|
|
|
|
|
}
|
|
|
|
|