1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-06 00:40:04 +00:00

Add [get,set,mod]BaseDisposition functions to npc type

This commit is contained in:
Sebastian Fieber 2024-05-29 23:11:56 +02:00
parent 644c7dc135
commit f683adeb14
2 changed files with 49 additions and 0 deletions

View File

@ -107,6 +107,34 @@ namespace MWLua
return MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(o.ptr());
};
npc["getBaseDisposition"] = [](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 cls.getNpcStats(o.ptr()).getBaseDisposition();
};
npc["setBaseDisposition"] = [](const Object& o, const Object& player, int value) {
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");
cls.getNpcStats(o.ptr()).setBaseDisposition(value);
};
npc["modBaseDisposition"] = [](const Object& o, const Object& player, int value) {
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");
auto& stats = cls.getNpcStats(o.ptr());
stats.setBaseDisposition(stats.getBaseDisposition() + value);
};
npc["getFactionRank"] = [](const Object& actor, std::string_view faction) {
const MWWorld::Ptr ptr = actor.ptr();
ESM::RefId factionId = parseFactionId(faction);

View File

@ -1003,6 +1003,27 @@
-- @param openmw.core#GameObject player The player that you want to check the disposition for.
-- @return #number
---
-- Returns the current base disposition of the provided NPC. This is their base disposition, before modifiers such as personality and faction relations are taken into account.
-- @function [parent=#NPC] getBaseDisposition
-- @param openmw.core#GameObject object
-- @param openmw.core#GameObject player The player that you want to check the disposition for.
-- @return #number
---
-- Set the base disposition of the provided NPC.
-- @function [parent=#NPC] setBaseDisposition
-- @param openmw.core#GameObject object
-- @param openmw.core#GameObject player The player that you want to set the disposition for.
-- @param #number value BaseDisposition is set to this value
---
-- Modify the base disposition of the provided NPC by a certain amount.
-- @function [parent=#NPC] modBaseDisposition
-- @param openmw.core#GameObject object
-- @param openmw.core#GameObject player The player that you want to modify the disposition for.
-- @param #number value Base disposition modification value
---
-- Get the total weight that the actor can carry.
-- @function [parent=#NPC] getCapacity