diff --git a/src/main/scala/net/psforever/objects/global/GlobalDefinitionsProjectile.scala b/src/main/scala/net/psforever/objects/global/GlobalDefinitionsProjectile.scala index 7b3e4f5de..c16487aea 100644 --- a/src/main/scala/net/psforever/objects/global/GlobalDefinitionsProjectile.scala +++ b/src/main/scala/net/psforever/objects/global/GlobalDefinitionsProjectile.scala @@ -1783,7 +1783,7 @@ object GlobalDefinitionsProjectile { spitfire_aa_ammo_projectile.Lifespan = 5f ProjectileDefinition.CalculateDerivedFields(spitfire_aa_ammo_projectile) spitfire_aa_ammo_projectile.Modifiers = List( - //FlakHit, + CerberusTurretWrongTarget, FlakBurst, MaxDistanceCutoff ) diff --git a/src/main/scala/net/psforever/objects/vital/projectile/ProjectileDamageModifierFunctions.scala b/src/main/scala/net/psforever/objects/vital/projectile/ProjectileDamageModifierFunctions.scala index e9fcaa11a..8d1541408 100644 --- a/src/main/scala/net/psforever/objects/vital/projectile/ProjectileDamageModifierFunctions.scala +++ b/src/main/scala/net/psforever/objects/vital/projectile/ProjectileDamageModifierFunctions.scala @@ -1,9 +1,10 @@ // Copyright (c) 2020 PSForever package net.psforever.objects.vital.projectile +import net.psforever.objects.GlobalDefinitions import net.psforever.objects.ballistics._ import net.psforever.objects.equipment.ChargeFireModeDefinition -import net.psforever.objects.sourcing.PlayerSource +import net.psforever.objects.sourcing.{PlayerSource, VehicleSource} import net.psforever.objects.vital.base._ import net.psforever.objects.vital.damage.DamageModifierFunctions import net.psforever.objects.vital.interaction.DamageInteraction @@ -354,6 +355,19 @@ case object ShieldAgainstRadiation extends ProjectileDamageModifiers.Mod { } } +/** The Cerberus turret can not target any entities besides flying vehicles. + * An exception to this rule, however, happens when retaliating against something that damaged it first. */ +case object CerberusTurretWrongTarget extends ProjectileDamageModifiers.Mod { + def calculate(damage: Int, data: DamageInteraction, cause: ProjectileReason): Int = { + data.target match { + case v: VehicleSource if GlobalDefinitions.isFlightVehicle(v.Definition) => + damage + case _ => + damage - (math.random() * 3d).toInt - 1 + } + } +} + /* Functions */ object ProjectileDamageModifierFunctions { /**