diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 9534ecc904..36e59f6bd9 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -60,7 +60,7 @@ add_openmw_dir (mwclass add_openmw_dir (mwmechanics mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells - activespells + activespells npcstats ) add_openmw_dir (mwbase diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index d4f711885c..3a91ec63f5 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -233,7 +233,8 @@ namespace MWClass case Combat: - stats.mCombat = set; + // Combat stance ignored for now; need to be determined based on draw state instead of + // being maunally set. break; } } @@ -260,7 +261,7 @@ namespace MWClass case Combat: - return stats.mCombat; + return false; } return false; diff --git a/apps/openmw/mwinput/inputmanager.cpp b/apps/openmw/mwinput/inputmanager.cpp index a2bafcbf78..73cadacd0f 100644 --- a/apps/openmw/mwinput/inputmanager.cpp +++ b/apps/openmw/mwinput/inputmanager.cpp @@ -102,15 +102,15 @@ private: { if (windows.isGuiMode()) return; - DrawState state = player.getDrawState(); - if (state == DrawState_Weapon || state == DrawState_Nothing) + MWMechanics::DrawState state = player.getDrawState(); + if (state == MWMechanics::DrawState_Weapon || state == MWMechanics::DrawState_Nothing) { - player.setDrawState(DrawState_Spell); + player.setDrawState(MWMechanics::DrawState_Spell); std::cout << "Player has now readied his hands for spellcasting!\n"; } else { - player.setDrawState(DrawState_Nothing); + player.setDrawState(MWMechanics::DrawState_Nothing); std::cout << "Player does not have any kind of attack ready now.\n"; } } @@ -119,15 +119,15 @@ private: { if (windows.isGuiMode()) return; - DrawState state = player.getDrawState(); - if (state == DrawState_Spell || state == DrawState_Nothing) + MWMechanics::DrawState state = player.getDrawState(); + if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing) { - player.setDrawState(DrawState_Weapon); + player.setDrawState(MWMechanics::DrawState_Weapon); std::cout << "Player is now drawing his weapon.\n"; } else { - player.setDrawState(DrawState_Nothing); + player.setDrawState(MWMechanics::DrawState_Nothing); std::cout << "Player does not have any kind of attack ready now.\n"; } } @@ -336,7 +336,7 @@ private: poller.bind(A_MoveRight, KC_D); poller.bind(A_MoveForward, KC_W); poller.bind(A_MoveBackward, KC_S); - + poller.bind(A_Jump, KC_E); poller.bind(A_Crouch, KC_LCONTROL); } diff --git a/apps/openmw/mwmechanics/drawstate.hpp b/apps/openmw/mwmechanics/drawstate.hpp index 772086d90a..94b48fdd8e 100644 --- a/apps/openmw/mwmechanics/drawstate.hpp +++ b/apps/openmw/mwmechanics/drawstate.hpp @@ -3,11 +3,14 @@ #undef DrawState -enum DrawState +namespace MWMechanics { - DrawState_Weapon = 0, - DrawState_Spell = 1, - DrawState_Nothing = 2, -}; + enum DrawState + { + DrawState_Weapon = 0, + DrawState_Spell = 1, + DrawState_Nothing = 2, + }; +} #endif diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp new file mode 100644 index 0000000000..70db00bb75 --- /dev/null +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -0,0 +1,17 @@ + +#include "npcstats.hpp" + +MWMechanics::NpcStats::NpcStats() +: mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), + mDrawState (DrawState_Nothing) +{} + +MWMechanics::DrawState MWMechanics::NpcStats::getDrawState() const +{ + return mDrawState; +} + +void MWMechanics::NpcStats::setDrawState (DrawState state) +{ + mDrawState = state; +} diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 972863b728..c2907ccb54 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -3,6 +3,7 @@ #include #include +#include #include "stat.hpp" #include "drawstate.hpp" @@ -16,10 +17,14 @@ namespace MWMechanics /// \note For technical reasons the spell list and the currently selected spell is also handled by /// CreatureStats, even though they are actually NPC stats. - struct NpcStats + class NpcStats { - // NPCs other than the player can only have one faction. But for the sake of consistency - // we use the same data structure for the PC and the NPCs. + DrawState mDrawState; + + public: + + /// NPCs other than the player can only have one faction. But for the sake of consistency + /// we use the same data structure for the PC and the NPCs. /// \note the faction key must be in lowercase std::map mFactionRank; @@ -29,11 +34,12 @@ namespace MWMechanics bool mForceSneak; bool mRun; bool mSneak; - bool mCombat; - DrawState mDrawState; - NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false), - mCombat (false) , mDrawState(DrawState_Nothing) {} + NpcStats(); + + DrawState getDrawState() const; + + void setDrawState (DrawState state); }; } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 0eeebad4e4..d8b3285efc 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -56,10 +56,10 @@ namespace MWWorld mClass = new_class; } - void Player::setDrawState(const DrawState& value) + void Player::setDrawState (MWMechanics::DrawState state) { MWWorld::Ptr ptr = getPlayer(); - MWWorld::Class::get(ptr).getNpcStats(ptr).mDrawState = value; + MWWorld::Class::get(ptr).getNpcStats(ptr).setDrawState (state); } void Player::setAutoMove (bool enable) @@ -111,10 +111,10 @@ namespace MWWorld MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running); } - DrawState Player::getDrawState() + MWMechanics::DrawState Player::getDrawState() { MWWorld::Ptr ptr = getPlayer(); - return MWWorld::Class::get(ptr).getNpcStats(ptr).mDrawState; + return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState(); } } diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index b1692bd81a..2c87cf91b5 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -83,7 +83,7 @@ namespace MWWorld void setClass (const ESM::Class& class_); - void setDrawState(const DrawState& state); + void setDrawState (MWMechanics::DrawState state); std::string getName() const { @@ -115,7 +115,7 @@ namespace MWWorld return mAutoMove; } - DrawState getDrawState(); + MWMechanics::DrawState getDrawState(); /// \todo constness void setAutoMove (bool enable);