1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-31 14:36:39 +00:00

Decrease weapon condition on successful hits

This commit is contained in:
Chris Robinson 2013-07-28 15:17:01 -07:00
parent 465f4d2063
commit 1af48ab6e0

View file

@ -354,6 +354,7 @@ namespace MWClass
float damage = 0.0f; float damage = 0.0f;
if(!weapon.isEmpty()) if(!weapon.isEmpty())
{ {
const bool weaphashealth = get(weapon).hasItemHealth(weapon);
const unsigned char *attack = NULL; const unsigned char *attack = NULL;
if(type == MWMechanics::CreatureStats::AT_Chop) if(type == MWMechanics::CreatureStats::AT_Chop)
attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop; attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
@ -365,13 +366,23 @@ namespace MWClass
{ {
damage = attack[0] + ((attack[1]-attack[0])*npcstats.getAttackStrength()); damage = attack[0] + ((attack[1]-attack[0])*npcstats.getAttackStrength());
damage *= 0.5f + (crstats.getAttribute(ESM::Attribute::Luck).getModified() / 100.0f); damage *= 0.5f + (crstats.getAttribute(ESM::Attribute::Luck).getModified() / 100.0f);
//damage *= weapon_current_health / weapon_max_health; if(weaphashealth)
{
int weapmaxhealth = weapon.get<ESM::Weapon>()->mBase->mData.mHealth;
if(weapon.getCellRef().mCharge == -1)
weapon.getCellRef().mCharge = weapmaxhealth;
damage *= float(weapon.getCellRef().mCharge) / weapmaxhealth;
}
if(!othercls.hasDetected(victim, ptr)) if(!othercls.hasDetected(victim, ptr))
{ {
damage *= gmst.find("fCombatCriticalStrikeMult")->getFloat(); damage *= gmst.find("fCombatCriticalStrikeMult")->getFloat();
MWBase::Environment::get().getWindowManager()->messageBox("#{sTargetCriticalStrike}"); MWBase::Environment::get().getWindowManager()->messageBox("#{sTargetCriticalStrike}");
MWBase::Environment::get().getSoundManager()->playSound3D(victim, "critical damage", 1.0f, 1.0f); MWBase::Environment::get().getSoundManager()->playSound3D(victim, "critical damage", 1.0f, 1.0f);
} }
weapon.getCellRef().mCharge -= std::min(std::max(1,
(int)(damage * gmst.find("fWeaponDamageMult")->getFloat())),
weapon.getCellRef().mCharge);
damage /= std::min(1.0f + othercls.getArmorRating(victim)/std::max(1.0f, damage), 4.0f); damage /= std::min(1.0f + othercls.getArmorRating(victim)/std::max(1.0f, damage), 4.0f);
} }
healthdmg = true; healthdmg = true;
@ -396,8 +407,7 @@ namespace MWClass
npcstats.isWerewolf()); npcstats.isWerewolf());
if(healthdmg) if(healthdmg)
{ {
// Not sure this is right... damage *= gmst.find("fHandtoHandHealthPer")->getFloat();
damage *= gmst.find("fHandtoHandHealthPer")->getFloat() * 1.5f;
damage /= othercls.getArmorRating(victim); damage /= othercls.getArmorRating(victim);
} }
} }
@ -440,6 +450,10 @@ namespace MWClass
MWBase::Environment::get().getDialogueManager()->say(ptr, "hit"); MWBase::Environment::get().getDialogueManager()->say(ptr, "hit");
if(object.isEmpty())
sndMgr->playSound3D(ptr, "Hand To Hand Hit", 1.0f, 1.0f);
else
{
// Hit percentages: // Hit percentages:
// cuirass = 30% // cuirass = 30%
// shield, helmet, greaves, boots, pauldrons = 10% each // shield, helmet, greaves, boots, pauldrons = 10% each
@ -463,9 +477,7 @@ namespace MWClass
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())
{ {
if(object.isEmpty()) switch(get(armor).getEquipmentSkill(armor))
sndMgr->playSound3D(ptr, "Hand To Hand Hit", 1.0f, 1.0f);
else switch(get(armor).getEquipmentSkill(armor))
{ {
case ESM::Skill::LightArmor: case ESM::Skill::LightArmor:
sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f); sndMgr->playSound3D(ptr, "Light Armor Hit", 1.0f, 1.0f);
@ -478,8 +490,7 @@ namespace MWClass
break; break;
} }
} }
else if(object.isEmpty()) }
sndMgr->playSound3D(ptr, "Hand To Hand Hit", 1.0f, 1.0f);
} }
if(ishealth) if(ishealth)