forked from mirror/openmw-tes3mp
Check animation state for GetPCRunning and GetPCSneaking
This commit is contained in:
parent
8acf0ba633
commit
bc7353f100
8 changed files with 68 additions and 7 deletions
|
@ -243,6 +243,9 @@ namespace MWBase
|
||||||
virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId) = 0;
|
virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId) = 0;
|
||||||
|
|
||||||
virtual void confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count) = 0;
|
virtual void confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count) = 0;
|
||||||
|
|
||||||
|
virtual bool isRunning(const MWWorld::Ptr& ptr) = 0;
|
||||||
|
virtual bool isSneaking(const MWWorld::Ptr& ptr) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -802,6 +802,26 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Actors::isRunning(const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
PtrActorMap::iterator it = mActors.find(ptr);
|
||||||
|
if (it == mActors.end())
|
||||||
|
return false;
|
||||||
|
CharacterController* ctrl = it->second->getCharacterController();
|
||||||
|
|
||||||
|
return ctrl->isRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Actors::isSneaking(const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
PtrActorMap::iterator it = mActors.find(ptr);
|
||||||
|
if (it == mActors.end())
|
||||||
|
return false;
|
||||||
|
CharacterController* ctrl = it->second->getCharacterController();
|
||||||
|
|
||||||
|
return ctrl->isSneaking();
|
||||||
|
}
|
||||||
|
|
||||||
void Actors::updateDrowning(const MWWorld::Ptr& ptr, float duration)
|
void Actors::updateDrowning(const MWWorld::Ptr& ptr, float duration)
|
||||||
{
|
{
|
||||||
PtrActorMap::iterator it = mActors.find(ptr);
|
PtrActorMap::iterator it = mActors.find(ptr);
|
||||||
|
|
|
@ -107,6 +107,9 @@ namespace MWMechanics
|
||||||
int countDeaths (const std::string& id) const;
|
int countDeaths (const std::string& id) const;
|
||||||
///< Return the number of deaths for actors with the given ID.
|
///< Return the number of deaths for actors with the given ID.
|
||||||
|
|
||||||
|
bool isRunning(const MWWorld::Ptr& ptr);
|
||||||
|
bool isSneaking(const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
void forceStateUpdate(const MWWorld::Ptr &ptr);
|
void forceStateUpdate(const MWWorld::Ptr &ptr);
|
||||||
|
|
||||||
bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number, bool persist=false);
|
bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number, bool persist=false);
|
||||||
|
|
|
@ -1650,7 +1650,7 @@ void CharacterController::update(float duration)
|
||||||
mSecondsOfSwimming -= 1;
|
mSecondsOfSwimming -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(isrunning)
|
else if(isrunning && !sneak)
|
||||||
{
|
{
|
||||||
mSecondsOfRunning += duration;
|
mSecondsOfRunning += duration;
|
||||||
while(mSecondsOfRunning > 1)
|
while(mSecondsOfRunning > 1)
|
||||||
|
@ -1688,7 +1688,7 @@ void CharacterController::update(float duration)
|
||||||
else
|
else
|
||||||
fatigueLoss = fFatigueSwimRunBase + encumbrance * fFatigueSwimRunMult;
|
fatigueLoss = fFatigueSwimRunBase + encumbrance * fFatigueSwimRunMult;
|
||||||
}
|
}
|
||||||
if (isrunning)
|
else if (isrunning)
|
||||||
fatigueLoss = fFatigueRunBase + encumbrance * fFatigueRunMult;
|
fatigueLoss = fFatigueRunBase + encumbrance * fFatigueRunMult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2237,6 +2237,18 @@ bool CharacterController::isSneaking() const
|
||||||
mMovementState == CharState_SneakRight;
|
mMovementState == CharState_SneakRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CharacterController::isRunning() const
|
||||||
|
{
|
||||||
|
return mMovementState == CharState_RunForward ||
|
||||||
|
mMovementState == CharState_RunBack ||
|
||||||
|
mMovementState == CharState_RunLeft ||
|
||||||
|
mMovementState == CharState_RunRight ||
|
||||||
|
mMovementState == CharState_SwimRunForward ||
|
||||||
|
mMovementState == CharState_SwimRunBack ||
|
||||||
|
mMovementState == CharState_SwimRunLeft ||
|
||||||
|
mMovementState == CharState_SwimRunRight;
|
||||||
|
}
|
||||||
|
|
||||||
void CharacterController::setAttackingOrSpell(bool attackingOrSpell)
|
void CharacterController::setAttackingOrSpell(bool attackingOrSpell)
|
||||||
{
|
{
|
||||||
mAttackingOrSpell = attackingOrSpell;
|
mAttackingOrSpell = attackingOrSpell;
|
||||||
|
|
|
@ -266,6 +266,7 @@ public:
|
||||||
bool isReadyToBlock() const;
|
bool isReadyToBlock() const;
|
||||||
bool isKnockedOut() const;
|
bool isKnockedOut() const;
|
||||||
bool isSneaking() const;
|
bool isSneaking() const;
|
||||||
|
bool isRunning() const;
|
||||||
|
|
||||||
void setAttackingOrSpell(bool attackingOrSpell);
|
void setAttackingOrSpell(bool attackingOrSpell);
|
||||||
void setAIAttackType(const std::string& attackType);
|
void setAIAttackType(const std::string& attackType);
|
||||||
|
|
|
@ -422,6 +422,16 @@ namespace MWMechanics
|
||||||
mObjects.update(duration, paused);
|
mObjects.update(duration, paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MechanicsManager::isRunning(const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
return mActors.isRunning(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MechanicsManager::isSneaking(const MWWorld::Ptr& ptr)
|
||||||
|
{
|
||||||
|
return mActors.isSneaking(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
void MechanicsManager::rest(bool sleep)
|
void MechanicsManager::rest(bool sleep)
|
||||||
{
|
{
|
||||||
mActors.rest(sleep);
|
mActors.rest(sleep);
|
||||||
|
|
|
@ -208,6 +208,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
virtual void confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count);
|
virtual void confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count);
|
||||||
|
|
||||||
|
virtual bool isRunning(const MWWorld::Ptr& ptr);
|
||||||
|
virtual bool isSneaking(const MWWorld::Ptr& ptr);
|
||||||
private:
|
private:
|
||||||
void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
void reportCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
|
||||||
OffenseType type, int arg=0);
|
OffenseType type, int arg=0);
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/inputmanager.hpp"
|
#include "../mwbase/inputmanager.hpp"
|
||||||
|
#include "../mwbase/mechanicsmanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
#include "../mwmechanics/npcstats.hpp"
|
#include "../mwmechanics/npcstats.hpp"
|
||||||
|
#include "../mwmechanics/movement.hpp"
|
||||||
|
|
||||||
#include "interpretercontext.hpp"
|
#include "interpretercontext.hpp"
|
||||||
#include "ref.hpp"
|
#include "ref.hpp"
|
||||||
|
@ -167,7 +169,11 @@ namespace MWScript
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||||
runtime.push (ptr.getClass().getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Run));
|
const MWWorld::Class &cls = ptr.getClass();
|
||||||
|
|
||||||
|
bool isRunning = MWBase::Environment::get().getMechanicsManager()->isRunning(ptr);
|
||||||
|
|
||||||
|
runtime.push (isRunning && cls.getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Run));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -177,8 +183,12 @@ namespace MWScript
|
||||||
|
|
||||||
virtual void execute (Interpreter::Runtime& runtime)
|
virtual void execute (Interpreter::Runtime& runtime)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||||
runtime.push (ptr.getClass().getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Sneak));
|
const MWWorld::Class &cls = ptr.getClass();
|
||||||
|
|
||||||
|
bool isSneaking = MWBase::Environment::get().getMechanicsManager()->isSneaking(ptr);
|
||||||
|
|
||||||
|
runtime.push (isSneaking && cls.getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Sneak));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue