Merge pull request #949 from Allofich/master

Fix return values for AITravel
pull/1/head
scrawl 9 years ago
commit a45643f150

@ -47,7 +47,7 @@ bool MWMechanics::AiPackage::shouldCancelPreviousAi() const
bool MWMechanics::AiPackage::getRepeat() const
{
return true;
return false;
}
MWMechanics::AiPackage::AiPackage() : mTimer(0.26f), mStarted(false) { //mTimer starts at .26 to force initial pathbuild

@ -87,8 +87,7 @@ namespace MWMechanics
/// Upon adding this Ai package, should the Ai Sequence attempt to cancel previous Ai packages (default true)?
virtual bool shouldCancelPreviousAi() const;
/// Return true if this package should repeat. Can only be false for AIWander, if AIWander is assigned
/// assigned through the console or script.
/// Return true if this package should repeat. Currently only used for Wander packages.
virtual bool getRepeat() const;
bool isTargetMagicallyHidden(const MWWorld::Ptr& target);

@ -29,13 +29,14 @@ void AiSequence::copy (const AiSequence& sequence)
mPackages.push_back ((*iter)->clone());
}
AiSequence::AiSequence() : mDone (false), mLastAiPackage(-1) {}
AiSequence::AiSequence() : mDone (false), mRepeat(false), mLastAiPackage(-1) {}
AiSequence::AiSequence (const AiSequence& sequence)
{
copy (sequence);
mDone = sequence.mDone;
mLastAiPackage = sequence.mLastAiPackage;
mRepeat = sequence.mRepeat;
}
AiSequence& AiSequence::operator= (const AiSequence& sequence)
@ -231,7 +232,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
if (package->execute (actor,characterController,state,duration))
{
// Put repeating noncombat AI packages on the end of the stack so they can be used again
if (isActualAiPackage(packageTypeId) && package->getRepeat())
if (isActualAiPackage(packageTypeId) && (mRepeat || package->getRepeat()))
{
mPackages.push_back(package->clone());
}
@ -292,6 +293,7 @@ void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor)
else
++it;
}
mRepeat=false;
}
// insert new package in correct place depending on priority
@ -317,6 +319,10 @@ AiPackage* MWMechanics::AiSequence::getActivePackage()
void AiSequence::fill(const ESM::AIPackageList &list)
{
// If there is more than one package in the list, enable repeating
if (!list.mList.empty() && list.mList.begin() != (list.mList.end()-1))
mRepeat = true;
for (std::vector<ESM::AIPackage>::const_iterator it = list.mList.begin(); it != list.mList.end(); ++it)
{
MWMechanics::AiPackage* package;
@ -366,6 +372,19 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence)
if (!sequence.mPackages.empty())
clear();
// If there is more than one non-combat, non-pursue package in the list, enable repeating.
int count = 0;
for (std::vector<ESM::AiSequence::AiPackageContainer>::const_iterator it = sequence.mPackages.begin();
it != sequence.mPackages.end(); ++it)
{
if (isActualAiPackage(it->mType))
count++;
}
if (count > 1)
mRepeat = true;
// Load packages
for (std::vector<ESM::AiSequence::AiPackageContainer>::const_iterator it = sequence.mPackages.begin();
it != sequence.mPackages.end(); ++it)
{

@ -40,6 +40,9 @@ namespace MWMechanics
///Finished with top AIPackage, set for one frame
bool mDone;
///Does this AI sequence repeat (repeating of Wander packages handled separately)
bool mRepeat;
///Copy AiSequence
void copy (const AiSequence& sequence);

Loading…
Cancel
Save