Merge pull request #1142 from ScrawnyRonnie/item_swap

Item Swapping
This commit is contained in:
Fate-JH 2023-11-28 20:05:38 -05:00 committed by GitHub
commit 5552d3469c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 3 deletions

View file

@ -106,7 +106,7 @@ class SessionTerminalHandlers(
lastTerminalOrderFulfillment = true
case Terminal.BuyVehicle(vehicle, _, _)
if tplayer.avatar.purchaseCooldown(vehicle.Definition).nonEmpty =>
if tplayer.avatar.purchaseCooldown(vehicle.Definition).nonEmpty || tplayer.spectator =>
sendResponse(ItemTransactionResultMessage(msg.terminal_guid, TransactionType.Buy, success = false))
lastTerminalOrderFulfillment = true

View file

@ -324,7 +324,7 @@ class PlayerControl(player: Player, avatarActor: typed.ActorRef[AvatarActor.Comm
player.Name,
AvatarAction.ObjectHeld(player.GUID, before, -1)
)
} else if (!resistance && before != slot && (player.DrawnSlot = slot) != before) {
} else if ((!resistance && before != slot && (player.DrawnSlot = slot) != before) && ItemSwapSlot != before) {
val mySlot = if (updateMyHolsterArm) slot else -1 //use as a short-circuit
events ! AvatarServiceMessage(
player.Continent,
@ -353,6 +353,9 @@ class PlayerControl(player: Player, avatarActor: typed.ActorRef[AvatarActor.Comm
log.info(s"${player.Name} lowers ${player.Sex.possessive} hand")
}
}
UpdateItemSwapSlot
} else if (ItemSwapSlot == before) {
UpdateItemSwapSlot
}
case Terminal.TerminalMessage(_, msg, order) =>

View file

@ -42,6 +42,7 @@ trait ContainableBehavior {
* The destination is set back to normal - flag to `0` - when both of the attempts short-circuit due to timeout.
*/
private var waitOnMoveItemOps: Int = 0
private var itemSwapSlot: Int = 10 // Just a number higher than any inventory item slots
final val containerBehavior: Receive = {
/* messages that modify delivery order */
@ -136,6 +137,15 @@ trait ContainableBehavior {
}
/* Functions (item transfer) */
// For issue 1108
def UpdateItemSwapSlot: Int = {
itemSwapSlot = 10
itemSwapSlot
}
// For issue 1108
def ItemSwapSlot: Int = {
itemSwapSlot
}
protected def ContainableMoveItem(
destination: PlanetSideServerObject with Container,
@ -154,6 +164,7 @@ trait ContainableBehavior {
LocalPutItemInSlot(item, dest) match {
case Containable.ItemPutInSlot(_, _, _, None) => ; //success
case Containable.ItemPutInSlot(_, _, _, Some(swapItem)) => //success, but with swap item
itemSwapSlot = dest
LocalPutItemInSlotOnlyOrAway(swapItem, slot) match {
case Containable.ItemPutInSlot(_, _, _, None) => ;
case _ =>
@ -174,6 +185,7 @@ trait ContainableBehavior {
case Success(Containable.ItemPutInSlot(_, _, _, None)) => ; //successful
case Success(Containable.ItemPutInSlot(_, _, _, Some(swapItem))) => //successful, but with swap item
itemSwapSlot = dest
PutItBackOrDropIt(source, swapItem, slot, destination.Actor)
case Success(_: Containable.CanNotPutItemInSlot) => //failure case ; try restore original item placement

View file

@ -25,7 +25,6 @@ import scala.util.Random
*/
class HackCaptureActor extends Actor {
private[this] val log = org.log4s.getLogger
/** main timer for completing or clearing hacked states */
private var clearTrigger: Cancellable = Default.Cancellable
/** list of currently hacked server objects */
@ -167,6 +166,7 @@ class HackCaptureActor extends Actor {
case Some((owner, _, _)) =>
log.error(s"TrySpawnCaptureFlag: couldn't find any neighbouring $hackingFaction facilities of ${owner.Name} for LLU hack")
owner.GetFlagSocket.foreach { _.clearOldFlagData() }
terminal.Zone.LocalEvents ! CaptureFlagManager.Lost(owner.GetFlag.get, CaptureFlagLostReasonEnum.Ended)
false
case _ =>
log.error(s"TrySpawnCaptureFlag: expecting a terminal ${terminal.GUID.guid} with the ctf owning facility")