mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-24 18:39:59 +00:00
Merge branch 'tastytastyenchantments' into 'master'
Use the correct id to absorb enchantments Closes #7796 See merge request OpenMW/openmw!3813
This commit is contained in:
commit
df6e104e6f
@ -133,6 +133,7 @@
|
|||||||
Bug #7765: OpenMW-CS: Touch Record option is broken
|
Bug #7765: OpenMW-CS: Touch Record option is broken
|
||||||
Bug #7770: Sword of the Perithia: Script execution failure
|
Bug #7770: Sword of the Perithia: Script execution failure
|
||||||
Bug #7780: Non-ASCII texture paths in NIF files don't work
|
Bug #7780: Non-ASCII texture paths in NIF files don't work
|
||||||
|
Bug #7796: Absorbed enchantments don't restore magicka
|
||||||
Feature #2566: Handle NAM9 records for manual cell references
|
Feature #2566: Handle NAM9 records for manual cell references
|
||||||
Feature #3537: Shader-based water ripples
|
Feature #3537: Shader-based water ripples
|
||||||
Feature #5173: Support for NiFogProperty
|
Feature #5173: Support for NiFogProperty
|
||||||
|
@ -174,6 +174,25 @@ namespace MWMechanics
|
|||||||
mWorsenings = -1;
|
mWorsenings = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESM::RefId ActiveSpells::ActiveSpellParams::getEnchantment() const
|
||||||
|
{
|
||||||
|
// Enchantment id is not stored directly. Instead the enchanted item is stored.
|
||||||
|
const auto& store = MWBase::Environment::get().getESMStore();
|
||||||
|
switch (store->find(mId))
|
||||||
|
{
|
||||||
|
case ESM::REC_ARMO:
|
||||||
|
return store->get<ESM::Armor>().find(mId)->mEnchant;
|
||||||
|
case ESM::REC_BOOK:
|
||||||
|
return store->get<ESM::Book>().find(mId)->mEnchant;
|
||||||
|
case ESM::REC_CLOT:
|
||||||
|
return store->get<ESM::Clothing>().find(mId)->mEnchant;
|
||||||
|
case ESM::REC_WEAP:
|
||||||
|
return store->get<ESM::Weapon>().find(mId)->mEnchant;
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ActiveSpells::update(const MWWorld::Ptr& ptr, float duration)
|
void ActiveSpells::update(const MWWorld::Ptr& ptr, float duration)
|
||||||
{
|
{
|
||||||
if (mIterating)
|
if (mIterating)
|
||||||
@ -438,21 +457,8 @@ namespace MWMechanics
|
|||||||
if (store->get<ESM::Enchantment>().search(id) == nullptr)
|
if (store->get<ESM::Enchantment>().search(id) == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Enchantment id is not stored directly. Instead the enchanted item is stored.
|
|
||||||
return std::find_if(mSpells.begin(), mSpells.end(), [&](const auto& spell) {
|
return std::find_if(mSpells.begin(), mSpells.end(), [&](const auto& spell) {
|
||||||
switch (store->find(spell.mId))
|
return spell.getEnchantment() == id;
|
||||||
{
|
|
||||||
case ESM::REC_ARMO:
|
|
||||||
return store->get<ESM::Armor>().find(spell.mId)->mEnchant == id;
|
|
||||||
case ESM::REC_BOOK:
|
|
||||||
return store->get<ESM::Book>().find(spell.mId)->mEnchant == id;
|
|
||||||
case ESM::REC_CLOT:
|
|
||||||
return store->get<ESM::Clothing>().find(spell.mId)->mEnchant == id;
|
|
||||||
case ESM::REC_WEAP:
|
|
||||||
return store->get<ESM::Weapon>().find(spell.mId)->mEnchant == id;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}) != mSpells.end();
|
}) != mSpells.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ namespace MWMechanics
|
|||||||
const std::string& getDisplayName() const { return mDisplayName; }
|
const std::string& getDisplayName() const { return mDisplayName; }
|
||||||
|
|
||||||
ESM::RefNum getItem() const { return mItem; }
|
ESM::RefNum getItem() const { return mItem; }
|
||||||
|
ESM::RefId getEnchantment() const;
|
||||||
|
|
||||||
// Increments worsenings count and sets the next timestamp
|
// Increments worsenings count and sets the next timestamp
|
||||||
void worsen();
|
void worsen();
|
||||||
|
@ -279,7 +279,8 @@ namespace
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void absorbSpell(const ESM::RefId& spellId, const MWWorld::Ptr& caster, const MWWorld::Ptr& target)
|
void absorbSpell(const MWMechanics::ActiveSpells::ActiveSpellParams& spellParams, const MWWorld::Ptr& caster,
|
||||||
|
const MWWorld::Ptr& target)
|
||||||
{
|
{
|
||||||
const auto& esmStore = *MWBase::Environment::get().getESMStore();
|
const auto& esmStore = *MWBase::Environment::get().getESMStore();
|
||||||
const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Absorb"));
|
const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Absorb"));
|
||||||
@ -287,15 +288,14 @@ namespace
|
|||||||
if (animation && !absorbStatic->mModel.empty())
|
if (animation && !absorbStatic->mModel.empty())
|
||||||
animation->addEffect(Misc::ResourceHelpers::correctMeshPath(absorbStatic->mModel),
|
animation->addEffect(Misc::ResourceHelpers::correctMeshPath(absorbStatic->mModel),
|
||||||
ESM::MagicEffect::indexToName(ESM::MagicEffect::SpellAbsorption), false);
|
ESM::MagicEffect::indexToName(ESM::MagicEffect::SpellAbsorption), false);
|
||||||
const ESM::Spell* spell = esmStore.get<ESM::Spell>().search(spellId);
|
|
||||||
int spellCost = 0;
|
int spellCost = 0;
|
||||||
if (spell)
|
if (const ESM::Spell* spell = esmStore.get<ESM::Spell>().search(spellParams.getId()))
|
||||||
{
|
{
|
||||||
spellCost = MWMechanics::calcSpellCost(*spell);
|
spellCost = MWMechanics::calcSpellCost(*spell);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const ESM::Enchantment* enchantment = esmStore.get<ESM::Enchantment>().search(spellId);
|
const ESM::Enchantment* enchantment = esmStore.get<ESM::Enchantment>().search(spellParams.getEnchantment());
|
||||||
if (enchantment)
|
if (enchantment)
|
||||||
spellCost = MWMechanics::getEffectiveEnchantmentCastCost(*enchantment, caster);
|
spellCost = MWMechanics::getEffectiveEnchantmentCastCost(*enchantment, caster);
|
||||||
}
|
}
|
||||||
@ -342,7 +342,7 @@ namespace
|
|||||||
{
|
{
|
||||||
if (canAbsorb && Misc::Rng::roll0to99(prng) < activeEffect.mMagnitude)
|
if (canAbsorb && Misc::Rng::roll0to99(prng) < activeEffect.mMagnitude)
|
||||||
{
|
{
|
||||||
absorbSpell(spellParams.getId(), caster, target);
|
absorbSpell(spellParams, caster, target);
|
||||||
return MWMechanics::MagicApplicationResult::Type::REMOVED;
|
return MWMechanics::MagicApplicationResult::Type::REMOVED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user