mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 11:15:39 +00:00
Merge remote-tracking branch 'scrawl/master'
This commit is contained in:
commit
9e21da9636
10 changed files with 87 additions and 36 deletions
|
@ -407,29 +407,25 @@ MWWorld::ContainerStoreIterator getActiveWeapon(CreatureStats &stats, MWWorld::I
|
|||
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";
|
||||
}
|
||||
else if (mHitState == CharState_KnockDown)
|
||||
{
|
||||
mDeathState = CharState_DeathKnockDown;
|
||||
break;
|
||||
case CharState_DeathKnockDown:
|
||||
mCurrentDeath = "deathknockdown";
|
||||
}
|
||||
else if (mHitState == CharState_KnockOut)
|
||||
{
|
||||
mDeathState = CharState_DeathKnockOut;
|
||||
break;
|
||||
case CharState_DeathKnockOut:
|
||||
mCurrentDeath = "deathknockout";
|
||||
break;
|
||||
default:
|
||||
mCurrentDeath = "death" + Ogre::StringConverter::toString(death - CharState_Death1 + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int selected=0;
|
||||
mCurrentDeath = chooseRandomGroup("death", &selected);
|
||||
mDeathState = static_cast<CharacterState>(CharState_Death1 + (selected-1));
|
||||
}
|
||||
mDeathState = death;
|
||||
|
||||
mPtr.getClass().getCreatureStats(mPtr).setDeathAnimation(mDeathState - CharState_Death1);
|
||||
|
||||
// For dead actors, refreshCurrentAnims is no longer called, so we need to disable the movement state manually.
|
||||
mMovementState = CharState_None;
|
||||
|
@ -440,6 +436,29 @@ void CharacterController::playRandomDeath(float startpoint)
|
|||
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)
|
||||
: mPtr(ptr)
|
||||
, mAnimation(anim)
|
||||
|
@ -497,7 +516,8 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
|||
|
||||
if(mDeathState != CharState_None)
|
||||
{
|
||||
playRandomDeath(1.0f);
|
||||
int deathindex = mPtr.getClass().getCreatureStats(mPtr).getDeathAnimation();
|
||||
playDeath(1.0f, CharacterState(CharState_Death1 + deathindex));
|
||||
}
|
||||
else
|
||||
refreshCurrentAnims(mIdleState, mMovementState, true);
|
||||
|
|
|
@ -181,6 +181,7 @@ class CharacterController
|
|||
|
||||
void updateVisibility();
|
||||
|
||||
void playDeath(float startpoint, CharacterState death);
|
||||
void playRandomDeath(float startpoint = 0.0f);
|
||||
|
||||
/// 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),
|
||||
mKnockdownOverOneFrame(false), mHitRecovery(false), mBlock(false),
|
||||
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)
|
||||
mAiSettings[i] = 0;
|
||||
|
@ -498,6 +499,7 @@ namespace MWMechanics
|
|||
state.mDrawState = mDrawState;
|
||||
state.mLevel = mLevel;
|
||||
state.mActorId = mActorId;
|
||||
state.mDeathAnimation = mDeathAnimation;
|
||||
|
||||
mSpells.writeState(state.mSpells);
|
||||
mActiveSpells.writeState(state.mActiveSpells);
|
||||
|
@ -537,6 +539,7 @@ namespace MWMechanics
|
|||
mDrawState = DrawState_(state.mDrawState);
|
||||
mLevel = state.mLevel;
|
||||
mActorId = state.mActorId;
|
||||
mDeathAnimation = state.mDeathAnimation;
|
||||
|
||||
mSpells.readState(state.mSpells);
|
||||
mActiveSpells.readState(state.mActiveSpells);
|
||||
|
@ -590,4 +593,14 @@ namespace MWMechanics
|
|||
{
|
||||
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;
|
||||
|
||||
// The index of the death animation that was played
|
||||
unsigned char mDeathAnimation;
|
||||
|
||||
protected:
|
||||
// These two are only set by NpcStats, but they are declared in CreatureStats to prevent using virtual methods.
|
||||
bool mIsWerewolf;
|
||||
|
@ -250,6 +253,9 @@ namespace MWMechanics
|
|||
void setGoldPool(int pool);
|
||||
int getGoldPool() const;
|
||||
|
||||
unsigned char getDeathAnimation() const;
|
||||
void setDeathAnimation(unsigned char index);
|
||||
|
||||
int getActorId();
|
||||
///< Will generate an actor ID, if the actor does not have one yet.
|
||||
|
||||
|
|
|
@ -54,17 +54,12 @@ void Actors::insertBegin(const MWWorld::Ptr &ptr)
|
|||
// Convert MW rotation to a quaternion:
|
||||
f = ptr.getCellRef().getPosition().rot;
|
||||
|
||||
// Rotate around X axis
|
||||
Ogre::Quaternion xr(Ogre::Radian(-f[0]), Ogre::Vector3::UNIT_X);
|
||||
|
||||
// Rotate around Y axis
|
||||
Ogre::Quaternion yr(Ogre::Radian(-f[1]), Ogre::Vector3::UNIT_Y);
|
||||
|
||||
// Rotate around Z axis
|
||||
// For rendering purposes, actors should only rotate around the Z axis.
|
||||
// X rotation is used for camera rotation (for the player) and for
|
||||
// ranged magic / ranged weapon aiming.
|
||||
Ogre::Quaternion zr(Ogre::Radian(-f[2]), Ogre::Vector3::UNIT_Z);
|
||||
|
||||
// Rotates first around z, then y, then x
|
||||
insert->setOrientation(xr*yr*zr);
|
||||
insert->setOrientation(zr);
|
||||
ptr.getRefData().setBaseNode(insert);
|
||||
}
|
||||
|
||||
|
|
|
@ -775,11 +775,11 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
|
|||
}
|
||||
|
||||
/* Look in reverse; last-inserted source has priority. */
|
||||
AnimState state;
|
||||
AnimSourceList::reverse_iterator iter(mAnimSources.rbegin());
|
||||
for(;iter != mAnimSources.rend();++iter)
|
||||
{
|
||||
const NifOgre::TextKeyMap &textkeys = (*iter)->mTextKeys;
|
||||
AnimState state;
|
||||
if(reset(state, textkeys, groupname, start, stop, startpoint))
|
||||
{
|
||||
state.mSource = *iter;
|
||||
|
@ -821,6 +821,13 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
|
|||
std::cerr<< "Failed to find animation "<<groupname<<" for "<<mPtr.getCellRef().getRefId() <<std::endl;
|
||||
|
||||
resetActiveGroups();
|
||||
|
||||
if (!state.mPlaying && mNonAccumCtrl)
|
||||
{
|
||||
// If the animation state is not playing, we need to manually apply the accumulation
|
||||
// (see updatePosition, which would be called if the animation was playing)
|
||||
mAccumRoot->setPosition(-mNonAccumCtrl->getTranslation(state.mTime)*mAccumulate);
|
||||
}
|
||||
}
|
||||
|
||||
bool Animation::isPlaying(const std::string &groupname) const
|
||||
|
|
|
@ -33,12 +33,12 @@ void ESMStore::load(ESM::ESMReader &esm, Loading::Listener* listener)
|
|||
// Cache parent esX files by tracking their indices in the global list of
|
||||
// all files/readers used by the engine. This will greaty accelerate
|
||||
// refnumber mangling, as required for handling moved references.
|
||||
int index = ~0;
|
||||
const std::vector<ESM::Header::MasterData> &masters = esm.getGameFiles();
|
||||
std::vector<ESM::ESMReader> *allPlugins = esm.getGlobalReaderList();
|
||||
for (size_t j = 0; j < masters.size(); j++) {
|
||||
ESM::Header::MasterData &mast = const_cast<ESM::Header::MasterData&>(masters[j]);
|
||||
std::string fname = mast.name;
|
||||
int index = ~0;
|
||||
for (int i = 0; i < esm.getIndex(); i++) {
|
||||
const std::string &candidate = allPlugins->at(i).getContext().filename;
|
||||
std::string fnamecandidate = boost::filesystem::path(candidate).filename().string();
|
||||
|
|
|
@ -1116,13 +1116,15 @@ namespace MWWorld
|
|||
while(ptr.getRefData().getLocalRotation().rot[2]<=-fullRotateRad)
|
||||
ptr.getRefData().getLocalRotation().rot[2]+=fullRotateRad;
|
||||
|
||||
Ogre::Quaternion worldRotQuat(Ogre::Quaternion(Ogre::Radian(ptr.getRefData().getPosition().rot[0]), Ogre::Vector3::NEGATIVE_UNIT_X)*
|
||||
Ogre::Quaternion(Ogre::Radian(ptr.getRefData().getPosition().rot[1]), Ogre::Vector3::NEGATIVE_UNIT_Y)*
|
||||
Ogre::Quaternion(Ogre::Radian(ptr.getRefData().getPosition().rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z));
|
||||
Ogre::Quaternion worldRotQuat(Ogre::Radian(ptr.getRefData().getPosition().rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z);
|
||||
if (!ptr.getClass().isActor())
|
||||
worldRotQuat = Ogre::Quaternion(Ogre::Radian(ptr.getRefData().getPosition().rot[0]), Ogre::Vector3::NEGATIVE_UNIT_X)*
|
||||
Ogre::Quaternion(Ogre::Radian(ptr.getRefData().getPosition().rot[1]), Ogre::Vector3::NEGATIVE_UNIT_Y)* worldRotQuat;
|
||||
|
||||
Ogre::Quaternion rot(Ogre::Quaternion(Ogre::Degree(x), Ogre::Vector3::NEGATIVE_UNIT_X)*
|
||||
Ogre::Quaternion(Ogre::Degree(y), Ogre::Vector3::NEGATIVE_UNIT_Y)*
|
||||
Ogre::Quaternion(Ogre::Degree(z), Ogre::Vector3::NEGATIVE_UNIT_Z));
|
||||
Ogre::Quaternion rot(Ogre::Degree(z), Ogre::Vector3::NEGATIVE_UNIT_Z);
|
||||
if (!ptr.getClass().isActor())
|
||||
rot = Ogre::Quaternion(Ogre::Degree(x), Ogre::Vector3::NEGATIVE_UNIT_X)*
|
||||
Ogre::Quaternion(Ogre::Degree(y), Ogre::Vector3::NEGATIVE_UNIT_Y)*rot;
|
||||
|
||||
ptr.getRefData().getBaseNode()->setOrientation(worldRotQuat*rot);
|
||||
mPhysics->rotateObject(ptr);
|
||||
|
|
|
@ -74,6 +74,9 @@ void ESM::CreatureStats::load (ESMReader &esm)
|
|||
mActorId = -1;
|
||||
esm.getHNOT (mActorId, "ACID");
|
||||
|
||||
mDeathAnimation = 0;
|
||||
esm.getHNOT (mDeathAnimation, "DANM");
|
||||
|
||||
mSpells.load(esm);
|
||||
mActiveSpells.load(esm);
|
||||
}
|
||||
|
@ -152,6 +155,9 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
|
|||
if (mActorId != -1)
|
||||
esm.writeHNT ("ACID", mActorId);
|
||||
|
||||
if (mDeathAnimation)
|
||||
esm.writeHNT ("DANM", mDeathAnimation);
|
||||
|
||||
mSpells.save(esm);
|
||||
mActiveSpells.save(esm);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace ESM
|
|||
std::string mLastHitObject;
|
||||
bool mRecalcDynamicStats;
|
||||
int mDrawState;
|
||||
unsigned char mDeathAnimation;
|
||||
|
||||
int mLevel;
|
||||
|
||||
|
|
Loading…
Reference in a new issue