mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-17 08:26:50 -04:00
Reset initial wander position when commanding actors and don't create return packages when stacking actual ai packages
This commit is contained in:
parent
57fb334a6e
commit
88cac9b0fa
@ -119,6 +119,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
/// Reset pathfinding state
|
/// Reset pathfinding state
|
||||||
void reset();
|
void reset();
|
||||||
|
virtual void resetInitialPosition() {}
|
||||||
|
|
||||||
/// Return if actor's rotation speed is sufficient to rotate to the destination pathpoint on the run. Otherwise
|
/// Return if actor's rotation speed is sufficient to rotate to the destination pathpoint on the run. Otherwise
|
||||||
/// actor should rotate while standing.
|
/// actor should rotate while standing.
|
||||||
|
@ -400,7 +400,7 @@ namespace MWMechanics
|
|||||||
const auto newTypeId = package.getTypeId();
|
const auto newTypeId = package.getTypeId();
|
||||||
if (currentTypeId <= MWMechanics::AiPackageTypeId::Wander
|
if (currentTypeId <= MWMechanics::AiPackageTypeId::Wander
|
||||||
&& !hasPackage(MWMechanics::AiPackageTypeId::InternalTravel)
|
&& !hasPackage(MWMechanics::AiPackageTypeId::InternalTravel)
|
||||||
&& (newTypeId <= MWMechanics::AiPackageTypeId::Combat || newTypeId == MWMechanics::AiPackageTypeId::Pursue
|
&& (newTypeId == MWMechanics::AiPackageTypeId::Combat || newTypeId == MWMechanics::AiPackageTypeId::Pursue
|
||||||
|| newTypeId == MWMechanics::AiPackageTypeId::Cast))
|
|| newTypeId == MWMechanics::AiPackageTypeId::Cast))
|
||||||
{
|
{
|
||||||
osg::Vec3f dest;
|
osg::Vec3f dest;
|
||||||
@ -432,8 +432,14 @@ namespace MWMechanics
|
|||||||
}
|
}
|
||||||
|
|
||||||
// insert new package in correct place depending on priority
|
// insert new package in correct place depending on priority
|
||||||
|
bool resetInitialPositions = false;
|
||||||
for (auto it = mPackages.begin(); it != mPackages.end(); ++it)
|
for (auto it = mPackages.begin(); it != mPackages.end(); ++it)
|
||||||
{
|
{
|
||||||
|
if (resetInitialPositions)
|
||||||
|
{
|
||||||
|
(*it)->resetInitialPosition();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// We should override current AiCast package, if we try to add a new one.
|
// We should override current AiCast package, if we try to add a new one.
|
||||||
if ((*it)->getTypeId() == MWMechanics::AiPackageTypeId::Cast
|
if ((*it)->getTypeId() == MWMechanics::AiPackageTypeId::Cast
|
||||||
&& package.getTypeId() == MWMechanics::AiPackageTypeId::Cast)
|
&& package.getTypeId() == MWMechanics::AiPackageTypeId::Cast)
|
||||||
@ -444,22 +450,25 @@ namespace MWMechanics
|
|||||||
|
|
||||||
if ((*it)->getPriority() <= package.getPriority())
|
if ((*it)->getPriority() <= package.getPriority())
|
||||||
{
|
{
|
||||||
|
if (cancelOther && isActualAiPackage((*it)->getTypeId()))
|
||||||
|
mAiState.reset();
|
||||||
onPackageAdded(package);
|
onPackageAdded(package);
|
||||||
mPackages.insert(it, package.clone());
|
it = mPackages.insert(it, package.clone());
|
||||||
return;
|
if (newTypeId == MWMechanics::AiPackageTypeId::Follow)
|
||||||
|
resetInitialPositions = true;
|
||||||
|
else
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (resetInitialPositions)
|
||||||
|
return;
|
||||||
|
|
||||||
onPackageAdded(package);
|
onPackageAdded(package);
|
||||||
mPackages.push_back(package.clone());
|
mPackages.push_back(package.clone());
|
||||||
|
|
||||||
// Make sure that temporary storage is empty
|
// Make sure that temporary storage is empty
|
||||||
if (cancelOther)
|
if (cancelOther)
|
||||||
{
|
mAiState.reset();
|
||||||
mAiState.moveIn(std::make_unique<AiCombatStorage>());
|
|
||||||
mAiState.moveIn(std::make_unique<AiFollowStorage>());
|
|
||||||
mAiState.moveIn(std::make_unique<AiWanderStorage>());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWMechanics::AiSequence::isEmpty() const
|
bool MWMechanics::AiSequence::isEmpty() const
|
||||||
|
@ -59,12 +59,7 @@ namespace MWMechanics
|
|||||||
mStorage = std::make_unique<Derived>(payload);
|
mStorage = std::make_unique<Derived>(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief takes ownership of the passed object
|
void reset() { mStorage.reset(); }
|
||||||
template <class Derived>
|
|
||||||
void moveIn(std::unique_ptr<Derived>&& storage)
|
|
||||||
{
|
|
||||||
mStorage = std::move(storage);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,6 +676,13 @@ namespace MWMechanics
|
|||||||
stopMovement(actor);
|
stopMovement(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AiWander::resetInitialPosition()
|
||||||
|
{
|
||||||
|
mStoredInitialActorPosition = false;
|
||||||
|
mPathFinder.clearPath();
|
||||||
|
mHasDestination = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool AiWander::playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect)
|
bool AiWander::playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect)
|
||||||
{
|
{
|
||||||
if ((GroupIndex_MinIdle <= idleSelect) && (idleSelect <= GroupIndex_MaxIdle))
|
if ((GroupIndex_MinIdle <= idleSelect) && (idleSelect <= GroupIndex_MaxIdle))
|
||||||
@ -804,7 +811,7 @@ namespace MWMechanics
|
|||||||
|
|
||||||
converter.toWorld(dest);
|
converter.toWorld(dest);
|
||||||
|
|
||||||
state.moveIn(std::make_unique<AiWanderStorage>());
|
state.reset();
|
||||||
|
|
||||||
osg::Vec3f pos(static_cast<float>(dest.mX), static_cast<float>(dest.mY), static_cast<float>(dest.mZ));
|
osg::Vec3f pos(static_cast<float>(dest.mX), static_cast<float>(dest.mY), static_cast<float>(dest.mZ));
|
||||||
MWBase::Environment::get().getWorld()->moveObject(actor, pos);
|
MWBase::Environment::get().getWorld()->moveObject(actor, pos);
|
||||||
|
@ -121,6 +121,8 @@ namespace MWMechanics
|
|||||||
|
|
||||||
static std::string_view getIdleGroupName(size_t index) { return sIdleSelectToGroupName[index]; }
|
static std::string_view getIdleGroupName(size_t index) { return sIdleSelectToGroupName[index]; }
|
||||||
|
|
||||||
|
void resetInitialPosition() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void stopWalking(const MWWorld::Ptr& actor);
|
void stopWalking(const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user