1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-29 00:06:43 +00:00

Fix attack after shoot

This commit is contained in:
Andrei Kortunov 2018-08-15 14:16:19 +04:00
parent dcd381049c
commit 8a48258b1b

View file

@ -1385,14 +1385,6 @@ bool CharacterController::updateWeaponState()
MWBase::Environment::get().getWorld()->breakInvisibility(mPtr); MWBase::Environment::get().getWorld()->breakInvisibility(mPtr);
mAttackStrength = 0; mAttackStrength = 0;
// Randomize attacks for non-bipedal creatures with Weapon flag
if (mPtr.getClass().getTypeName() == typeid(ESM::Creature).name() &&
!mPtr.getClass().isBipedal(mPtr) &&
(!mAnimation->hasAnimation(mCurrentWeapon) || isRandomAttackAnimation(mCurrentWeapon)))
{
mCurrentWeapon = chooseRandomAttackAnimation();
}
if(mWeaponType == WeapType_Spell) if(mWeaponType == WeapType_Spell)
{ {
// Unset casting flag, otherwise pressing the mouse button down would // Unset casting flag, otherwise pressing the mouse button down would
@ -1401,15 +1393,10 @@ bool CharacterController::updateWeaponState()
if (mPtr == player) if (mPtr == player)
{ {
MWBase::Environment::get().getWorld()->getPlayer().setAttackingOrSpell(false); MWBase::Environment::get().getWorld()->getPlayer().setAttackingOrSpell(false);
}
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); // For the player, set the spell we want to cast
// This has to be done at the start of the casting animation,
// For the player, set the spell we want to cast // *not* when selecting a spell in the GUI (otherwise you could change the spell mid-animation)
// This has to be done at the start of the casting animation,
// *not* when selecting a spell in the GUI (otherwise you could change the spell mid-animation)
if (mPtr == player)
{
std::string selectedSpell = MWBase::Environment::get().getWindowManager()->getSelectedSpell(); std::string selectedSpell = MWBase::Environment::get().getWindowManager()->getSelectedSpell();
stats.getSpells().setSelectedSpell(selectedSpell); stats.getSpells().setSelectedSpell(selectedSpell);
} }
@ -1421,6 +1408,7 @@ bool CharacterController::updateWeaponState()
MWMechanics::CastSpell cast(mPtr, NULL, false, mCastingManualSpell); MWMechanics::CastSpell cast(mPtr, NULL, false, mCastingManualSpell);
cast.playSpellCastingEffects(spellid); cast.playSpellCastingEffects(spellid);
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
const ESM::Spell *spell = store.get<ESM::Spell>().find(spellid); const ESM::Spell *spell = store.get<ESM::Spell>().find(spellid);
const ESM::ENAMstruct &lastEffect = spell->mEffects.mList.back(); const ESM::ENAMstruct &lastEffect = spell->mEffects.mList.back();
const ESM::MagicEffect *effect; const ESM::MagicEffect *effect;
@ -1520,13 +1508,12 @@ bool CharacterController::updateWeaponState()
startKey = mAttackType+" start"; startKey = mAttackType+" start";
stopKey = mAttackType+" min attack"; stopKey = mAttackType+" min attack";
} }
else if (isRandomAttackAnimation(mCurrentWeapon))
if (isRandomAttackAnimation(mCurrentWeapon))
{ {
startKey = "start"; startKey = "start";
stopKey = "stop"; stopKey = "stop";
} }
else if (mAttackType != "shoot") else
{ {
if(mPtr == getPlayer()) if(mPtr == getPlayer())
{ {