mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-30 14:41:23 +00:00
Remove redundant params
This commit is contained in:
parent
4eafe3696c
commit
8d66b2e75d
3 changed files with 26 additions and 34 deletions
|
@ -39,7 +39,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CastSpell::explodeSpell(const ESM::EffectList& effects, const MWWorld::Ptr& caster, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const
|
void CastSpell::explodeSpell(const ESM::EffectList& effects, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const
|
||||||
{
|
{
|
||||||
const auto world = MWBase::Environment::get().getWorld();
|
const auto world = MWBase::Environment::get().getWorld();
|
||||||
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
@ -57,7 +57,7 @@ namespace MWMechanics
|
||||||
continue; // Don't play explosion for projectiles with 0-area effects
|
continue; // Don't play explosion for projectiles with 0-area effects
|
||||||
|
|
||||||
if (!mFromProjectile && effectInfo.mRange == ESM::RT_Touch && !ignore.isEmpty() && !ignore.getClass().isActor() && !ignore.getClass().hasToolTip(ignore)
|
if (!mFromProjectile && effectInfo.mRange == ESM::RT_Touch && !ignore.isEmpty() && !ignore.getClass().isActor() && !ignore.getClass().hasToolTip(ignore)
|
||||||
&& (caster.isEmpty() || caster.getClass().isActor()))
|
&& (mCaster.isEmpty() || mCaster.getClass().isActor()))
|
||||||
continue; // Don't play explosion for touch spells on non-activatable objects except when spell is from a projectile enchantment or ExplodeSpell
|
continue; // Don't play explosion for touch spells on non-activatable objects except when spell is from a projectile enchantment or ExplodeSpell
|
||||||
|
|
||||||
// Spawn the explosion orb effect
|
// Spawn the explosion orb effect
|
||||||
|
@ -114,26 +114,22 @@ namespace MWMechanics
|
||||||
// Now apply the appropriate effects to each actor in range
|
// Now apply the appropriate effects to each actor in range
|
||||||
for (auto& applyPair : toApply)
|
for (auto& applyPair : toApply)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr source = caster;
|
|
||||||
// Vanilla-compatible behaviour of never applying the spell to the caster
|
// Vanilla-compatible behaviour of never applying the spell to the caster
|
||||||
// (could be changed by mods later)
|
// (could be changed by mods later)
|
||||||
if (applyPair.first == caster)
|
if (applyPair.first == mCaster)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (applyPair.first == ignore)
|
if (applyPair.first == ignore)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (source.isEmpty())
|
MWMechanics::CastSpell cast(mCaster, applyPair.first);
|
||||||
source = applyPair.first;
|
|
||||||
|
|
||||||
MWMechanics::CastSpell cast(source, applyPair.first);
|
|
||||||
cast.mHitPosition = mHitPosition;
|
cast.mHitPosition = mHitPosition;
|
||||||
cast.mId = mId;
|
cast.mId = mId;
|
||||||
cast.mSourceName = mSourceName;
|
cast.mSourceName = mSourceName;
|
||||||
cast.mSlot = mSlot;
|
cast.mSlot = mSlot;
|
||||||
ESM::EffectList effectsToApply;
|
ESM::EffectList effectsToApply;
|
||||||
effectsToApply.mList = applyPair.second;
|
effectsToApply.mList = applyPair.second;
|
||||||
cast.inflict(applyPair.first, caster, effectsToApply, rangeType, true);
|
cast.inflict(applyPair.first, effectsToApply, rangeType, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +150,7 @@ namespace MWMechanics
|
||||||
MWBase::Environment::get().getWorld()->launchMagicBolt(mId, mCaster, fallbackDirection, mSlot);
|
MWBase::Environment::get().getWorld()->launchMagicBolt(mId, mCaster, fallbackDirection, mSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CastSpell::inflict(const MWWorld::Ptr &target, const MWWorld::Ptr &caster,
|
void CastSpell::inflict(const MWWorld::Ptr& target, const ESM::EffectList& effects, ESM::RangeType range, bool exploded)
|
||||||
const ESM::EffectList &effects, ESM::RangeType range, bool exploded)
|
|
||||||
{
|
{
|
||||||
const bool targetIsActor = !target.isEmpty() && target.getClass().isActor();
|
const bool targetIsActor = !target.isEmpty() && target.getClass().isActor();
|
||||||
if (targetIsActor)
|
if (targetIsActor)
|
||||||
|
@ -197,9 +192,9 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveSpells::ActiveSpellParams params(*this, caster);
|
ActiveSpells::ActiveSpellParams params(*this, mCaster);
|
||||||
|
|
||||||
bool castByPlayer = (!caster.isEmpty() && caster == getPlayer());
|
bool castByPlayer = (!mCaster.isEmpty() && mCaster == getPlayer());
|
||||||
|
|
||||||
const ActiveSpells* targetSpells = nullptr;
|
const ActiveSpells* targetSpells = nullptr;
|
||||||
if (targetIsActor)
|
if (targetIsActor)
|
||||||
|
@ -230,8 +225,7 @@ namespace MWMechanics
|
||||||
canCastAnEffect = true;
|
canCastAnEffect = true;
|
||||||
|
|
||||||
// caster needs to be an actor for linked effects (e.g. Absorb)
|
// caster needs to be an actor for linked effects (e.g. Absorb)
|
||||||
if (magicEffect->mData.mFlags & ESM::MagicEffect::CasterLinked
|
if (magicEffect->mData.mFlags & ESM::MagicEffect::CasterLinked && (mCaster.isEmpty() || !mCaster.getClass().isActor()))
|
||||||
&& (caster.isEmpty() || !caster.getClass().isActor()))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ActiveSpells::ActiveEffect effect;
|
ActiveSpells::ActiveEffect effect;
|
||||||
|
@ -259,7 +253,7 @@ namespace MWMechanics
|
||||||
params.getEffects().emplace_back(effect);
|
params.getEffects().emplace_back(effect);
|
||||||
|
|
||||||
bool effectAffectsHealth = magicEffect->mData.mFlags & ESM::MagicEffect::Harmful || effectIt->mEffectID == ESM::MagicEffect::RestoreHealth;
|
bool effectAffectsHealth = magicEffect->mData.mFlags & ESM::MagicEffect::Harmful || effectIt->mEffectID == ESM::MagicEffect::RestoreHealth;
|
||||||
if (castByPlayer && target != caster && targetIsActor && effectAffectsHealth)
|
if (castByPlayer && target != mCaster && targetIsActor && effectAffectsHealth)
|
||||||
{
|
{
|
||||||
// If player is attempting to cast a harmful spell on or is healing a living target, show the target's HP bar.
|
// If player is attempting to cast a harmful spell on or is healing a living target, show the target's HP bar.
|
||||||
MWBase::Environment::get().getWindowManager()->setEnemy(target);
|
MWBase::Environment::get().getWindowManager()->setEnemy(target);
|
||||||
|
@ -272,7 +266,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exploded)
|
if (!exploded)
|
||||||
explodeSpell(effects, caster, target, range);
|
explodeSpell(effects, target, range);
|
||||||
|
|
||||||
if (!target.isEmpty())
|
if (!target.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -285,7 +279,7 @@ namespace MWMechanics
|
||||||
// Apply effects instantly. We can ignore effect deletion since the entire params object gets deleted afterwards anyway
|
// Apply effects instantly. We can ignore effect deletion since the entire params object gets deleted afterwards anyway
|
||||||
// and we can ignore reflection since non-actors cannot reflect spells
|
// and we can ignore reflection since non-actors cannot reflect spells
|
||||||
for(auto& effect : params.getEffects())
|
for(auto& effect : params.getEffects())
|
||||||
applyMagicEffect(target, caster, params, effect, 0.f);
|
applyMagicEffect(target, mCaster, params, effect, 0.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -381,17 +375,17 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isProjectile)
|
if (isProjectile)
|
||||||
inflict(mTarget, mCaster, enchantment->mEffects, ESM::RT_Self);
|
inflict(mTarget, enchantment->mEffects, ESM::RT_Self);
|
||||||
else
|
else
|
||||||
inflict(mCaster, mCaster, enchantment->mEffects, ESM::RT_Self);
|
inflict(mCaster, enchantment->mEffects, ESM::RT_Self);
|
||||||
|
|
||||||
if (isProjectile || !mTarget.isEmpty())
|
if (isProjectile || !mTarget.isEmpty())
|
||||||
inflict(mTarget, mCaster, enchantment->mEffects, ESM::RT_Touch);
|
inflict(mTarget, enchantment->mEffects, ESM::RT_Touch);
|
||||||
|
|
||||||
if (launchProjectile)
|
if (launchProjectile)
|
||||||
launchMagicBolt();
|
launchMagicBolt();
|
||||||
else if (isProjectile || !mTarget.isEmpty())
|
else if (isProjectile || !mTarget.isEmpty())
|
||||||
inflict(mTarget, mCaster, enchantment->mEffects, ESM::RT_Target);
|
inflict(mTarget, enchantment->mEffects, ESM::RT_Target);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +396,7 @@ namespace MWMechanics
|
||||||
mId = potion->mId;
|
mId = potion->mId;
|
||||||
mType = ESM::ActiveSpells::Type_Consumable;
|
mType = ESM::ActiveSpells::Type_Consumable;
|
||||||
|
|
||||||
inflict(mCaster, mCaster, potion->mEffects, ESM::RT_Self);
|
inflict(mCaster, potion->mEffects, ESM::RT_Self);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -461,10 +455,10 @@ namespace MWMechanics
|
||||||
if (!mCaster.getClass().isActor())
|
if (!mCaster.getClass().isActor())
|
||||||
playSpellCastingEffects(spell->mEffects.mList);
|
playSpellCastingEffects(spell->mEffects.mList);
|
||||||
|
|
||||||
inflict(mCaster, mCaster, spell->mEffects, ESM::RT_Self);
|
inflict(mCaster, spell->mEffects, ESM::RT_Self);
|
||||||
|
|
||||||
if (!mTarget.isEmpty())
|
if (!mTarget.isEmpty())
|
||||||
inflict(mTarget, mCaster, spell->mEffects, ESM::RT_Touch);
|
inflict(mTarget, spell->mEffects, ESM::RT_Touch);
|
||||||
|
|
||||||
launchMagicBolt();
|
launchMagicBolt();
|
||||||
|
|
||||||
|
@ -528,7 +522,7 @@ namespace MWMechanics
|
||||||
ESM::EffectList effects;
|
ESM::EffectList effects;
|
||||||
effects.mList.push_back(effect);
|
effects.mList.push_back(effect);
|
||||||
|
|
||||||
inflict(mCaster, mCaster, effects, ESM::RT_Self);
|
inflict(mCaster, effects, ESM::RT_Self);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@ namespace MWMechanics
|
||||||
|
|
||||||
void playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& effects);
|
void playSpellCastingEffects(const std::vector<ESM::ENAMstruct>& effects);
|
||||||
|
|
||||||
void explodeSpell(const ESM::EffectList& effects, const MWWorld::Ptr& caster, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const;
|
void explodeSpell(const ESM::EffectList& effects, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const;
|
||||||
|
|
||||||
|
/// Launch a bolt with the given effects.
|
||||||
|
void launchMagicBolt();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string mId; // ID of spell, potion, item etc
|
std::string mId; // ID of spell, potion, item etc
|
||||||
|
@ -57,13 +60,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
void playSpellCastingEffects(std::string_view spellid, bool enchantment);
|
void playSpellCastingEffects(std::string_view spellid, bool enchantment);
|
||||||
|
|
||||||
/// Launch a bolt with the given effects.
|
|
||||||
void launchMagicBolt ();
|
|
||||||
|
|
||||||
/// @note \a target can be any type of object, not just actors.
|
/// @note \a target can be any type of object, not just actors.
|
||||||
/// @note \a caster can be any type of object, or even an empty object.
|
void inflict(const MWWorld::Ptr& target, const ESM::EffectList& effects, ESM::RangeType range, bool exploded = false);
|
||||||
void inflict (const MWWorld::Ptr& target, const MWWorld::Ptr& caster,
|
|
||||||
const ESM::EffectList& effects, ESM::RangeType range, bool exploded=false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void playEffects(const MWWorld::Ptr& target, const ESM::MagicEffect& magicEffect, bool playNonLooping = true);
|
void playEffects(const MWWorld::Ptr& target, const ESM::MagicEffect& magicEffect, bool playNonLooping = true);
|
||||||
|
|
|
@ -575,7 +575,7 @@ namespace MWWorld
|
||||||
const MWWorld::Ptr& ptr = ref.getPtr();
|
const MWWorld::Ptr& ptr = ref.getPtr();
|
||||||
effects = &esmStore.get<ESM::Enchantment>().find(ptr.getClass().getEnchantment(ptr))->mEffects;
|
effects = &esmStore.get<ESM::Enchantment>().find(ptr.getClass().getEnchantment(ptr))->mEffects;
|
||||||
}
|
}
|
||||||
cast.inflict(target, caster, *effects, ESM::RT_Target);
|
cast.inflict(target, *effects, ESM::RT_Target);
|
||||||
|
|
||||||
magicBoltState.mToDelete = true;
|
magicBoltState.mToDelete = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue