|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
#include "mechanicsmanagerimp.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwworld/esmstore.hpp"
|
|
|
|
|
#include "../mwworld/inventorystore.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
@ -668,4 +669,52 @@ namespace MWMechanics
|
|
|
|
|
mActors.skipAnimation(ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float MechanicsManager::getArmorRating(const MWWorld::Ptr &ptr)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(ptr).getInventoryStore(ptr);
|
|
|
|
|
const MWWorld::Store<ESM::GameSetting> &gmst =
|
|
|
|
|
MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();
|
|
|
|
|
|
|
|
|
|
int ratings[MWWorld::InventoryStore::Slots];
|
|
|
|
|
|
|
|
|
|
int iBaseArmorSkill = gmst.find("iBaseArmorSkill")->getInt();
|
|
|
|
|
float fUnarmoredBase1 = gmst.find("fUnarmoredBase1")->getFloat();
|
|
|
|
|
float fUnarmoredBase2 = gmst.find("fUnarmoredBase2")->getFloat();
|
|
|
|
|
int unarmoredSkill = MWWorld::Class::get(ptr).getNpcStats(ptr).getSkill(ESM::Skill::Unarmored).getModified();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < MWWorld::InventoryStore::Slots; ++i)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::ContainerStoreIterator it = invStore.getSlot(i);
|
|
|
|
|
if (it == invStore.end() || it->getTypeName() != typeid(ESM::Armor).name())
|
|
|
|
|
{
|
|
|
|
|
// unarmored
|
|
|
|
|
ratings[i] = (fUnarmoredBase1 * unarmoredSkill) * (fUnarmoredBase2 * unarmoredSkill);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Armor> *ref =
|
|
|
|
|
it->get<ESM::Armor>();
|
|
|
|
|
|
|
|
|
|
int armorSkillType = MWWorld::Class::get(*it).getEquipmentSkill(*it);
|
|
|
|
|
int armorSkill = MWWorld::Class::get(ptr).getNpcStats(ptr).getSkill(armorSkillType).getModified();
|
|
|
|
|
|
|
|
|
|
if (ref->mBase->mData.mWeight == 0)
|
|
|
|
|
ratings[i] = ref->mBase->mData.mArmor;
|
|
|
|
|
else
|
|
|
|
|
ratings[i] = ref->mBase->mData.mArmor * armorSkill / iBaseArmorSkill;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float shield = MWWorld::Class::get(ptr).getCreatureStats(ptr).getMagicEffects().get(3).mMagnitude;
|
|
|
|
|
|
|
|
|
|
return ratings[MWWorld::InventoryStore::Slot_Cuirass] * 0.3
|
|
|
|
|
+ (ratings[MWWorld::InventoryStore::Slot_CarriedLeft] + ratings[MWWorld::InventoryStore::Slot_Helmet]
|
|
|
|
|
+ ratings[MWWorld::InventoryStore::Slot_Greaves] + ratings[MWWorld::InventoryStore::Slot_Boots]
|
|
|
|
|
+ ratings[MWWorld::InventoryStore::Slot_LeftPauldron] + ratings[MWWorld::InventoryStore::Slot_RightPauldron]
|
|
|
|
|
) * 0.1
|
|
|
|
|
+ (ratings[MWWorld::InventoryStore::Slot_LeftGauntlet] + MWWorld::InventoryStore::Slot_RightGauntlet)
|
|
|
|
|
* 0.05
|
|
|
|
|
+ shield;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|