mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 01:23:53 +00:00
Merge branch 'effect_indices' into 'master'
Preserve effect indices when applying AoE and targeted spells Closes #6957 See merge request OpenMW/openmw!2315 (cherry picked from commit5ed9764f3b
)a5476082
Preserve effect indices when applying AoE and targeted spells
This commit is contained in:
parent
b2d0b3da93
commit
19df671bba
2 changed files with 19 additions and 3 deletions
|
@ -539,6 +539,7 @@ namespace MWWorld
|
||||||
MWMechanics::projectileHit(caster, target, bow, projectileRef.getPtr(), pos, projectileState.mAttackStrength);
|
MWMechanics::projectileHit(caster, target, bow, projectileRef.getPtr(), pos, projectileState.mAttackStrength);
|
||||||
projectileState.mToDelete = true;
|
projectileState.mToDelete = true;
|
||||||
}
|
}
|
||||||
|
const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore();
|
||||||
for (auto& magicBoltState : mMagicBolts)
|
for (auto& magicBoltState : mMagicBolts)
|
||||||
{
|
{
|
||||||
if (magicBoltState.mToDelete)
|
if (magicBoltState.mToDelete)
|
||||||
|
@ -563,9 +564,14 @@ namespace MWWorld
|
||||||
cast.mId = magicBoltState.mSpellId;
|
cast.mId = magicBoltState.mSpellId;
|
||||||
cast.mSourceName = magicBoltState.mSourceName;
|
cast.mSourceName = magicBoltState.mSourceName;
|
||||||
cast.mSlot = magicBoltState.mSlot;
|
cast.mSlot = magicBoltState.mSlot;
|
||||||
cast.inflict(target, caster, magicBoltState.mEffects, ESM::RT_Target, true);
|
// Grab original effect list so the indices are correct
|
||||||
|
const ESM::EffectList* effects;
|
||||||
|
if (const ESM::Spell* spell = esmStore.get<ESM::Spell>().search(magicBoltState.mSpellId))
|
||||||
|
effects = &spell->mEffects;
|
||||||
|
else
|
||||||
|
effects = &esmStore.get<ESM::Enchantment>().find(magicBoltState.mSpellId)->mEffects;
|
||||||
|
cast.inflict(target, caster, *effects, ESM::RT_Target);
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->explodeSpell(pos, magicBoltState.mEffects, caster, target, ESM::RT_Target, magicBoltState.mSpellId, magicBoltState.mSourceName, false, magicBoltState.mSlot);
|
|
||||||
magicBoltState.mToDelete = true;
|
magicBoltState.mToDelete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3730,8 +3730,10 @@ namespace MWWorld
|
||||||
const std::string& id, const std::string& sourceName, const bool fromProjectile, int slot)
|
const std::string& id, const std::string& sourceName, const bool fromProjectile, int slot)
|
||||||
{
|
{
|
||||||
std::map<MWWorld::Ptr, std::vector<ESM::ENAMstruct> > toApply;
|
std::map<MWWorld::Ptr, std::vector<ESM::ENAMstruct> > toApply;
|
||||||
|
int index = -1;
|
||||||
for (const ESM::ENAMstruct& effectInfo : effects.mList)
|
for (const ESM::ENAMstruct& effectInfo : effects.mList)
|
||||||
{
|
{
|
||||||
|
++index;
|
||||||
const ESM::MagicEffect* effect = mStore.get<ESM::MagicEffect>().find(effectInfo.mEffectID);
|
const ESM::MagicEffect* effect = mStore.get<ESM::MagicEffect>().find(effectInfo.mEffectID);
|
||||||
|
|
||||||
if (effectInfo.mRange != rangeType || (effectInfo.mArea <= 0 && !ignore.isEmpty() && ignore.getClass().isActor()))
|
if (effectInfo.mRange != rangeType || (effectInfo.mArea <= 0 && !ignore.isEmpty() && ignore.getClass().isActor()))
|
||||||
|
@ -3786,7 +3788,15 @@ namespace MWWorld
|
||||||
if (affected.getClass().isActor() && !isActorCollisionEnabled(affected))
|
if (affected.getClass().isActor() && !isActorCollisionEnabled(affected))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
toApply[affected].push_back(effectInfo);
|
auto& list = toApply[affected];
|
||||||
|
while (list.size() < static_cast<std::size_t>(index))
|
||||||
|
{
|
||||||
|
// Insert dummy effects to preserve indices
|
||||||
|
auto& dummy = list.emplace_back(effectInfo);
|
||||||
|
dummy.mRange = ESM::RT_Self;
|
||||||
|
assert(dummy.mRange != rangeType);
|
||||||
|
}
|
||||||
|
list.push_back(effectInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue