mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 17:06:43 +00:00
Fix incorrect weapon health meter for fully repaired weapons, fix exception when equipping lockpicks or probes
This commit is contained in:
parent
5ff098b8fb
commit
6c5ea1ea7a
5 changed files with 26 additions and 2 deletions
|
@ -181,4 +181,12 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
return npcServices & ESM::NPC::Picks;
|
return npcServices & ESM::NPC::Picks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Lockpick::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
|
||||||
|
ptr.get<ESM::Lockpick>();
|
||||||
|
|
||||||
|
return ref->mBase->mData.mUses;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,9 @@ namespace MWClass
|
||||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||||
|
|
||||||
|
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Return item max health or throw an exception, if class does not have item health
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,4 +180,12 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
return npcServices & ESM::NPC::Probes;
|
return npcServices & ESM::NPC::Probes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Probe::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
||||||
|
{
|
||||||
|
MWWorld::LiveCellRef<ESM::Probe> *ref =
|
||||||
|
ptr.get<ESM::Probe>();
|
||||||
|
|
||||||
|
return ref->mBase->mData.mUses;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,9 @@ namespace MWClass
|
||||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||||
|
|
||||||
|
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||||
|
///< Return item max health or throw an exception, if class does not have item health
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -918,14 +918,16 @@ namespace MWGui
|
||||||
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>()
|
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>()
|
||||||
.find(MWWorld::Class::get(item).getEnchantment(item));
|
.find(MWWorld::Class::get(item).getEnchantment(item));
|
||||||
|
|
||||||
int chargePercent = item.getCellRef().mEnchantmentCharge / static_cast<float>(ench->mData.mCharge) * 100;
|
int chargePercent = (item.getCellRef().mEnchantmentCharge == -1) ? 100
|
||||||
|
: (item.getCellRef().mEnchantmentCharge / static_cast<float>(ench->mData.mCharge) * 100);
|
||||||
mHud->setSelectedEnchantItem(item, chargePercent);
|
mHud->setSelectedEnchantItem(item, chargePercent);
|
||||||
mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item));
|
mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
|
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
|
||||||
{
|
{
|
||||||
int durabilityPercent = item.getCellRef().mCharge / static_cast<float>(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100;
|
int durabilityPercent = (item.getCellRef().mCharge == -1) ? 100
|
||||||
|
: (item.getCellRef().mCharge / static_cast<float>(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100);
|
||||||
mHud->setSelectedWeapon(item, durabilityPercent);
|
mHud->setSelectedWeapon(item, durabilityPercent);
|
||||||
mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item));
|
mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue