mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:56:43 +00:00 
			
		
		
		
	Detangle attack start, knockdown attack cancel and on-going wind-up logic
This commit is contained in:
		
							parent
							
								
									8f280c521c
								
							
						
					
					
						commit
						09141388ad
					
				
					 1 changed files with 25 additions and 25 deletions
				
			
		| 
						 | 
					@ -1579,19 +1579,30 @@ bool CharacterController::updateWeaponState()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            resetCurrentIdleState();
 | 
					            resetCurrentIdleState();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!animPlaying)
 | 
					 | 
				
			||||||
            animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
 | 
					 | 
				
			||||||
        if (mUpperBodyState == UpperBodyState::AttackWindUp && !isKnockedDown())
 | 
					 | 
				
			||||||
            mAttackStrength = complete;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					
 | 
				
			||||||
    {
 | 
					    if (!animPlaying)
 | 
				
			||||||
        animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
 | 
					        animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
 | 
				
			||||||
        if (mUpperBodyState == UpperBodyState::AttackWindUp && !isKnockedDown())
 | 
					
 | 
				
			||||||
 | 
					    if (isKnockedDown())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (mUpperBodyState > UpperBodyState::WeaponEquipped)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            mUpperBodyState = UpperBodyState::WeaponEquipped;
 | 
				
			||||||
 | 
					            if (mWeaponType > ESM::Weapon::None)
 | 
				
			||||||
 | 
					                mAnimation->showWeapons(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if (!mCurrentWeapon.empty())
 | 
				
			||||||
 | 
					            mAnimation->disable(mCurrentWeapon);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (mUpperBodyState == UpperBodyState::AttackWindUp)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        mAttackStrength = complete;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!getAttackingOrSpell())
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            world->breakInvisibility(mPtr);
 | 
					            world->breakInvisibility(mPtr);
 | 
				
			||||||
            float attackStrength = complete;
 | 
					 | 
				
			||||||
            float minAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon+": "+mAttackType+" "+"min attack");
 | 
					            float minAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon+": "+mAttackType+" "+"min attack");
 | 
				
			||||||
            float maxAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon+": "+mAttackType+" "+"max attack");
 | 
					            float maxAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon+": "+mAttackType+" "+"max attack");
 | 
				
			||||||
            if (minAttackTime == maxAttackTime)
 | 
					            if (minAttackTime == maxAttackTime)
 | 
				
			||||||
| 
						 | 
					@ -1599,12 +1610,12 @@ bool CharacterController::updateWeaponState()
 | 
				
			||||||
                // most creatures don't actually have an attack wind-up animation, so use a uniform random value
 | 
					                // most creatures don't actually have an attack wind-up animation, so use a uniform random value
 | 
				
			||||||
                // (even some creatures that can use weapons don't have a wind-up animation either, e.g. Rieklings)
 | 
					                // (even some creatures that can use weapons don't have a wind-up animation either, e.g. Rieklings)
 | 
				
			||||||
                // Note: vanilla MW uses a random value for *all* non-player actors, but we probably don't need to go that far.
 | 
					                // Note: vanilla MW uses a random value for *all* non-player actors, but we probably don't need to go that far.
 | 
				
			||||||
                attackStrength = std::min(1.f, 0.1f + Misc::Rng::rollClosedProbability(prng));
 | 
					                mAttackStrength = std::min(1.f, 0.1f + Misc::Rng::rollClosedProbability(prng));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(weapclass != ESM::WeaponType::Ranged && weapclass != ESM::WeaponType::Thrown)
 | 
					            if(weapclass != ESM::WeaponType::Ranged && weapclass != ESM::WeaponType::Thrown)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if(isWerewolf)
 | 
					                if (isWerewolf)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    const MWWorld::ESMStore &store = world->getStore();
 | 
					                    const MWWorld::ESMStore &store = world->getStore();
 | 
				
			||||||
                    const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfSwing", prng);
 | 
					                    const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfSwing", prng);
 | 
				
			||||||
| 
						 | 
					@ -1613,12 +1624,12 @@ bool CharacterController::updateWeaponState()
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    playSwishSound(attackStrength);
 | 
					                    playSwishSound(mAttackStrength);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            mAttackStrength = attackStrength;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            mAnimation->disable(mCurrentWeapon);
 | 
					            if (animPlaying)
 | 
				
			||||||
 | 
					                mAnimation->disable(mCurrentWeapon);
 | 
				
			||||||
            mAnimation->play(mCurrentWeapon, priorityWeapon,
 | 
					            mAnimation->play(mCurrentWeapon, priorityWeapon,
 | 
				
			||||||
                             MWRender::Animation::BlendMask_All, false,
 | 
					                             MWRender::Animation::BlendMask_All, false,
 | 
				
			||||||
                             weapSpeed, mAttackType+" max attack", mAttackType+" min hit",
 | 
					                             weapSpeed, mAttackType+" max attack", mAttackType+" min hit",
 | 
				
			||||||
| 
						 | 
					@ -1627,17 +1638,6 @@ bool CharacterController::updateWeaponState()
 | 
				
			||||||
            complete = 0.f;
 | 
					            complete = 0.f;
 | 
				
			||||||
            mUpperBodyState = UpperBodyState::AttackRelease;
 | 
					            mUpperBodyState = UpperBodyState::AttackRelease;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (isKnockedDown())
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (mUpperBodyState > UpperBodyState::WeaponEquipped)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                mUpperBodyState = UpperBodyState::WeaponEquipped;
 | 
					 | 
				
			||||||
                if (mWeaponType > ESM::Weapon::None)
 | 
					 | 
				
			||||||
                    mAnimation->showWeapons(true);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if (!mCurrentWeapon.empty())
 | 
					 | 
				
			||||||
                mAnimation->disable(mCurrentWeapon);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mAnimation->setPitchFactor(0.f);
 | 
					    mAnimation->setPitchFactor(0.f);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue