forked from mirror/openmw-tes3mp
Added new method and variable to track float remainders of disintegration effections
This commit is contained in:
parent
876d9c6a84
commit
9624d8aade
6 changed files with 27 additions and 2 deletions
|
@ -980,8 +980,10 @@ namespace MWMechanics
|
||||||
if (charge == 0)
|
if (charge == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// FIXME: charge should be a float, not int so that damage < 1 per frame can be applied.
|
// Store remainder of disintegrate amount (automatically subtracted if > 1)
|
||||||
// This was also a bug in the original engine.
|
item->getCellRef().applyChargeRemainderToBeSubtracted(disintegrate - std::floor(disintegrate));
|
||||||
|
|
||||||
|
charge = item->getClass().getItemHealth(*item);
|
||||||
charge -=
|
charge -=
|
||||||
std::min(static_cast<int>(disintegrate),
|
std::min(static_cast<int>(disintegrate),
|
||||||
charge);
|
charge);
|
||||||
|
|
|
@ -93,6 +93,25 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CellRef::applyChargeRemainderToBeSubtracted(float chargeRemainder)
|
||||||
|
{
|
||||||
|
mCellRef.mChargeIntRemainder += std::abs(chargeRemainder);
|
||||||
|
if (mCellRef.mChargeIntRemainder > 1.0f)
|
||||||
|
{
|
||||||
|
float newChargeRemainder = (mCellRef.mChargeIntRemainder - std::floor(mCellRef.mChargeIntRemainder));
|
||||||
|
if (mCellRef.mChargeInt <= static_cast<int>(mCellRef.mChargeIntRemainder))
|
||||||
|
{
|
||||||
|
mCellRef.mChargeInt = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mCellRef.mChargeInt -= static_cast<int>(mCellRef.mChargeIntRemainder);
|
||||||
|
}
|
||||||
|
|
||||||
|
mCellRef.mChargeIntRemainder = newChargeRemainder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float CellRef::getChargeFloat() const
|
float CellRef::getChargeFloat() const
|
||||||
{
|
{
|
||||||
return mCellRef.mChargeFloat;
|
return mCellRef.mChargeFloat;
|
||||||
|
|
|
@ -65,6 +65,7 @@ namespace MWWorld
|
||||||
float getChargeFloat() const; // Implemented as union with int charge
|
float getChargeFloat() const; // Implemented as union with int charge
|
||||||
void setCharge(int charge);
|
void setCharge(int charge);
|
||||||
void setChargeFloat(float charge);
|
void setChargeFloat(float charge);
|
||||||
|
void applyChargeRemainderToBeSubtracted(float chargeRemainder);
|
||||||
|
|
||||||
// The NPC that owns this object (and will get angry if you steal it)
|
// The NPC that owns this object (and will get angry if you steal it)
|
||||||
std::string getOwner() const;
|
std::string getOwner() const;
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace
|
||||||
cellRef.mScale = 1;
|
cellRef.mScale = 1;
|
||||||
cellRef.mFactionRank = 0;
|
cellRef.mFactionRank = 0;
|
||||||
cellRef.mChargeInt = -1;
|
cellRef.mChargeInt = -1;
|
||||||
|
cellRef.mChargeIntRemainder = 0.0f;
|
||||||
cellRef.mGoldValue = 1;
|
cellRef.mGoldValue = 1;
|
||||||
cellRef.mEnchantmentCharge = -1;
|
cellRef.mEnchantmentCharge = -1;
|
||||||
cellRef.mTeleport = false;
|
cellRef.mTeleport = false;
|
||||||
|
|
|
@ -196,6 +196,7 @@ void ESM::CellRef::blank()
|
||||||
mFaction.clear();
|
mFaction.clear();
|
||||||
mFactionRank = -2;
|
mFactionRank = -2;
|
||||||
mChargeInt = -1;
|
mChargeInt = -1;
|
||||||
|
mChargeIntRemainder = 0.0f;
|
||||||
mEnchantmentCharge = -1;
|
mEnchantmentCharge = -1;
|
||||||
mGoldValue = 0;
|
mGoldValue = 0;
|
||||||
mDestCell.clear();
|
mDestCell.clear();
|
||||||
|
|
|
@ -69,6 +69,7 @@ namespace ESM
|
||||||
int mChargeInt; // Used by everything except lights
|
int mChargeInt; // Used by everything except lights
|
||||||
float mChargeFloat; // Used only by lights
|
float mChargeFloat; // Used only by lights
|
||||||
};
|
};
|
||||||
|
float mChargeIntRemainder; // Used by everythign except lights (amount of charge not applied to mChargeInt)
|
||||||
|
|
||||||
// Remaining enchantment charge. This could be -1 if the charge was not touched yet (i.e. full).
|
// Remaining enchantment charge. This could be -1 if the charge was not touched yet (i.e. full).
|
||||||
float mEnchantmentCharge;
|
float mEnchantmentCharge;
|
||||||
|
|
Loading…
Reference in a new issue