Use random attack strength for creatures (Bug #1876)

Determining the attack strength from the time the wind-up animation was held will not work properly, as most creatures don't have this animation.

This fixes another balancing issue with Rieklings (they were previously using an attack strength of 1 every time).
deque
scrawl 10 years ago
parent b6635c7964
commit adbc50366b

@ -277,8 +277,7 @@ namespace MWClass
break;
}
// I think this should be random, since attack1-3 animations don't have an attack strength like NPCs do
float damage = min + (max - min) * ::rand()/(RAND_MAX+1.0);
float damage = min + (max - min) * stats.getAttackStrength();
if (!weapon.isEmpty())
{

@ -960,6 +960,15 @@ bool CharacterController::updateWeaponState()
animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
if(mUpperBodyState == UpperCharState_MinAttackToMaxAttack && mHitState != CharState_KnockDown)
{
float attackStrength = complete;
if (!mPtr.getClass().isNpc())
{
// 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)
// 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 + std::rand() / float(RAND_MAX));
}
if(mAttackType != "shoot")
{
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
@ -974,15 +983,15 @@ bool CharacterController::updateWeaponState()
else
{
std::string sound = "SwishM";
if(complete < 0.5f)
if(attackStrength < 0.5f)
sndMgr->playSound3D(mPtr, sound, 1.0f, 0.8f); //Weak attack
else if(complete < 1.0f)
else if(attackStrength < 1.0f)
sndMgr->playSound3D(mPtr, sound, 1.0f, 1.0f); //Medium attack
else
sndMgr->playSound3D(mPtr, sound, 1.0f, 1.2f); //Strong attack
}
}
stats.setAttackStrength(complete);
stats.setAttackStrength(attackStrength);
mAnimation->disable(mCurrentWeapon);
mAnimation->play(mCurrentWeapon, Priority_Weapon,

Loading…
Cancel
Save