mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 20:23:54 +00:00
Store death animation index in CreatureStats
This commit is contained in:
parent
3cd835e61a
commit
0966755a0c
6 changed files with 66 additions and 19 deletions
|
@ -407,29 +407,25 @@ MWWorld::ContainerStoreIterator getActiveWeapon(CreatureStats &stats, MWWorld::I
|
||||||
return inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
return inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterController::playRandomDeath(float startpoint)
|
void CharacterController::playDeath(float startpoint, CharacterState death)
|
||||||
{
|
{
|
||||||
if(MWBase::Environment::get().getWorld()->isSwimming(mPtr) && mAnimation->hasAnimation("swimdeath"))
|
switch (death)
|
||||||
{
|
{
|
||||||
mDeathState = CharState_SwimDeath;
|
case CharState_SwimDeath:
|
||||||
mCurrentDeath = "swimdeath";
|
mCurrentDeath = "swimdeath";
|
||||||
}
|
break;
|
||||||
else if (mHitState == CharState_KnockDown)
|
case CharState_DeathKnockDown:
|
||||||
{
|
|
||||||
mDeathState = CharState_DeathKnockDown;
|
|
||||||
mCurrentDeath = "deathknockdown";
|
mCurrentDeath = "deathknockdown";
|
||||||
}
|
break;
|
||||||
else if (mHitState == CharState_KnockOut)
|
case CharState_DeathKnockOut:
|
||||||
{
|
|
||||||
mDeathState = CharState_DeathKnockOut;
|
|
||||||
mCurrentDeath = "deathknockout";
|
mCurrentDeath = "deathknockout";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mCurrentDeath = "death" + Ogre::StringConverter::toString(death - CharState_Death1 + 1);
|
||||||
}
|
}
|
||||||
else
|
mDeathState = death;
|
||||||
{
|
|
||||||
int selected=0;
|
mPtr.getClass().getCreatureStats(mPtr).setDeathAnimation(mDeathState - CharState_Death1);
|
||||||
mCurrentDeath = chooseRandomGroup("death", &selected);
|
|
||||||
mDeathState = static_cast<CharacterState>(CharState_Death1 + (selected-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// For dead actors, refreshCurrentAnims is no longer called, so we need to disable the movement state manually.
|
// For dead actors, refreshCurrentAnims is no longer called, so we need to disable the movement state manually.
|
||||||
mMovementState = CharState_None;
|
mMovementState = CharState_None;
|
||||||
|
@ -440,6 +436,29 @@ void CharacterController::playRandomDeath(float startpoint)
|
||||||
false, 1.0f, "start", "stop", startpoint, 0);
|
false, 1.0f, "start", "stop", startpoint, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterController::playRandomDeath(float startpoint)
|
||||||
|
{
|
||||||
|
if(MWBase::Environment::get().getWorld()->isSwimming(mPtr) && mAnimation->hasAnimation("swimdeath"))
|
||||||
|
{
|
||||||
|
mDeathState = CharState_SwimDeath;
|
||||||
|
}
|
||||||
|
else if (mHitState == CharState_KnockDown)
|
||||||
|
{
|
||||||
|
mDeathState = CharState_DeathKnockDown;
|
||||||
|
}
|
||||||
|
else if (mHitState == CharState_KnockOut)
|
||||||
|
{
|
||||||
|
mDeathState = CharState_DeathKnockOut;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int selected=0;
|
||||||
|
chooseRandomGroup("death", &selected);
|
||||||
|
mDeathState = static_cast<CharacterState>(CharState_Death1 + (selected-1));
|
||||||
|
}
|
||||||
|
playDeath(startpoint, mDeathState);
|
||||||
|
}
|
||||||
|
|
||||||
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim)
|
CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim)
|
||||||
: mPtr(ptr)
|
: mPtr(ptr)
|
||||||
, mAnimation(anim)
|
, mAnimation(anim)
|
||||||
|
@ -497,7 +516,8 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
||||||
|
|
||||||
if(mDeathState != CharState_None)
|
if(mDeathState != CharState_None)
|
||||||
{
|
{
|
||||||
playRandomDeath(1.0f);
|
int deathindex = mPtr.getClass().getCreatureStats(mPtr).getDeathAnimation();
|
||||||
|
playDeath(1.0f, CharacterState(CharState_Death1 + deathindex));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
refreshCurrentAnims(mIdleState, mMovementState, true);
|
refreshCurrentAnims(mIdleState, mMovementState, true);
|
||||||
|
|
|
@ -181,6 +181,7 @@ class CharacterController
|
||||||
|
|
||||||
void updateVisibility();
|
void updateVisibility();
|
||||||
|
|
||||||
|
void playDeath(float startpoint, CharacterState death);
|
||||||
void playRandomDeath(float startpoint = 0.0f);
|
void playRandomDeath(float startpoint = 0.0f);
|
||||||
|
|
||||||
/// choose a random animation group with \a prefix and numeric suffix
|
/// choose a random animation group with \a prefix and numeric suffix
|
||||||
|
|
|
@ -22,7 +22,8 @@ namespace MWMechanics
|
||||||
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false),
|
mFallHeight(0), mRecalcDynamicStats(false), mKnockdown(false), mKnockdownOneFrame(false),
|
||||||
mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
|
mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
|
||||||
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f),
|
mMovementFlags(0), mDrawState (DrawState_Nothing), mAttackStrength(0.f),
|
||||||
mLastRestock(0,0), mGoldPool(0), mActorId(-1)
|
mLastRestock(0,0), mGoldPool(0), mActorId(-1),
|
||||||
|
mDeathAnimation(0)
|
||||||
{
|
{
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
mAiSettings[i] = 0;
|
mAiSettings[i] = 0;
|
||||||
|
@ -498,6 +499,7 @@ namespace MWMechanics
|
||||||
state.mDrawState = mDrawState;
|
state.mDrawState = mDrawState;
|
||||||
state.mLevel = mLevel;
|
state.mLevel = mLevel;
|
||||||
state.mActorId = mActorId;
|
state.mActorId = mActorId;
|
||||||
|
state.mDeathAnimation = mDeathAnimation;
|
||||||
|
|
||||||
mSpells.writeState(state.mSpells);
|
mSpells.writeState(state.mSpells);
|
||||||
mActiveSpells.writeState(state.mActiveSpells);
|
mActiveSpells.writeState(state.mActiveSpells);
|
||||||
|
@ -537,6 +539,7 @@ namespace MWMechanics
|
||||||
mDrawState = DrawState_(state.mDrawState);
|
mDrawState = DrawState_(state.mDrawState);
|
||||||
mLevel = state.mLevel;
|
mLevel = state.mLevel;
|
||||||
mActorId = state.mActorId;
|
mActorId = state.mActorId;
|
||||||
|
mDeathAnimation = state.mDeathAnimation;
|
||||||
|
|
||||||
mSpells.readState(state.mSpells);
|
mSpells.readState(state.mSpells);
|
||||||
mActiveSpells.readState(state.mActiveSpells);
|
mActiveSpells.readState(state.mActiveSpells);
|
||||||
|
@ -590,4 +593,14 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
esm.getHNT(sActorId, "COUN");
|
esm.getHNT(sActorId, "COUN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char CreatureStats::getDeathAnimation() const
|
||||||
|
{
|
||||||
|
return mDeathAnimation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreatureStats::setDeathAnimation(unsigned char index)
|
||||||
|
{
|
||||||
|
mDeathAnimation = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,9 @@ namespace MWMechanics
|
||||||
|
|
||||||
int mActorId;
|
int mActorId;
|
||||||
|
|
||||||
|
// The index of the death animation that was played
|
||||||
|
unsigned char mDeathAnimation;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// These two are only set by NpcStats, but they are declared in CreatureStats to prevent using virtual methods.
|
// These two are only set by NpcStats, but they are declared in CreatureStats to prevent using virtual methods.
|
||||||
bool mIsWerewolf;
|
bool mIsWerewolf;
|
||||||
|
@ -250,6 +253,9 @@ namespace MWMechanics
|
||||||
void setGoldPool(int pool);
|
void setGoldPool(int pool);
|
||||||
int getGoldPool() const;
|
int getGoldPool() const;
|
||||||
|
|
||||||
|
unsigned char getDeathAnimation() const;
|
||||||
|
void setDeathAnimation(unsigned char index);
|
||||||
|
|
||||||
int getActorId();
|
int getActorId();
|
||||||
///< Will generate an actor ID, if the actor does not have one yet.
|
///< Will generate an actor ID, if the actor does not have one yet.
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,9 @@ void ESM::CreatureStats::load (ESMReader &esm)
|
||||||
mActorId = -1;
|
mActorId = -1;
|
||||||
esm.getHNOT (mActorId, "ACID");
|
esm.getHNOT (mActorId, "ACID");
|
||||||
|
|
||||||
|
mDeathAnimation = 0;
|
||||||
|
esm.getHNOT (mDeathAnimation, "DANM");
|
||||||
|
|
||||||
mSpells.load(esm);
|
mSpells.load(esm);
|
||||||
mActiveSpells.load(esm);
|
mActiveSpells.load(esm);
|
||||||
}
|
}
|
||||||
|
@ -152,6 +155,9 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
|
||||||
if (mActorId != -1)
|
if (mActorId != -1)
|
||||||
esm.writeHNT ("ACID", mActorId);
|
esm.writeHNT ("ACID", mActorId);
|
||||||
|
|
||||||
|
if (mDeathAnimation)
|
||||||
|
esm.writeHNT ("DANM", mDeathAnimation);
|
||||||
|
|
||||||
mSpells.save(esm);
|
mSpells.save(esm);
|
||||||
mActiveSpells.save(esm);
|
mActiveSpells.save(esm);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace ESM
|
||||||
std::string mLastHitObject;
|
std::string mLastHitObject;
|
||||||
bool mRecalcDynamicStats;
|
bool mRecalcDynamicStats;
|
||||||
int mDrawState;
|
int mDrawState;
|
||||||
|
unsigned char mDeathAnimation;
|
||||||
|
|
||||||
int mLevel;
|
int mLevel;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue