Merge pull request #1258 from ScrawnyRonnie/squad_kill_exp

Spread The Wealth (With My Squad)
This commit is contained in:
ScrawnyRonnie 2025-01-30 12:20:11 -05:00 committed by GitHub
commit eb04d37108
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 49 additions and 2 deletions

View file

@ -3039,6 +3039,8 @@ class AvatarActor(
if (exp > 0L) {
setBep(avatar.bep + exp, msg)
zone.actor ! ZoneActor.RewardOurSupporters(playerSource, historyTranscript, killStat, exp)
zone.AvatarEvents ! AvatarServiceMessage(
player.Name, AvatarAction.ShareKillExperienceWithSquad(player, exp))
}
}

View file

@ -473,6 +473,9 @@ class AvatarHandlerLogic(val ops: SessionAvatarHandlers, implicit val context: A
case AvatarResponse.FacilityCaptureRewards(buildingId, zoneNumber, cep) =>
ops.facilityCaptureRewards(buildingId, zoneNumber, cep)
case AvatarResponse.ShareKillExperienceWithSquad(killer, exp) =>
ops.shareKillExperienceWithSquad(killer, exp)
case AvatarResponse.SendResponse(msg) =>
sendResponse(msg)

View file

@ -3,7 +3,7 @@ package net.psforever.actors.session.support
import akka.actor.{ActorContext, typed}
import net.psforever.objects.serverobject.mount.Mountable
import net.psforever.objects.{Default, PlanetSideGameObject}
import net.psforever.objects.{Default, PlanetSideGameObject, Player}
import net.psforever.objects.sourcing.{PlayerSource, SourceEntry}
import net.psforever.packet.game.objectcreate.ConstructorData
import net.psforever.objects.zones.exp
@ -123,6 +123,31 @@ class SessionAvatarHandlers(
avatarActor ! AvatarActor.AwardFacilityCaptureBep(cep)
}
/**
*
* @param killer the player who got the kill
* @param exp the amount of bep they received for the kill
* Squad members of a "killer" will receive a split of the experience if they are both alive
* and in the same zone as the killer. The amount received is
* based on the size of the squad. Each squad member that meets the criteria will receive a fractional split.
*/
def shareKillExperienceWithSquad(killer: Player, exp: Long): Unit = {
//TODO consider squad experience waypoint in exp calculation
val squadUI = sessionLogic.squad.squadUI
val squadSize = squadUI.size
if (squadSize > 1) {
val expSplit = exp / squadSize
val squadMembers = squadUI.filterNot(_._1 == killer.CharId).map { case (_, member) => member }.toList.map(_.name)
val playersInZone = killer.Zone.Players.map { avatar => (avatar.id, avatar.basic.name) }
val squadMembersHere = playersInZone.filter(member => squadMembers.contains(member._2))
squadMembersHere.foreach { member =>
killer.Zone.AvatarEvents ! AvatarServiceMessage(
member._2,
AvatarAction.AwardBep(member._1, expSplit, ExperienceType.Normal))
}
}
}
/**
* Properly format a `DestroyDisplayMessage` packet
* given sufficient information about a target (victim) and an actor (killer).

View file

@ -182,7 +182,8 @@ class ZoneActor(
case ZoneMapUpdate() =>
zone.Buildings
.filter(_._2.BuildingType == StructureType.Facility)
.filter(building =>
building._2.BuildingType == StructureType.Facility || building._2.BuildingType == StructureType.Tower)
.values
.foreach(_.Actor ! BuildingActor.MapUpdate())
Behaviors.same

View file

@ -29,8 +29,13 @@ object Support {
//setup
val historyList = history.toList
val withKills = victim.progress.kills.nonEmpty
//TODO Issue #1259 - Use another method to capture time of death than current time ("kill shots" aren't working)
/*
val fullLifespan = (historyList.headOption, historyList.lastOption) match {
case (Some(spawn), Some(death)) => death.time - spawn.time
*/
val fullLifespan = historyList.headOption match {
case Some(spawn) => System.currentTimeMillis() - spawn.time
case _ => 0L
}
val recordOfWornTimes = countTimeWhileExoSuitOrMounted(historyList)

View file

@ -458,6 +458,15 @@ class AvatarService(zone: Zone) extends Actor {
)
)
case AvatarAction.ShareKillExperienceWithSquad(killer, exp) =>
AvatarEvents.publish(
AvatarServiceResponse(
s"/$forChannel/Avatar",
Service.defaultPlayerGUID,
AvatarResponse.ShareKillExperienceWithSquad(killer, exp)
)
)
case _ => ()
}

View file

@ -160,6 +160,7 @@ object AvatarAction {
final case class AwardBep(charId: Long, bep: Long, expType: ExperienceType) extends Action
final case class AwardCep(charId: Long, bep: Long) extends Action
final case class FacilityCaptureRewards(building_id: Int, zone_number: Int, exp: Long) extends Action
final case class ShareKillExperienceWithSquad(killer: Player, exp: Long) extends Action
final case class TeardownConnection() extends Action
// final case class PlayerStateShift(killer : PlanetSideGUID, victim : PlanetSideGUID) extends Action

View file

@ -132,4 +132,5 @@ object AvatarResponse {
final case class AwardBep(charId: Long, bep: Long, expType: ExperienceType) extends Response
final case class AwardCep(charId: Long, bep: Long) extends Response
final case class FacilityCaptureRewards(building_id: Int, zone_number: Int, exp: Long) extends Response
final case class ShareKillExperienceWithSquad(killer: Player, exp: Long) extends Response
}