reverse order of protocol so that the avatar state (normal, csr) is checked first and then it calls back up to the specific avatar to perform the action

This commit is contained in:
Fate-JH 2025-09-23 13:08:18 -04:00
parent f88323805a
commit 11d14b0626
6 changed files with 50 additions and 15 deletions

View file

@ -10,6 +10,7 @@ import net.psforever.objects.PlanetSideGameObject
import net.psforever.objects.inventory.Container
import net.psforever.objects.serverobject.containable.ContainableBehavior
import net.psforever.objects.serverobject.mount.Mountable
import net.psforever.objects.vital.RevivingActivity
import net.psforever.packet.game.{AvatarImplantMessage, CreateShortcutMessage, ImplantAction}
import net.psforever.services.avatar.AvatarServiceResponse
import net.psforever.types.ImplantType
@ -474,7 +475,7 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
player.FreeHand.Equipment.foreach(DropEquipmentFromInventory(player)(_))
AvatarActor.updateToolDischargeFor(avatar)
AvatarActor.savePlayerLocation(player)
ops.revive(player.GUID)
ops.revive()
avatarActor ! AvatarActor.InitializeImplants
//render
CustomerServiceRepresentativeMode.renderPlayer(sessionLogic, continent, player)
@ -484,7 +485,17 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
case AvatarResponse.Revive(revivalTargetGuid)
if resolvedPlayerGuid == revivalTargetGuid =>
ops.revive(revivalTargetGuid)
ops.revive()
player.Actor ! Player.Revive
player.History
.findLast { _.isInstanceOf[RevivingActivity] }
.map {
case activity: RevivingActivity
if System.currentTimeMillis() - activity.time < 5000L =>
val reviveMessage = s"@YouHaveBeenMessage^revived~^${activity.user.unique.name}~"
sendResponse(ChatMsg(ChatMessageType.UNK_227, reviveMessage))
None
}
/* uncommon messages (utility, or once in a while) */
case AvatarResponse.ChangeAmmo(weapon_guid, weapon_slot, previous_guid, ammo_id, ammo_guid, ammo_data)

View file

@ -9,6 +9,7 @@ import net.psforever.objects.{Default, PlanetSideGameObject}
import net.psforever.objects.serverobject.containable.ContainableBehavior
import net.psforever.objects.serverobject.mount.Mountable
import net.psforever.objects.sourcing.PlayerSource
import net.psforever.objects.vital.RevivingActivity
import net.psforever.objects.vital.interaction.Adversarial
import net.psforever.packet.game.{AvatarImplantMessage, CreateShortcutMessage, ImplantAction, PlanetsideStringAttributeMessage}
import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage}
@ -592,7 +593,17 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
case AvatarResponse.Revive(revivalTargetGuid)
if resolvedPlayerGuid == revivalTargetGuid =>
log.info(s"No time for rest, ${player.Name}. Back on your feet!")
ops.revive(revivalTargetGuid)
ops.revive()
player.Actor ! Player.Revive
player.History
.findLast { _.isInstanceOf[RevivingActivity] }
.map {
case activity: RevivingActivity
if System.currentTimeMillis() - activity.time < 5000L =>
val reviveMessage = s"@YouHaveBeenMessage^revived~^${activity.user.unique.name}~"
sendResponse(ChatMsg(ChatMessageType.UNK_227, reviveMessage))
None
}
/* uncommon messages (utility, or once in a while) */
case AvatarResponse.ChangeAmmo(weapon_guid, weapon_slot, previous_guid, ammo_id, ammo_guid, ammo_data)

View file

@ -201,20 +201,12 @@ class SessionAvatarHandlers(
)
}
def revive(revivalTargetGuid: PlanetSideGUID): Unit = {
def revive(): Unit = {
val spawn = sessionLogic.zoning.spawn
spawn.reviveTimer.cancel()
spawn.reviveTimer = Default.Cancellable
spawn.respawnTimer.cancel()
spawn.respawnTimer = Default.Cancellable
player.Revive
val health = player.Health
sendResponse(PlanetsideAttributeMessage(revivalTargetGuid, attribute_type=0, health))
sendResponse(AvatarDeadStateMessage(DeadState.Alive, timer_max=0, timer=0, player.Position, player.Faction, unk5=true))
continent.AvatarEvents ! AvatarServiceMessage(
continent.id,
AvatarAction.PlanetsideAttributeToAll(revivalTargetGuid, attribute_type=0, health)
)
}
def killedWhileMounted(obj: PlanetSideGameObject with Mountable, playerGuid: PlanetSideGUID): Unit = {

View file

@ -629,6 +629,8 @@ object Player {
}
}
case object Revive
def apply(core: Avatar): Player = {
new Player(core)
}

View file

@ -70,6 +70,7 @@ object Players {
val name = target.Name
val medicName = medic.Name
log.info(s"$medicName had revived $name")
//give credit even if the player does not revive
target.LogActivity(RevivingActivity(PlayerSource(target), PlayerSource(medic), target.MaxHealth, item.Definition))
val magazine = item.Discharge(Some(25))
target.Zone.AvatarEvents ! AvatarServiceMessage(
@ -79,9 +80,7 @@ object Players {
InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine)
)
)
target.Zone.AvatarEvents ! AvatarServiceMessage(name, AvatarAction.Revive(target.GUID))
val reviveMessage = s"@YouHaveBeenMessage^revived~^$medicName~"
PlayerControl.sendResponse(target.Zone, name, ChatMsg(ChatMessageType.UNK_227, reviveMessage))
PlayerControl.sendResponse(target.Zone, name, AvatarAction.Revive(target.GUID))
}
/**

View file

@ -116,6 +116,19 @@ class PlayerControl(player: Player, avatarActor: typed.ActorRef[AvatarActor.Comm
case Player.Die(None) =>
suicide()
case Player.Revive
if player.Health == 0 && !player.isBackpack =>
player.Revive
val revivalTargetGuid = player.GUID
val health = player.Health
val zone = player.Zone
val zoneId = zone.id
sendResponse(zone, zoneId, PlanetsideAttributeMessage(revivalTargetGuid, attribute_type=0, health))
sendResponse(zone, zoneId, AvatarDeadStateMessage(DeadState.Alive, timer_max=0, timer=0, player.Position, player.Faction, unk5=true))
sendResponse(zone, zoneId, AvatarAction.PlanetsideAttributeToAll(revivalTargetGuid, attribute_type=0, health))
avatarActor ! AvatarActor.InitializeImplants
avatarActor ! AvatarActor.SuspendStaminaRegeneration(Duration(1, "second"))
case CommonMessages.Use(user, Some(item: Tool))
if item.Definition == GlobalDefinitions.medicalapplicator && player.isAlive =>
//heal
@ -982,6 +995,9 @@ class PlayerControl(player: Player, avatarActor: typed.ActorRef[AvatarActor.Comm
super.CancelJammeredStatus(target)
//uninitialize implants
avatarActor ! AvatarActor.DeinitializeImplants
//no stamina
avatarActor ! AvatarActor.SuspendStaminaRegeneration(Duration(1, "day"))
avatarActor ! AvatarActor.ConsumeStamina(player.avatar.maxStamina)
//log historical event
target.LogActivity(cause)
@ -1222,6 +1238,10 @@ object PlayerControl {
zone.AvatarEvents ! AvatarServiceMessage(channel, AvatarAction.SendResponse(Service.defaultPlayerGUID, msg))
}
def sendResponse(zone: Zone, channel: String, msg: AvatarAction.Action): Unit = {
zone.AvatarEvents ! AvatarServiceMessage(channel, msg)
}
def maxRestriction(player: Player, slot: Int): Boolean = {
if (player.ExoSuit == ExoSuitType.MAX) {
slot != 0