Armor tooltip should show the effective armor rating

celladd
scrawl 10 years ago
parent 2f2a95f735
commit 239c0071f5

@ -245,7 +245,8 @@ namespace MWClass
else
typeText = "#{sHeavy}";
text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->mBase->mData.mArmor);
text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(getEffectiveArmorRating(ptr,
MWBase::Environment::get().getWorld()->getPlayerPtr()));
int remainingHealth = getItemHealth(ptr);
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
@ -290,6 +291,22 @@ namespace MWClass
return record->mId;
}
int Armor::getEffectiveArmorRating(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const
{
MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>();
int armorSkillType = getEquipmentSkill(ptr);
int armorSkill = actor.getClass().getSkill(actor, armorSkillType);
const MWBase::World *world = MWBase::Environment::get().getWorld();
int iBaseArmorSkill = world->getStore().get<ESM::GameSetting>().find("iBaseArmorSkill")->getInt();
if(ref->mBase->mData.mWeight == 0)
return ref->mBase->mData.mArmor;
else
return ref->mBase->mData.mArmor * armorSkill / iBaseArmorSkill;
}
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const
{
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);

@ -86,6 +86,9 @@ namespace MWClass
virtual int getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
/// Get the effective armor rating, factoring in the actor's skills, for the given armor.
virtual int getEffectiveArmorRating(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const;
};
}

@ -1086,7 +1086,6 @@ namespace MWClass
MWMechanics::NpcStats &stats = getNpcStats(ptr);
MWWorld::InventoryStore &invStore = getInventoryStore(ptr);
int iBaseArmorSkill = store.find("iBaseArmorSkill")->getInt();
float fUnarmoredBase1 = store.find("fUnarmoredBase1")->getFloat();
float fUnarmoredBase2 = store.find("fUnarmoredBase2")->getFloat();
int unarmoredSkill = stats.getSkill(ESM::Skill::Unarmored).getModified();
@ -1102,15 +1101,7 @@ namespace MWClass
}
else
{
MWWorld::LiveCellRef<ESM::Armor> *ref = it->get<ESM::Armor>();
int armorSkillType = it->getClass().getEquipmentSkill(*it);
int armorSkill = stats.getSkill(armorSkillType).getModified();
if(ref->mBase->mData.mWeight == 0)
ratings[i] = ref->mBase->mData.mArmor;
else
ratings[i] = ref->mBase->mData.mArmor * armorSkill / iBaseArmorSkill;
ratings[i] = it->getClass().getEffectiveArmorRating(*it, ptr);
}
}

@ -454,4 +454,9 @@ namespace MWWorld
{
return -1;
}
int Class::getEffectiveArmorRating(const Ptr &ptr, const Ptr &actor) const
{
throw std::runtime_error("class does not support armor ratings");
}
}

@ -347,6 +347,9 @@ namespace MWWorld
virtual std::string getPrimaryFaction (const MWWorld::Ptr& ptr) const;
virtual int getPrimaryFactionRank (const MWWorld::Ptr& ptr) const;
/// Get the effective armor rating, factoring in the actor's skills, for the given armor.
virtual int getEffectiveArmorRating(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const;
};
}

Loading…
Cancel
Save