diff --git a/apps/openmw/mwlua/types/player.cpp b/apps/openmw/mwlua/types/player.cpp index 130d3ded21..b2befe89de 100644 --- a/apps/openmw/mwlua/types/player.cpp +++ b/apps/openmw/mwlua/types/player.cpp @@ -186,6 +186,15 @@ namespace MWLua const MWWorld::Class& cls = o.ptr().getClass(); return cls.getNpcStats(o.ptr()).getBounty(); }; + player["setCrimeLevel"] = [](const Object& o, int amount) { + verifyPlayer(o); + if (!dynamic_cast(&o)) + throw std::runtime_error("Only global scripts can change crime level"); + const MWWorld::Class& cls = o.ptr().getClass(); + cls.getNpcStats(o.ptr()).setBounty(amount); + if (amount == 0) + MWBase::Environment::get().getWorld()->getPlayer().recordCrimeId(); + }; player["isCharGenFinished"] = [](const Object&) -> bool { return MWBase::Environment::get().getWorld()->getGlobalFloat(MWWorld::Globals::sCharGenState) == -1; }; diff --git a/files/lua_api/openmw/types.lua b/files/lua_api/openmw/types.lua index 149d9bd9fa..90344cbae1 100644 --- a/files/lua_api/openmw/types.lua +++ b/files/lua_api/openmw/types.lua @@ -1123,6 +1123,12 @@ -- @param openmw.core#GameObject player -- @return #number +--- +-- Sets the bounty or crime level of the player, may only be used in global scripts +-- @function [parent=#Player] setCrimeLevel +-- @param openmw.core#GameObject player +-- @param #number crimeLevel The requested crime level + --- -- Whether the character generation for this player is finished. -- @function [parent=#Player] isCharGenFinished