Use the correct slash, chop or thrust animation

actorid
scrawl 12 years ago
parent 9043fe427f
commit 91e95e1404

@ -91,6 +91,7 @@ namespace MWGui
WindowBase("openmw_settings_window.layout")
{
getWidget(mOkButton, "OkButton");
getWidget(mBestAttackButton, "BestAttackButton");
getWidget(mSubtitlesButton, "SubtitlesButton");
getWidget(mCrosshairButton, "CrosshairButton");
getWidget(mResolutionList, "ResolutionList");
@ -131,6 +132,7 @@ namespace MWGui
mSubtitlesButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mCrosshairButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mBestAttackButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mInvertYButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled);
@ -200,6 +202,7 @@ namespace MWGui
mSubtitlesButton->setCaptionWithReplacing(Settings::Manager::getBool("subtitles", "GUI") ? "#{sOn}" : "#{sOff}");
mCrosshairButton->setCaptionWithReplacing(Settings::Manager::getBool("crosshair", "HUD") ? "#{sOn}" : "#{sOff}");
mBestAttackButton->setCaptionWithReplacing(Settings::Manager::getBool("best attack", "Game") ? "#{sOn}" : "#{sOff}");
float fovVal = (Settings::Manager::getFloat("field of view", "General")-sFovMin)/(sFovMax-sFovMin);
mFOVSlider->setScrollPosition(fovVal * (mFOVSlider->getScrollRange()-1));
@ -407,6 +410,8 @@ namespace MWGui
Settings::Manager::setBool("crosshair", "HUD", newState);
else if (_sender == mSubtitlesButton)
Settings::Manager::setBool("subtitles", "GUI", newState);
else if (_sender == mBestAttackButton)
Settings::Manager::setBool("best attack", "Game", newState);
apply();
}

@ -32,6 +32,7 @@ namespace MWGui
MyGUI::ScrollBar* mToolTipDelaySlider;
MyGUI::Button* mSubtitlesButton;
MyGUI::Button* mCrosshairButton;
MyGUI::Button* mBestAttackButton;
// graphics
MyGUI::ListBox* mResolutionList;

@ -165,6 +165,20 @@ namespace MWInput
if (action == A_Use)
{
MWWorld::Class::get(mPlayer.getPlayer()).getCreatureStats(mPlayer.getPlayer()).setAttackingOrSpell(currentValue);
if (currentValue == 1)
{
int type = MWMechanics::CreatureStats::AT_Chop;
bool forward = (mInputBinder->getChannel(A_MoveForward)->getValue() > 0
|| mInputBinder->getChannel(A_MoveBackward)->getValue() > 0);
bool side = (mInputBinder->getChannel(A_MoveLeft)->getValue() > 0
|| mInputBinder->getChannel(A_MoveRight)->getValue() > 0);
if (side && !forward)
type = MWMechanics::CreatureStats::AT_Slash;
if (forward && !side)
type = MWMechanics::CreatureStats::AT_Thrust;
MWWorld::Class::get(mPlayer.getPlayer()).getCreatureStats(mPlayer.getPlayer()).setAttackType(type);
}
}
if (currentValue == 1)

@ -35,6 +35,23 @@
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
namespace
{
int getBestAttack (const ESM::Weapon* weapon)
{
int slash = (weapon->mData.mSlash[0] + weapon->mData.mSlash[1])/2;
int chop = (weapon->mData.mChop[0] + weapon->mData.mChop[1])/2;
int thrust = (weapon->mData.mThrust[0] + weapon->mData.mThrust[1])/2;
if (slash >= chop && slash >= thrust)
return MWMechanics::CreatureStats::AT_Slash;
else if (chop >= slash && chop >= thrust)
return MWMechanics::CreatureStats::AT_Chop;
else
return MWMechanics::CreatureStats::AT_Thrust;
}
}
namespace MWMechanics
{
@ -540,13 +557,25 @@ void CharacterController::update(float duration, Movement &movement)
float complete;
float speedMult;
bool animPlaying = mAnimation->getInfo(weapgroup,&complete,&speedMult,&start,&stop);
if(cls.getCreatureStats(mPtr).getAttackingOrSpell())
{
if(mUpperBodyState == UpperCharState_WeapEquiped)
{
int attackType = cls.getCreatureStats(mPtr).getAttackType();
if (Settings::Manager::getBool("best attack", "Game") && weapon != inv.end())
attackType = getBestAttack(weapon->get<ESM::Weapon>()->mBase);
if (attackType == MWMechanics::CreatureStats::AT_Chop)
mAttackType = "chop";
else if (attackType == MWMechanics::CreatureStats::AT_Slash)
mAttackType = "slash";
else
mAttackType = "thrust";
mAnimation->play(weapgroup, Priority_Weapon,
MWRender::Animation::Group_UpperBody, false,
weapSpeed,"chop start", "chop min attack", 0.0f, 0);
weapSpeed, mAttackType+" start", mAttackType+" min attack", 0.0f, 0);
mUpperBodyState = UpperCharState_ChopStartToMinAttack;
}
}
@ -557,13 +586,13 @@ void CharacterController::update(float duration, Movement &movement)
mAnimation->disable(weapgroup);
mAnimation->play(weapgroup, Priority_Weapon,
MWRender::Animation::Group_UpperBody, false,
weapSpeed,"chop max attack", "chop min hit", 1-complete, 0);
weapSpeed, mAttackType+" max attack", mAttackType+" min hit", 1-complete, 0);
}
else
{
mAnimation->play(weapgroup, Priority_Weapon,
MWRender::Animation::Group_UpperBody, false,
weapSpeed,"chop max attack", "chop min hit", 0, 0);
weapSpeed, mAttackType+" max attack", mAttackType+" min hit", 0, 0);
}
mUpperBodyState = UpperCharState_ChopMaxAttackToMinHit;
}
@ -577,7 +606,7 @@ void CharacterController::update(float duration, Movement &movement)
mAnimation->disable(weapgroup);
mAnimation->play(weapgroup, Priority_Weapon,
MWRender::Animation::Group_UpperBody, false,
weapSpeed,"chop min attack", "chop max attack",0, 0);
weapSpeed, mAttackType+" min attack", mAttackType+" max attack",0, 0);
mUpperBodyState = UpperCharState_ChopMinAttackToMaxAttack;
}
else if(mUpperBodyState == UpperCharState_ChopMaxAttackToMinHit && complete == 1)
@ -585,7 +614,7 @@ void CharacterController::update(float duration, Movement &movement)
mAnimation->disable(weapgroup);
mAnimation->play(weapgroup, Priority_Weapon,
MWRender::Animation::Group_UpperBody, false,
weapSpeed,"chop min hit", "chop hit",0, 0);
weapSpeed, mAttackType+" min hit", mAttackType+" hit",0, 0);
mUpperBodyState = UpperCharState_ChopMinHitToHit;
}
else if(mUpperBodyState == UpperCharState_ChopMinHitToHit && complete == 1)
@ -593,7 +622,7 @@ void CharacterController::update(float duration, Movement &movement)
mAnimation->disable(weapgroup);
mAnimation->play(weapgroup, Priority_Weapon,
MWRender::Animation::Group_UpperBody, false,
weapSpeed,"chop large follow start", "chop large follow stop",0, 0);
weapSpeed, mAttackType+" large follow start", mAttackType+" large follow stop",0, 0);
mUpperBodyState = UpperCharState_ChopLargeFollowStartToLargeFollowStop;
}
else if(mUpperBodyState == UpperCharState_ChopLargeFollowStartToLargeFollowStop && complete == 1)

@ -146,6 +146,8 @@ class CharacterController
float mSecondsOfSwimming;
float mSecondsOfRunning;
std::string mAttackType; // slash, chop or thrust
void refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force=false);
static void getWeaponGroup(WeaponType weaptype, std::string &group);

@ -36,6 +36,8 @@ namespace MWMechanics
bool mHostile;
bool mAttackingOrSpell;//for the player, this is true if the left mouse button is pressed, false if not.
int mAttackType;
public:
CreatureStats();
@ -88,6 +90,15 @@ namespace MWMechanics
void setAttackingOrSpell(const bool &attackingOrSpell);
enum AttackType
{
AT_Slash,
AT_Thrust,
AT_Chop
};
void setAttackType(int attackType) { mAttackType = attackType; }
int getAttackType() { return mAttackType; }
void setLevel(int level);
void setAiSetting (int index, int value);

@ -654,7 +654,7 @@ void Animation::resetActiveGroups()
return;
const Ogre::SharedPtr<AnimSource> &animsrc = state->second.mSource;
const NifOgre::TextKeyMap &keys = animsrc->mTextKeys;
//const NifOgre::TextKeyMap &keys = animsrc->mTextKeys;
const std::vector<Ogre::Controller<Ogre::Real> >&ctrls = animsrc->mControllers[0];
for(size_t i = 0;i < ctrls.size();i++)
{

@ -44,6 +44,12 @@
<Property key="TextAlign" value="Right"/>
</Widget>
<Widget type="HBox" skin="" position="4 170 260 24">
<Widget type="AutoSizedButton" skin="MW_Button" align="Left Top" name="BestAttackButton"/>
<Widget type="AutoSizedTextBox" skin="SandText" align="Left Top">
<Property key="Caption" value="#{sBestAttack}"/>
</Widget>
</Widget>
<Widget type="HBox" skin="" position="4 200 260 24">
<Widget type="AutoSizedButton" skin="MW_Button" align="Left Top" name="SubtitlesButton"/>

@ -163,3 +163,7 @@ ui sensitivity = 1.0
camera y multiplier = 1.0
ui y multiplier = 1.0
[Game]
# Always use the most powerful attack when striking with a weapon (chop, slash or thrust)
best attack = false

Loading…
Cancel
Save