forked from mirror/openmw-tes3mp
AiWander: resume moving to destination after combat
This commit is contained in:
parent
18ff097e4a
commit
81f29d8dcd
4 changed files with 33 additions and 9 deletions
|
@ -79,6 +79,9 @@ namespace MWMechanics
|
||||||
/// Get the target actor the AI is targeted at (not applicable to all AI packages, default return empty Ptr)
|
/// Get the target actor the AI is targeted at (not applicable to all AI packages, default return empty Ptr)
|
||||||
virtual MWWorld::Ptr getTarget() const;
|
virtual MWWorld::Ptr getTarget() const;
|
||||||
|
|
||||||
|
/// Get the destination point of the AI package (not applicable to all AI packages, default return (0, 0, 0))
|
||||||
|
virtual osg::Vec3f getDestination(const MWWorld::Ptr& actor) const { return osg::Vec3f(0, 0, 0); };
|
||||||
|
|
||||||
/// Return true if having this AiPackage makes the actor side with the target in fights (default false)
|
/// Return true if having this AiPackage makes the actor side with the target in fights (default false)
|
||||||
virtual bool sideWithTarget() const;
|
virtual bool sideWithTarget() const;
|
||||||
|
|
||||||
|
|
|
@ -338,6 +338,15 @@ namespace MWMechanics
|
||||||
return mRepeat;
|
return mRepeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::Vec3f AiWander::getDestination(const MWWorld::Ptr& actor) const
|
||||||
|
{
|
||||||
|
if (mHasDestination)
|
||||||
|
return mDestination;
|
||||||
|
|
||||||
|
const ESM::Pathgrid::Point currentPosition = actor.getRefData().getPosition().pos;
|
||||||
|
const osg::Vec3f currentPositionVec3f = osg::Vec3f(currentPosition.mX, currentPosition.mY, currentPosition.mZ);
|
||||||
|
return currentPositionVec3f;
|
||||||
|
}
|
||||||
|
|
||||||
bool AiWander::isPackageCompleted(const MWWorld::Ptr& actor, AiWanderStorage& storage)
|
bool AiWander::isPackageCompleted(const MWWorld::Ptr& actor, AiWanderStorage& storage)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,6 +50,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool getRepeat() const;
|
bool getRepeat() const;
|
||||||
|
|
||||||
|
osg::Vec3f getDestination(const MWWorld::Ptr& actor) const;
|
||||||
|
|
||||||
enum GreetingState {
|
enum GreetingState {
|
||||||
Greet_None,
|
Greet_None,
|
||||||
Greet_InProgress,
|
Greet_InProgress,
|
||||||
|
|
|
@ -1605,12 +1605,22 @@ namespace MWMechanics
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// we should return a wandering actor back after combat
|
// we should return a wandering actor back after combat
|
||||||
// TODO: only for stationary wander?
|
// the same thing for actors without AI packages
|
||||||
if (!aiSequence.isInCombat() && aiSequence.getLastRunTypeId() == MWMechanics::AiPackage::TypeIdWander)
|
if (!aiSequence.isInCombat() && aiSequence.getTypeId() <= MWMechanics::AiPackage::TypeIdWander)
|
||||||
{
|
{
|
||||||
osg::Vec3f pos = ptr.getRefData().getPosition().asVec3();
|
int typeId = aiSequence.getTypeId();
|
||||||
|
osg::Vec3f dest;
|
||||||
|
if (typeId == MWMechanics::AiPackage::TypeIdNone)
|
||||||
|
{
|
||||||
|
dest = ptr.getRefData().getPosition().asVec3();
|
||||||
|
}
|
||||||
|
else if (typeId == MWMechanics::AiPackage::TypeIdWander)
|
||||||
|
{
|
||||||
|
AiPackage* activePackage = aiSequence.getActivePackage();
|
||||||
|
dest = activePackage->getDestination(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
MWMechanics::AiTravel travelPackage(pos.x(), pos.y(), pos.z());
|
MWMechanics::AiTravel travelPackage(dest.x(), dest.y(), dest.z());
|
||||||
aiSequence.stack(travelPackage, ptr, false);
|
aiSequence.stack(travelPackage, ptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue