mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Don't play magic effect sounds & visual effects for unsuitable targets (Fixes #2811)
This commit is contained in:
parent
211deeb63e
commit
1e18a73b1c
3 changed files with 31 additions and 19 deletions
|
@ -489,8 +489,8 @@ namespace MWMechanics
|
||||||
if (!wasDead && isDead)
|
if (!wasDead && isDead)
|
||||||
MWBase::Environment::get().getMechanicsManager()->actorKilled(target, caster);
|
MWBase::Environment::get().getMechanicsManager()->actorKilled(target, caster);
|
||||||
}
|
}
|
||||||
else
|
else if (!applyInstantEffect(target, caster, EffectKey(*effectIt), magnitude))
|
||||||
applyInstantEffect(target, caster, EffectKey(*effectIt), magnitude);
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-casting a summon effect will remove the creature from previous castings of that effect.
|
// Re-casting a summon effect will remove the creature from previous castings of that effect.
|
||||||
|
@ -559,7 +559,7 @@ namespace MWMechanics
|
||||||
target.getClass().onHit(target, 0.f, true, MWWorld::Ptr(), caster, true);
|
target.getClass().onHit(target, 0.f, true, MWWorld::Ptr(), caster, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CastSpell::applyInstantEffect(const MWWorld::Ptr &target, const MWWorld::Ptr &caster, const MWMechanics::EffectKey& effect, float magnitude)
|
bool CastSpell::applyInstantEffect(const MWWorld::Ptr &target, const MWWorld::Ptr &caster, const MWMechanics::EffectKey& effect, float magnitude)
|
||||||
{
|
{
|
||||||
short effectId = effect.mId;
|
short effectId = effect.mId;
|
||||||
if (target.getClass().canLock(target))
|
if (target.getClass().canLock(target))
|
||||||
|
@ -572,6 +572,7 @@ namespace MWMechanics
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicLockSuccess}");
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicLockSuccess}");
|
||||||
target.getClass().lock(target, static_cast<int>(magnitude));
|
target.getClass().lock(target, static_cast<int>(magnitude));
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (effectId == ESM::MagicEffect::Open)
|
else if (effectId == ESM::MagicEffect::Open)
|
||||||
{
|
{
|
||||||
|
@ -590,43 +591,55 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);
|
MWBase::Environment::get().getSoundManager()->playSound3D(target, "Open Lock Fail", 1.f, 1.f);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (target.getClass().isActor())
|
||||||
{
|
{
|
||||||
if (effectId == ESM::MagicEffect::CurePoison)
|
switch (effectId)
|
||||||
|
{
|
||||||
|
case ESM::MagicEffect::CurePoison:
|
||||||
target.getClass().getCreatureStats(target).getActiveSpells().purgeEffect(ESM::MagicEffect::Poison);
|
target.getClass().getCreatureStats(target).getActiveSpells().purgeEffect(ESM::MagicEffect::Poison);
|
||||||
else if (effectId == ESM::MagicEffect::CureParalyzation)
|
return true;
|
||||||
|
case ESM::MagicEffect::CureParalyzation:
|
||||||
target.getClass().getCreatureStats(target).getActiveSpells().purgeEffect(ESM::MagicEffect::Paralyze);
|
target.getClass().getCreatureStats(target).getActiveSpells().purgeEffect(ESM::MagicEffect::Paralyze);
|
||||||
else if (effectId == ESM::MagicEffect::CureCommonDisease)
|
return true;
|
||||||
|
case ESM::MagicEffect::CureCommonDisease:
|
||||||
target.getClass().getCreatureStats(target).getSpells().purgeCommonDisease();
|
target.getClass().getCreatureStats(target).getSpells().purgeCommonDisease();
|
||||||
else if (effectId == ESM::MagicEffect::CureBlightDisease)
|
return true;
|
||||||
|
case ESM::MagicEffect::CureBlightDisease:
|
||||||
target.getClass().getCreatureStats(target).getSpells().purgeBlightDisease();
|
target.getClass().getCreatureStats(target).getSpells().purgeBlightDisease();
|
||||||
else if (effectId == ESM::MagicEffect::CureCorprusDisease)
|
return true;
|
||||||
|
case ESM::MagicEffect::CureCorprusDisease:
|
||||||
target.getClass().getCreatureStats(target).getSpells().purgeCorprusDisease();
|
target.getClass().getCreatureStats(target).getSpells().purgeCorprusDisease();
|
||||||
else if (effectId == ESM::MagicEffect::Dispel)
|
return true;
|
||||||
|
case ESM::MagicEffect::Dispel:
|
||||||
target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(magnitude);
|
target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(magnitude);
|
||||||
else if (effectId == ESM::MagicEffect::RemoveCurse)
|
return true;
|
||||||
|
case ESM::MagicEffect::RemoveCurse:
|
||||||
target.getClass().getCreatureStats(target).getSpells().purgeCurses();
|
target.getClass().getCreatureStats(target).getSpells().purgeCurses();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (target != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if (target != MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
return;
|
return false;
|
||||||
if (!MWBase::Environment::get().getWorld()->isTeleportingEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (effectId == ESM::MagicEffect::DivineIntervention)
|
if (effectId == ESM::MagicEffect::DivineIntervention)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->teleportToClosestMarker(target, "divinemarker");
|
MWBase::Environment::get().getWorld()->teleportToClosestMarker(target, "divinemarker");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (effectId == ESM::MagicEffect::AlmsiviIntervention)
|
else if (effectId == ESM::MagicEffect::AlmsiviIntervention)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->teleportToClosestMarker(target, "templemarker");
|
MWBase::Environment::get().getWorld()->teleportToClosestMarker(target, "templemarker");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (effectId == ESM::MagicEffect::Mark)
|
else if (effectId == ESM::MagicEffect::Mark)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().markPosition(
|
MWBase::Environment::get().getWorld()->getPlayer().markPosition(
|
||||||
target.getCell(), target.getRefData().getPosition());
|
target.getCell(), target.getRefData().getPosition());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (effectId == ESM::MagicEffect::Recall)
|
else if (effectId == ESM::MagicEffect::Recall)
|
||||||
{
|
{
|
||||||
|
@ -640,8 +653,10 @@ namespace MWMechanics
|
||||||
markedPosition, false);
|
markedPosition, false);
|
||||||
action.execute(target);
|
action.execute(target);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,8 @@ namespace MWMechanics
|
||||||
const ESM::EffectList& effects, ESM::RangeType range, bool reflected=false, bool exploded=false);
|
const ESM::EffectList& effects, ESM::RangeType range, bool reflected=false, bool exploded=false);
|
||||||
|
|
||||||
/// @note \a caster can be any type of object, or even an empty object.
|
/// @note \a caster can be any type of object, or even an empty object.
|
||||||
void applyInstantEffect (const MWWorld::Ptr& target, const MWWorld::Ptr& caster, const MWMechanics::EffectKey& effect, float magnitude);
|
/// @return was the target suitable for the effect?
|
||||||
|
bool applyInstantEffect (const MWWorld::Ptr& target, const MWWorld::Ptr& caster, const MWMechanics::EffectKey& effect, float magnitude);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2656,10 +2656,6 @@ namespace MWWorld
|
||||||
target = result.mHitObject;
|
target = result.mHitObject;
|
||||||
hitPosition = result.mHitPos;
|
hitPosition = result.mHitPos;
|
||||||
|
|
||||||
// don't allow casting on non-activatable objects
|
|
||||||
if (!target.isEmpty() && !target.getClass().isActor() && target.getClass().getName(target).empty())
|
|
||||||
target = MWWorld::Ptr();
|
|
||||||
|
|
||||||
std::string selectedSpell = stats.getSpells().getSelectedSpell();
|
std::string selectedSpell = stats.getSpells().getSelectedSpell();
|
||||||
|
|
||||||
MWMechanics::CastSpell cast(actor, target);
|
MWMechanics::CastSpell cast(actor, target);
|
||||||
|
|
Loading…
Reference in a new issue