Merge pull request #1147 from Resaec/gm_capturebase_turret_kick

GM command capturebase kicks players from turrets
This commit is contained in:
Fate-JH 2023-12-18 16:48:03 -05:00 committed by GitHub
commit 93c3463985
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 15 deletions

View file

@ -5,6 +5,9 @@ import akka.actor.typed.{ActorRef, Behavior, PostStop, SupervisorStrategy}
import akka.actor.typed.receptionist.Receptionist
import akka.actor.typed.scaladsl.{ActorContext, Behaviors, StashBuffer}
import akka.actor.typed.scaladsl.adapter._
import net.psforever.actors.zone.ZoneActor
import net.psforever.objects.sourcing.PlayerSource
import net.psforever.services.local.{LocalAction, LocalServiceMessage}
import scala.collection.mutable
import scala.concurrent.ExecutionContextExecutor
@ -483,8 +486,21 @@ class ChatActor(
)
buildings foreach { building =>
// TODO implement timer
val terminal = building.CaptureTerminal.get
building.Actor ! BuildingActor.SetFaction(faction)
building.Actor ! BuildingActor.AmenityStateChange(terminal, Some(false))
// clear any previous hack via "resecure"
if (building.CaptureTerminalIsHacked) {
building.Zone.LocalEvents ! LocalServiceMessage(terminal.Zone.id,LocalAction.ResecureCaptureTerminal(terminal, PlayerSource.Nobody))
}
// push any updates this might cause to clients
building.Zone.actor ! ZoneActor.ZoneMapUpdate()
}
case (_, Some(0), _, None, _) =>
sessionActor ! SessionActor.SendResponse(
ChatMsg(

View file

@ -258,17 +258,17 @@ class SessionMountHandlers(
case Mountable.CanDismount(obj: Mountable, _, _) =>
log.warn(s"DismountVehicleMsg: $obj is some dismountable object but nothing will happen for ${player.Name}")
case Mountable.CanNotMount(obj: Vehicle, mountPoint) =>
log.warn(s"MountVehicleMsg: ${tplayer.Name} attempted to mount $obj's mount $mountPoint, but was not allowed")
obj.GetSeatFromMountPoint(mountPoint).collect {
case Mountable.CanNotMount(obj: Vehicle, seatNumber) =>
log.warn(s"MountVehicleMsg: ${tplayer.Name} attempted to mount $obj's seat $seatNumber, but was not allowed")
obj.GetSeatFromMountPoint(seatNumber).collect {
case seatNum if obj.SeatPermissionGroup(seatNum).contains(AccessPermissionGroup.Driver) =>
sendResponse(
ChatMsg(ChatMessageType.CMT_OPEN, wideContents=false, recipient="", "You are not the driver of this vehicle.", note=None)
)
}
case Mountable.CanNotMount(obj: Mountable, mountPoint) =>
log.warn(s"MountVehicleMsg: ${tplayer.Name} attempted to mount $obj's mount $mountPoint, but was not allowed")
case Mountable.CanNotMount(obj: Mountable, seatNumber) =>
log.warn(s"MountVehicleMsg: ${tplayer.Name} attempted to mount $obj's seat $seatNumber, but was not allowed")
case Mountable.CanNotDismount(obj, seatNum) =>
log.warn(s"DismountVehicleMsg: ${tplayer.Name} attempted to dismount $obj's mount $seatNum, but was not allowed")

View file

@ -1,6 +1,7 @@
// Copyright (c) 2021 PSForever
package net.psforever.objects.serverobject.mount
import net.psforever.objects.Player
import net.psforever.types.BailType
trait MountableSpace[A <: MountableEntity] {
@ -92,6 +93,10 @@ trait MountableSpace[A <: MountableEntity] {
case Some(p) if testToUnmount(p) =>
_occupant = None
p.BailProtection = bailable && (bailType == BailType.Bailed || bailType == BailType.Kicked)
p match {
case player: Player =>
player.VehicleSeated = None
}
None
case _ =>
occupant

View file

@ -18,16 +18,27 @@ trait CaptureTerminalAwareBehavior {
case true => ; // CC is resecured
case false => // CC is hacked
// Remove seated occupants for mountables
if (CaptureTerminalAwareObject.isInstanceOf[Mountable]) {
CaptureTerminalAwareObject.asInstanceOf[Mountable].Seats.filter(x => x._2.isOccupied).foreach(x => {
val (seat_num, seat) = x
val user = seat.occupant.get
CaptureTerminalAwareObject.Zone.VehicleEvents ! VehicleServiceMessage(
CaptureTerminalAwareObject.Zone.id,
VehicleAction.KickPassenger(user.GUID, seat_num, true, CaptureTerminalAwareObject.GUID)
)
seat.unmount(user)
})
CaptureTerminalAwareObject match {
case mountable: Mountable =>
val guid = mountable.GUID
val zone = mountable.Zone
val zoneId = zone.id
val events = zone.VehicleEvents
mountable.Seats.values.zipWithIndex.foreach {
case (seat, seat_num) =>
seat.occupant match {
case Some(player) =>
seat.unmount(player)
player.VehicleSeated = None
if (player.HasGUID) {
events ! VehicleServiceMessage(zoneId, VehicleAction.KickPassenger(player.GUID, seat_num, true, guid))
}
case None => ;
}
}
case _ =>
}
}
}