mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Merge branch 'cattlethief' into 'master'
Some checks are pending
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
Build and test / Ubuntu (push) Waiting to run
Some checks are pending
Build and test / Windows (2019) (push) Blocked by required conditions
Build and test / Windows (2022) (push) Blocked by required conditions
Build and test / MacOS (push) Waiting to run
Build and test / Read .env file and expose it as output (push) Waiting to run
Build and test / Ubuntu (push) Waiting to run
Fix AI issues with Command spells Closes #5331 See merge request OpenMW/openmw!4599
This commit is contained in:
commit
a4a6d8f3d4
5 changed files with 22 additions and 14 deletions
|
@ -119,6 +119,7 @@ namespace MWMechanics
|
|||
|
||||
/// Reset pathfinding state
|
||||
void reset();
|
||||
virtual void resetInitialPosition() {}
|
||||
|
||||
/// Return if actor's rotation speed is sufficient to rotate to the destination pathpoint on the run. Otherwise
|
||||
/// actor should rotate while standing.
|
||||
|
|
|
@ -400,7 +400,7 @@ namespace MWMechanics
|
|||
const auto newTypeId = package.getTypeId();
|
||||
if (currentTypeId <= MWMechanics::AiPackageTypeId::Wander
|
||||
&& !hasPackage(MWMechanics::AiPackageTypeId::InternalTravel)
|
||||
&& (newTypeId <= MWMechanics::AiPackageTypeId::Combat || newTypeId == MWMechanics::AiPackageTypeId::Pursue
|
||||
&& (newTypeId == MWMechanics::AiPackageTypeId::Combat || newTypeId == MWMechanics::AiPackageTypeId::Pursue
|
||||
|| newTypeId == MWMechanics::AiPackageTypeId::Cast))
|
||||
{
|
||||
osg::Vec3f dest;
|
||||
|
@ -444,8 +444,15 @@ namespace MWMechanics
|
|||
|
||||
if ((*it)->getPriority() <= package.getPriority())
|
||||
{
|
||||
if (cancelOther && isActualAiPackage((*it)->getTypeId()))
|
||||
mAiState.reset();
|
||||
onPackageAdded(package);
|
||||
mPackages.insert(it, package.clone());
|
||||
it = mPackages.insert(it, package.clone());
|
||||
if (newTypeId == MWMechanics::AiPackageTypeId::Follow)
|
||||
{
|
||||
for (++it; it != mPackages.end(); ++it)
|
||||
(*it)->resetInitialPosition();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -455,11 +462,7 @@ namespace MWMechanics
|
|||
|
||||
// Make sure that temporary storage is empty
|
||||
if (cancelOther)
|
||||
{
|
||||
mAiState.moveIn(std::make_unique<AiCombatStorage>());
|
||||
mAiState.moveIn(std::make_unique<AiFollowStorage>());
|
||||
mAiState.moveIn(std::make_unique<AiWanderStorage>());
|
||||
}
|
||||
mAiState.reset();
|
||||
}
|
||||
|
||||
bool MWMechanics::AiSequence::isEmpty() const
|
||||
|
|
|
@ -59,12 +59,7 @@ namespace MWMechanics
|
|||
mStorage = std::make_unique<Derived>(payload);
|
||||
}
|
||||
|
||||
/// \brief takes ownership of the passed object
|
||||
template <class Derived>
|
||||
void moveIn(std::unique_ptr<Derived>&& storage)
|
||||
{
|
||||
mStorage = std::move(storage);
|
||||
}
|
||||
void reset() { mStorage.reset(); }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -676,6 +676,13 @@ namespace MWMechanics
|
|||
stopMovement(actor);
|
||||
}
|
||||
|
||||
void AiWander::resetInitialPosition()
|
||||
{
|
||||
mStoredInitialActorPosition = false;
|
||||
mPathFinder.clearPath();
|
||||
mHasDestination = false;
|
||||
}
|
||||
|
||||
bool AiWander::playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect)
|
||||
{
|
||||
if ((GroupIndex_MinIdle <= idleSelect) && (idleSelect <= GroupIndex_MaxIdle))
|
||||
|
@ -804,7 +811,7 @@ namespace MWMechanics
|
|||
|
||||
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));
|
||||
MWBase::Environment::get().getWorld()->moveObject(actor, pos);
|
||||
|
|
|
@ -121,6 +121,8 @@ namespace MWMechanics
|
|||
|
||||
static std::string_view getIdleGroupName(size_t index) { return sIdleSelectToGroupName[index]; }
|
||||
|
||||
void resetInitialPosition() override;
|
||||
|
||||
private:
|
||||
void stopWalking(const MWWorld::Ptr& actor);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue