mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-13 21:40:11 +00:00
Porting old work
This commit is contained in:
parent
b17f383c6d
commit
3947f44aa3
@ -20,6 +20,7 @@
|
|||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
#include "../mwgui/bookwindow.hpp"
|
#include "../mwgui/bookwindow.hpp"
|
||||||
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
|
|
||||||
using namespace ICS;
|
using namespace ICS;
|
||||||
|
|
||||||
@ -498,6 +499,8 @@ namespace MWInput
|
|||||||
|
|
||||||
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc));
|
MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc));
|
||||||
|
|
||||||
|
MWWorld::Class::get(mPlayer.getPlayer()).getCreatureStats(mPlayer.getPlayer()).setAttackingOrSpell(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +512,6 @@ namespace MWInput
|
|||||||
return true; // MyGUI has no use for these events
|
return true; // MyGUI has no use for these events
|
||||||
|
|
||||||
MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id));
|
MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI(id));
|
||||||
|
|
||||||
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
|
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
|
||||||
{
|
{
|
||||||
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +175,7 @@ CharacterController::CharacterController(const MWWorld::Ptr &ptr, MWRender::Anim
|
|||||||
: mPtr(ptr)
|
: mPtr(ptr)
|
||||||
, mAnimation(anim)
|
, mAnimation(anim)
|
||||||
, mCharState(state)
|
, mCharState(state)
|
||||||
|
, mUpperBodyState(UpperCharState_Nothing)
|
||||||
, mWeaponType(WeapType_None)
|
, mWeaponType(WeapType_None)
|
||||||
, mSkipAnim(false)
|
, mSkipAnim(false)
|
||||||
, mSecondsOfRunning(0)
|
, mSecondsOfRunning(0)
|
||||||
@ -237,6 +238,26 @@ 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();
|
||||||
|
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();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
bool onground = world->isOnGround(mPtr);
|
bool onground = world->isOnGround(mPtr);
|
||||||
@ -333,7 +354,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|||||||
mAnimQueue.pop_front();
|
mAnimQueue.pop_front();
|
||||||
|
|
||||||
mAnimation->play(mAnimQueue.front().first, Priority_Default,
|
mAnimation->play(mAnimQueue.front().first, Priority_Default,
|
||||||
MWRender::Animation::Group_All, false,
|
MWRender::Animation::Group_All, true,
|
||||||
"start", "stop", 0.0f, mAnimQueue.front().second);
|
"start", "stop", 0.0f, mAnimQueue.front().second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,6 +445,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|||||||
mAnimation->play(weapgroup, Priority_Weapon,
|
mAnimation->play(weapgroup, Priority_Weapon,
|
||||||
MWRender::Animation::Group_UpperBody, true,
|
MWRender::Animation::Group_UpperBody, true,
|
||||||
"unequip start", "unequip stop", 0.0f, 0);
|
"unequip start", "unequip stop", 0.0f, 0);
|
||||||
|
mUpperBodyState = UpperCharState_UnEquipingWeap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -432,6 +454,7 @@ void CharacterController::update(float duration, Movement &movement)
|
|||||||
mAnimation->play(weapgroup, Priority_Weapon,
|
mAnimation->play(weapgroup, Priority_Weapon,
|
||||||
MWRender::Animation::Group_UpperBody, true,
|
MWRender::Animation::Group_UpperBody, true,
|
||||||
"equip start", "equip stop", 0.0f, 0);
|
"equip start", "equip stop", 0.0f, 0);
|
||||||
|
mUpperBodyState = UpperCharState_EquipingWeap;
|
||||||
}
|
}
|
||||||
|
|
||||||
mWeaponType = weaptype;
|
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);
|
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())
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,21 @@ enum WeaponType {
|
|||||||
WeapType_Spell
|
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
|
class CharacterController
|
||||||
{
|
{
|
||||||
MWWorld::Ptr mPtr;
|
MWWorld::Ptr mPtr;
|
||||||
@ -101,6 +116,7 @@ class CharacterController
|
|||||||
AnimationQueue mAnimQueue;
|
AnimationQueue mAnimQueue;
|
||||||
|
|
||||||
CharacterState mCharState;
|
CharacterState mCharState;
|
||||||
|
UpperBodyCharacterState mUpperBodyState;
|
||||||
WeaponType mWeaponType;
|
WeaponType mWeaponType;
|
||||||
bool mSkipAnim;
|
bool mSkipAnim;
|
||||||
|
|
||||||
|
@ -12,7 +12,8 @@ namespace MWMechanics
|
|||||||
CreatureStats::CreatureStats()
|
CreatureStats::CreatureStats()
|
||||||
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mDied (false), mFriendlyHits (0),
|
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mDied (false), mFriendlyHits (0),
|
||||||
mTalkedTo (false), mAlarmed (false),
|
mTalkedTo (false), mAlarmed (false),
|
||||||
mAttacked (false), mHostile (false)
|
mAttacked (false), mHostile (false),
|
||||||
|
mAttackingOrSpell(false)
|
||||||
{
|
{
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
mAiSettings[i] = 0;
|
mAiSettings[i] = 0;
|
||||||
@ -90,6 +91,16 @@ namespace MWMechanics
|
|||||||
return mMagicEffects;
|
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
|
int CreatureStats::getLevel() const
|
||||||
{
|
{
|
||||||
return mLevel;
|
return mLevel;
|
||||||
@ -191,6 +202,17 @@ namespace MWMechanics
|
|||||||
mMagicEffects = effects;
|
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)
|
void CreatureStats::setAiSetting (int index, int value)
|
||||||
{
|
{
|
||||||
assert (index>=0 && index<4);
|
assert (index>=0 && index<4);
|
||||||
|
@ -34,6 +34,8 @@ namespace MWMechanics
|
|||||||
bool mAlarmed;
|
bool mAlarmed;
|
||||||
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.
|
||||||
|
std::list<std::pair<std::string,std::string>> mLastAnimKeys;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CreatureStats();
|
CreatureStats();
|
||||||
@ -54,6 +56,10 @@ namespace MWMechanics
|
|||||||
|
|
||||||
const MagicEffects & getMagicEffects() const;
|
const MagicEffects & getMagicEffects() 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;
|
||||||
@ -83,6 +89,10 @@ namespace MWMechanics
|
|||||||
|
|
||||||
void setMagicEffects(const MagicEffects &effects);
|
void setMagicEffects(const MagicEffects &effects);
|
||||||
|
|
||||||
|
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);
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
|
|
||||||
#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
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -475,6 +480,8 @@ 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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user