Fix CellRef to load current weapon/armor health correctly, also show it in the tooltips

actorid
scrawl 12 years ago
parent feaf2b43fb
commit 8e2f9f5186

@ -227,7 +227,7 @@ void loadCell(ESM::Cell &cell, ESM::ESMReader &esm, Arguments& info)
std::cout << " Refnum: " << ref.mRefnum << std::endl;
std::cout << " ID: '" << ref.mRefID << "'\n";
std::cout << " Owner: '" << ref.mOwner << "'\n";
std::cout << " INTV: " << ref.mIntv << " NAM9: " << ref.mIntv << std::endl;
std::cout << " Uses/health: " << ref.mCharge << " NAM9: " << ref.mNam9 << std::endl;
}
}

@ -247,8 +247,9 @@ namespace MWClass
text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->mBase->mData.mArmor);
/// \todo store the current armor health somewhere
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
int remainingHealth = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mHealth;
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (" + typeText + ")";
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

@ -142,9 +142,9 @@ namespace MWClass
std::string text;
/// \todo store remaining uses somewhere
int remainingUses = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mUses;
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses);
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

@ -141,9 +141,9 @@ namespace MWClass
std::string text;
/// \todo store remaining uses somewhere
int remainingUses = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mUses;
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses);
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

@ -131,9 +131,9 @@ namespace MWClass
std::string text;
/// \todo store remaining uses somewhere
int remainingUses = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mUses;
text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses);
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

@ -334,9 +334,12 @@ namespace MWClass
}
}
/// \todo store the current weapon health somewhere
if (ref->mBase->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
{
int remainingHealth = (ptr.getCellRef().mCharge != -1) ? ptr.getCellRef().mCharge : ref->mBase->mData.mHealth;
text += "\n#{sCondition}: " + MWGui::ToolTips::toString(remainingHealth) + "/"
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
}
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");

@ -68,8 +68,7 @@ namespace MWWorld
cellRef.mRefnum = -1;
cellRef.mScale = 1;
cellRef.mFactIndex = 0;
cellRef.mCharge = 0;
cellRef.mIntv = 0;
cellRef.mCharge = -1;
cellRef.mNam9 = 0;
cellRef.mTeleport = false;
cellRef.mLockLevel = 0;

@ -14,7 +14,7 @@
namespace ESM
{
/// Some overloaded copare operators.
/// Some overloaded compare operators.
bool operator==(const MovedCellRef& ref, int pRefnum)
{
return (ref.mRefnum == pRefnum);
@ -43,13 +43,9 @@ void CellRef::save(ESMWriter &esm)
esm.writeHNT("INDX", mFactIndex);
}
if (mCharge != -1.0) {
esm.writeHNT("XCHG", mCharge);
}
if (mCharge != -1)
esm.writeHNT("INTV", mCharge);
if (mIntv != -1) {
esm.writeHNT("INTV", mIntv);
}
if (mNam9 != 0) {
esm.writeHNT("NAM9", mNam9);
}
@ -285,12 +281,9 @@ bool Cell::getNextRef(ESMReader &esm, CellRef &ref)
ref.mFactIndex = -2;
esm.getHNOT(ref.mFactIndex, "INDX");
ref.mCharge = -1.0;
esm.getHNOT(ref.mCharge, "XCHG");
ref.mIntv = -1;
ref.mNam9 = 0;
esm.getHNOT(ref.mIntv, "INTV");
ref.mCharge = -1;
esm.getHNOT(ref.mCharge, "INTV");
esm.getHNOT(ref.mNam9, "NAM9");
// Present for doors that teleport you to another cell.

@ -52,15 +52,11 @@ public:
// is -1, which I assume means "any rank".
int mFactIndex;
// Depends on context - possibly weapon health, number of uses left
// or weapon magic charge?
float mCharge;
// I have no idea, these are present some times, often along with
// owner (ANAM) and sometimes otherwise. They are often (but not
// always) 1. INTV is big for lights (possibly a float?), might have
// something to do with remaining light "charge".
int mIntv, mNam9;
// For weapon or armor, this is the remaining item health.
// For tools (lockpicks, probes, repair hammer) it is the remaining uses.
int mCharge;
int mNam9;
// For doors - true if this door teleports to somewhere else, false
// if it should open through animation.

Loading…
Cancel
Save