mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-04-28 07:15:21 +00:00
Added correct sounds for hacking terminals/lockers & consolidated FinishHacking function
Wait for target actor to set HackedBy property before sending LocalAction.HackTemporarily to fix crash when run in the wrong order
This commit is contained in:
parent
9707e88924
commit
ca8d72cc4c
10 changed files with 38 additions and 48 deletions
|
|
@ -1,13 +1,15 @@
|
||||||
package net.psforever.objects.serverobject.hackable
|
package net.psforever.objects.serverobject.hackable
|
||||||
|
|
||||||
import net.psforever.objects.Player
|
import net.psforever.objects.Player
|
||||||
import net.psforever.packet.game.PlanetSideGUID
|
import net.psforever.packet.game.{PlanetSideGUID, TriggeredSound}
|
||||||
import net.psforever.types.Vector3
|
import net.psforever.types.Vector3
|
||||||
|
|
||||||
trait Hackable {
|
trait Hackable {
|
||||||
/** An entry that maintains a reference to the `Player`, and the player's GUID and location when the message was received. */
|
/** An entry that maintains a reference to the `Player`, and the player's GUID and location when the message was received. */
|
||||||
private var hackedBy : Option[(Player, PlanetSideGUID, Vector3)] = None
|
private var hackedBy : Option[(Player, PlanetSideGUID, Vector3)] = None
|
||||||
|
|
||||||
|
private var hackSound : TriggeredSound.Value = TriggeredSound.HackDoor
|
||||||
|
|
||||||
def HackedBy : Option[(Player, PlanetSideGUID, Vector3)] = hackedBy
|
def HackedBy : Option[(Player, PlanetSideGUID, Vector3)] = hackedBy
|
||||||
|
|
||||||
def HackedBy_=(agent : Player) : Option[(Player, PlanetSideGUID, Vector3)] = HackedBy_=(Some(agent))
|
def HackedBy_=(agent : Player) : Option[(Player, PlanetSideGUID, Vector3)] = HackedBy_=(Some(agent))
|
||||||
|
|
@ -38,4 +40,10 @@ trait Hackable {
|
||||||
}
|
}
|
||||||
HackedBy
|
HackedBy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def HackSound : TriggeredSound.Value = hackSound
|
||||||
|
def HackSound_=(sound : TriggeredSound.Value) : TriggeredSound.Value = {
|
||||||
|
hackSound = sound
|
||||||
|
hackSound
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package net.psforever.objects.serverobject.locks
|
||||||
|
|
||||||
import net.psforever.objects.serverobject.hackable.Hackable
|
import net.psforever.objects.serverobject.hackable.Hackable
|
||||||
import net.psforever.objects.serverobject.structures.Amenity
|
import net.psforever.objects.serverobject.structures.Amenity
|
||||||
|
import net.psforever.packet.game.TriggeredSound
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A structure-owned server object that is a "door lock."<br>
|
* A structure-owned server object that is a "door lock."<br>
|
||||||
|
|
@ -15,6 +16,7 @@ import net.psforever.objects.serverobject.structures.Amenity
|
||||||
*/
|
*/
|
||||||
class IFFLock(private val idef : IFFLockDefinition) extends Amenity with Hackable {
|
class IFFLock(private val idef : IFFLockDefinition) extends Amenity with Hackable {
|
||||||
def Definition : IFFLockDefinition = idef
|
def Definition : IFFLockDefinition = idef
|
||||||
|
HackSound = TriggeredSound.HackDoor
|
||||||
}
|
}
|
||||||
|
|
||||||
object IFFLock {
|
object IFFLock {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class IFFLockControl(lock : IFFLock) extends Actor with FactionAffinityBehavior.
|
||||||
def receive : Receive = checkBehavior.orElse {
|
def receive : Receive = checkBehavior.orElse {
|
||||||
case CommonMessages.Hack(player) =>
|
case CommonMessages.Hack(player) =>
|
||||||
lock.HackedBy = player
|
lock.HackedBy = player
|
||||||
|
sender ! true
|
||||||
case CommonMessages.ClearHack() =>
|
case CommonMessages.ClearHack() =>
|
||||||
lock.HackedBy = None
|
lock.HackedBy = None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@ import akka.actor.{ActorContext, Props}
|
||||||
import net.psforever.objects.GlobalDefinitions
|
import net.psforever.objects.GlobalDefinitions
|
||||||
import net.psforever.objects.serverobject.hackable.Hackable
|
import net.psforever.objects.serverobject.hackable.Hackable
|
||||||
import net.psforever.objects.serverobject.structures.Amenity
|
import net.psforever.objects.serverobject.structures.Amenity
|
||||||
|
import net.psforever.packet.game.TriggeredSound
|
||||||
|
|
||||||
class Locker extends Amenity with Hackable {
|
class Locker extends Amenity with Hackable {
|
||||||
def Definition : LockerDefinition = GlobalDefinitions.mb_locker
|
def Definition : LockerDefinition = GlobalDefinitions.mb_locker
|
||||||
|
HackSound = TriggeredSound.HackTerminal
|
||||||
}
|
}
|
||||||
|
|
||||||
object Locker {
|
object Locker {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class LockerControl(locker : Locker) extends Actor with FactionAffinityBehavior.
|
||||||
def receive : Receive = checkBehavior.orElse {
|
def receive : Receive = checkBehavior.orElse {
|
||||||
case CommonMessages.Hack(player) =>
|
case CommonMessages.Hack(player) =>
|
||||||
locker.HackedBy = player
|
locker.HackedBy = player
|
||||||
|
sender ! true
|
||||||
case CommonMessages.ClearHack() =>
|
case CommonMessages.ClearHack() =>
|
||||||
locker.HackedBy = None
|
locker.HackedBy = None
|
||||||
case _ => ;
|
case _ => ;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class ProximityTerminalControl(term : Terminal with ProximityUnit) extends Actor
|
||||||
.orElse {
|
.orElse {
|
||||||
case CommonMessages.Hack(player) =>
|
case CommonMessages.Hack(player) =>
|
||||||
term.HackedBy = player
|
term.HackedBy = player
|
||||||
|
sender ! true
|
||||||
case CommonMessages.ClearHack() =>
|
case CommonMessages.ClearHack() =>
|
||||||
term.HackedBy = None
|
term.HackedBy = None
|
||||||
case _ => ;
|
case _ => ;
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ import net.psforever.objects.Player
|
||||||
import net.psforever.objects.definition.VehicleDefinition
|
import net.psforever.objects.definition.VehicleDefinition
|
||||||
import net.psforever.objects.serverobject.hackable.Hackable
|
import net.psforever.objects.serverobject.hackable.Hackable
|
||||||
import net.psforever.objects.serverobject.structures.Amenity
|
import net.psforever.objects.serverobject.structures.Amenity
|
||||||
import net.psforever.packet.game.{ItemTransactionMessage}
|
import net.psforever.packet.game.{ItemTransactionMessage, TriggeredSound}
|
||||||
import net.psforever.types.{TransactionType}
|
import net.psforever.types.TransactionType
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A structure-owned server object that is a "terminal" that can be accessed for amenities and services.
|
* A structure-owned server object that is a "terminal" that can be accessed for amenities and services.
|
||||||
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
* @param tdef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||||
*/
|
*/
|
||||||
class Terminal(tdef : TerminalDefinition) extends Amenity with Hackable {
|
class Terminal(tdef : TerminalDefinition) extends Amenity with Hackable {
|
||||||
|
HackSound = TriggeredSound.HackTerminal
|
||||||
|
|
||||||
//the following fields and related methods are neither finalized nor integrated; GOTO Request
|
//the following fields and related methods are neither finalized nor integrated; GOTO Request
|
||||||
private var health : Int = 100 //TODO not real health value
|
private var health : Int = 100 //TODO not real health value
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class TerminalControl(term : Terminal) extends Actor with FactionAffinityBehavio
|
||||||
|
|
||||||
case CommonMessages.Hack(player) =>
|
case CommonMessages.Hack(player) =>
|
||||||
term.HackedBy = player
|
term.HackedBy = player
|
||||||
|
sender ! true
|
||||||
case CommonMessages.ClearHack() =>
|
case CommonMessages.ClearHack() =>
|
||||||
term.HackedBy = None
|
term.HackedBy = None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ object TriggeredSound extends Enumeration {
|
||||||
|
|
||||||
val
|
val
|
||||||
SpawnInTube,
|
SpawnInTube,
|
||||||
Unknown1,
|
HackTerminal,
|
||||||
Hack,
|
HackVehicle,
|
||||||
HackDoor,
|
HackDoor,
|
||||||
Unknown4,
|
Unknown4,
|
||||||
LockedOut,
|
LockedOut,
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,10 @@ import services.vehicle.VehicleAction.UnstowEquipment
|
||||||
import services.vehicle.{VehicleAction, VehicleResponse, VehicleServiceMessage, VehicleServiceResponse}
|
import services.vehicle.{VehicleAction, VehicleResponse, VehicleServiceMessage, VehicleServiceResponse}
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
|
import scala.concurrent.Future
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import scala.util.Success
|
import scala.util.Success
|
||||||
|
import akka.pattern.ask
|
||||||
|
|
||||||
class WorldSessionActor extends Actor with MDCContextAware {
|
class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
import WorldSessionActor._
|
import WorldSessionActor._
|
||||||
|
|
@ -2469,7 +2471,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
case Some(tool : SimpleItem) =>
|
case Some(tool : SimpleItem) =>
|
||||||
if(tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
if(tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
||||||
progressBarValue = Some(-GetPlayerHackSpeed())
|
progressBarValue = Some(-GetPlayerHackSpeed())
|
||||||
self ! WorldSessionActor.ItemHacking(player, panel, tool.GUID, GetPlayerHackSpeed(), FinishHackingDoor(panel, 1114636288L))
|
self ! WorldSessionActor.ItemHacking(player, panel, tool.GUID, GetPlayerHackSpeed(), FinishHacking(panel, 1114636288L))
|
||||||
log.info("Hacking a door~")
|
log.info("Hacking a door~")
|
||||||
}
|
}
|
||||||
case _ => ;
|
case _ => ;
|
||||||
|
|
@ -2531,7 +2533,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
case Some(tool: SimpleItem) =>
|
case Some(tool: SimpleItem) =>
|
||||||
if (tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
if (tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
||||||
progressBarValue = Some(-GetPlayerHackSpeed())
|
progressBarValue = Some(-GetPlayerHackSpeed())
|
||||||
self ! WorldSessionActor.ItemHacking(player, obj, tool.GUID, GetPlayerHackSpeed(), FinishHackingLocker(obj, 3212836864L))
|
self ! WorldSessionActor.ItemHacking(player, obj, tool.GUID, GetPlayerHackSpeed(), FinishHacking(obj, 3212836864L))
|
||||||
log.info("Hacking a locker")
|
log.info("Hacking a locker")
|
||||||
}
|
}
|
||||||
case _ => ;
|
case _ => ;
|
||||||
|
|
@ -2607,7 +2609,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
case Some(tool: SimpleItem) =>
|
case Some(tool: SimpleItem) =>
|
||||||
if (tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
if (tool.Definition == GlobalDefinitions.remote_electronics_kit) {
|
||||||
progressBarValue = Some(-GetPlayerHackSpeed())
|
progressBarValue = Some(-GetPlayerHackSpeed())
|
||||||
self ! WorldSessionActor.ItemHacking(player, obj, tool.GUID, GetPlayerHackSpeed(), FinishHackingTerminal(obj, 3212836864L))
|
self ! WorldSessionActor.ItemHacking(player, obj, tool.GUID, GetPlayerHackSpeed(), FinishHacking(obj, 3212836864L))
|
||||||
log.info("Hacking a terminal")
|
log.info("Hacking a terminal")
|
||||||
}
|
}
|
||||||
case _ => ;
|
case _ => ;
|
||||||
|
|
@ -3433,47 +3435,23 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The process of hacking the `Door` `IFFLock` is completed.
|
* The process of hacking an object is completed
|
||||||
* Pass the message onto the lock and onto the local events system.
|
* Pass the message onto the hackable object and onto the local events system.
|
||||||
* @param target the `IFFLock` belonging to the door that is being hacked
|
* @param target the `Hackable` object that has been hacked
|
||||||
* @param unk na;
|
* @param unk na;
|
||||||
* used by `HackingMessage` as `unk5`
|
* used by `HackMessage` as `unk5`
|
||||||
* @see `HackMessage`
|
* @see `HackMessage`
|
||||||
*/
|
*/
|
||||||
//TODO add params here depending on which params in HackMessage are important
|
//TODO add params here depending on which params in HackMessage are important
|
||||||
private def FinishHackingDoor(target : IFFLock, unk : Long)() : Unit = {
|
private def FinishHacking(target : PlanetSideServerObject with Hackable, unk : Long)() : Unit = {
|
||||||
target.Actor ! CommonMessages.Hack(player)
|
// Wait for the target actor to set the HackedBy property, otherwise LocalAction.HackTemporarily will not complete properly
|
||||||
localService ! LocalServiceMessage(continent.Id, LocalAction.TriggerSound(player.GUID, TriggeredSound.HackDoor, player.Position, 30, 0.49803925f))
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
|
ask(target.Actor, CommonMessages.Hack(player))(1 second).mapTo[Boolean].onComplete {
|
||||||
|
case Success(_) =>
|
||||||
|
localService ! LocalServiceMessage(continent.Id, LocalAction.TriggerSound(player.GUID, target.HackSound, player.Position, 30, 0.49803925f))
|
||||||
localService ! LocalServiceMessage(continent.Id, LocalAction.HackTemporarily(player.GUID, continent, target, unk))
|
localService ! LocalServiceMessage(continent.Id, LocalAction.HackTemporarily(player.GUID, continent, target, unk))
|
||||||
|
case scala.util.Failure(_) => log.warn(s"Hack message failed on target guid: ${target.GUID}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The process of hacking a terminal
|
|
||||||
* Pass the message onto the terminal and onto the local events system.
|
|
||||||
* @param target the `terminal` being hacked
|
|
||||||
* @param unk na;
|
|
||||||
* used by `HackingMessage` as `unk5`
|
|
||||||
* @see `HackMessage`
|
|
||||||
*/
|
|
||||||
//TODO add params here depending on which params in HackMessage are important
|
|
||||||
private def FinishHackingTerminal(target : Terminal, unk : Long)() : Unit = {
|
|
||||||
target.Actor ! CommonMessages.Hack(player)
|
|
||||||
localService ! LocalServiceMessage(continent.Id, LocalAction.TriggerSound(player.GUID, TriggeredSound.HackDoor, player.Position, 30, 0.49803925f))
|
|
||||||
localService ! LocalServiceMessage(continent.Id, LocalAction.HackTemporarily(player.GUID, continent, target, unk))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The process of hacking a locker
|
|
||||||
* Pass the message onto the locker and onto the local events system.
|
|
||||||
* @param target the `locker` being hacked
|
|
||||||
* @param unk na;
|
|
||||||
* used by `HackingMessage` as `unk5`
|
|
||||||
* @see `HackMessage`
|
|
||||||
*/
|
|
||||||
private def FinishHackingLocker(target : Locker, unk : Long)() : Unit = {
|
|
||||||
target.Actor ! CommonMessages.Hack(player)
|
|
||||||
localService ! LocalServiceMessage(continent.Id, LocalAction.TriggerSound(player.GUID, TriggeredSound.HackDoor, player.Position, 30, 0.49803925f))
|
|
||||||
localService ! LocalServiceMessage(continent.Id, LocalAction.HackTemporarily(player.GUID, continent, target, unk))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue