mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
Merge pull request #1152 from Aussiemon/disintegration2
Bug #2777: Fix for disintegration efffects eliminated by framerate (attempt #2)
This commit is contained in:
commit
b7f8b572ae
6 changed files with 26 additions and 2 deletions
|
@ -980,8 +980,10 @@ namespace MWMechanics
|
|||
if (charge == 0)
|
||||
return false;
|
||||
|
||||
// FIXME: charge should be a float, not int so that damage < 1 per frame can be applied.
|
||||
// This was also a bug in the original engine.
|
||||
// Store remainder of disintegrate amount (automatically subtracted if > 1)
|
||||
item->getCellRef().applyChargeRemainderToBeSubtracted(disintegrate - std::floor(disintegrate));
|
||||
|
||||
charge = item->getClass().getItemHealth(*item);
|
||||
charge -=
|
||||
std::min(static_cast<int>(disintegrate),
|
||||
charge);
|
||||
|
|
|
@ -93,6 +93,24 @@ 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
|
||||
{
|
||||
return mCellRef.mChargeFloat;
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace MWWorld
|
|||
float getChargeFloat() const; // Implemented as union with int charge
|
||||
void setCharge(int charge);
|
||||
void setChargeFloat(float charge);
|
||||
void applyChargeRemainderToBeSubtracted(float chargeRemainder); // Stores remainders and applies if > 1
|
||||
|
||||
// The NPC that owns this object (and will get angry if you steal it)
|
||||
std::string getOwner() const;
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace
|
|||
cellRef.mScale = 1;
|
||||
cellRef.mFactionRank = 0;
|
||||
cellRef.mChargeInt = -1;
|
||||
cellRef.mChargeIntRemainder = 0.0f;
|
||||
cellRef.mGoldValue = 1;
|
||||
cellRef.mEnchantmentCharge = -1;
|
||||
cellRef.mTeleport = false;
|
||||
|
|
|
@ -196,6 +196,7 @@ void ESM::CellRef::blank()
|
|||
mFaction.clear();
|
||||
mFactionRank = -2;
|
||||
mChargeInt = -1;
|
||||
mChargeIntRemainder = 0.0f;
|
||||
mEnchantmentCharge = -1;
|
||||
mGoldValue = 0;
|
||||
mDestCell.clear();
|
||||
|
|
|
@ -69,6 +69,7 @@ namespace ESM
|
|||
int mChargeInt; // Used by everything except lights
|
||||
float mChargeFloat; // Used only by lights
|
||||
};
|
||||
float mChargeIntRemainder; // Stores amount of charge not subtracted from mChargeInt
|
||||
|
||||
// Remaining enchantment charge. This could be -1 if the charge was not touched yet (i.e. full).
|
||||
float mEnchantmentCharge;
|
||||
|
|
Loading…
Reference in a new issue