|
|
@ -30,7 +30,7 @@ namespace MWMechanics
|
|
|
|
return 0.f;
|
|
|
|
return 0.f;
|
|
|
|
|
|
|
|
|
|
|
|
float rating=0.f;
|
|
|
|
float rating=0.f;
|
|
|
|
float bonus=0.f;
|
|
|
|
float rangedMult=1.f;
|
|
|
|
|
|
|
|
|
|
|
|
if (weapon->mData.mType >= ESM::Weapon::MarksmanBow && weapon->mData.mType <= ESM::Weapon::MarksmanThrown)
|
|
|
|
if (weapon->mData.mType >= ESM::Weapon::MarksmanBow && weapon->mData.mType <= ESM::Weapon::MarksmanThrown)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -44,25 +44,33 @@ namespace MWMechanics
|
|
|
|
if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(enemy), 0.75f))
|
|
|
|
if (MWBase::Environment::get().getWorld()->isUnderwater(MWWorld::ConstPtr(enemy), 0.75f))
|
|
|
|
return 0.f;
|
|
|
|
return 0.f;
|
|
|
|
|
|
|
|
|
|
|
|
bonus+=1.5f;
|
|
|
|
if (getDistanceMinusHalfExtents(actor, enemy) >= getMaxAttackDistance(enemy))
|
|
|
|
|
|
|
|
rangedMult = 1.5f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (weapon->mData.mType >= ESM::Weapon::MarksmanBow)
|
|
|
|
if (weapon->mData.mType >= ESM::Weapon::MarksmanBow)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rating = (weapon->mData.mChop[0] + weapon->mData.mChop[1]) / 2.f;
|
|
|
|
float rangedDamage = weapon->mData.mChop[0] + weapon->mData.mChop[1];
|
|
|
|
|
|
|
|
MWMechanics::adjustWeaponDamage(rangedDamage, item, actor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rating = rangedDamage / 2.f;
|
|
|
|
|
|
|
|
|
|
|
|
if (weapon->mData.mType >= ESM::Weapon::MarksmanThrown)
|
|
|
|
if (weapon->mData.mType >= ESM::Weapon::MarksmanThrown)
|
|
|
|
MWMechanics::resistNormalWeapon(enemy, actor, item, rating);
|
|
|
|
MWMechanics::resistNormalWeapon(enemy, actor, item, rating);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
float meleeDamage = 0.f;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i<2; ++i)
|
|
|
|
for (int i=0; i<2; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rating += weapon->mData.mSlash[i];
|
|
|
|
meleeDamage += weapon->mData.mSlash[i];
|
|
|
|
rating += weapon->mData.mThrust[i];
|
|
|
|
meleeDamage += weapon->mData.mThrust[i];
|
|
|
|
rating += weapon->mData.mChop[i];
|
|
|
|
meleeDamage += weapon->mData.mChop[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rating /= 6.f;
|
|
|
|
|
|
|
|
|
|
|
|
MWMechanics::adjustWeaponDamage(meleeDamage, item, actor);
|
|
|
|
|
|
|
|
rating = meleeDamage / 6.f;
|
|
|
|
|
|
|
|
|
|
|
|
MWMechanics::resistNormalWeapon(enemy, actor, item, rating);
|
|
|
|
MWMechanics::resistNormalWeapon(enemy, actor, item, rating);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -71,7 +79,6 @@ namespace MWMechanics
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (item.getClass().getItemHealth(item) == 0)
|
|
|
|
if (item.getClass().getItemHealth(item) == 0)
|
|
|
|
return 0.f;
|
|
|
|
return 0.f;
|
|
|
|
rating *= item.getClass().getItemHealth(item) / float(item.getClass().getItemMaxHealth(item));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (weapon->mData.mType == ESM::Weapon::MarksmanBow)
|
|
|
|
if (weapon->mData.mType == ESM::Weapon::MarksmanBow)
|
|
|
@ -103,13 +110,12 @@ namespace MWMechanics
|
|
|
|
|
|
|
|
|
|
|
|
int skill = item.getClass().getEquipmentSkill(item);
|
|
|
|
int skill = item.getClass().getEquipmentSkill(item);
|
|
|
|
if (skill != -1)
|
|
|
|
if (skill != -1)
|
|
|
|
rating *= actor.getClass().getSkill(actor, skill) / 100.f;
|
|
|
|
{
|
|
|
|
|
|
|
|
int value = actor.getClass().getSkill(actor, skill);
|
|
|
|
// There is no need to apply bonus if weapon rating == 0
|
|
|
|
rating *= MWMechanics::getHitChance(actor, enemy, value) / 100.f;
|
|
|
|
if (rating == 0.f)
|
|
|
|
}
|
|
|
|
return 0.f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rating + bonus;
|
|
|
|
return rating * rangedMult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float rateAmmo(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy, MWWorld::Ptr &bestAmmo, ESM::Weapon::Type ammoType)
|
|
|
|
float rateAmmo(const MWWorld::Ptr &actor, const MWWorld::Ptr &enemy, MWWorld::Ptr &bestAmmo, ESM::Weapon::Type ammoType)
|
|
|
|