mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:23:51 +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:
parent
434fd21584
commit
23ffb8a4dc
3 changed files with 12 additions and 2 deletions
|
@ -23,7 +23,7 @@ void MWMechanics::AiSequence::copy (const AiSequence& sequence)
|
||||||
mPackages.push_back ((*iter)->clone());
|
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)
|
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())
|
if (!mPackages.empty())
|
||||||
{
|
{
|
||||||
|
mLastAiPackage = mPackages.front()->getTypeId();
|
||||||
if (mPackages.front()->execute (actor,duration))
|
if (mPackages.front()->execute (actor,duration))
|
||||||
{
|
{
|
||||||
delete *mPackages.begin();
|
delete *mPackages.begin();
|
||||||
|
@ -91,7 +92,9 @@ void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
mDone = true;
|
mDone = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
mDone = false;
|
mDone = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
void copy (const AiSequence& sequence);
|
void copy (const AiSequence& sequence);
|
||||||
|
|
||||||
|
// The type of AI package that ran last
|
||||||
|
int mLastAiPackage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
AiSequence();
|
AiSequence();
|
||||||
|
@ -36,6 +39,10 @@ namespace MWMechanics
|
||||||
int getTypeId() const;
|
int getTypeId() const;
|
||||||
///< @see enum AiPackage::TypeId
|
///< @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;
|
bool getCombatTarget (std::string &targetActorId) const;
|
||||||
///< Return true and assign target if combat package is currently
|
///< Return true and assign target if combat package is currently
|
||||||
/// active, return false otherwise
|
/// active, return false otherwise
|
||||||
|
|
|
@ -352,7 +352,7 @@ namespace MWScript
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr = R()(runtime);
|
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);
|
runtime.push (value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue