mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 19:06:41 +00:00
lua - add isFleeing() to lua AI interface
This commit is contained in:
parent
4873a9fbf3
commit
234476bdae
2 changed files with 14 additions and 0 deletions
|
@ -132,6 +132,15 @@ namespace MWLua
|
|||
});
|
||||
|
||||
aiPackage["isRepeat"] = sol::readonly_property([](const AiPackage& p) { return p.getRepeat(); });
|
||||
|
||||
selfAPI["_isFleeing"] = [](SelfObject& self) -> bool {
|
||||
const MWWorld::Ptr& ptr = self.ptr();
|
||||
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
|
||||
if (ai.isEmpty())
|
||||
return false;
|
||||
else
|
||||
return ai.isFleeing();
|
||||
};
|
||||
selfAPI["_getActiveAiPackage"] = [](SelfObject& self) -> sol::optional<std::shared_ptr<AiPackage>> {
|
||||
const MWWorld::Ptr& ptr = self.ptr();
|
||||
MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence();
|
||||
|
|
|
@ -80,6 +80,11 @@ return {
|
|||
-- @return #Package
|
||||
getActivePackage = function() return self:_getActiveAiPackage() end,
|
||||
|
||||
--- Return whether the actor is fleeing.
|
||||
-- @function [parent=#AI] isFleeing
|
||||
-- @return #boolean
|
||||
isFleeing = function() return self:_isFleeing() end,
|
||||
|
||||
--- Start new AI package.
|
||||
-- @function [parent=#AI] startPackage
|
||||
-- @param #table options See the "Built-in AI packages" page.
|
||||
|
|
Loading…
Reference in a new issue