mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 22:36:43 +00:00
Reduce wepaon condition even if attack misses
This commit is contained in:
parent
63fd04882a
commit
691ba02115
2 changed files with 35 additions and 0 deletions
|
@ -254,6 +254,23 @@ namespace MWClass
|
||||||
if((::rand()/(RAND_MAX+1.0)) > hitchance/100.0f)
|
if((::rand()/(RAND_MAX+1.0)) > hitchance/100.0f)
|
||||||
{
|
{
|
||||||
victim.getClass().onHit(victim, 0.0f, false, MWWorld::Ptr(), ptr, false);
|
victim.getClass().onHit(victim, 0.0f, false, MWWorld::Ptr(), ptr, false);
|
||||||
|
|
||||||
|
// Weapon health is reduced by 1 even if the attack misses
|
||||||
|
const bool weaphashealth = !weapon.isEmpty() && weapon.getClass().hasItemHealth(weapon);
|
||||||
|
if(weaphashealth)
|
||||||
|
{
|
||||||
|
int weaphealth = weapon.getClass().getItemHealth(weapon);
|
||||||
|
|
||||||
|
if (!MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
{
|
||||||
|
weaphealth -= std::min(1, weaphealth);
|
||||||
|
weapon.getCellRef().setCharge(weaphealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Weapon broken? unequip it
|
||||||
|
if (weapon.getCellRef().getCharge() == 0)
|
||||||
|
weapon = *getInventoryStore(ptr).unequipItem(weapon, ptr);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -527,6 +527,24 @@ namespace MWClass
|
||||||
if((::rand()/(RAND_MAX+1.0)) > hitchance/100.0f)
|
if((::rand()/(RAND_MAX+1.0)) > hitchance/100.0f)
|
||||||
{
|
{
|
||||||
othercls.onHit(victim, 0.0f, false, weapon, ptr, false);
|
othercls.onHit(victim, 0.0f, false, weapon, ptr, false);
|
||||||
|
|
||||||
|
// Weapon health is reduced by 1 even if the attack misses
|
||||||
|
const bool weaphashealth = !weapon.isEmpty() && weapon.getClass().hasItemHealth(weapon);
|
||||||
|
if(weaphashealth)
|
||||||
|
{
|
||||||
|
int weaphealth = weapon.getClass().getItemHealth(weapon);
|
||||||
|
|
||||||
|
if (!MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
|
{
|
||||||
|
weaphealth -= std::min(1, weaphealth);
|
||||||
|
weapon.getCellRef().setCharge(weaphealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Weapon broken? unequip it
|
||||||
|
if (weaphealth == 0)
|
||||||
|
weapon = *inv.unequipItem(weapon, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue