Skip to content

Commit

Permalink
Fix monsters doing bonus damage even when hit missed
Browse files Browse the repository at this point in the history
Also fixes bonus damage being applied for second and third attacks when they are 0. Fixes problem reported here https://forums.dfworkshop.net/viewtopic.php?f=4&t=4368
  • Loading branch information
Interkarma committed Dec 14, 2020
1 parent 6c98c86 commit 5674a60
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Assets/Scripts/Game/Formulas/FormulaHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -635,17 +635,21 @@ public static int CalculateAttackDamage(DaggerfallEntity attacker, DaggerfallEnt

int reflexesChance = 50 - (10 * ((int)player.Reflexes - 2));

int hitDamage = 0;
if (DFRandom.rand() % 100 < reflexesChance && minBaseDamage > 0 && CalculateSuccessfulHit(attacker, target, chanceToHitMod, struckBodyPart))
{
int hitDamage = UnityEngine.Random.Range(minBaseDamage, maxBaseDamage + 1);
hitDamage = UnityEngine.Random.Range(minBaseDamage, maxBaseDamage + 1);
// Apply special monster attack effects
if (hitDamage > 0)
OnMonsterHit(AIAttacker, target, hitDamage);

damage += hitDamage;
}

damage += GetBonusOrPenaltyByEnemyType(attacker, target);
// Apply bonus damage only when monster has actually hit, or they will accumulate bonus damage even for missed attacks and zero-damage attacks
if (hitDamage > 0)
damage += GetBonusOrPenaltyByEnemyType(attacker, target);

++attackNumber;
}
}
Expand Down

0 comments on commit 5674a60

Please sign in to comment.