forked from mirror/openmw-tes3mp
Move Water Walking check into checkEffectTarget()
This commit is contained in:
parent
f25c65260c
commit
22b11c5947
1 changed files with 15 additions and 18 deletions
|
@ -259,7 +259,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if the given affect can be applied to the target. If \a castByPlayer, emits a message box on failure.
|
/// Check if the given affect can be applied to the target. If \a castByPlayer, emits a message box on failure.
|
||||||
bool checkEffectTarget (int effectId, const MWWorld::Ptr& target, bool castByPlayer)
|
bool checkEffectTarget (int effectId, const MWWorld::Ptr& target, const MWWorld::Ptr& caster, bool castByPlayer)
|
||||||
{
|
{
|
||||||
switch (effectId)
|
switch (effectId)
|
||||||
{
|
{
|
||||||
|
@ -291,8 +291,20 @@ namespace MWMechanics
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case ESM::MagicEffect::WaterWalking:
|
||||||
|
if (target.getClass().isPureWaterCreature(target))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
|
if (!world->isWaterWalkingCastableOnTarget(target))
|
||||||
|
{
|
||||||
|
if (castByPlayer && caster == target)
|
||||||
|
MWBase::Environment::get().getWindowManager()->messageBox ("#{sMagicInvalidEffect}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,23 +395,8 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
canCastAnEffect = true;
|
canCastAnEffect = true;
|
||||||
|
|
||||||
if (magicEffect->mIndex == ESM::MagicEffect::WaterWalking)
|
|
||||||
{
|
|
||||||
if (target.getClass().isPureWaterCreature(target))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
if (!checkEffectTarget(effectIt->mEffectID, target, caster, castByPlayer))
|
||||||
|
|
||||||
if (!world->isWaterWalkingCastableOnTarget(target))
|
|
||||||
{
|
|
||||||
if (castByPlayer && caster == target)
|
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox ("#{sMagicInvalidEffect}");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!checkEffectTarget(effectIt->mEffectID, target, castByPlayer))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// caster needs to be an actor for linked effects (e.g. Absorb)
|
// caster needs to be an actor for linked effects (e.g. Absorb)
|
||||||
|
|
Loading…
Reference in a new issue