mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 23:45:33 +00:00
Merge remote-tracking branch 'scrawl/athletics'
This commit is contained in:
commit
93c98e1df4
3 changed files with 30 additions and 3 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ static void getStateInfo(CharacterState state, std::string *group)
|
||||||
|
|
||||||
|
|
||||||
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state, bool loop)
|
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim, CharacterState state, bool loop)
|
||||||
: mPtr(ptr), mAnimation(anim), mCharState(state), mSkipAnim(false), mMovingAnim(false)
|
: mPtr(ptr), mAnimation(anim), mCharState(state), mSkipAnim(false), mMovingAnim(false), mSecondsOfRunning(0), mSecondsOfSwimming(0)
|
||||||
{
|
{
|
||||||
if(!mAnimation)
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
|
@ -152,6 +153,29 @@ void CharacterController::update(float duration, Movement &movement)
|
||||||
const Ogre::Vector3 &rot = cls.getRotationVector(mPtr);
|
const Ogre::Vector3 &rot = cls.getRotationVector(mPtr);
|
||||||
speed = cls.getSpeed(mPtr);
|
speed = cls.getSpeed(mPtr);
|
||||||
|
|
||||||
|
// advance athletics
|
||||||
|
if (vec.squaredLength() > 0 && mPtr == MWBase::Environment::get().getWorld()->getPlayer().getPlayer())
|
||||||
|
{
|
||||||
|
if (inwater)
|
||||||
|
{
|
||||||
|
mSecondsOfSwimming += duration;
|
||||||
|
while (mSecondsOfSwimming > 1)
|
||||||
|
{
|
||||||
|
MWWorld::Class::get(mPtr).skillUsageSucceeded(mPtr, ESM::Skill::Athletics, 1);
|
||||||
|
mSecondsOfSwimming -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isrunning)
|
||||||
|
{
|
||||||
|
mSecondsOfRunning += duration;
|
||||||
|
while (mSecondsOfRunning > 1)
|
||||||
|
{
|
||||||
|
MWWorld::Class::get(mPtr).skillUsageSucceeded(mPtr, ESM::Skill::Athletics, 0);
|
||||||
|
mSecondsOfRunning -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: The state should be set to Jump, and X/Y movement should be disallowed except
|
/* 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). */
|
* for the initial thrust (which would be carried by "physics" until landing). */
|
||||||
if(onground && vec.z > 0.0f)
|
if(onground && vec.z > 0.0f)
|
||||||
|
|
|
@ -79,6 +79,10 @@ class CharacterController
|
||||||
bool mLooping;
|
bool mLooping;
|
||||||
bool mSkipAnim;
|
bool mSkipAnim;
|
||||||
|
|
||||||
|
// counted for skill increase
|
||||||
|
float mSecondsOfSwimming;
|
||||||
|
float mSecondsOfRunning;
|
||||||
|
|
||||||
bool mMovingAnim;
|
bool mMovingAnim;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -169,8 +169,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla
|
||||||
if (specialisationFactor<=0)
|
if (specialisationFactor<=0)
|
||||||
throw std::runtime_error ("invalid skill specialisation factor");
|
throw std::runtime_error ("invalid skill specialisation factor");
|
||||||
}
|
}
|
||||||
|
return 1.0 / ((level+1) * (1.0/skillFactor) * typeFactor * specialisationFactor);
|
||||||
return 1.0 / (level +1) * (1.0 / (skillFactor)) * typeFactor * specialisationFactor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType)
|
void MWMechanics::NpcStats::useSkill (int skillIndex, const ESM::Class& class_, int usageType)
|
||||||
|
|
Loading…
Reference in a new issue