From 2dd44142d2088b32d8eaee72c41ecee2890fce2d Mon Sep 17 00:00:00 2001 From: Fate-JH Date: Tue, 14 May 2024 22:03:27 -0400 Subject: [PATCH] restored experience awarded from mine kills; removed situations where mine damage no longer works (#1197) --- .../session/support/ZoningOperations.scala | 3 +- .../objects/ExplosiveDeployable.scala | 74 +++++++++---------- .../objects/sourcing/PlayerSource.scala | 2 +- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/main/scala/net/psforever/actors/session/support/ZoningOperations.scala b/src/main/scala/net/psforever/actors/session/support/ZoningOperations.scala index bb0c93584..1be59aa2b 100644 --- a/src/main/scala/net/psforever/actors/session/support/ZoningOperations.scala +++ b/src/main/scala/net/psforever/actors/session/support/ZoningOperations.scala @@ -3048,12 +3048,12 @@ class ZoningOperations( //killed during spawn setup or possibly a relog into a corpse (by accident?) tplayer.Actor ! Player.Die() } else { + //properly logged in AvatarActor.savePlayerData(tplayer) sessionLogic.general.displayCharSavedMsgThenRenewTimer( Config.app.game.savedMsg.short.fixed, Config.app.game.savedMsg.short.variable ) - //player val effortBy = nextSpawnPoint .collect { case sp: SpawnTube => (sp, continent.GUID(sp.Owner.GUID)) } .collect { @@ -3078,6 +3078,7 @@ class ZoningOperations( } } upstreamMessageCount = 0 + player.allowInteraction = true setAvatar = true if ( !account.gm && /* gm's are excluded */ diff --git a/src/main/scala/net/psforever/objects/ExplosiveDeployable.scala b/src/main/scala/net/psforever/objects/ExplosiveDeployable.scala index a99d72c15..928abb746 100644 --- a/src/main/scala/net/psforever/objects/ExplosiveDeployable.scala +++ b/src/main/scala/net/psforever/objects/ExplosiveDeployable.scala @@ -3,7 +3,7 @@ package net.psforever.objects import akka.actor.{Actor, ActorContext, ActorRef, Props} import net.psforever.objects.ce._ -import net.psforever.objects.definition.{DeployableDefinition, ExoSuitDefinition} +import net.psforever.objects.definition.DeployableDefinition import net.psforever.objects.definition.converter.SmallDeployableConverter import net.psforever.objects.equipment.JammableUnit import net.psforever.objects.geometry.d3.VolumetricGeometry @@ -11,14 +11,14 @@ import net.psforever.objects.serverobject.affinity.FactionAffinity import net.psforever.objects.serverobject.PlanetSideServerObject import net.psforever.objects.serverobject.damage.{Damageable, DamageableEntity} import net.psforever.objects.serverobject.damage.Damageable.Target -import net.psforever.objects.sourcing.{DeployableSource, PlayerSource, SourceEntry, UniquePlayer} +import net.psforever.objects.sourcing.{DeployableSource, PlayerSource, SourceEntry} import net.psforever.objects.vital.etc.TrippedMineReason import net.psforever.objects.vital.resolution.ResolutionCalculations.Output import net.psforever.objects.vital.{SimpleResolutions, Vitality} import net.psforever.objects.vital.interaction.{DamageInteraction, DamageResult} import net.psforever.objects.vital.projectile.ProjectileReason import net.psforever.objects.zones.Zone -import net.psforever.types.{CharacterSex, ExoSuitType, Vector3} +import net.psforever.types.Vector3 import net.psforever.services.Service import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage} import net.psforever.services.local.{LocalAction, LocalServiceMessage} @@ -321,40 +321,40 @@ object MineDeployableControl { private case class Triggered() def trippedMineReason(mine: ExplosiveDeployable): TrippedMineReason = { - val deployableSource = DeployableSource(mine) - val blame = mine.OwnerName match { - case Some(name) => - val(charId, exosuit, seatedIn): (Long, ExoSuitType.Value, Option[(SourceEntry, Int)]) = mine.Zone - .LivePlayers - .find { _.Name.equals(name) } match { - case Some(player) => - //if the owner is alive in the same zone as the mine, use data from their body to create the source - (player.CharId, player.ExoSuit, PlayerSource.mountableAndSeat(player)) - case None => - //if the owner is as dead as a corpse or is not in the same zone as the mine, use defaults - (0L, ExoSuitType.Standard, None) - } - val faction = mine.Faction - PlayerSource( - GlobalDefinitions.avatar, - exosuit, - seatedIn, - health = 100, - armor = 0, - mine.Position, - Vector3.Zero, - None, - crouching = false, - jumping = false, - ExoSuitDefinition.Select(exosuit, faction), - bep = 0, - progress = PlayerSource.Nobody.progress, - UniquePlayer(charId, name, CharacterSex.Male, mine.Faction) - ) - case None => - //credit where credit is due - deployableSource - } + lazy val deployableSource = DeployableSource(mine) + val zone = mine.Zone + val ownerName = mine.OwnerName + val blame = zone + .Players + .find(a => ownerName.contains(a.name)) + .collect { a => + val name = a.name + assignBlameToFrom(name, zone.LivePlayers) + .orElse(assignBlameToFrom(name, zone.Corpses)) + .getOrElse { + val player = PlayerSource(name, mine.Faction, mine.Position) //might report minor inconsistencies, e.g., exo-suit type + player.copy(unique = player.unique.copy(charId = a.id), progress = a.scorecard.CurrentLife) + } + } + .getOrElse(deployableSource) TrippedMineReason(deployableSource, blame) } + + /** + * Find a player with a given name from this list of possible players. + * If the player is seated, attach a shallow copy of the mounting information. + * @param name player name + * @param blameList possible players in which to find the player name + * @return discovered player as a reference, or `None` if not found + */ + private def assignBlameToFrom(name: String, blameList: List[Player]): Option[SourceEntry] = { + blameList + .find(_.Name.equals(name)) + .map { player => + PlayerSource + .mountableAndSeat(player) + .map { case (mount, seat) => PlayerSource.inSeat(player, mount, seat) } + .getOrElse { PlayerSource(player) } + } + } } diff --git a/src/main/scala/net/psforever/objects/sourcing/PlayerSource.scala b/src/main/scala/net/psforever/objects/sourcing/PlayerSource.scala index c7405e041..042ed7db3 100644 --- a/src/main/scala/net/psforever/objects/sourcing/PlayerSource.scala +++ b/src/main/scala/net/psforever/objects/sourcing/PlayerSource.scala @@ -141,7 +141,7 @@ object PlayerSource { player.Jumping, ExoSuitDefinition.Select(exosuit, player.Faction), avatar.bep, - progress = tokenLife, + progress = avatar.scorecard.CurrentLife, UniquePlayer(player) ) }