mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Athletics skill increase
This commit is contained in:
parent
7821610ec6
commit
07891fa213
3 changed files with 30 additions and 3 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
#include "../mwworld/player.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)
|
||||
: 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)
|
||||
return;
|
||||
|
@ -152,6 +153,29 @@ void CharacterController::update(float duration, Movement &movement)
|
|||
const Ogre::Vector3 &rot = cls.getRotationVector(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
|
||||
* for the initial thrust (which would be carried by "physics" until landing). */
|
||||
if(onground && vec.z > 0.0f)
|
||||
|
|
|
@ -79,6 +79,10 @@ class CharacterController
|
|||
bool mLooping;
|
||||
bool mSkipAnim;
|
||||
|
||||
// counted for skill increase
|
||||
float mSecondsOfSwimming;
|
||||
float mSecondsOfRunning;
|
||||
|
||||
bool mMovingAnim;
|
||||
|
||||
public:
|
||||
|
|
|
@ -169,8 +169,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla
|
|||
if (specialisationFactor<=0)
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue