mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-01 04:34:32 +00:00
Merge branch 'werewolf-lua-api' into 'master'
Add Lua API for werewolf state management See merge request OpenMW/openmw!4940
This commit is contained in:
commit
93c4424f91
3 changed files with 27 additions and 1 deletions
|
|
@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
|
|||
set(OPENMW_VERSION_MAJOR 0)
|
||||
set(OPENMW_VERSION_MINOR 51)
|
||||
set(OPENMW_VERSION_RELEASE 0)
|
||||
set(OPENMW_LUA_API_REVISION 103)
|
||||
set(OPENMW_LUA_API_REVISION 104)
|
||||
set(OPENMW_POSTPROCESSING_API_REVISION 3)
|
||||
|
||||
set(OPENMW_VERSION_COMMITHASH "")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "../classbindings.hpp"
|
||||
#include "../localscripts.hpp"
|
||||
#include "../luamanagerimp.hpp"
|
||||
#include "../racebindings.hpp"
|
||||
#include "../stats.hpp"
|
||||
|
||||
|
|
@ -246,6 +247,20 @@ namespace MWLua
|
|||
throw std::runtime_error("NPC or Player expected");
|
||||
};
|
||||
|
||||
npc["setWerewolf"] = [context](const Object& obj, bool werewolf) -> void {
|
||||
if (dynamic_cast<const LObject*>(&obj) && !dynamic_cast<const SelfObject*>(&obj))
|
||||
throw std::runtime_error("Local scripts can modify only self");
|
||||
|
||||
const MWWorld::Ptr& ptr = obj.ptr();
|
||||
if (!ptr.getClass().isNpc())
|
||||
throw std::runtime_error("NPC or Player expected");
|
||||
context.mLuaManager->addAction(
|
||||
[obj = Object(ptr), werewolf] {
|
||||
MWBase::Environment::get().getMechanicsManager()->setWerewolf(obj.ptr(), werewolf);
|
||||
},
|
||||
"setWerewolfAction");
|
||||
};
|
||||
|
||||
npc["getDisposition"] = [](const Object& o, const Object& player) -> int {
|
||||
const MWWorld::Class& cls = o.ptr().getClass();
|
||||
verifyPlayer(player);
|
||||
|
|
|
|||
|
|
@ -1088,6 +1088,17 @@
|
|||
-- @param openmw.core#GameObject actor
|
||||
-- @return #boolean
|
||||
|
||||
---
|
||||
-- Turn an NPC or player into werewolf form or back to normal form.
|
||||
-- Can only be used in global scripts or on self in local scripts.
|
||||
-- @function [parent=#NPC] setWerewolf
|
||||
-- @param openmw.core#GameObject actor The NPC or player to transform
|
||||
-- @param #boolean werewolf True to transform into werewolf, false to transform back to normal
|
||||
-- @usage -- Transform player into werewolf in a global script
|
||||
-- player.type.setWerewolf(player, true)
|
||||
-- @usage -- Transform self back to normal in a local script
|
||||
-- self.type.setWerewolf(self, false)
|
||||
|
||||
---
|
||||
-- Returns the read-only @{#NpcRecord} of an NPC
|
||||
-- @function [parent=#NPC] record
|
||||
|
|
|
|||
Loading…
Reference in a new issue