mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:49:41 +00:00
Make unarmed creature attacks not affect armor condition (fixes #2455)
This commit is contained in:
parent
a45d86bdf3
commit
bccba24c40
3 changed files with 21 additions and 16 deletions
|
@ -4,6 +4,7 @@
|
||||||
Bug #1990: Sunrise/sunset not set correct
|
Bug #1990: Sunrise/sunset not set correct
|
||||||
Bug #2222: Fatigue's effect on selling price is backwards
|
Bug #2222: Fatigue's effect on selling price is backwards
|
||||||
Bug #2326: After a bound item expires the last equipped item of that type is not automatically re-equipped
|
Bug #2326: After a bound item expires the last equipped item of that type is not automatically re-equipped
|
||||||
|
Bug #2455: Creatures attacks degrade armor
|
||||||
Bug #2562: Forcing AI to activate a teleport door sometimes causes a crash
|
Bug #2562: Forcing AI to activate a teleport door sometimes causes a crash
|
||||||
Bug #2772: Non-existing class or faction freezes the game
|
Bug #2772: Non-existing class or faction freezes the game
|
||||||
Bug #2835: Player able to slowly move when overencumbered
|
Bug #2835: Player able to slowly move when overencumbered
|
||||||
|
|
|
@ -773,22 +773,24 @@ namespace MWClass
|
||||||
float x = damage / (damage + getArmorRating(ptr));
|
float x = damage / (damage + getArmorRating(ptr));
|
||||||
damage *= std::max(gmst.fCombatArmorMinMult->getFloat(), x);
|
damage *= std::max(gmst.fCombatArmorMinMult->getFloat(), x);
|
||||||
int damageDiff = static_cast<int>(unmitigatedDamage - damage);
|
int damageDiff = static_cast<int>(unmitigatedDamage - damage);
|
||||||
if (damage < 1)
|
damage = std::max(1.f, damage);
|
||||||
damage = 1;
|
damageDiff = std::max(1, damageDiff);
|
||||||
|
|
||||||
MWWorld::InventoryStore &inv = getInventoryStore(ptr);
|
MWWorld::InventoryStore &inv = getInventoryStore(ptr);
|
||||||
MWWorld::ContainerStoreIterator armorslot = inv.getSlot(hitslot);
|
MWWorld::ContainerStoreIterator armorslot = inv.getSlot(hitslot);
|
||||||
MWWorld::Ptr armor = ((armorslot != inv.end()) ? *armorslot : MWWorld::Ptr());
|
MWWorld::Ptr armor = ((armorslot != inv.end()) ? *armorslot : MWWorld::Ptr());
|
||||||
if(!armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name())
|
if(!armor.isEmpty() && armor.getTypeName() == typeid(ESM::Armor).name())
|
||||||
{
|
{
|
||||||
int armorhealth = armor.getClass().getItemHealth(armor);
|
if (!(object.isEmpty() && !attacker.getClass().isNpc())) // Unarmed creature attacks don't affect armor condition
|
||||||
armorhealth -= std::min(std::max(1, damageDiff),
|
{
|
||||||
armorhealth);
|
int armorhealth = armor.getClass().getItemHealth(armor);
|
||||||
armor.getCellRef().setCharge(armorhealth);
|
armorhealth -= std::min(damageDiff, armorhealth);
|
||||||
|
armor.getCellRef().setCharge(armorhealth);
|
||||||
|
|
||||||
// Armor broken? unequip it
|
// Armor broken? unequip it
|
||||||
if (armorhealth == 0)
|
if (armorhealth == 0)
|
||||||
armor = *inv.unequipItem(armor, ptr);
|
armor = *inv.unequipItem(armor, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
if (ptr == MWMechanics::getPlayer())
|
if (ptr == MWMechanics::getPlayer())
|
||||||
skillUsageSucceeded(ptr, armor.getClass().getEquipmentSkill(armor), 0);
|
skillUsageSucceeded(ptr, armor.getClass().getEquipmentSkill(armor), 0);
|
||||||
|
|
|
@ -115,14 +115,16 @@ namespace MWMechanics
|
||||||
|
|
||||||
if (Misc::Rng::roll0to99() < x)
|
if (Misc::Rng::roll0to99() < x)
|
||||||
{
|
{
|
||||||
// Reduce shield durability by incoming damage
|
if (!(weapon.isEmpty() && !attacker.getClass().isNpc())) // Unarmed creature attacks don't affect armor condition
|
||||||
int shieldhealth = shield->getClass().getItemHealth(*shield);
|
{
|
||||||
|
// Reduce shield durability by incoming damage
|
||||||
shieldhealth -= std::min(shieldhealth, int(damage));
|
int shieldhealth = shield->getClass().getItemHealth(*shield);
|
||||||
shield->getCellRef().setCharge(shieldhealth);
|
|
||||||
if (shieldhealth == 0)
|
|
||||||
inv.unequipItem(*shield, blocker);
|
|
||||||
|
|
||||||
|
shieldhealth -= std::min(shieldhealth, int(damage));
|
||||||
|
shield->getCellRef().setCharge(shieldhealth);
|
||||||
|
if (shieldhealth == 0)
|
||||||
|
inv.unequipItem(*shield, blocker);
|
||||||
|
}
|
||||||
// Reduce blocker fatigue
|
// Reduce blocker fatigue
|
||||||
const float fFatigueBlockBase = gmst.find("fFatigueBlockBase")->getFloat();
|
const float fFatigueBlockBase = gmst.find("fFatigueBlockBase")->getFloat();
|
||||||
const float fFatigueBlockMult = gmst.find("fFatigueBlockMult")->getFloat();
|
const float fFatigueBlockMult = gmst.find("fFatigueBlockMult")->getFloat();
|
||||||
|
|
Loading…
Reference in a new issue