1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 09:15:36 +00:00

Fixes #1143: Make getCurrentAiPackage return the package that was run last, not the package that will be run in the next frame.

This makes the Mehra Milo script work properly.
This commit is contained in:
scrawl 2014-01-28 20:57:37 +01:00
parent 434fd21584
commit 23ffb8a4dc
3 changed files with 12 additions and 2 deletions

View file

@ -23,7 +23,7 @@ void MWMechanics::AiSequence::copy (const AiSequence& sequence)
mPackages.push_back ((*iter)->clone());
}
MWMechanics::AiSequence::AiSequence() : mDone (false) {}
MWMechanics::AiSequence::AiSequence() : mDone (false), mLastAiPackage(-1) {}
MWMechanics::AiSequence::AiSequence (const AiSequence& sequence) : mDone (false)
{
@ -84,6 +84,7 @@ void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor,float duration)
{
if (!mPackages.empty())
{
mLastAiPackage = mPackages.front()->getTypeId();
if (mPackages.front()->execute (actor,duration))
{
delete *mPackages.begin();
@ -91,7 +92,9 @@ void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor,float duration)
mDone = true;
}
else
{
mDone = false;
}
}
}
}

View file

@ -23,6 +23,9 @@ namespace MWMechanics
void copy (const AiSequence& sequence);
// The type of AI package that ran last
int mLastAiPackage;
public:
AiSequence();
@ -36,6 +39,10 @@ namespace MWMechanics
int getTypeId() const;
///< @see enum AiPackage::TypeId
int getLastRunTypeId() const { return mLastAiPackage; }
///< Get the typeid of the Ai package that ran last, NOT the currently "active" Ai package that will be run in the next frame.
/// This difference is important when an Ai package has just finished and been removed.
bool getCombatTarget (std::string &targetActorId) const;
///< Return true and assign target if combat package is currently
/// active, return false otherwise

View file

@ -352,7 +352,7 @@ namespace MWScript
{
MWWorld::Ptr ptr = R()(runtime);
Interpreter::Type_Integer value = MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().getTypeId ();
Interpreter::Type_Integer value = MWWorld::Class::get (ptr).getCreatureStats (ptr).getAiSequence().getLastRunTypeId();
runtime.push (value);
}