Merge pull request #1253 from ScrawnyRonnie/capture-exp

Facility Capture Experience
This commit is contained in:
ScrawnyRonnie 2025-01-23 14:57:21 -05:00 committed by GitHub
commit 7baf0d8cfb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 13 deletions

View file

@ -59,7 +59,7 @@ class SessionAvatarHandlers(
//TODO squad services deactivated, participation trophy rewards for now - 11-20-2023 //TODO squad services deactivated, participation trophy rewards for now - 11-20-2023
//must be in a squad to earn experience //must be in a squad to earn experience
val charId = player.CharId val charId = player.CharId
val squadUI = sessionLogic.squad.squadUI /*val squadUI = sessionLogic.squad.squadUI
val participation = continent val participation = continent
.Building(buildingId) .Building(buildingId)
.map { building => .map { building =>
@ -117,7 +117,10 @@ class SessionAvatarHandlers(
exp.ToDatabase.reportFacilityCapture(charId, buildingId, zoneNumber, modifiedExp, expType="bep") exp.ToDatabase.reportFacilityCapture(charId, buildingId, zoneNumber, modifiedExp, expType="bep")
avatarActor ! AvatarActor.AwardFacilityCaptureBep(modifiedExp) avatarActor ! AvatarActor.AwardFacilityCaptureBep(modifiedExp)
Some(modifiedExp) Some(modifiedExp)
} }*/
//if not in squad (temporary)
exp.ToDatabase.reportFacilityCapture(charId, zoneNumber, buildingId, cep, expType="bep")
avatarActor ! AvatarActor.AwardFacilityCaptureBep(cep)
} }
/** /**

View file

@ -41,13 +41,13 @@ trait FacilityHackParticipation extends ParticipationLogic {
.filterNot { case (_, (_, _, t)) => curr - t > hackTime } .filterNot { case (_, (_, _, t)) => curr - t > hackTime }
.partition { case (p, _) => uniqueList2.contains(p) } .partition { case (p, _) => uniqueList2.contains(p) }
} }
val newParticipaants = list val newParticipants = list
.filterNot { p => .filterNot { p =>
playerContribution.exists { case (u, _) => p.CharId == u } playerContribution.exists { case (u, _) => p.CharId == u }
} }
playerContribution = playerContribution =
vanguardParticipants.map { case (u, (p, d, _)) => (u, (p, d + 1, curr)) } ++ vanguardParticipants.map { case (u, (p, d, _)) => (u, (p, d + 1, curr)) } ++
newParticipaants.map { p => (p.CharId, (p, 1, curr)) } ++ newParticipants.map { p => (p.CharId, (p, 1, curr)) } ++
missingParticipants missingParticipants
} }
} }

View file

@ -28,7 +28,9 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
def TryUpdate(): Unit = { def TryUpdate(): Unit = {
val list = building.PlayersInSOI val list = building.PlayersInSOI
updatePlayers(list) if (list.nonEmpty) {
updatePlayers(list)
}
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
if (now - lastInfoRequest > 60000L) { if (now - lastInfoRequest > 60000L) {
updatePopulationOverTime(list, now, before = 900000L) updatePopulationOverTime(list, now, before = 900000L)
@ -123,7 +125,7 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
hackStart, hackStart,
completionTime, completionTime,
opposingFaction, opposingFaction,
contributionOpposing contributionVictor
) )
) )
//1) experience from killing opposingFaction across duration of hack //1) experience from killing opposingFaction across duration of hack
@ -249,11 +251,14 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
overallTimeMultiplier * overallTimeMultiplier *
Config.app.game.experience.cep.rate + competitionBonus Config.app.game.experience.cep.rate + competitionBonus
).toLong ).toLong
//8. reward participants //8. reward participants that are still in the zone
//Classically, only players in the SOI are rewarded, and the llu runner too
val hackerId = hacker.CharId val hackerId = hacker.CharId
val contributingPlayers = contributionVictor
.filter { case (player, _, _) => player.Zone.id == building.Zone.id }
.map { case (player, _, _) => player }
.toList
//terminal hacker (always cep) //terminal hacker (always cep)
if (playersInSoi.exists(_.CharId == hackerId) && flagCarrier.map(_.CharId).getOrElse(0L) != hackerId) { if (contributingPlayers.exists(_.CharId == hackerId) && flagCarrier.map(_.CharId).getOrElse(0L) != hackerId) {
ToDatabase.reportFacilityCapture( ToDatabase.reportFacilityCapture(
hackerId, hackerId,
zoneNumber, zoneNumber,
@ -264,7 +269,7 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
events ! AvatarServiceMessage(hacker.Name, AvatarAction.AwardCep(hackerId, finalCep)) events ! AvatarServiceMessage(hacker.Name, AvatarAction.AwardCep(hackerId, finalCep))
} }
//bystanders (cep if squad leader, bep otherwise) //bystanders (cep if squad leader, bep otherwise)
playersInSoi contributingPlayers
.filterNot { _.CharId == hackerId } .filterNot { _.CharId == hackerId }
.foreach { player => .foreach { player =>
val charId = player.CharId val charId = player.CharId
@ -336,7 +341,7 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
val towerRadius = math.pow(tower.Definition.SOIRadius.toDouble * 0.7d, 2d).toFloat val towerRadius = math.pow(tower.Definition.SOIRadius.toDouble * 0.7d, 2d).toFloat
list list
.map { case (p, f, kills) => .map { case (p, f, kills) =>
val filteredKills = kills.filter { kill => Vector3.DistanceSquared(kill.victim.Position.xy, towerPosition) <= towerRadius } val filteredKills = kills.filter { kill => Vector3.DistanceSquared(kill.victim.Position.xy, towerPosition) >= towerRadius }
(p, f, filteredKills) (p, f, filteredKills)
} }
.filter { case (_, _, kills) => kills.nonEmpty } .filter { case (_, _, kills) => kills.nonEmpty }

View file

@ -11,11 +11,14 @@ import net.psforever.util.Config
final case class TowerHackParticipation(building: Building) extends FacilityHackParticipation { final case class TowerHackParticipation(building: Building) extends FacilityHackParticipation {
def TryUpdate(): Unit = { def TryUpdate(): Unit = {
val list = building.PlayersInSOI val list = building.PlayersInSOI
updatePlayers(building.PlayersInSOI) if (list.nonEmpty) {
updatePlayers(list)
}
val now = System.currentTimeMillis() val now = System.currentTimeMillis()
if (now - lastInfoRequest > 60000L) { if (now - lastInfoRequest > 60000L) {
updatePopulationOverTime(list, now, before = 300000L) updatePopulationOverTime(list, now, before = 300000L)
} }
lastInfoRequest = now
} }
def RewardFacilityCapture( def RewardFacilityCapture(

View file

@ -106,7 +106,7 @@ class HackCaptureActor extends Actor {
NotifyHackStateChange(target, isResecured = true) NotifyHackStateChange(target, isResecured = true)
building.Participation.RewardFacilityCapture( building.Participation.RewardFacilityCapture(
target.Faction, target.Faction,
faction, HackCaptureActor.GetAttackingFaction(building, faction),
hacker, hacker,
facilityHackTime, facilityHackTime,
hackTime, hackTime,
@ -347,6 +347,30 @@ object HackCaptureActor {
.get .get
} }
def GetAttackingFaction(
building: Building,
excludeThisFaction: PlanetSideEmpire.Value
): PlanetSideEmpire.Value = {
// Use PlayerContributionRaw to calculate attacking faction
val factionEfforts = building.Participation
.PlayerContributionRaw
.values
.foldLeft(Array.fill(4)(0L)) { case (efforts, (player, duration, _)) =>
val factionId = player.Faction.id
efforts.update(factionId, efforts(factionId) + duration)
efforts
}
// Exclude the specified faction
factionEfforts.update(excludeThisFaction.id, Long.MinValue)
// Find the faction with the highest contribution
factionEfforts.indices
.maxByOption(factionEfforts)
.map(PlanetSideEmpire.apply)
.getOrElse(PlanetSideEmpire.NEUTRAL)
}
def GetHackingFaction(terminal: CaptureTerminal): Option[PlanetSideEmpire.Value] = { def GetHackingFaction(terminal: CaptureTerminal): Option[PlanetSideEmpire.Value] = {
terminal.HackedBy.map { a => a.player.Faction } terminal.HackedBy.map { a => a.player.Faction }
} }