Restore stamina drain on taking health damage via ResolutionCalculations

This commit is contained in:
Mazo 2020-04-15 21:14:43 +01:00
parent a50612dd99
commit d768b3d62c
2 changed files with 9 additions and 0 deletions

View file

@ -36,6 +36,7 @@ class PlayerControl(player : Player) extends Actor
def JammableObject = player
def DamageableObject = player
private [this] val log = org.log4s.getLogger(player.Name)
private [this] val damageLog = org.log4s.getLogger(Damageable.LogChannel)
// A collection of timers for each slot to trigger stamina drain on an interval

View file

@ -154,6 +154,8 @@ object ResolutionCalculations {
player.Armor = result._1
b = result._2
val originalHealth = player.Health
// Then bleed through to health if armour ran out
result = SubtractWithRemainder(player.Health, b)
player.Health = result._1
@ -163,6 +165,12 @@ object ResolutionCalculations {
result = SubtractWithRemainder(player.Health, a)
player.Health = result._1
a = result._2
// If any health damage was applied also drain an amount of stamina equal to half the health damage
if(player.Health < originalHealth) {
val delta = originalHealth - player.Health
player.Stamina = player.Stamina - math.floor(delta / 2).toInt
}
}
case _ =>
}