mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 17:19:39 +00:00
Fix idle animation and Fix water creature manual wandering
This commit is contained in:
parent
3dec10c686
commit
e9157e9200
2 changed files with 14 additions and 4 deletions
|
@ -16,7 +16,6 @@
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
#include "../mwworld/esmstore.hpp"
|
#include "../mwworld/esmstore.hpp"
|
||||||
#include "../mwworld/cellstore.hpp"
|
#include "../mwworld/cellstore.hpp"
|
||||||
#include "../mwworld/customdata.hpp"
|
|
||||||
|
|
||||||
#include "creaturestats.hpp"
|
#include "creaturestats.hpp"
|
||||||
#include "steering.hpp"
|
#include "steering.hpp"
|
||||||
|
@ -253,14 +252,16 @@ namespace MWMechanics
|
||||||
// Typically want to idle for a short time before the next wander
|
// Typically want to idle for a short time before the next wander
|
||||||
if (Misc::Rng::rollDice(100) >= 96) {
|
if (Misc::Rng::rollDice(100) >= 96) {
|
||||||
wanderNearStart(actor, storage, mDistance);
|
wanderNearStart(actor, storage, mDistance);
|
||||||
|
} else {
|
||||||
|
storage.setState(Wander_IdleNow);
|
||||||
}
|
}
|
||||||
} else if (mAllowedNodes.empty() && !storage.mIsWanderingManually) {
|
} else if (mAllowedNodes.empty() && !storage.mIsWanderingManually) {
|
||||||
storage.mCanWanderAlongPathGrid = false;
|
storage.mCanWanderAlongPathGrid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If Wandering manually and hit an obstacle, stop
|
// If Wandering manually and hit an obstacle, stop
|
||||||
if (storage.mIsWanderingManually && mObstacleCheck.check(actor, duration*10.0f, 2.5f)) {
|
if (storage.mIsWanderingManually && mObstacleCheck.check(actor, duration, 2.0f)) {
|
||||||
stopWalking(actor, storage);
|
completeManualWalking(actor, storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles.
|
// Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles.
|
||||||
|
@ -293,6 +294,8 @@ namespace MWMechanics
|
||||||
setPathToAnAllowedNode(actor, storage, pos);
|
setPathToAnAllowedNode(actor, storage, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (storage.mIsWanderingManually && storage.mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], DESTINATION_TOLERANCE)) {
|
||||||
|
completeManualWalking(actor, storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false; // AiWander package not yet completed
|
return false; // AiWander package not yet completed
|
||||||
|
@ -365,7 +368,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
// Check if land creature will walk onto water or if water creature will swim onto land
|
// Check if land creature will walk onto water or if water creature will swim onto land
|
||||||
if ((!isWaterCreature && !destinationIsAtWater(actor, destination)) ||
|
if ((!isWaterCreature && !destinationIsAtWater(actor, destination)) ||
|
||||||
(isWaterCreature && destinationThroughGround(currentPositionVec3f, destination))) {
|
(isWaterCreature && !destinationThroughGround(currentPositionVec3f, destination))) {
|
||||||
storage.mPathFinder.buildSyncedPath(currentPosition, destinationPosition, actor.getCell(), true);
|
storage.mPathFinder.buildSyncedPath(currentPosition, destinationPosition, actor.getCell(), true);
|
||||||
storage.mPathFinder.addPointToPath(destinationPosition);
|
storage.mPathFinder.addPointToPath(destinationPosition);
|
||||||
storage.setState(Wander_Walking, true);
|
storage.setState(Wander_Walking, true);
|
||||||
|
@ -392,6 +395,12 @@ namespace MWMechanics
|
||||||
destination.x(), destination.y(), destination.z());
|
destination.x(), destination.y(), destination.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiWander::completeManualWalking(const MWWorld::Ptr &actor, AiWanderStorage &storage) {
|
||||||
|
stopWalking(actor, storage);
|
||||||
|
mObstacleCheck.clear();
|
||||||
|
storage.setState(Wander_IdleNow);
|
||||||
|
}
|
||||||
|
|
||||||
void AiWander::doPerFrameActionsForState(const MWWorld::Ptr& actor, float duration, AiWanderStorage& storage, ESM::Position& pos)
|
void AiWander::doPerFrameActionsForState(const MWWorld::Ptr& actor, float duration, AiWanderStorage& storage, ESM::Position& pos)
|
||||||
{
|
{
|
||||||
switch (storage.mState)
|
switch (storage.mState)
|
||||||
|
|
|
@ -97,6 +97,7 @@ namespace MWMechanics
|
||||||
void wanderNearStart(const MWWorld::Ptr &actor, AiWanderStorage &storage, int wanderDistance);
|
void wanderNearStart(const MWWorld::Ptr &actor, AiWanderStorage &storage, int wanderDistance);
|
||||||
bool destinationIsAtWater(const MWWorld::Ptr &actor, const osg::Vec3f& destination);
|
bool destinationIsAtWater(const MWWorld::Ptr &actor, const osg::Vec3f& destination);
|
||||||
bool destinationThroughGround(const osg::Vec3f& startPoint, const osg::Vec3f& destination);
|
bool destinationThroughGround(const osg::Vec3f& startPoint, const osg::Vec3f& destination);
|
||||||
|
void completeManualWalking(const MWWorld::Ptr &actor, AiWanderStorage &storage);
|
||||||
|
|
||||||
int mDistance; // how far the actor can wander from the spawn point
|
int mDistance; // how far the actor can wander from the spawn point
|
||||||
int mDuration;
|
int mDuration;
|
||||||
|
|
Loading…
Reference in a new issue