Skip to content

Commit

Permalink
Apply strength modifier to weapon damage
Browse files Browse the repository at this point in the history
Also put pre-modifier weapon damage calculation into its own function
  • Loading branch information
Allofich committed Jan 5, 2017
1 parent 6de85bc commit 74e96fc
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions Assets/Scripts/Game/WeaponManager.cs
Expand Up @@ -183,6 +183,26 @@ public void SheathWeapons()
ShowWeapons(false);
}

public int CalculateWeaponDamage(WeaponTypes weaponType, MetalTypes metalType)
{
// Fudge values, to be replaced
int damage_low = 1;
int damage_high = 24;

// Hand-to-hand damage formula based on Daggerfall Chronicles and testing original game.
// Daggerfall Chronicles table lists hand-to-hand skills of 80 and above (45 through 79 are omitted)
// as if they cause 2 to be added to damage_high instead of 1, but the hand-to-hand damage display
// in the in-game character sheet contradicts this.
// From testing in original Daggerfall there didn't seem to be a difference in damage from swing type.
if (weaponType == WeaponTypes.Melee)
{
int skill = playerEntity.Skills.HandToHand;
damage_low = (skill / 10) + 1;
damage_high = (skill / 5) + 1;
}
return Random.Range(damage_low, damage_high + 1);
}

public void Reset()
{
usingRightHand = true;
Expand Down Expand Up @@ -481,22 +501,18 @@ private void MeleeDamage(FPSWeapon weapon)

// TODO: Use correct damage based on weapon and swing type
// Just using fudge values during development
int damage_low = 1;
int damage_high = 24;

// Hand-to-hand damage formula based on Daggerfall Chronicles and testing original game.
// Daggerfall Chronicles table lists hand-to-hand skills of 80 and above (45 through 79 are omitted)
// as if they cause 2 to be added to damage_high instead of 1, but the hand-to-hand damage display in the
// character sheet in the original game contradicts this.
// From some quick testing in original Daggerfall there didn't seem to be a difference in damage from swing type
if (weapon.WeaponType == WeaponTypes.Melee)

// Get damage before strength modifier
int damage = CalculateWeaponDamage(weapon.WeaponType, weapon.MetalType);

// Apply the strength modifier. Testing in original Daggerfall shows hand-to-hand ignores it
if (weapon.WeaponType != WeaponTypes.Melee)
{
int skill = playerEntity.Skills.HandToHand;
damage_low = (skill / 10) + 1;
damage_high = (skill / 5) + 1;
int strengthModifier = (playerEntity.Stats.Strength / 10) - 5;

// Weapons can do 0 damage (no blood or hit sound in original Daggerfall)
damage = Mathf.Max(0, damage + strengthModifier);
}

int damage = Random.Range(damage_low, damage_high + 1);

//// Check if hit has an EnemyHealth
//// This is part of the old Demo code and will eventually be removed
Expand Down

0 comments on commit 74e96fc

Please sign in to comment.