mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-06 17:11:25 +00:00
Move werewolf silver damage mult applying into a new function
This commit is contained in:
parent
808b8ce8db
commit
64d5cd17d6
5 changed files with 25 additions and 12 deletions
|
@ -308,6 +308,7 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
damage = attack[0] + ((attack[1]-attack[0])*attackStrength);
|
damage = attack[0] + ((attack[1]-attack[0])*attackStrength);
|
||||||
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
|
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
|
||||||
|
MWMechanics::applyWerewolfDamageMult(victim, weapon, damage);
|
||||||
MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
|
MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
|
||||||
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
|
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -621,6 +621,7 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
|
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
|
||||||
resisted = MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
|
resisted = MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
|
||||||
|
MWMechanics::applyWerewolfDamageMult(victim, weapon, damage);
|
||||||
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
|
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
|
||||||
healthdmg = true;
|
healthdmg = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,25 +163,30 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool resistNormalWeapon(const MWWorld::Ptr &actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr &weapon, float &damage)
|
bool resistNormalWeapon(const MWWorld::Ptr &actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr &weapon, float &damage)
|
||||||
{
|
{
|
||||||
if (damage == 0)
|
if (damage == 0 || weapon.isEmpty() || !isNormalWeapon(weapon))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (isNormalWeapon(weapon))
|
|
||||||
{
|
|
||||||
const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects();
|
const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects();
|
||||||
const float resistance = effects.get(ESM::MagicEffect::ResistNormalWeapons).getMagnitude() / 100.f;
|
const float resistance = effects.get(ESM::MagicEffect::ResistNormalWeapons).getMagnitude() / 100.f;
|
||||||
const float weakness = effects.get(ESM::MagicEffect::WeaknessToNormalWeapons).getMagnitude() / 100.f;
|
const float weakness = effects.get(ESM::MagicEffect::WeaknessToNormalWeapons).getMagnitude() / 100.f;
|
||||||
|
|
||||||
damage *= 1.f - std::min(1.f, resistance-weakness);
|
damage *= 1.f - std::min(1.f, resistance-weakness);
|
||||||
}
|
|
||||||
|
|
||||||
if ((weapon.get<ESM::Weapon>()->mBase->mData.mFlags & ESM::Weapon::Silver)
|
|
||||||
&& actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
|
||||||
damage *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->mValue.getFloat();
|
|
||||||
|
|
||||||
return (damage == 0);
|
return (damage == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void applyWerewolfDamageMult(const MWWorld::Ptr &actor, const MWWorld::Ptr &weapon, float &damage)
|
||||||
|
{
|
||||||
|
if (damage == 0 || weapon.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const int &flags = weapon.get<ESM::Weapon>()->mBase->mData.mFlags;
|
||||||
|
bool isSilver = flags & ESM::Weapon::Silver;
|
||||||
|
|
||||||
|
if (isSilver && actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
||||||
|
damage *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->mValue.getFloat();
|
||||||
|
}
|
||||||
|
|
||||||
void projectileHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, MWWorld::Ptr weapon, const MWWorld::Ptr& projectile,
|
void projectileHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, MWWorld::Ptr weapon, const MWWorld::Ptr& projectile,
|
||||||
const osg::Vec3f& hitPosition, float attackStrength)
|
const osg::Vec3f& hitPosition, float attackStrength)
|
||||||
{
|
{
|
||||||
|
@ -219,6 +224,7 @@ namespace MWMechanics
|
||||||
|
|
||||||
adjustWeaponDamage(damage, weapon, attacker);
|
adjustWeaponDamage(damage, weapon, attacker);
|
||||||
bool resisted = resistNormalWeapon(victim, attacker, projectile, damage);
|
bool resisted = resistNormalWeapon(victim, attacker, projectile, damage);
|
||||||
|
applyWerewolfDamageMult(victim, projectile, damage);
|
||||||
|
|
||||||
if (attacker == getPlayer())
|
if (attacker == getPlayer())
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,8 @@ bool isNormalWeapon (const MWWorld::Ptr& weapon);
|
||||||
/// @return was the damage fully resisted?
|
/// @return was the damage fully resisted?
|
||||||
bool resistNormalWeapon (const MWWorld::Ptr& actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr& weapon, float& damage);
|
bool resistNormalWeapon (const MWWorld::Ptr& actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr& weapon, float& damage);
|
||||||
|
|
||||||
|
void applyWerewolfDamageMult (const MWWorld::Ptr& actor, const MWWorld::Ptr& weapon, float &damage);
|
||||||
|
|
||||||
/// @note for a thrown weapon, \a weapon == \a projectile, for bows/crossbows, \a projectile is the arrow/bolt
|
/// @note for a thrown weapon, \a weapon == \a projectile, for bows/crossbows, \a projectile is the arrow/bolt
|
||||||
/// @note \a victim may be empty (e.g. for a hit on terrain), a non-actor (environment objects) or an actor
|
/// @note \a victim may be empty (e.g. for a hit on terrain), a non-actor (environment objects) or an actor
|
||||||
void projectileHit (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, MWWorld::Ptr weapon, const MWWorld::Ptr& projectile,
|
void projectileHit (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, MWWorld::Ptr weapon, const MWWorld::Ptr& projectile,
|
||||||
|
|
|
@ -78,7 +78,10 @@ namespace MWMechanics
|
||||||
adjustWeaponDamage(rating, item, actor);
|
adjustWeaponDamage(rating, item, actor);
|
||||||
|
|
||||||
if (weapon->mData.mType != ESM::Weapon::MarksmanBow && weapon->mData.mType != ESM::Weapon::MarksmanCrossbow)
|
if (weapon->mData.mType != ESM::Weapon::MarksmanBow && weapon->mData.mType != ESM::Weapon::MarksmanCrossbow)
|
||||||
|
{
|
||||||
resistNormalWeapon(enemy, actor, item, rating);
|
resistNormalWeapon(enemy, actor, item, rating);
|
||||||
|
applyWerewolfDamageMult(enemy, item, rating);
|
||||||
|
}
|
||||||
else if (weapon->mData.mType == ESM::Weapon::MarksmanBow)
|
else if (weapon->mData.mType == ESM::Weapon::MarksmanBow)
|
||||||
{
|
{
|
||||||
if (arrowRating <= 0.f)
|
if (arrowRating <= 0.f)
|
||||||
|
|
Loading…
Reference in a new issue