From ad3cd5e5fa66e5a3da1666c66f154f57be6b07dc Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 6 Jul 2021 12:57:17 +0200 Subject: [PATCH] [Server] Add GetSpellsActiveStackingState() script function --- apps/openmw-mp/Script/Functions/Spells.cpp | 11 +++++++++++ apps/openmw-mp/Script/Functions/Spells.hpp | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/apps/openmw-mp/Script/Functions/Spells.cpp b/apps/openmw-mp/Script/Functions/Spells.cpp index 64bf88704..5753582fa 100644 --- a/apps/openmw-mp/Script/Functions/Spells.cpp +++ b/apps/openmw-mp/Script/Functions/Spells.cpp @@ -148,6 +148,17 @@ const char* SpellFunctions::GetSpellsActiveDisplayName(unsigned short pid, unsig return player->spellsActiveChanges.activeSpells.at(index).params.mDisplayName.c_str(); } +bool SpellFunctions::GetSpellsActiveStackingState(unsigned short pid, unsigned int index) noexcept +{ + Player* player; + GET_PLAYER(pid, player, ""); + + if (index >= player->spellsActiveChanges.activeSpells.size()) + return "invalid"; + + return player->spellsActiveChanges.activeSpells.at(index).isStackingSpell; +} + unsigned int SpellFunctions::GetSpellsActiveEffectCount(unsigned short pid, unsigned int index) noexcept { Player* player; diff --git a/apps/openmw-mp/Script/Functions/Spells.hpp b/apps/openmw-mp/Script/Functions/Spells.hpp index 12207e4aa..6c655eb19 100644 --- a/apps/openmw-mp/Script/Functions/Spells.hpp +++ b/apps/openmw-mp/Script/Functions/Spells.hpp @@ -20,6 +20,7 @@ {"GetSpellId", SpellFunctions::GetSpellId},\ {"GetSpellsActiveId", SpellFunctions::GetSpellsActiveId},\ {"GetSpellsActiveDisplayName", SpellFunctions::GetSpellsActiveDisplayName},\ + {"GetSpellsActiveStackingState", SpellFunctions::GetSpellsActiveStackingState},\ {"GetSpellsActiveEffectCount", SpellFunctions::GetSpellsActiveEffectCount},\ {"GetSpellsActiveEffectId", SpellFunctions::GetSpellsActiveEffectId},\ {"GetSpellsActiveEffectArg", SpellFunctions::GetSpellsActiveEffectArg},\ @@ -167,6 +168,15 @@ public: */ static const char* GetSpellsActiveDisplayName(unsigned short pid, unsigned int index) noexcept; + /** + * \brief Get the spell stacking state at a certain index in a player's latest spells active changes. + * + * \param pid The player ID whose spells active changes should be used. + * \param index The index of the spell. + * \return The spell stacking state. + */ + static bool GetSpellsActiveStackingState(unsigned short pid, unsigned int index) noexcept; + /** * \brief Get the number of effects at an index in a player's latest spells active changes. *