1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00

Merge branch 'lua-add-is-fleeing' into 'master'

lua - add isFleeing() to AI interface

See merge request OpenMW/openmw!4256
This commit is contained in:
psi29a 2024-08-01 09:55:50 +00:00
commit 488a05d14c
2 changed files with 14 additions and 0 deletions

View File

@ -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();

View File

@ -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.