mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 07:23:54 +00:00
Porting old work
This commit is contained in:
parent
b17f383c6d
commit
3947f44aa3
6 changed files with 102 additions and 3 deletions
|
@ -20,6 +20,7 @@
|
|||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
#include "../mwgui/bookwindow.hpp"
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
using namespace ICS;
|
||||
|
||||
|
@ -498,6 +499,8 @@ namespace MWInput
|
|||
|
||||
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc));
|
||||
|
||||
MWWorld::Class::get(mPlayer.getPlayer()).getCreatureStats(mPlayer.getPlayer()).setAttackingOrSpell(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -509,7 +512,6 @@ namespace MWInput
|
|||
return true; // MyGUI has no use for these events
|
||||
|
||||
MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id));
|
||||
|
||||
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
|
||||
{
|
||||
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
|
||||
|
@ -519,6 +521,8 @@ namespace MWInput
|
|||
}
|
||||
}
|
||||
|
||||
MWWorld::Class::get(mPlayer.getPlayer()).getCreatureStats(mPlayer.getPlayer()).setAttackingOrSpell(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
|||
: mPtr(ptr)
|
||||
, mAnimation(anim)
|
||||
, mCharState(state)
|
||||
, mUpperBodyState(UpperCharState_Nothing)
|
||||
, mWeaponType(WeapType_None)
|
||||
, mSkipAnim(false)
|
||||
, mSecondsOfRunning(0)
|
||||
|
@ -237,6 +238,26 @@ void CharacterController::update(float duration, Movement &movement)
|
|||
}
|
||||
else if(!cls.getCreatureStats(mPtr).isDead())
|
||||
{
|
||||
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();
|
||||
it!=cls.getCreatureStats(mPtr).getLastAnimKey().end();)
|
||||
{
|
||||
std::cout << "NE";
|
||||
std::pair<std::string,std::string> lastKey = *it;
|
||||
if(!lastKey.first.empty())
|
||||
{
|
||||
std::cout << lastKey.first << " " << lastKey.second << " ";
|
||||
//const std::string &evt = key->second;
|
||||
size_t off = lastKey.second.size()+2;
|
||||
size_t len = lastKey.first.size() - off;
|
||||
|
||||
if(lastKey.first.compare(off, len, "equip stop") == 0) mUpperBodyState = UpperCharState_WeapEquiped;
|
||||
if(lastKey.first.compare(off, len, "unequip stop") == 0) mUpperBodyState = UpperCharState_Nothing;
|
||||
if(lastKey.first.compare(off, len, "chop large follow stop") == 0){ mUpperBodyState = UpperCharState_WeapEquiped;std::cout << "FINISHED";}
|
||||
}
|
||||
it = cls.getCreatureStats(mPtr).getLastAnimKey().erase(it);
|
||||
}
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
|
||||
bool onground = world->isOnGround(mPtr);
|
||||
|
@ -333,7 +354,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|||
mAnimQueue.pop_front();
|
||||
|
||||
mAnimation->play(mAnimQueue.front().first, Priority_Default,
|
||||
MWRender::Animation::Group_All, false,
|
||||
MWRender::Animation::Group_All, true,
|
||||
"start", "stop", 0.0f, mAnimQueue.front().second);
|
||||
}
|
||||
}
|
||||
|
@ -424,6 +445,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|||
mAnimation->play(weapgroup, Priority_Weapon,
|
||||
MWRender::Animation::Group_UpperBody, true,
|
||||
"unequip start", "unequip stop", 0.0f, 0);
|
||||
mUpperBodyState = UpperCharState_UnEquipingWeap;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -432,6 +454,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|||
mAnimation->play(weapgroup, Priority_Weapon,
|
||||
MWRender::Animation::Group_UpperBody, true,
|
||||
"equip start", "equip stop", 0.0f, 0);
|
||||
mUpperBodyState = UpperCharState_EquipingWeap;
|
||||
}
|
||||
|
||||
mWeaponType = weaptype;
|
||||
|
@ -450,6 +473,23 @@ void CharacterController::update(float duration, Movement &movement)
|
|||
}
|
||||
}
|
||||
|
||||
if(cls.getCreatureStats(mPtr).getAttackingOrSpell())
|
||||
{
|
||||
if(mUpperBodyState == UpperCharState_WeapEquiped)
|
||||
{
|
||||
std::string weapgroup;
|
||||
getWeaponGroup(mWeaponType, weapgroup);
|
||||
mAnimation->play(weapgroup, Priority_Weapon,
|
||||
MWRender::Animation::Group_UpperBody, true,
|
||||
"chop start", "chop large follow stop", 0.0f, 0);
|
||||
mUpperBodyState = UpperCharState_ChopReadyingMouseHold;
|
||||
}
|
||||
}
|
||||
else if(mUpperBodyState == UpperCharState_ChopReadyingMouseHold)
|
||||
{
|
||||
mUpperBodyState = UpperCharState_ChopReadying;
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreIterator torch = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
if(torch != inv.end() && torch->getTypeName() == typeid(ESM::Light).name())
|
||||
{
|
||||
|
|
|
@ -92,6 +92,21 @@ enum WeaponType {
|
|||
WeapType_Spell
|
||||
};
|
||||
|
||||
enum UpperBodyCharacterState {
|
||||
UpperCharState_Nothing,
|
||||
UpperCharState_EquipingWeap,
|
||||
UpperCharState_UnEquipingWeap,
|
||||
UpperCharState_WeapEquiped,
|
||||
UpperCharState_Slashing,
|
||||
UpperCharState_ChopReadying,
|
||||
UpperCharState_ChopReadyingMouseHold, //when you keep your mouse clicked to ready your weapon
|
||||
UpperCharState_ChopReadyWaiting, //when your weapon is ready and you keep mouse hold
|
||||
UpperCharState_Choping,
|
||||
UpperCharState_Thrusting,
|
||||
UpperCharState_EquipingSpell,
|
||||
UpperCharState_UnEquipingSpell
|
||||
};
|
||||
|
||||
class CharacterController
|
||||
{
|
||||
MWWorld::Ptr mPtr;
|
||||
|
@ -101,6 +116,7 @@ class CharacterController
|
|||
AnimationQueue mAnimQueue;
|
||||
|
||||
CharacterState mCharState;
|
||||
UpperBodyCharacterState mUpperBodyState;
|
||||
WeaponType mWeaponType;
|
||||
bool mSkipAnim;
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ namespace MWMechanics
|
|||
CreatureStats::CreatureStats()
|
||||
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mDied (false), mFriendlyHits (0),
|
||||
mTalkedTo (false), mAlarmed (false),
|
||||
mAttacked (false), mHostile (false)
|
||||
mAttacked (false), mHostile (false),
|
||||
mAttackingOrSpell(false)
|
||||
{
|
||||
for (int i=0; i<4; ++i)
|
||||
mAiSettings[i] = 0;
|
||||
|
@ -90,6 +91,16 @@ namespace MWMechanics
|
|||
return mMagicEffects;
|
||||
}
|
||||
|
||||
const bool &CreatureStats::getAttackingOrSpell() const
|
||||
{
|
||||
return mAttackingOrSpell;
|
||||
}
|
||||
|
||||
std::list<std::pair<std::string,std::string>> &CreatureStats::getLastAnimKey()
|
||||
{
|
||||
return mLastAnimKeys;
|
||||
}
|
||||
|
||||
int CreatureStats::getLevel() const
|
||||
{
|
||||
return mLevel;
|
||||
|
@ -191,6 +202,17 @@ namespace MWMechanics
|
|||
mMagicEffects = effects;
|
||||
}
|
||||
|
||||
void CreatureStats::setAttackingOrSpell(const bool &attackingOrSpell)
|
||||
{
|
||||
mAttackingOrSpell = attackingOrSpell;
|
||||
}
|
||||
|
||||
/*void CreatureStats::setLastAnimKey(std::string key,std::string animGroup)
|
||||
{
|
||||
mLastAnimKey = key;
|
||||
mLastAnimGroup = animGroup;
|
||||
}*/
|
||||
|
||||
void CreatureStats::setAiSetting (int index, int value)
|
||||
{
|
||||
assert (index>=0 && index<4);
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace MWMechanics
|
|||
bool mAlarmed;
|
||||
bool mAttacked;
|
||||
bool mHostile;
|
||||
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:
|
||||
CreatureStats();
|
||||
|
@ -54,6 +56,10 @@ namespace MWMechanics
|
|||
|
||||
const MagicEffects & getMagicEffects() const;
|
||||
|
||||
const bool & getAttackingOrSpell() const;
|
||||
|
||||
std::list<std::pair<std::string,std::string>> & getLastAnimKey();
|
||||
|
||||
int getLevel() const;
|
||||
|
||||
int getAiSetting (int index) const;
|
||||
|
@ -83,6 +89,10 @@ namespace MWMechanics
|
|||
|
||||
void setMagicEffects(const MagicEffects &effects);
|
||||
|
||||
void setAttackingOrSpell(const bool &attackingOrSpell);
|
||||
|
||||
//void addLastAnimKey(std::string key,std::string animGroup);
|
||||
|
||||
void setLevel(int level);
|
||||
|
||||
void setAiSetting (int index, int value);
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
|
||||
#include "../mwmechanics/character.hpp"
|
||||
|
||||
|
||||
//TODO: remove that and create a class interface
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
|
||||
|
@ -475,6 +480,8 @@ bool Animation::handleTextKey(AnimState &state, const std::string &groupname, co
|
|||
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)
|
||||
{
|
||||
showWeapons(true);
|
||||
|
|
Loading…
Reference in a new issue