mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-20 02:24:45 +00:00
importing controlled implementation changes from original exp-for-kda branch; code for contributions from prior activity, but will be adjusting to new contribution methods kill contributions should work; even if they don't, need to put this away for now extensivwe changes to the way OwnableByPlayer manages owner user information due to uniqueness, that changes a lot of vehicle and deployable code; fleshing out experience calculation procedure for future testing events for mounting and dismounting of both passenger and cargo; id'ing the installation of an amenity (vehicle or facility); separation of kill/assist experience and support experience calculations; retention of kill record which allows for the calculation of menace support experience accumulates and is given to the user in gradual provisions rewarding facility capture through cep; not fully tested yet; math sucks sort of cep to bep consditions for squad facility capture; bep deposit for ntu silo activity early reivision for v010; recording ongoing shots fired and landed restored bep from ntu deposits into resource silos; updating statistics in the database regarding kills and related stats including weapons; updated history management; basic experience calculation changes all rewarded support events are accounted for command experience calculations upon facility capture or resecure corrected database migrations most of the code for the play or progress system statistics window updates for exosuits to report kills; killing an llu runner gives cep; moving play or progress functionality to a bang command rather than piggybacking setbr; bep is no longer too high by error
109 lines
3.6 KiB
Scala
109 lines
3.6 KiB
Scala
// Copyright (c) 2017 PSForever
|
|
package net.psforever.objects
|
|
|
|
import akka.actor.{ActorContext, Props}
|
|
import net.psforever.objects.ce.{Deployable, DeployedItem}
|
|
import net.psforever.objects.guid.{GUIDTask, TaskWorkflow}
|
|
import net.psforever.objects.serverobject.{CommonMessages, PlanetSideServerObject}
|
|
import net.psforever.objects.sourcing.{PlayerSource, SourceEntry}
|
|
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
|
|
|
|
class BoomerDeployable(cdef: ExplosiveDeployableDefinition)
|
|
extends ExplosiveDeployable(cdef) {
|
|
private var trigger: Option[BoomerTrigger] = None
|
|
|
|
def Trigger: Option[BoomerTrigger] = trigger
|
|
|
|
def Trigger_=(item: BoomerTrigger): Option[BoomerTrigger] = {
|
|
if (trigger.isEmpty) { //can only set trigger once
|
|
trigger = Some(item)
|
|
}
|
|
Trigger
|
|
}
|
|
|
|
def Trigger_=(item: Option[BoomerTrigger]): Option[BoomerTrigger] = {
|
|
if (item.isEmpty) {
|
|
trigger = None
|
|
}
|
|
Trigger
|
|
}
|
|
}
|
|
|
|
class BoomerDeployableDefinition(private val objectId: Int) extends ExplosiveDeployableDefinition(objectId) {
|
|
override def Initialize(obj: Deployable, context: ActorContext): Unit = {
|
|
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) {
|
|
|
|
def receive: Receive =
|
|
commonMineBehavior
|
|
.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
|
|
mine.Destroyed = true
|
|
ExplosiveDeployableControl.DamageResolution(
|
|
mine,
|
|
DamageInteraction(
|
|
SourceEntry(mine),
|
|
TriggerUsedReason(PlayerSource(player), trigger.GUID),
|
|
mine.Position
|
|
).calculate()(mine),
|
|
damage = 0
|
|
)
|
|
|
|
case _ => ;
|
|
}
|
|
|
|
override def loseOwnership(faction: PlanetSideEmpire.Value): Unit = {
|
|
super.loseOwnership(PlanetSideEmpire.NEUTRAL)
|
|
val guid = mine.OwnerGuid
|
|
mine.AssignOwnership(None)
|
|
mine.OwnerGuid = guid
|
|
}
|
|
|
|
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)
|
|
case _ => ;
|
|
}
|
|
zone.AvatarEvents! AvatarServiceMessage(
|
|
zone.id,
|
|
AvatarAction.ObjectDelete(Service.defaultPlayerGUID, guid)
|
|
)
|
|
TaskWorkflow.execute(GUIDTask.unregisterObject(zone.GUID, trigger))
|
|
case None => ;
|
|
}
|
|
}
|
|
}
|