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).
This commit is contained in:
scrawl 2014-09-07 04:46:47 +02:00
parent b6635c7964
commit adbc50366b
2 changed files with 13 additions and 5 deletions

View file

@ -277,8 +277,7 @@ namespace MWClass
break; 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) * stats.getAttackStrength();
float damage = min + (max - min) * ::rand()/(RAND_MAX+1.0);
if (!weapon.isEmpty()) if (!weapon.isEmpty())
{ {

View file

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