diff --git a/apps/openmw-mp/Script/Functions/Mechanics.cpp b/apps/openmw-mp/Script/Functions/Mechanics.cpp index 8577666b2..c4349b990 100644 --- a/apps/openmw-mp/Script/Functions/Mechanics.cpp +++ b/apps/openmw-mp/Script/Functions/Mechanics.cpp @@ -129,6 +129,23 @@ const char *MechanicsFunctions::GetSelectedSpellId(unsigned short pid) noexcept return player->selectedSpellId.c_str(); } +unsigned int MechanicsFunctions::GetDrawState(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, false); + + return player->drawState; +} + +bool MechanicsFunctions::GetSneakState(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, false); + + // TODO: Avoid having to use a magic number here + return (player->movementFlags & 8) != 0; +} + void MechanicsFunctions::SetMarkCell(unsigned short pid, const char *cellDescription) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/Functions/Mechanics.hpp b/apps/openmw-mp/Script/Functions/Mechanics.hpp index d04f541f5..edc5d8133 100644 --- a/apps/openmw-mp/Script/Functions/Mechanics.hpp +++ b/apps/openmw-mp/Script/Functions/Mechanics.hpp @@ -21,6 +21,9 @@ {"GetPlayerKillerMpNum", MechanicsFunctions::GetPlayerKillerMpNum},\ {"GetPlayerKillerName", MechanicsFunctions::GetPlayerKillerName},\ \ + {"GetDrawState", MechanicsFunctions::GetDrawState},\ + {"GetSneakState", MechanicsFunctions::GetSneakState},\ + \ {"SetMarkCell", MechanicsFunctions::SetMarkCell},\ {"SetMarkPos", MechanicsFunctions::SetMarkPos},\ {"SetMarkRot", MechanicsFunctions::SetMarkRot},\ @@ -151,6 +154,23 @@ public: */ static const char *GetPlayerKillerName(unsigned short pid) noexcept; + /** + * \brief Get the draw state of a player (0 for nothing, 1 for drawn weapon, + * 2 for drawn spell). + * + * \param pid The player ID. + * \return The draw state. + */ + static unsigned int GetDrawState(unsigned short pid) noexcept; + + /** + * \brief Get the sneak state of a player. + * + * \param pid The player ID. + * \return Whether the player is sneaking. + */ + static bool GetSneakState(unsigned short pid) noexcept; + /** * \brief Set the Mark cell of a player. *