diff --git a/src/main/scala/net/psforever/objects/avatar/interaction/WithWater.scala b/src/main/scala/net/psforever/objects/avatar/interaction/WithWater.scala index cb3aeb448..674b6dbfb 100644 --- a/src/main/scala/net/psforever/objects/avatar/interaction/WithWater.scala +++ b/src/main/scala/net/psforever/objects/avatar/interaction/WithWater.scala @@ -307,6 +307,6 @@ object WithWater { /** special environmental trait to queue actions independent from the primary wading test */ case object WaterAction extends EnvironmentTrait { override def canInteractWith(obj: PlanetSideGameObject): Boolean = false - override def testingDepth: Float = Float.PositiveInfinity + override def testingDepth(obj: PlanetSideGameObject): Float = Float.PositiveInfinity } } diff --git a/src/main/scala/net/psforever/objects/serverobject/environment/EnvironmentAttribute.scala b/src/main/scala/net/psforever/objects/serverobject/environment/EnvironmentAttribute.scala index e7e88c7dc..232923956 100644 --- a/src/main/scala/net/psforever/objects/serverobject/environment/EnvironmentAttribute.scala +++ b/src/main/scala/net/psforever/objects/serverobject/environment/EnvironmentAttribute.scala @@ -11,7 +11,7 @@ import net.psforever.types.Vector3 abstract class EnvironmentTrait { def canInteractWith(obj: PlanetSideGameObject): Boolean - def testingDepth: Float + def testingDepth(obj: PlanetSideGameObject): Float } object EnvironmentAttribute { @@ -28,21 +28,32 @@ object EnvironmentAttribute { }) } - def testingDepth: Float = 0.2f + def testingDepth(obj: PlanetSideGameObject): Float = { + obj match { + case v: Vehicle if v.Flying.nonEmpty => + 0f + case _: Vehicle if !obj.Definition.DrownAtMaxDepth => + obj.Definition.MaxDepth * 0.9f + case _: Vehicle => + obj.Definition.MaxDepth * 0.6f + case _ => + 0.2f + } + } } case object Lava extends EnvironmentTrait { /** lava can only interact with anything capable of registering damage */ def canInteractWith(obj: PlanetSideGameObject): Boolean = canInteractWithDamagingFields(obj) - val testingDepth: Float = 0f + def testingDepth(obj: _root_.net.psforever.objects.PlanetSideGameObject): Float = 0f } case object Death extends EnvironmentTrait { /** death can only interact with anything capable of registering damage */ def canInteractWith(obj: PlanetSideGameObject): Boolean = canInteractWithDamagingFields(obj) - val testingDepth: Float = 0f + def testingDepth(obj: _root_.net.psforever.objects.PlanetSideGameObject): Float = 0f } case object GantryDenialField @@ -55,7 +66,7 @@ object EnvironmentAttribute { } } - val testingDepth: Float = 0f + def testingDepth(obj: _root_.net.psforever.objects.PlanetSideGameObject): Float = 0f } case object MovementFieldTrigger @@ -63,7 +74,7 @@ object EnvironmentAttribute { /** only interact with living player characters or vehicles */ def canInteractWith(obj: PlanetSideGameObject): Boolean = canInteractWithPlayersAndVehicles(obj) - val testingDepth: Float = 0f + def testingDepth(obj: _root_.net.psforever.objects.PlanetSideGameObject): Float = 0f } case object InteriorField @@ -71,7 +82,7 @@ object EnvironmentAttribute { /** only interact with living player characters or vehicles */ def canInteractWith(obj: PlanetSideGameObject): Boolean = canInteractWithPlayersAndVehicles(obj) - val testingDepth: Float = 0f + def testingDepth(obj: _root_.net.psforever.objects.PlanetSideGameObject): Float = 0f } /** diff --git a/src/main/scala/net/psforever/objects/serverobject/environment/interaction/InteractWithEnvironment.scala b/src/main/scala/net/psforever/objects/serverobject/environment/interaction/InteractWithEnvironment.scala index 3ccc489d1..33c550209 100644 --- a/src/main/scala/net/psforever/objects/serverobject/environment/interaction/InteractWithEnvironment.scala +++ b/src/main/scala/net/psforever/objects/serverobject/environment/interaction/InteractWithEnvironment.scala @@ -119,7 +119,7 @@ object InteractWithEnvironment { sector: SectorPopulation ): Set[PieceOfEnvironment] = { sector.environmentList - .filter(body => body.attribute.canInteractWith(obj) && body.testInteraction(obj, body.attribute.testingDepth)) + .filter(body => body.attribute.canInteractWith(obj) && body.testInteraction(obj, body.attribute.testingDepth(obj))) .distinctBy(_.attribute) .toSet } @@ -136,7 +136,7 @@ object InteractWithEnvironment { body: PieceOfEnvironment, obj: PlanetSideServerObject ): Option[PieceOfEnvironment] = { - if ((obj.Zone eq zone) && body.testInteraction(obj, body.attribute.testingDepth)) { + if ((obj.Zone eq zone) && body.testInteraction(obj, body.attribute.testingDepth(obj))) { Some(body) } else { None diff --git a/src/main/scala/net/psforever/objects/vehicles/interaction/WithWater.scala b/src/main/scala/net/psforever/objects/vehicles/interaction/WithWater.scala index dd4dc299d..01208856a 100644 --- a/src/main/scala/net/psforever/objects/vehicles/interaction/WithWater.scala +++ b/src/main/scala/net/psforever/objects/vehicles/interaction/WithWater.scala @@ -237,7 +237,7 @@ object WithWater { /** special environmental trait to queue actions independent from the primary wading test */ case object WaterAction extends EnvironmentTrait { override def canInteractWith(obj: PlanetSideGameObject): Boolean = false - override def testingDepth: Float = Float.PositiveInfinity + override def testingDepth(obj: PlanetSideGameObject): Float = Float.PositiveInfinity } /**