mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-04-29 00:05:28 +00:00
sidedness now helps determine target validity for automated turrets
This commit is contained in:
parent
9319f7e7bd
commit
51b4cff7d8
2 changed files with 10 additions and 5 deletions
|
|
@ -3,13 +3,15 @@ package net.psforever.objects.serverobject.turret.auto
|
||||||
|
|
||||||
import net.psforever.objects.definition.ObjectDefinition
|
import net.psforever.objects.definition.ObjectDefinition
|
||||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||||
|
import net.psforever.objects.serverobject.interior.InteriorAware
|
||||||
import net.psforever.objects.serverobject.turret.{TurretDefinition, WeaponTurret}
|
import net.psforever.objects.serverobject.turret.{TurretDefinition, WeaponTurret}
|
||||||
import net.psforever.objects.sourcing.{SourceEntry, SourceUniqueness}
|
import net.psforever.objects.sourcing.{SourceEntry, SourceUniqueness}
|
||||||
import net.psforever.objects.vital.Vitality
|
import net.psforever.objects.vital.Vitality
|
||||||
|
|
||||||
trait AutomatedTurret
|
trait AutomatedTurret
|
||||||
extends PlanetSideServerObject
|
extends PlanetSideServerObject
|
||||||
with WeaponTurret {
|
with WeaponTurret
|
||||||
|
with InteriorAware {
|
||||||
import AutomatedTurret.Target
|
import AutomatedTurret.Target
|
||||||
private var currentTarget: Option[Target] = None
|
private var currentTarget: Option[Target] = None
|
||||||
|
|
||||||
|
|
@ -66,5 +68,5 @@ trait AutomatedTurret
|
||||||
}
|
}
|
||||||
|
|
||||||
object AutomatedTurret {
|
object AutomatedTurret {
|
||||||
type Target = PlanetSideServerObject with Vitality
|
type Target = PlanetSideServerObject with Vitality with InteriorAware
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import net.psforever.objects.avatar.scoring.EquipmentStat
|
||||||
import net.psforever.objects.equipment.EffectTarget
|
import net.psforever.objects.equipment.EffectTarget
|
||||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||||
import net.psforever.objects.serverobject.damage.DamageableEntity
|
import net.psforever.objects.serverobject.damage.DamageableEntity
|
||||||
|
import net.psforever.objects.serverobject.interior.Sidedness
|
||||||
import net.psforever.objects.serverobject.mount.Mountable
|
import net.psforever.objects.serverobject.mount.Mountable
|
||||||
import net.psforever.objects.serverobject.turret.Automation
|
import net.psforever.objects.serverobject.turret.Automation
|
||||||
import net.psforever.objects.sourcing.{PlayerSource, SourceEntry, SourceUniqueness}
|
import net.psforever.objects.sourcing.{PlayerSource, SourceEntry, SourceUniqueness}
|
||||||
|
|
@ -326,6 +327,7 @@ trait AutomatedTurretBehavior {
|
||||||
AutomatedTurretObject.Target.orElse {
|
AutomatedTurretObject.Target.orElse {
|
||||||
val turretPosition = AutomatedTurretObject.Position
|
val turretPosition = AutomatedTurretObject.Position
|
||||||
val turretGuid = AutomatedTurretObject.GUID
|
val turretGuid = AutomatedTurretObject.GUID
|
||||||
|
val side = AutomatedTurretObject.WhichSide
|
||||||
val weaponGuid = AutomatedTurretObject.Weapons.values.head.Equipment.get.GUID
|
val weaponGuid = AutomatedTurretObject.Weapons.values.head.Equipment.get.GUID
|
||||||
val radius = autoStats.get.ranges.trigger
|
val radius = autoStats.get.ranges.trigger
|
||||||
val validation = autoStats.get.checks.validation
|
val validation = autoStats.get.checks.validation
|
||||||
|
|
@ -337,6 +339,7 @@ trait AutomatedTurretBehavior {
|
||||||
.collect { case target
|
.collect { case target
|
||||||
if !target.Destroyed &&
|
if !target.Destroyed &&
|
||||||
target.Faction != faction &&
|
target.Faction != faction &&
|
||||||
|
Sidedness.equals(target.WhichSide, side) &&
|
||||||
AutomatedTurretBehavior.shapedDistanceCheckAgainstValue(autoStats, target.Position, turretPosition, radius, result = -1) &&
|
AutomatedTurretBehavior.shapedDistanceCheckAgainstValue(autoStats, target.Position, turretPosition, radius, result = -1) &&
|
||||||
validation.exists(func => func(target)) &&
|
validation.exists(func => func(target)) &&
|
||||||
disqualifiers.takeWhile(func => func(target)).isEmpty =>
|
disqualifiers.takeWhile(func => func(target)).isEmpty =>
|
||||||
|
|
@ -650,7 +653,7 @@ trait AutomatedTurretBehavior {
|
||||||
* @param cause information about the damaging incident that caused the turret to consider retaliation
|
* @param cause information about the damaging incident that caused the turret to consider retaliation
|
||||||
* @return something the turret can potentially shoot at
|
* @return something the turret can potentially shoot at
|
||||||
*/
|
*/
|
||||||
protected def attemptRetaliation(target: Target, cause: DamageResult): Option[Target] = {
|
protected def attemptRetaliation(target: PlanetSideServerObject with Vitality, cause: DamageResult): Option[PlanetSideServerObject with Vitality] = {
|
||||||
val unique = SourceUniqueness(target)
|
val unique = SourceUniqueness(target)
|
||||||
if (
|
if (
|
||||||
automaticOperation &&
|
automaticOperation &&
|
||||||
|
|
@ -931,7 +934,7 @@ object AutomatedTurretBehavior {
|
||||||
* @return entity that caused the damage
|
* @return entity that caused the damage
|
||||||
* @see `Vitality`
|
* @see `Vitality`
|
||||||
*/
|
*/
|
||||||
def getAttackVectorFromCause(zone: Zone, cause: DamageResult): Option[PlanetSideServerObject with Vitality] = {
|
def getAttackVectorFromCause(zone: Zone, cause: DamageResult): Option[AutomatedTurret.Target] = {
|
||||||
import net.psforever.objects.sourcing._
|
import net.psforever.objects.sourcing._
|
||||||
cause
|
cause
|
||||||
.interaction
|
.interaction
|
||||||
|
|
@ -962,7 +965,7 @@ object AutomatedTurretBehavior {
|
||||||
}
|
}
|
||||||
.flatten
|
.flatten
|
||||||
.collect {
|
.collect {
|
||||||
case out: PlanetSideServerObject with Vitality => out
|
case out: AutomatedTurret.Target => out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue