Add personal shield to damage resolution calculations (#465)

This commit is contained in:
Mazo 2020-05-26 21:17:39 +01:00 committed by GitHub
parent 11a01b038f
commit 210ce0605c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,7 @@ import net.psforever.objects.serverobject.structures.Amenity
import net.psforever.objects.serverobject.turret.FacilityTurret
import net.psforever.objects.vital.Vitality
import net.psforever.objects.vital.projectile.ProjectileCalculations
import net.psforever.types.ImplantType
/**
* The base for the combining step of all projectile-induced damage calculation function literals.
@ -135,7 +136,6 @@ object ResolutionCalculations {
case player : Player =>
var (a, b) = damageValues
var result = (0, 0)
//TODO Personal Shield implant test should go here and modify the values a and b
if(player.isAlive && !(a == 0 && b == 0)) {
if(player.Capacitor.toInt > 0 && player.isShielded) {
// Subtract armour damage from capacitor
@ -149,6 +149,21 @@ object ResolutionCalculations {
a = result._2
}
player.Implants.find(x => x._1 == ImplantType.PersonalShield) match {
case Some(x) if x._3 == true => {
// Subtract armour damage from stamina
result = SubtractWithRemainder(player.Stamina, b)
player.Stamina = result._1
b = result._2
// Then follow up with health damage if any stamina is left
result = SubtractWithRemainder(player.Stamina, a)
player.Stamina = result._1
a = result._2
}
case _ => ;
}
// Subtract any remaining armour damage from armour
result = SubtractWithRemainder(player.Armor, b)
player.Armor = result._1