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 #3733: Normal maps are inverted on mirrored UVs
Bug #4329: Removed birthsign abilities are restored after reloading the save Bug #4329: Removed birthsign abilities are restored after reloading the save
Bug #4383: Bow model obscures crosshair when arrow is drawn 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 #4411: Reloading a saved game while falling prevents damage in some cases
Bug #4540: Rain delay when exiting water Bug #4540: Rain delay when exiting water
Bug #4701: PrisonMarker record is not hardcoded like other markers Bug #4701: PrisonMarker record is not hardcoded like other markers

@ -308,7 +308,6 @@ 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);
} }

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

@ -153,7 +153,7 @@ namespace MWMechanics
if (weapon.isEmpty()) if (weapon.isEmpty())
return false; 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 isSilver = flags & ESM::Weapon::Silver;
bool isMagical = flags & ESM::Weapon::Magical; bool isMagical = flags & ESM::Weapon::Magical;
bool isEnchanted = !weapon.getClass().getEnchantment(weapon).empty(); 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")); 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)) if (damage == 0 || weapon.isEmpty() || !isNormalWeapon(weapon))
return false; return;
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;
@ -172,19 +172,23 @@ namespace MWMechanics
damage *= 1.f - std::min(1.f, resistance-weakness); 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) 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; 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; bool isSilver = flags & ESM::Weapon::Silver;
if (isSilver && actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf()) if (isSilver && actor.getClass().getNpcStats(actor).isWerewolf())
damage *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fWereWolfSilverWeaponDamageMult")->mValue.getFloat(); {
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, 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); damage += attack[0] + ((attack[1] - attack[0]) * attackStrength);
adjustWeaponDamage(damage, weapon, attacker); 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); applyWerewolfDamageMult(victim, projectile, damage);
if (attacker == getPlayer()) if (attacker == getPlayer())
{ {
if (resisted)
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResistsWeapons}");
attacker.getClass().skillUsageSucceeded(attacker, weaponSkill, 0); attacker.getClass().skillUsageSucceeded(attacker, weaponSkill, 0);
const MWMechanics::AiSequence& sequence = victim.getClass().getCreatureStats(victim).getAiSequence(); 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? /// @return does normal weapon resistance and weakness apply to the weapon?
bool isNormalWeapon (const MWWorld::Ptr& weapon); bool isNormalWeapon (const MWWorld::Ptr& weapon);
/// @return was the damage fully resisted? void 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); void applyWerewolfDamageMult (const MWWorld::Ptr& actor, const MWWorld::Ptr& weapon, float &damage);

Loading…
Cancel
Save