diff --git a/apps/openmw/mwlua/localscripts.cpp b/apps/openmw/mwlua/localscripts.cpp index 4e7b171ff0..1230c6fa91 100644 --- a/apps/openmw/mwlua/localscripts.cpp +++ b/apps/openmw/mwlua/localscripts.cpp @@ -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> { const MWWorld::Ptr& ptr = self.ptr(); MWMechanics::AiSequence& ai = ptr.getClass().getCreatureStats(ptr).getAiSequence(); diff --git a/files/data/scripts/omw/ai.lua b/files/data/scripts/omw/ai.lua index e875e9f616..16a420cca1 100644 --- a/files/data/scripts/omw/ai.lua +++ b/files/data/scripts/omw/ai.lua @@ -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.