mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Jump acrobatics working, started falling acrobatics implementation
This commit is contained in:
parent
add3cd6456
commit
5a8c1661be
6 changed files with 65 additions and 2 deletions
|
@ -470,6 +470,34 @@ namespace MWClass
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Npc::getFallDamage(const MWWorld::Ptr &ptr, float fallHeight) const
|
||||||
|
{
|
||||||
|
const float fallDistanceMin = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fFallDamageDistanceMin")->getFloat();
|
||||||
|
|
||||||
|
if(fallHeight>=fallDistanceMin)
|
||||||
|
{
|
||||||
|
const float acrobaticsSkill = MWWorld::Class::get(ptr).getNpcStats (ptr).getSkill (ESM::Skill::Acrobatics).getModified();
|
||||||
|
const CustomData *npcdata = static_cast<const CustomData*>(ptr.getRefData().getCustomData());
|
||||||
|
const float jumpSpellBonus = npcdata->mCreatureStats.getMagicEffects().get(MWMechanics::EffectKey(9/*jump*/)).mMagnitude;
|
||||||
|
const float fallAcroBase = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fFallAcroBase")->getFloat();
|
||||||
|
const float fallAcroMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fFallAcroMult")->getFloat();
|
||||||
|
const float fallDistanceBase = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fFallDistanceBase")->getFloat();
|
||||||
|
const float fallDistanceMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fFallDistanceMult")->getFloat();
|
||||||
|
|
||||||
|
float x = fallHeight - fallDistanceMin;
|
||||||
|
x -= (1.5 * acrobaticsSkill) + jumpSpellBonus;
|
||||||
|
x = std::max(0.0f, x);
|
||||||
|
|
||||||
|
float a = fallAcroBase + (fallAcroMult * (100 - acrobaticsSkill));
|
||||||
|
x = fallDistanceBase + (fallDistanceMult * x);
|
||||||
|
x *= a;
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const
|
MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ensureCustomData (ptr);
|
ensureCustomData (ptr);
|
||||||
|
|
|
@ -91,6 +91,9 @@ namespace MWClass
|
||||||
virtual float getJump(const MWWorld::Ptr &ptr) const;
|
virtual float getJump(const MWWorld::Ptr &ptr) const;
|
||||||
///< Return jump velocity (not accounting for movement)
|
///< Return jump velocity (not accounting for movement)
|
||||||
|
|
||||||
|
virtual float getFallDamage(const MWWorld::Ptr &ptr, float fallHeight) const;
|
||||||
|
///< Return amount of health points lost when falling
|
||||||
|
|
||||||
virtual MWMechanics::Movement& getMovementSettings (const MWWorld::Ptr& ptr) const;
|
virtual MWMechanics::Movement& getMovementSettings (const MWWorld::Ptr& ptr) const;
|
||||||
///< Return desired movement.
|
///< Return desired movement.
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include "../mwworld/player.hpp"
|
#include "../mwworld/player.hpp"
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/stat.hpp"
|
||||||
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
@ -105,7 +107,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), mSecondsOfFalling(0)
|
mSecondsOfRunning(0), mSecondsOfSwimming(0), mHighestPosition(0)
|
||||||
{
|
{
|
||||||
if(!mAnimation)
|
if(!mAnimation)
|
||||||
return;
|
return;
|
||||||
|
@ -200,8 +202,29 @@ void CharacterController::update(float duration, Movement &movement)
|
||||||
movement.mPosition[2] += x * 0.707f * duration;
|
movement.mPosition[2] += x * 0.707f * duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//To calculate how much player will fall down
|
||||||
|
if(movement.mPosition[2] > mHighestPosition)
|
||||||
|
mHighestPosition = movement.mPosition[2];
|
||||||
|
|
||||||
//decrease fatigue by fFatigueJumpBase + (1 - normalizedEncumbrance) * fFatigueJumpMult;
|
//decrease fatigue by fFatigueJumpBase + (1 - normalizedEncumbrance) * fFatigueJumpMult;
|
||||||
}
|
}
|
||||||
|
else if(vec.z==0.0f && getState()==CharState_Jump)
|
||||||
|
{
|
||||||
|
float healthLost = cls.getFallDamage(mPtr, mHighestPosition);
|
||||||
|
|
||||||
|
if(healthLost>0.0f)
|
||||||
|
{
|
||||||
|
DynamicStat<float> health = cls.getCreatureStats(mPtr).getHealth();
|
||||||
|
int fatigue = MWWorld::Class::get (mPtr).getCreatureStats (mPtr).getFatigue().getBase();
|
||||||
|
int iHealth = health.getBase();
|
||||||
|
health.setBase (iHealth-(healthLost * (1 - (0.25 * fatigue))));
|
||||||
|
cls.getCreatureStats(mPtr).setHealth (health);
|
||||||
|
MWWorld::Class::get(mPtr).skillUsageSucceeded(mPtr, ESM::Skill::Acrobatics, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(CharState_Idle, true);
|
||||||
|
mHighestPosition=0;
|
||||||
|
}
|
||||||
|
|
||||||
if(std::abs(vec.x/2.0f) > std::abs(vec.y) && speed > 0.0f)
|
if(std::abs(vec.x/2.0f) > std::abs(vec.y) && speed > 0.0f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,8 @@ class CharacterController
|
||||||
// counted for skill increase
|
// counted for skill increase
|
||||||
float mSecondsOfSwimming;
|
float mSecondsOfSwimming;
|
||||||
float mSecondsOfRunning;
|
float mSecondsOfRunning;
|
||||||
float mSecondsOfFalling;
|
|
||||||
|
float mHighestPosition;
|
||||||
|
|
||||||
bool mMovingAnim;
|
bool mMovingAnim;
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,11 @@ namespace MWWorld
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Class::getFallDamage(const MWWorld::Ptr &ptr, float fallHeight) const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
float Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
|
float Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
throw std::runtime_error ("class does not support enchanting");
|
throw std::runtime_error ("class does not support enchanting");
|
||||||
|
|
|
@ -146,6 +146,9 @@ namespace MWWorld
|
||||||
virtual float getJump(const MWWorld::Ptr &ptr) const;
|
virtual float getJump(const MWWorld::Ptr &ptr) const;
|
||||||
///< Return jump velocity (not accounting for movement)
|
///< Return jump velocity (not accounting for movement)
|
||||||
|
|
||||||
|
virtual float getFallDamage(const MWWorld::Ptr &ptr, float fallHeight) const;
|
||||||
|
///< Return amount of health points lost when falling
|
||||||
|
|
||||||
virtual MWMechanics::Movement& getMovementSettings (const Ptr& ptr) const;
|
virtual MWMechanics::Movement& getMovementSettings (const Ptr& ptr) const;
|
||||||
///< Return desired movement.
|
///< Return desired movement.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue