Make normal weapon resistance behavior closer to vanilla (bug #4384)

Check both the ranged weapon and the projectile before modifying the damage
Don't attempt to apply NPC-specific werewolf damage mult to damage to creatures
pull/541/head
Capostrophic 6 years ago
parent 64d5cd17d6
commit b738cc0383

@ -7,6 +7,7 @@
Bug #3733: Normal maps are inverted on mirrored UVs
Bug #4329: Removed birthsign abilities are restored after reloading the save
Bug #4383: Bow model obscures crosshair when arrow is drawn
Bug #4384: Resist Normal Weapons only checks ammunition for ranged weapons
Bug #4411: Reloading a saved game while falling prevents damage in some cases
Bug #4540: Rain delay when exiting water
Bug #4701: PrisonMarker record is not hardcoded like other markers

@ -308,7 +308,6 @@ namespace MWClass
{
damage = attack[0] + ((attack[1]-attack[0])*attackStrength);
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
MWMechanics::applyWerewolfDamageMult(victim, weapon, damage);
MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
}

@ -604,7 +604,6 @@ namespace MWClass
}
bool healthdmg;
bool resisted = false;
float damage = 0.0f;
if(!weapon.isEmpty())
{
@ -620,7 +619,7 @@ namespace MWClass
damage = attack[0] + ((attack[1]-attack[0])*attackStrength);
}
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
resisted = MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
MWMechanics::resistNormalWeapon(victim, ptr, weapon, damage);
MWMechanics::applyWerewolfDamageMult(victim, weapon, damage);
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
healthdmg = true;
@ -632,8 +631,6 @@ namespace MWClass
if(ptr == MWMechanics::getPlayer())
{
skillUsageSucceeded(ptr, weapskill, 0);
if (resisted)
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResistsWeapons}");
const MWMechanics::AiSequence& seq = victim.getClass().getCreatureStats(victim).getAiSequence();

@ -153,7 +153,7 @@ namespace MWMechanics
if (weapon.isEmpty())
return false;
const int &flags = weapon.get<ESM::Weapon>()->mBase->mData.mFlags;
const int flags = weapon.get<ESM::Weapon>()->mBase->mData.mFlags;
bool isSilver = flags & ESM::Weapon::Silver;
bool isMagical = flags & ESM::Weapon::Magical;
bool isEnchanted = !weapon.getClass().getEnchantment(weapon).empty();
@ -161,10 +161,10 @@ namespace MWMechanics
return !isSilver && !isMagical && (!isEnchanted || !Settings::Manager::getBool("enchanted weapons are magical", "Game"));
}
bool resistNormalWeapon(const MWWorld::Ptr &actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr &weapon, float &damage)
void resistNormalWeapon(const MWWorld::Ptr &actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr &weapon, float &damage)
{
if (damage == 0 || weapon.isEmpty() || !isNormalWeapon(weapon))
return false;
return;
const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects();
const float resistance = effects.get(ESM::MagicEffect::ResistNormalWeapons).getMagnitude() / 100.f;
@ -172,19 +172,23 @@ namespace MWMechanics
damage *= 1.f - std::min(1.f, resistance-weakness);
return (damage == 0);
if (damage == 0 && attacker == getPlayer())
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResistsWeapons}");
}
void applyWerewolfDamageMult(const MWWorld::Ptr &actor, const MWWorld::Ptr &weapon, float &damage)
{
if (damage == 0 || weapon.isEmpty())
if (damage == 0 || weapon.isEmpty() || !actor.getClass().isNpc())
return;
const int &flags = weapon.get<ESM::Weapon>()->mBase->mData.mFlags;
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();
if (isSilver && actor.getClass().getNpcStats(actor).isWerewolf())
{
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
damage *= store.get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->mValue.getFloat();
}
}
void projectileHit(const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, MWWorld::Ptr weapon, const MWWorld::Ptr& projectile,
@ -223,14 +227,12 @@ namespace MWMechanics
damage += attack[0] + ((attack[1] - attack[0]) * attackStrength);
adjustWeaponDamage(damage, weapon, attacker);
bool resisted = resistNormalWeapon(victim, attacker, projectile, damage);
if (weapon == projectile || isNormalWeapon(weapon)) // NB: both the weapon and the projectile need to be normal
resistNormalWeapon(victim, attacker, projectile, damage);
applyWerewolfDamageMult(victim, projectile, damage);
if (attacker == getPlayer())
{
if (resisted)
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResistsWeapons}");
attacker.getClass().skillUsageSucceeded(attacker, weaponSkill, 0);
const MWMechanics::AiSequence& sequence = victim.getClass().getCreatureStats(victim).getAiSequence();

@ -15,8 +15,7 @@ bool blockMeleeAttack (const MWWorld::Ptr& attacker, const MWWorld::Ptr& blocker
/// @return does normal weapon resistance and weakness apply to the weapon?
bool isNormalWeapon (const MWWorld::Ptr& weapon);
/// @return was the damage fully resisted?
bool resistNormalWeapon (const MWWorld::Ptr& actor, const MWWorld::Ptr& attacker, const MWWorld::Ptr& weapon, float& damage);
void 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);

Loading…
Cancel
Save