mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Armor tooltip should show the effective armor rating
This commit is contained in:
parent
2f2a95f735
commit
239c0071f5
5 changed files with 30 additions and 11 deletions
|
@ -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…
Reference in a new issue