forked from teamnwah/openmw-tes3coop
Combat mechanic fixes
This commit is contained in:
parent
a846bb1aa3
commit
767624f518
5 changed files with 19 additions and 26 deletions
|
@ -249,7 +249,7 @@ namespace MWClass
|
||||||
|
|
||||||
float hitchance = MWMechanics::getHitChance(ptr, victim, ref->mBase->mData.mCombat);
|
float hitchance = MWMechanics::getHitChance(ptr, victim, ref->mBase->mData.mCombat);
|
||||||
|
|
||||||
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);
|
||||||
MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr);
|
MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr);
|
||||||
|
@ -288,9 +288,7 @@ namespace MWClass
|
||||||
if(attack)
|
if(attack)
|
||||||
{
|
{
|
||||||
damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength());
|
damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength());
|
||||||
damage *= gmst.find("fDamageStrengthBase")->getFloat() +
|
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
|
||||||
(stats.getAttribute(ESM::Attribute::Strength).getModified() * gmst.find("fDamageStrengthMult")->getFloat() * 0.1f);
|
|
||||||
MWMechanics::adjustWeaponDamage(damage, weapon);
|
|
||||||
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
|
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -279,8 +279,6 @@ namespace MWClass
|
||||||
gmst.fKnockDownMult = store.find("fKnockDownMult");
|
gmst.fKnockDownMult = store.find("fKnockDownMult");
|
||||||
gmst.iKnockDownOddsMult = store.find("iKnockDownOddsMult");
|
gmst.iKnockDownOddsMult = store.find("iKnockDownOddsMult");
|
||||||
gmst.iKnockDownOddsBase = store.find("iKnockDownOddsBase");
|
gmst.iKnockDownOddsBase = store.find("iKnockDownOddsBase");
|
||||||
gmst.fDamageStrengthBase = store.find("fDamageStrengthBase");
|
|
||||||
gmst.fDamageStrengthMult = store.find("fDamageStrengthMult");
|
|
||||||
gmst.fCombatArmorMinMult = store.find("fCombatArmorMinMult");
|
gmst.fCombatArmorMinMult = store.find("fCombatArmorMinMult");
|
||||||
|
|
||||||
inited = true;
|
inited = true;
|
||||||
|
@ -516,7 +514,7 @@ namespace MWClass
|
||||||
|
|
||||||
float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill));
|
float hitchance = MWMechanics::getHitChance(ptr, victim, ptr.getClass().getSkill(ptr, weapskill));
|
||||||
|
|
||||||
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);
|
||||||
MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr);
|
MWMechanics::reduceWeaponCondition(0.f, false, weapon, ptr);
|
||||||
|
@ -538,10 +536,8 @@ namespace MWClass
|
||||||
if(attack)
|
if(attack)
|
||||||
{
|
{
|
||||||
damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength());
|
damage = attack[0] + ((attack[1]-attack[0])*stats.getAttackStrength());
|
||||||
damage *= gmst.fDamageStrengthBase->getFloat() +
|
|
||||||
(stats.getAttribute(ESM::Attribute::Strength).getModified() * gmst.fDamageStrengthMult->getFloat() * 0.1f);
|
|
||||||
}
|
}
|
||||||
MWMechanics::adjustWeaponDamage(damage, weapon);
|
MWMechanics::adjustWeaponDamage(damage, weapon, ptr);
|
||||||
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
|
MWMechanics::reduceWeaponCondition(damage, true, weapon, ptr);
|
||||||
healthdmg = true;
|
healthdmg = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,6 @@ namespace MWClass
|
||||||
const ESM::GameSetting *fKnockDownMult;
|
const ESM::GameSetting *fKnockDownMult;
|
||||||
const ESM::GameSetting *iKnockDownOddsMult;
|
const ESM::GameSetting *iKnockDownOddsMult;
|
||||||
const ESM::GameSetting *iKnockDownOddsBase;
|
const ESM::GameSetting *iKnockDownOddsBase;
|
||||||
const ESM::GameSetting *fDamageStrengthBase;
|
|
||||||
const ESM::GameSetting *fDamageStrengthMult;
|
|
||||||
const ESM::GameSetting *fCombatArmorMinMult;
|
const ESM::GameSetting *fCombatArmorMinMult;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -186,29 +186,23 @@ namespace MWMechanics
|
||||||
int skillValue = attacker.getClass().getSkill(attacker,
|
int skillValue = attacker.getClass().getSkill(attacker,
|
||||||
weapon.getClass().getEquipmentSkill(weapon));
|
weapon.getClass().getEquipmentSkill(weapon));
|
||||||
|
|
||||||
if((::rand()/(RAND_MAX+1.0)) > getHitChance(attacker, victim, skillValue)/100.0f)
|
if((::rand()/(RAND_MAX+1.0)) >= getHitChance(attacker, victim, skillValue)/100.0f)
|
||||||
{
|
{
|
||||||
victim.getClass().onHit(victim, 0.0f, false, projectile, attacker, false);
|
victim.getClass().onHit(victim, 0.0f, false, projectile, attacker, false);
|
||||||
MWMechanics::reduceWeaponCondition(0.f, false, weapon, attacker);
|
MWMechanics::reduceWeaponCondition(0.f, false, weapon, attacker);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float fDamageStrengthBase = gmst.find("fDamageStrengthBase")->getFloat();
|
|
||||||
float fDamageStrengthMult = gmst.find("fDamageStrengthMult")->getFloat();
|
|
||||||
|
|
||||||
const unsigned char* attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
|
const unsigned char* attack = weapon.get<ESM::Weapon>()->mBase->mData.mChop;
|
||||||
float damage = attack[0] + ((attack[1]-attack[0])*attackerStats.getAttackStrength()); // Bow/crossbow damage
|
float damage = attack[0] + ((attack[1]-attack[0])*attackerStats.getAttackStrength()); // Bow/crossbow damage
|
||||||
if (weapon != projectile)
|
|
||||||
{
|
|
||||||
// Arrow/bolt damage
|
// Arrow/bolt damage
|
||||||
|
// NB in case of thrown weapons, we are applying the damage twice since projectile == weapon
|
||||||
attack = projectile.get<ESM::Weapon>()->mBase->mData.mChop;
|
attack = projectile.get<ESM::Weapon>()->mBase->mData.mChop;
|
||||||
damage += attack[0] + ((attack[1]-attack[0])*attackerStats.getAttackStrength());
|
damage += attack[0] + ((attack[1]-attack[0])*attackerStats.getAttackStrength());
|
||||||
}
|
|
||||||
|
|
||||||
damage *= fDamageStrengthBase +
|
adjustWeaponDamage(damage, weapon, attacker);
|
||||||
(attackerStats.getAttribute(ESM::Attribute::Strength).getModified() * fDamageStrengthMult * 0.1f);
|
|
||||||
|
|
||||||
adjustWeaponDamage(damage, weapon);
|
|
||||||
reduceWeaponCondition(damage, true, weapon, attacker);
|
reduceWeaponCondition(damage, true, weapon, attacker);
|
||||||
|
|
||||||
if(attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
if(attacker == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||||
|
@ -347,7 +341,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjustWeaponDamage(float &damage, const MWWorld::Ptr &weapon)
|
void adjustWeaponDamage(float &damage, const MWWorld::Ptr &weapon, const MWWorld::Ptr& attacker)
|
||||||
{
|
{
|
||||||
if (weapon.isEmpty())
|
if (weapon.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
@ -359,6 +353,13 @@ namespace MWMechanics
|
||||||
int weapmaxhealth = weapon.getClass().getItemMaxHealth(weapon);
|
int weapmaxhealth = weapon.getClass().getItemMaxHealth(weapon);
|
||||||
damage *= (float(weaphealth) / weapmaxhealth);
|
damage *= (float(weaphealth) / weapmaxhealth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const float fDamageStrengthBase = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||||
|
.find("fDamageStrengthBase")->getFloat();
|
||||||
|
static const float fDamageStrengthMult = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
|
||||||
|
.find("fDamageStrengthMult")->getFloat();
|
||||||
|
damage *= fDamageStrengthBase +
|
||||||
|
(attacker.getClass().getCreatureStats(attacker).getAttribute(ESM::Attribute::Strength).getModified() * fDamageStrengthMult * 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void getHandToHandDamage(const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, float &damage, bool &healthdmg)
|
void getHandToHandDamage(const MWWorld::Ptr &attacker, const MWWorld::Ptr &victim, float &damage, bool &healthdmg)
|
||||||
|
|
|
@ -30,7 +30,7 @@ void applyElementalShields(const MWWorld::Ptr& attacker, const MWWorld::Ptr& vic
|
||||||
void reduceWeaponCondition (float damage, bool hit, MWWorld::Ptr& weapon, const MWWorld::Ptr& attacker);
|
void reduceWeaponCondition (float damage, bool hit, MWWorld::Ptr& weapon, const MWWorld::Ptr& attacker);
|
||||||
|
|
||||||
/// Adjust weapon damage based on its condition. A used weapon will be less effective.
|
/// Adjust weapon damage based on its condition. A used weapon will be less effective.
|
||||||
void adjustWeaponDamage (float& damage, const MWWorld::Ptr& weapon);
|
void adjustWeaponDamage (float& damage, const MWWorld::Ptr& weapon, const MWWorld::Ptr& attacker);
|
||||||
|
|
||||||
void getHandToHandDamage (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, float& damage, bool& healthdmg);
|
void getHandToHandDamage (const MWWorld::Ptr& attacker, const MWWorld::Ptr& victim, float& damage, bool& healthdmg);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue