diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index b32623b3f0..078ccc448d 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -62,7 +62,7 @@ add_openmw_dir (mwlua luamanagerimp object worldview userdataserializer luaevents engineevents objectvariant context globalscripts localscripts playerscripts luabindings objectbindings cellbindings camerabindings uibindings inputbindings nearbybindings postprocessingbindings stats debugbindings - types/types types/door types/actor types/container types/weapon types/npc types/creature types/activator types/book types/lockpick types/probe types/apparatus types/potion types/ingredient types/misc types/repair types/armor types/light types/static types/clothing + types/types types/door types/actor types/container types/weapon types/npc types/creature types/player types/activator types/book types/lockpick types/probe types/apparatus types/potion types/ingredient types/misc types/repair types/armor types/light types/static types/clothing worker magicbindings ) diff --git a/apps/openmw/mwlua/types/player.cpp b/apps/openmw/mwlua/types/player.cpp new file mode 100644 index 0000000000..4203e68d06 --- /dev/null +++ b/apps/openmw/mwlua/types/player.cpp @@ -0,0 +1,16 @@ +#include "types.hpp" + +#include +#include + +namespace MWLua +{ + + void addPlayerBindings(sol::table player, const Context& context) + { + player["getCrimeLevel"] = [](const Object& o) -> int { + const MWWorld::Class& cls = o.ptr().getClass(); + return cls.getNpcStats(o.ptr()).getBounty(); + }; + } +} diff --git a/apps/openmw/mwlua/types/types.cpp b/apps/openmw/mwlua/types/types.cpp index 8af374af2e..a3e0b52cbd 100644 --- a/apps/openmw/mwlua/types/types.cpp +++ b/apps/openmw/mwlua/types/types.cpp @@ -187,7 +187,7 @@ namespace MWLua addCreatureBindings(addType(ObjectTypeName::Creature, { ESM::REC_CREA }, ObjectTypeName::Actor), context); addNpcBindings( addType(ObjectTypeName::NPC, { ESM::REC_INTERNAL_PLAYER, ESM::REC_NPC_ }, ObjectTypeName::Actor), context); - addType(ObjectTypeName::Player, { ESM::REC_INTERNAL_PLAYER }, ObjectTypeName::NPC); + addPlayerBindings(addType(ObjectTypeName::Player, { ESM::REC_INTERNAL_PLAYER }, ObjectTypeName::NPC), context); addArmorBindings(addType(ObjectTypeName::Armor, { ESM::REC_ARMO }, ObjectTypeName::Item), context); addClothingBindings(addType(ObjectTypeName::Clothing, { ESM::REC_CLOT }, ObjectTypeName::Item), context); diff --git a/apps/openmw/mwlua/types/types.hpp b/apps/openmw/mwlua/types/types.hpp index cc0a8f3b82..abd2cb0051 100644 --- a/apps/openmw/mwlua/types/types.hpp +++ b/apps/openmw/mwlua/types/types.hpp @@ -50,6 +50,7 @@ namespace MWLua void addActorBindings(sol::table actor, const Context& context); void addWeaponBindings(sol::table weapon, const Context& context); void addNpcBindings(sol::table npc, const Context& context); + void addPlayerBindings(sol::table player, const Context& context); void addCreatureBindings(sol::table creature, const Context& context); void addLockpickBindings(sol::table lockpick, const Context& context); void addProbeBindings(sol::table probe, const Context& context); diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index f4ff7758c3..ccb7c38897 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -647,7 +647,11 @@ -- @param openmw.core#GameObject object -- @return #boolean - +--- +-- Returns the bounty or crime level of the player +-- @function [parent=#Player] getCrimeLevel +-- @param openmw.core#GameObject actor +-- @return #number --- @{#Armor} functions -- @field [parent=#types] #Armor Armor