mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
Merge branch 'lua_dispo' into 'master'
Add function to get current disposition, add baseDisposition to NPC record See merge request OpenMW/openmw!3370
This commit is contained in:
commit
03f1a30468
@ -4,6 +4,7 @@
|
||||
#include <components/lua/luastate.hpp>
|
||||
|
||||
#include <apps/openmw/mwbase/environment.hpp>
|
||||
#include <apps/openmw/mwbase/mechanicsmanager.hpp>
|
||||
#include <apps/openmw/mwbase/world.hpp>
|
||||
#include <apps/openmw/mwmechanics/npcstats.hpp>
|
||||
#include <apps/openmw/mwworld/class.hpp>
|
||||
@ -41,6 +42,8 @@ namespace MWLua
|
||||
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mScript.serializeText(); });
|
||||
record["hair"]
|
||||
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHair.serializeText(); });
|
||||
record["baseDisposition"]
|
||||
= sol::readonly_property([](const ESM::NPC& rec) -> int { return (int)rec.mNpdt.mDisposition; });
|
||||
record["head"]
|
||||
= sol::readonly_property([](const ESM::NPC& rec) -> std::string { return rec.mHead.serializeText(); });
|
||||
record["isMale"] = sol::readonly_property([](const ESM::NPC& rec) -> bool { return rec.isMale(); });
|
||||
@ -54,5 +57,14 @@ namespace MWLua
|
||||
else
|
||||
throw std::runtime_error("NPC or Player expected");
|
||||
};
|
||||
|
||||
npc["getDisposition"] = [](const Object& o, const Object& player) -> int {
|
||||
if (player.ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
throw std::runtime_error("The argument must be a player!");
|
||||
const MWWorld::Class& cls = o.ptr().getClass();
|
||||
if (!cls.isNpc())
|
||||
throw std::runtime_error("NPC expected");
|
||||
return MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(o.ptr());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -714,6 +714,13 @@
|
||||
-- @param openmw.core#GameObject object
|
||||
-- @return #boolean
|
||||
|
||||
---
|
||||
-- Returns the current disposition of the provided NPC. This is their derived disposition, after modifiers such as personality and faction relations are taken into account.
|
||||
-- @function [parent=#NPC] getDisposition
|
||||
-- @param openmw.core#GameObject object
|
||||
-- @param openmw.core#GameObject player The player that you want to check the disposition for.
|
||||
-- @return #number
|
||||
|
||||
---
|
||||
-- Whether the NPC or player is in the werewolf form at the moment.
|
||||
-- @function [parent=#NPC] isWerewolf
|
||||
@ -736,6 +743,7 @@
|
||||
-- @field #string hair Path to the hair body part model
|
||||
-- @field #string head Path to the head body part model
|
||||
-- @field #number baseGold The base barter gold of the NPC
|
||||
-- @field #number baseDisposition NPC's starting disposition
|
||||
-- @field #bool isMale The gender setting of the NPC
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user