|
|
|
@ -947,16 +947,6 @@ namespace MWClass
|
|
|
|
|
bool inair = !world->isOnGround(ptr) && !swimming && !world->isFlying(ptr);
|
|
|
|
|
running = running && (inair || MWBase::Environment::get().getMechanicsManager()->isRunning(ptr));
|
|
|
|
|
|
|
|
|
|
float walkSpeed = gmst.fMinWalkSpeed->mValue.getFloat() + 0.01f*npcdata->mNpcStats.getAttribute(ESM::Attribute::Speed).getModified()*
|
|
|
|
|
(gmst.fMaxWalkSpeed->mValue.getFloat() - gmst.fMinWalkSpeed->mValue.getFloat());
|
|
|
|
|
walkSpeed *= 1.0f - gmst.fEncumberedMoveEffect->mValue.getFloat()*normalizedEncumbrance;
|
|
|
|
|
walkSpeed = std::max(0.0f, walkSpeed);
|
|
|
|
|
if(sneaking)
|
|
|
|
|
walkSpeed *= gmst.fSneakSpeedMultiplier->mValue.getFloat();
|
|
|
|
|
|
|
|
|
|
float runSpeed = walkSpeed*(0.01f * getSkill(ptr, ESM::Skill::Athletics) *
|
|
|
|
|
gmst.fAthleticsRunBonus->mValue.getFloat() + gmst.fBaseRunMultiplier->mValue.getFloat());
|
|
|
|
|
|
|
|
|
|
float moveSpeed;
|
|
|
|
|
if(getEncumbrance(ptr) > getCapacity(ptr))
|
|
|
|
|
moveSpeed = 0.0f;
|
|
|
|
@ -971,19 +961,11 @@ namespace MWClass
|
|
|
|
|
moveSpeed = flySpeed;
|
|
|
|
|
}
|
|
|
|
|
else if (swimming)
|
|
|
|
|
{
|
|
|
|
|
float swimSpeed = walkSpeed;
|
|
|
|
|
if(running)
|
|
|
|
|
swimSpeed = runSpeed;
|
|
|
|
|
swimSpeed *= 1.0f + 0.01f * mageffects.get(ESM::MagicEffect::SwiftSwim).getMagnitude();
|
|
|
|
|
swimSpeed *= gmst.fSwimRunBase->mValue.getFloat() + 0.01f*getSkill(ptr, ESM::Skill::Athletics)*
|
|
|
|
|
gmst.fSwimRunAthleticsMult->mValue.getFloat();
|
|
|
|
|
moveSpeed = swimSpeed;
|
|
|
|
|
}
|
|
|
|
|
moveSpeed = getSwimSpeed(ptr);
|
|
|
|
|
else if (running && !sneaking)
|
|
|
|
|
moveSpeed = runSpeed;
|
|
|
|
|
moveSpeed = getRunSpeed(ptr);
|
|
|
|
|
else
|
|
|
|
|
moveSpeed = walkSpeed;
|
|
|
|
|
moveSpeed = getWalkSpeed(ptr);
|
|
|
|
|
if(getMovementSettings(ptr).mPosition[0] != 0 && getMovementSettings(ptr).mPosition[1] == 0)
|
|
|
|
|
moveSpeed *= 0.75f;
|
|
|
|
|
|
|
|
|
@ -1448,4 +1430,56 @@ namespace MWClass
|
|
|
|
|
{
|
|
|
|
|
MWMechanics::setBaseAISetting<ESM::NPC>(id, setting, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Npc::getWalkSpeed(const MWWorld::Ptr& ptr) const
|
|
|
|
|
{
|
|
|
|
|
const GMST& gmst = getGmst();
|
|
|
|
|
const NpcCustomData* npcdata = static_cast<const NpcCustomData*>(ptr.getRefData().getCustomData());
|
|
|
|
|
const float normalizedEncumbrance = getNormalizedEncumbrance(ptr);
|
|
|
|
|
const bool sneaking = MWBase::Environment::get().getMechanicsManager()->isSneaking(ptr);
|
|
|
|
|
|
|
|
|
|
float walkSpeed = gmst.fMinWalkSpeed->mValue.getFloat()
|
|
|
|
|
+ 0.01f * npcdata->mNpcStats.getAttribute(ESM::Attribute::Speed).getModified()
|
|
|
|
|
* (gmst.fMaxWalkSpeed->mValue.getFloat() - gmst.fMinWalkSpeed->mValue.getFloat());
|
|
|
|
|
walkSpeed *= 1.0f - gmst.fEncumberedMoveEffect->mValue.getFloat()*normalizedEncumbrance;
|
|
|
|
|
walkSpeed = std::max(0.0f, walkSpeed);
|
|
|
|
|
if(sneaking)
|
|
|
|
|
walkSpeed *= gmst.fSneakSpeedMultiplier->mValue.getFloat();
|
|
|
|
|
|
|
|
|
|
return walkSpeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Npc::getRunSpeed(const MWWorld::Ptr& ptr) const
|
|
|
|
|
{
|
|
|
|
|
const GMST& gmst = getGmst();
|
|
|
|
|
return getWalkSpeed(ptr)
|
|
|
|
|
* (0.01f * getSkill(ptr, ESM::Skill::Athletics) * gmst.fAthleticsRunBonus->mValue.getFloat()
|
|
|
|
|
+ gmst.fBaseRunMultiplier->mValue.getFloat());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Npc::getSwimSpeed(const MWWorld::Ptr& ptr) const
|
|
|
|
|
{
|
|
|
|
|
const GMST& gmst = getGmst();
|
|
|
|
|
const MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
|
const MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
|
|
|
|
const NpcCustomData* npcdata = static_cast<const NpcCustomData*>(ptr.getRefData().getCustomData());
|
|
|
|
|
const MWMechanics::MagicEffects& mageffects = npcdata->mNpcStats.getMagicEffects();
|
|
|
|
|
const bool swimming = world->isSwimming(ptr);
|
|
|
|
|
const bool inair = !world->isOnGround(ptr) && !swimming && !world->isFlying(ptr);
|
|
|
|
|
const bool running = stats.getStance(MWMechanics::CreatureStats::Stance_Run)
|
|
|
|
|
&& (inair || MWBase::Environment::get().getMechanicsManager()->isRunning(ptr));
|
|
|
|
|
|
|
|
|
|
float swimSpeed;
|
|
|
|
|
|
|
|
|
|
if (running)
|
|
|
|
|
swimSpeed = getRunSpeed(ptr);
|
|
|
|
|
else
|
|
|
|
|
swimSpeed = getWalkSpeed(ptr);
|
|
|
|
|
|
|
|
|
|
swimSpeed *= 1.0f + 0.01f * mageffects.get(ESM::MagicEffect::SwiftSwim).getMagnitude();
|
|
|
|
|
swimSpeed *= gmst.fSwimRunBase->mValue.getFloat()
|
|
|
|
|
+ 0.01f * getSkill(ptr, ESM::Skill::Athletics) * gmst.fSwimRunAthleticsMult->mValue.getFloat();
|
|
|
|
|
|
|
|
|
|
return swimSpeed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|