change way animations keys are handled (thanks KittyCat!)

This commit is contained in:
gus 2013-07-15 16:37:25 +01:00
parent 3947f44aa3
commit 076f98cbba
4 changed files with 13 additions and 25 deletions

View file

@ -238,7 +238,7 @@ void CharacterController::update(float duration, Movement &movement)
} }
else if(!cls.getCreatureStats(mPtr).isDead()) else if(!cls.getCreatureStats(mPtr).isDead())
{ {
std::list<std::pair<std::string,std::string>> lastKeys = cls.getCreatureStats(mPtr).getLastAnimKey(); /*std::list<std::pair<std::string,std::string>> lastKeys = cls.getCreatureStats(mPtr).getLastAnimKey();
for(std::list<std::pair<std::string,std::string>>::iterator it = cls.getCreatureStats(mPtr).getLastAnimKey().begin(); for(std::list<std::pair<std::string,std::string>>::iterator it = cls.getCreatureStats(mPtr).getLastAnimKey().begin();
it!=cls.getCreatureStats(mPtr).getLastAnimKey().end();) it!=cls.getCreatureStats(mPtr).getLastAnimKey().end();)
{ {
@ -256,7 +256,7 @@ void CharacterController::update(float duration, Movement &movement)
if(lastKey.first.compare(off, len, "chop large follow stop") == 0){ mUpperBodyState = UpperCharState_WeapEquiped;std::cout << "FINISHED";} if(lastKey.first.compare(off, len, "chop large follow stop") == 0){ mUpperBodyState = UpperCharState_WeapEquiped;std::cout << "FINISHED";}
} }
it = cls.getCreatureStats(mPtr).getLastAnimKey().erase(it); it = cls.getCreatureStats(mPtr).getLastAnimKey().erase(it);
} }*/
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
@ -478,6 +478,7 @@ void CharacterController::update(float duration, Movement &movement)
if(mUpperBodyState == UpperCharState_WeapEquiped) if(mUpperBodyState == UpperCharState_WeapEquiped)
{ {
std::string weapgroup; std::string weapgroup;
std::cout << "attaquing";
getWeaponGroup(mWeaponType, weapgroup); getWeaponGroup(mWeaponType, weapgroup);
mAnimation->play(weapgroup, Priority_Weapon, mAnimation->play(weapgroup, Priority_Weapon,
MWRender::Animation::Group_UpperBody, true, MWRender::Animation::Group_UpperBody, true,
@ -490,6 +491,16 @@ void CharacterController::update(float duration, Movement &movement)
mUpperBodyState = UpperCharState_ChopReadying; mUpperBodyState = UpperCharState_ChopReadying;
} }
std::string weapgroup;
getWeaponGroup(mWeaponType, weapgroup);
std::string start;
std::string stop;
float complete;
bool animPlaying = mAnimation->getInfo(weapgroup,&complete,&start,&stop);
if(mUpperBodyState == UpperCharState_EquipingWeap && !animPlaying) mUpperBodyState = UpperCharState_WeapEquiped;
if(mUpperBodyState == UpperCharState_UnEquipingWeap && !animPlaying) mUpperBodyState = UpperCharState_Nothing;
if(mUpperBodyState == UpperCharState_ChopReadying && !animPlaying) mUpperBodyState = UpperCharState_WeapEquiped;
MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name()) if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name())
{ {

View file

@ -96,11 +96,6 @@ namespace MWMechanics
return mAttackingOrSpell; return mAttackingOrSpell;
} }
std::list<std::pair<std::string,std::string>> &CreatureStats::getLastAnimKey()
{
return mLastAnimKeys;
}
int CreatureStats::getLevel() const int CreatureStats::getLevel() const
{ {
return mLevel; return mLevel;
@ -207,12 +202,6 @@ namespace MWMechanics
mAttackingOrSpell = attackingOrSpell; mAttackingOrSpell = attackingOrSpell;
} }
/*void CreatureStats::setLastAnimKey(std::string key,std::string animGroup)
{
mLastAnimKey = key;
mLastAnimGroup = animGroup;
}*/
void CreatureStats::setAiSetting (int index, int value) void CreatureStats::setAiSetting (int index, int value)
{ {
assert (index>=0 && index<4); assert (index>=0 && index<4);

View file

@ -35,7 +35,6 @@ namespace MWMechanics
bool mAttacked; bool mAttacked;
bool mHostile; bool mHostile;
bool mAttackingOrSpell;//for the player, this is true if the left mouse button is pressed, false if not. bool mAttackingOrSpell;//for the player, this is true if the left mouse button is pressed, false if not.
std::list<std::pair<std::string,std::string>> mLastAnimKeys;
public: public:
CreatureStats(); CreatureStats();
@ -58,8 +57,6 @@ namespace MWMechanics
const bool & getAttackingOrSpell() const; const bool & getAttackingOrSpell() const;
std::list<std::pair<std::string,std::string>> & getLastAnimKey();
int getLevel() const; int getLevel() const;
int getAiSetting (int index) const; int getAiSetting (int index) const;
@ -91,8 +88,6 @@ namespace MWMechanics
void setAttackingOrSpell(const bool &attackingOrSpell); void setAttackingOrSpell(const bool &attackingOrSpell);
//void addLastAnimKey(std::string key,std::string animGroup);
void setLevel(int level); void setLevel(int level);
void setAiSetting (int index, int value); void setAiSetting (int index, int value);

View file

@ -15,11 +15,6 @@
#include "../mwmechanics/character.hpp" #include "../mwmechanics/character.hpp"
//TODO: remove that and create a class interface
#include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/class.hpp"
namespace MWRender namespace MWRender
{ {
@ -480,8 +475,6 @@ bool Animation::handleTextKey(AnimState &state, const std::string &groupname, co
return true; return true;
} }
MWWorld::Class::get(mPtr).getCreatureStats(mPtr).getLastAnimKey().push_back(std::pair<std::string,std::string>(key->second,groupname));
if(evt.compare(off, len, "equip attach") == 0) if(evt.compare(off, len, "equip attach") == 0)
{ {
showWeapons(true); showWeapons(true);