mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-01-19 18:44:45 +00:00
Merge pull request #1253 from ScrawnyRonnie/capture-exp
Facility Capture Experience
This commit is contained in:
commit
7baf0d8cfb
|
|
@ -59,7 +59,7 @@ class SessionAvatarHandlers(
|
|||
//TODO squad services deactivated, participation trophy rewards for now - 11-20-2023
|
||||
//must be in a squad to earn experience
|
||||
val charId = player.CharId
|
||||
val squadUI = sessionLogic.squad.squadUI
|
||||
/*val squadUI = sessionLogic.squad.squadUI
|
||||
val participation = continent
|
||||
.Building(buildingId)
|
||||
.map { building =>
|
||||
|
|
@ -117,7 +117,10 @@ class SessionAvatarHandlers(
|
|||
exp.ToDatabase.reportFacilityCapture(charId, buildingId, zoneNumber, modifiedExp, expType="bep")
|
||||
avatarActor ! AvatarActor.AwardFacilityCaptureBep(modifiedExp)
|
||||
Some(modifiedExp)
|
||||
}
|
||||
}*/
|
||||
//if not in squad (temporary)
|
||||
exp.ToDatabase.reportFacilityCapture(charId, zoneNumber, buildingId, cep, expType="bep")
|
||||
avatarActor ! AvatarActor.AwardFacilityCaptureBep(cep)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ trait FacilityHackParticipation extends ParticipationLogic {
|
|||
.filterNot { case (_, (_, _, t)) => curr - t > hackTime }
|
||||
.partition { case (p, _) => uniqueList2.contains(p) }
|
||||
}
|
||||
val newParticipaants = list
|
||||
val newParticipants = list
|
||||
.filterNot { p =>
|
||||
playerContribution.exists { case (u, _) => p.CharId == u }
|
||||
}
|
||||
playerContribution =
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
|
|||
|
||||
def TryUpdate(): Unit = {
|
||||
val list = building.PlayersInSOI
|
||||
updatePlayers(list)
|
||||
if (list.nonEmpty) {
|
||||
updatePlayers(list)
|
||||
}
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - lastInfoRequest > 60000L) {
|
||||
updatePopulationOverTime(list, now, before = 900000L)
|
||||
|
|
@ -123,7 +125,7 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
|
|||
hackStart,
|
||||
completionTime,
|
||||
opposingFaction,
|
||||
contributionOpposing
|
||||
contributionVictor
|
||||
)
|
||||
)
|
||||
//1) experience from killing opposingFaction across duration of hack
|
||||
|
|
@ -249,11 +251,14 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
|
|||
overallTimeMultiplier *
|
||||
Config.app.game.experience.cep.rate + competitionBonus
|
||||
).toLong
|
||||
//8. reward participants
|
||||
//Classically, only players in the SOI are rewarded, and the llu runner too
|
||||
//8. reward participants that are still in the zone
|
||||
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)
|
||||
if (playersInSoi.exists(_.CharId == hackerId) && flagCarrier.map(_.CharId).getOrElse(0L) != hackerId) {
|
||||
if (contributingPlayers.exists(_.CharId == hackerId) && flagCarrier.map(_.CharId).getOrElse(0L) != hackerId) {
|
||||
ToDatabase.reportFacilityCapture(
|
||||
hackerId,
|
||||
zoneNumber,
|
||||
|
|
@ -264,7 +269,7 @@ final case class MajorFacilityHackParticipation(building: Building) extends Faci
|
|||
events ! AvatarServiceMessage(hacker.Name, AvatarAction.AwardCep(hackerId, finalCep))
|
||||
}
|
||||
//bystanders (cep if squad leader, bep otherwise)
|
||||
playersInSoi
|
||||
contributingPlayers
|
||||
.filterNot { _.CharId == hackerId }
|
||||
.foreach { player =>
|
||||
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
|
||||
list
|
||||
.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)
|
||||
}
|
||||
.filter { case (_, _, kills) => kills.nonEmpty }
|
||||
|
|
|
|||
|
|
@ -11,11 +11,14 @@ import net.psforever.util.Config
|
|||
final case class TowerHackParticipation(building: Building) extends FacilityHackParticipation {
|
||||
def TryUpdate(): Unit = {
|
||||
val list = building.PlayersInSOI
|
||||
updatePlayers(building.PlayersInSOI)
|
||||
if (list.nonEmpty) {
|
||||
updatePlayers(list)
|
||||
}
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - lastInfoRequest > 60000L) {
|
||||
updatePopulationOverTime(list, now, before = 300000L)
|
||||
}
|
||||
lastInfoRequest = now
|
||||
}
|
||||
|
||||
def RewardFacilityCapture(
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class HackCaptureActor extends Actor {
|
|||
NotifyHackStateChange(target, isResecured = true)
|
||||
building.Participation.RewardFacilityCapture(
|
||||
target.Faction,
|
||||
faction,
|
||||
HackCaptureActor.GetAttackingFaction(building, faction),
|
||||
hacker,
|
||||
facilityHackTime,
|
||||
hackTime,
|
||||
|
|
@ -347,6 +347,30 @@ object HackCaptureActor {
|
|||
.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] = {
|
||||
terminal.HackedBy.map { a => a.player.Faction }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue