From 495207e2a57c59e1605751bc962780ec31e5efaf Mon Sep 17 00:00:00 2001 From: Telvanni 4Life Date: Wed, 17 Dec 2025 18:25:41 -0500 Subject: [PATCH] Triune Tests of Strength, Block, and Breathing Water. The ending of the words is ALMSIVI. --- apps/openmw/mwmechanics/spelleffects.cpp | 33 +++++++++++++----------- apps/openmw/mwmechanics/spellutil.cpp | 6 +++-- apps/openmw_tests/mwworld/teststore.cpp | 2 ++ components/esm3/creaturestats.cpp | 2 +- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwmechanics/spelleffects.cpp b/apps/openmw/mwmechanics/spelleffects.cpp index 0706e9961b..fa851e8511 100644 --- a/apps/openmw/mwmechanics/spelleffects.cpp +++ b/apps/openmw/mwmechanics/spelleffects.cpp @@ -391,19 +391,22 @@ namespace return MWMechanics::MagicApplicationResult::Type::APPLIED; } - static const std::map sBoundItemsMap{ - { ESM::MagicEffect::BoundBattleAxe, "sMagicBoundBattleAxeID" }, - { ESM::MagicEffect::BoundBoots, "sMagicBoundBootsID" }, - { ESM::MagicEffect::BoundCuirass, "sMagicBoundCuirassID" }, - { ESM::MagicEffect::BoundDagger, "sMagicBoundDaggerID" }, - { ESM::MagicEffect::BoundGloves, "sMagicBoundLeftGauntletID" }, - { ESM::MagicEffect::BoundHelm, "sMagicBoundHelmID" }, - { ESM::MagicEffect::BoundLongbow, "sMagicBoundLongbowID" }, - { ESM::MagicEffect::BoundLongsword, "sMagicBoundLongswordID" }, - { ESM::MagicEffect::BoundMace, "sMagicBoundMaceID" }, - { ESM::MagicEffect::BoundShield, "sMagicBoundShieldID" }, - { ESM::MagicEffect::BoundSpear, "sMagicBoundSpearID" }, - }; + const std::map& getBoundItemsMap() { + static const std::map sBoundItemsMap{ + { ESM::MagicEffect::BoundBattleAxe, "sMagicBoundBattleAxeID" }, + { ESM::MagicEffect::BoundBoots, "sMagicBoundBootsID" }, + { ESM::MagicEffect::BoundCuirass, "sMagicBoundCuirassID" }, + { ESM::MagicEffect::BoundDagger, "sMagicBoundDaggerID" }, + { ESM::MagicEffect::BoundGloves, "sMagicBoundLeftGauntletID" }, + { ESM::MagicEffect::BoundHelm, "sMagicBoundHelmID" }, + { ESM::MagicEffect::BoundLongbow, "sMagicBoundLongbowID" }, + { ESM::MagicEffect::BoundLongsword, "sMagicBoundLongswordID" }, + { ESM::MagicEffect::BoundMace, "sMagicBoundMaceID" }, + { ESM::MagicEffect::BoundShield, "sMagicBoundShieldID" }, + { ESM::MagicEffect::BoundSpear, "sMagicBoundSpearID" }, + }; + return sBoundItemsMap; + } using SpellsPurge = void (MWMechanics::Spells::*)(); void purgePermanent(const MWWorld::Ptr& target, SpellsPurge method, ESM::Spell::SpellType type) @@ -668,7 +671,7 @@ namespace MWMechanics { if (!target.getClass().hasInventoryStore(target)) return ESM::ActiveEffect::Flag_Invalid; - const std::string& item = sBoundItemsMap.at(effect.mEffectId); + const std::string& item = getBoundItemsMap().at(effect.mEffectId); const MWWorld::Store& gmst = world->getStore().get(); const ESM::RefId itemId = ESM::RefId::stringRefId(gmst.find(item)->mValue.getString()); if (!addBoundItem(itemId, target)) @@ -1278,7 +1281,7 @@ namespace MWMechanics effect.mEffectId == ESM::MagicEffect::BoundBoots || effect.mEffectId == ESM::MagicEffect::BoundShield) { - const std::string& item = sBoundItemsMap.at(effect.mEffectId); + const std::string& item = getBoundItemsMap().at(effect.mEffectId); removeBoundItem( ESM::RefId::stringRefId(world->getStore().get().find(item)->mValue.getString()), target); diff --git a/apps/openmw/mwmechanics/spellutil.cpp b/apps/openmw/mwmechanics/spellutil.cpp index 5ff67107a3..81985a80b0 100644 --- a/apps/openmw/mwmechanics/spellutil.cpp +++ b/apps/openmw/mwmechanics/spellutil.cpp @@ -172,11 +172,13 @@ namespace MWMechanics effect.mRange = ESM::RT_Self; effect.mArea = 0; - if (effect.mEffectID < 0) + if (effect.mEffectID.empty()) return std::nullopt; const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); - const auto magicEffect = store.get().find(effect.mEffectID); + const auto magicEffect = store.get().search(effect.mEffectID); + if (!magicEffect) + return std::nullopt; const MWMechanics::CreatureStats& creatureStats = caster.getClass().getCreatureStats(caster); float x = (caster.getClass().getSkill(caster, ESM::Skill::Alchemy) diff --git a/apps/openmw_tests/mwworld/teststore.cpp b/apps/openmw_tests/mwworld/teststore.cpp index 54ca941aaa..8c9d1060b3 100644 --- a/apps/openmw_tests/mwworld/teststore.cpp +++ b/apps/openmw_tests/mwworld/teststore.cpp @@ -447,6 +447,8 @@ namespace refId = ESM::Attribute::Strength; else if constexpr (std::is_same_v) refId = ESM::Skill::Block; + else if constexpr (std::is_same_v) + refId = ESM::MagicEffect::WaterBreathing; else refId = ESM::StringRefId(stringId); diff --git a/components/esm3/creaturestats.cpp b/components/esm3/creaturestats.cpp index c747a33a5f..7901efaf75 100644 --- a/components/esm3/creaturestats.cpp +++ b/components/esm3/creaturestats.cpp @@ -250,7 +250,7 @@ namespace ESM for (const auto& [effectId, actor] : mSummonedCreatures) { - esm.writeHNT("SUMM", effectId); + esm.writeHNT("SUMM", ESM::MagicEffect::refIdToIndex(effectId)); esm.writeFormId(actor, true, "ACID"); }