2018-09-23 12:00:58 +00:00
|
|
|
// Copyright (c) 2017 PSForever
|
|
|
|
|
package net.psforever.objects
|
|
|
|
|
|
2021-06-02 15:51:38 +00:00
|
|
|
import akka.actor.{ActorContext, Props}
|
|
|
|
|
import net.psforever.objects.ce.{Deployable, DeployedItem}
|
2021-08-16 01:27:45 +00:00
|
|
|
import net.psforever.objects.guid.{GUIDTask, TaskWorkflow}
|
2024-06-22 05:42:25 +00:00
|
|
|
import net.psforever.objects.serverobject.affinity.FactionAffinity
|
2021-06-02 15:51:38 +00:00
|
|
|
import net.psforever.objects.serverobject.{CommonMessages, PlanetSideServerObject}
|
2023-02-14 05:09:28 +00:00
|
|
|
import net.psforever.objects.sourcing.{PlayerSource, SourceEntry}
|
2024-06-22 05:42:25 +00:00
|
|
|
import net.psforever.objects.vital.Vitality
|
2021-06-02 15:51:38 +00:00
|
|
|
import net.psforever.objects.vital.etc.TriggerUsedReason
|
|
|
|
|
import net.psforever.objects.vital.interaction.DamageInteraction
|
|
|
|
|
import net.psforever.objects.zones.Zone
|
|
|
|
|
import net.psforever.services.Service
|
|
|
|
|
import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage}
|
|
|
|
|
import net.psforever.types.PlanetSideEmpire
|
|
|
|
|
|
2024-05-11 02:30:20 +00:00
|
|
|
import scala.annotation.unused
|
|
|
|
|
|
2021-06-02 15:51:38 +00:00
|
|
|
class BoomerDeployable(cdef: ExplosiveDeployableDefinition)
|
|
|
|
|
extends ExplosiveDeployable(cdef) {
|
2020-07-14 03:54:05 +00:00
|
|
|
private var trigger: Option[BoomerTrigger] = None
|
2018-09-23 12:00:58 +00:00
|
|
|
|
2020-07-14 03:54:05 +00:00
|
|
|
def Trigger: Option[BoomerTrigger] = trigger
|
2018-09-23 12:00:58 +00:00
|
|
|
|
2020-07-14 03:54:05 +00:00
|
|
|
def Trigger_=(item: BoomerTrigger): Option[BoomerTrigger] = {
|
|
|
|
|
if (trigger.isEmpty) { //can only set trigger once
|
2018-09-23 12:00:58 +00:00
|
|
|
trigger = Some(item)
|
|
|
|
|
}
|
|
|
|
|
Trigger
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-14 03:54:05 +00:00
|
|
|
def Trigger_=(item: Option[BoomerTrigger]): Option[BoomerTrigger] = {
|
|
|
|
|
if (item.isEmpty) {
|
2018-09-23 12:00:58 +00:00
|
|
|
trigger = None
|
|
|
|
|
}
|
|
|
|
|
Trigger
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-02 15:51:38 +00:00
|
|
|
|
2024-06-22 05:42:25 +00:00
|
|
|
class BoomerDeployableDefinition(private val objectId: Int)
|
|
|
|
|
extends ExplosiveDeployableDefinition(objectId) {
|
2023-02-14 05:09:28 +00:00
|
|
|
override def Initialize(obj: Deployable, context: ActorContext): Unit = {
|
2021-06-02 15:51:38 +00:00
|
|
|
obj.Actor =
|
|
|
|
|
context.actorOf(Props(classOf[BoomerDeployableControl], obj), PlanetSideServerObject.UniqueActorName(obj))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object BoomerDeployableDefinition {
|
|
|
|
|
def apply(dtype: DeployedItem.Value): BoomerDeployableDefinition = {
|
|
|
|
|
new BoomerDeployableDefinition(dtype.id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class BoomerDeployableControl(mine: BoomerDeployable)
|
|
|
|
|
extends ExplosiveDeployableControl(mine) {
|
|
|
|
|
|
The Blockmap (#852)
* separating geometry classes
* 2d geometry; retirement of the *3D suffix
* makings of an early block map datastructure
* entities in a zone - players, corpses, vehicles, deployables, ground clutter, and buildings - divided between sectors of the zone upon creation, management, or mounting; superfluous messages to keep track of blockmap state, for now
* trait for entities to be added to the blockmap; internal entity data keeps track of current blockmap sector information; calls to add/remove/update functions changed
* modified pieces of environment into an entities that can be added to a block map and have a countable bounding region; fixes for vehicle control seat occcupant collection; fix for squad individual callback references (original issue still remains?)
* introduced the block map into various existijng game calculationa where target selection can be reduced by its probing
* he_mines and jammer_mines now trigger if a valid target is detected at the initial point of deploy; they also trigger later, after a valid target has moved into the arming range of the mine
* conversion of interactions with zone into a queued, periodic set of tasks
* explosive deployable control -> mine deployable control
* tests repaired and all tests working
* mostly comments and documentation
* amenities are now represented on the blockmap
2021-06-12 03:02:48 +00:00
|
|
|
def receive: Receive =
|
|
|
|
|
commonMineBehavior
|
2021-06-02 15:51:38 +00:00
|
|
|
.orElse {
|
|
|
|
|
case CommonMessages.Use(player, Some(trigger: BoomerTrigger)) if mine.Trigger.contains(trigger) =>
|
|
|
|
|
// the trigger damages the mine, which sets it off, which causes an explosion
|
|
|
|
|
// think of this as an initiator to the proper explosion
|
2024-06-22 05:42:25 +00:00
|
|
|
HandleDamage(
|
2021-06-02 15:51:38 +00:00
|
|
|
mine,
|
|
|
|
|
DamageInteraction(
|
|
|
|
|
SourceEntry(mine),
|
|
|
|
|
TriggerUsedReason(PlayerSource(player), trigger.GUID),
|
|
|
|
|
mine.Position
|
|
|
|
|
).calculate()(mine),
|
|
|
|
|
damage = 0
|
|
|
|
|
)
|
2024-06-22 05:42:25 +00:00
|
|
|
case _ => ()
|
2021-06-02 15:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
2024-05-11 02:30:20 +00:00
|
|
|
def loseOwnership(@unused faction: PlanetSideEmpire.Value): Unit = {
|
|
|
|
|
super.loseOwnership(mine, PlanetSideEmpire.NEUTRAL)
|
2023-03-26 03:29:03 +00:00
|
|
|
val guid = mine.OwnerGuid
|
|
|
|
|
mine.AssignOwnership(None)
|
|
|
|
|
mine.OwnerGuid = guid
|
2021-06-02 15:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def gainOwnership(player: Player): Unit = {
|
|
|
|
|
mine.Faction = PlanetSideEmpire.NEUTRAL //force map icon redraw
|
|
|
|
|
super.gainOwnership(player, player.Faction)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override def dismissDeployable() : Unit = {
|
|
|
|
|
super.dismissDeployable()
|
|
|
|
|
val zone = mine.Zone
|
|
|
|
|
mine.Trigger match {
|
|
|
|
|
case Some(trigger) =>
|
|
|
|
|
mine.Trigger = None
|
|
|
|
|
trigger.Companion = None
|
|
|
|
|
val guid = trigger.GUID
|
|
|
|
|
Zone.EquipmentIs.Where(trigger, guid, zone) match {
|
|
|
|
|
case Some(Zone.EquipmentIs.InContainer(container, index)) =>
|
|
|
|
|
container.Slot(index).Equipment = None
|
|
|
|
|
case Some(Zone.EquipmentIs.OnGround()) =>
|
|
|
|
|
zone.Ground ! Zone.Ground.RemoveItem(guid)
|
2024-06-22 05:42:25 +00:00
|
|
|
case _ => ()
|
2021-06-02 15:51:38 +00:00
|
|
|
}
|
|
|
|
|
zone.AvatarEvents! AvatarServiceMessage(
|
|
|
|
|
zone.id,
|
2023-02-14 05:09:28 +00:00
|
|
|
AvatarAction.ObjectDelete(Service.defaultPlayerGUID, guid)
|
2021-06-02 15:51:38 +00:00
|
|
|
)
|
2021-08-16 01:27:45 +00:00
|
|
|
TaskWorkflow.execute(GUIDTask.unregisterObject(zone.GUID, trigger))
|
2024-06-22 05:42:25 +00:00
|
|
|
case None => ()
|
2021-06-02 15:51:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2024-06-22 05:42:25 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Boomers are not bothered by explosive sympathy
|
|
|
|
|
* but can still be affected by sources of jammering.
|
|
|
|
|
* @param obj the entity being damaged
|
|
|
|
|
* @param damage the amount of damage
|
|
|
|
|
* @param data historical information about the damage
|
|
|
|
|
* @return `true`, if the target can be affected;
|
|
|
|
|
* `false`, otherwise
|
|
|
|
|
*/
|
|
|
|
|
override def CanDetonate(obj: Vitality with FactionAffinity, damage: Int, data: DamageInteraction): Boolean = {
|
|
|
|
|
super.CanDetonate(obj, damage, data) || data.cause.isInstanceOf[TriggerUsedReason]
|
|
|
|
|
}
|
2021-06-02 15:51:38 +00:00
|
|
|
}
|