mirror of
https://github.com/psforever/PSF-LoginServer.git
synced 2026-07-16 08:55:18 +00:00
tighened up the iterative processing aspects of kill assist calculations; wrong database query for assists; assumption of flag being acquired when it really wasn't; assumption of facility capture start when no longer represented
This commit is contained in:
parent
5552d3469c
commit
f454748c28
4 changed files with 69 additions and 43 deletions
|
|
@ -191,6 +191,7 @@ object ExoSuitDefinition {
|
|||
case PlanetSideEmpire.TR => GlobalDefinitions.TRMAX.Use
|
||||
case PlanetSideEmpire.NC => GlobalDefinitions.NCMAX.Use
|
||||
case PlanetSideEmpire.VS => GlobalDefinitions.VSMAX.Use
|
||||
case _ => GlobalDefinitions.Standard.Use
|
||||
}
|
||||
case _ => GlobalDefinitions.Standard.Use
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,10 +145,11 @@ object KillAssists {
|
|||
.orElse {
|
||||
limitHistoryToThisLife(history)
|
||||
.lastOption
|
||||
.collect { case dam: DamagingActivity =>
|
||||
val res = dam.data
|
||||
(res, res.adversarial.get.attacker)
|
||||
.collect { case dam: DamagingActivity
|
||||
if dam.data.adversarial.nonEmpty =>
|
||||
dam.data
|
||||
}
|
||||
.map { data => (data, data.adversarial.get.attacker) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -600,37 +601,49 @@ object KillAssists {
|
|||
): Seq[(Long, Int)] = {
|
||||
var amt = amount
|
||||
var count = 0
|
||||
var newOrder: Seq[(Long, Int)] = Nil
|
||||
var newOrderPos: Seq[(Long, Int)] = Nil
|
||||
var newOrderNeg: Seq[(Long, Int)] = Nil
|
||||
order.takeWhile { entry =>
|
||||
val (id, total) = entry
|
||||
if (id > 0 && total > 0) {
|
||||
val part = participants(id)
|
||||
if (amount > total) {
|
||||
//drop this entry
|
||||
participants.put(id, part.copy(amount = 0, weapons = Nil)) //just in case
|
||||
amt = amt - total
|
||||
} else {
|
||||
//edit around the inclusion of this entry
|
||||
val newTotal = total - amt
|
||||
val trimmedWeapons = {
|
||||
var index = -1
|
||||
var weaponSum = 0
|
||||
val pweapons = part.weapons
|
||||
while (weaponSum < amt) {
|
||||
index += 1
|
||||
weaponSum = weaponSum + pweapons(index).amount
|
||||
participants.get(id) match {
|
||||
case Some(part) =>
|
||||
val reduceByValue = math.min(amt, total)
|
||||
val trimmedWeapons = {
|
||||
var index = 0
|
||||
var weaponSum = 0
|
||||
val pweapons = part.weapons
|
||||
val pwepiter = pweapons.iterator
|
||||
while (pwepiter.hasNext && weaponSum < reduceByValue) {
|
||||
weaponSum = weaponSum + pwepiter.next().amount
|
||||
index += 1
|
||||
}
|
||||
//output list(s)
|
||||
(if (weaponSum == reduceByValue) {
|
||||
newOrderNeg = newOrderNeg :+ (id, 0)
|
||||
index += 1
|
||||
pweapons.drop(index)
|
||||
} else if (weaponSum > reduceByValue) {
|
||||
newOrderPos = (id, total - amt) +: newOrderPos
|
||||
val remainder = pweapons.drop(index)
|
||||
remainder.headOption.map(_.copy(amount = weaponSum - reduceByValue)) ++ remainder.tail
|
||||
} else {
|
||||
newOrderPos = (id, total - amt) +: newOrderPos
|
||||
val remainder = pweapons.drop(index)
|
||||
remainder.headOption.map(_.copy(amount = reduceByValue - weaponSum)) ++ remainder.tail
|
||||
}) ++ pweapons.take(index).map(_.copy(amount = 0))
|
||||
}
|
||||
(pweapons(index).copy(amount = weaponSum - amt) +: pweapons.slice(index+1, pweapons.size)) ++
|
||||
pweapons.slice(0, index).map(_.copy(amount = 0))
|
||||
}
|
||||
newOrder = (id, newTotal) +: newOrder
|
||||
participants.put(id, part.copy(amount = part.amount - amount, weapons = trimmedWeapons))
|
||||
amt = 0
|
||||
participants.put(id, part.copy(amount = part.amount - reduceByValue, weapons = trimmedWeapons.toSeq))
|
||||
amt = amt - reduceByValue
|
||||
case _ =>
|
||||
//we do not have contribution stat data for this id
|
||||
//perform no calculations; devalue the entry
|
||||
newOrderNeg = newOrderNeg :+ (id, 0)
|
||||
}
|
||||
}
|
||||
count += 1
|
||||
amt > 0
|
||||
}
|
||||
newOrder ++ order.drop(count)
|
||||
newOrderPos ++ order.drop(count) ++ newOrderNeg//.reverse
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,16 +54,16 @@ object ToDatabase {
|
|||
position: Vector3,
|
||||
exp: Long
|
||||
): Unit = {
|
||||
ctx.run(query[persistence.Killactivity]
|
||||
ctx.run(query[persistence.Assistactivity]
|
||||
.insert(
|
||||
_.killerId -> lift(avatarId),
|
||||
_.victimId -> lift(victimId),
|
||||
_.weaponId -> lift(weaponId),
|
||||
_.zoneId -> lift(zoneId),
|
||||
_.px -> lift((position.x * 1000).toInt),
|
||||
_.py -> lift((position.y * 1000).toInt),
|
||||
_.pz -> lift((position.z * 1000).toInt),
|
||||
_.exp -> lift(exp)
|
||||
_.killerId -> lift(avatarId),
|
||||
_.victimId -> lift(victimId),
|
||||
_.weaponId -> lift(weaponId),
|
||||
_.zoneId -> lift(zoneId),
|
||||
_.px -> lift((position.x * 1000).toInt),
|
||||
_.py -> lift((position.y * 1000).toInt),
|
||||
_.pz -> lift((position.z * 1000).toInt),
|
||||
_.exp -> lift(exp)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -227,6 +227,12 @@ object ToDatabase {
|
|||
avatarIdAndExp.map { case (avatarId, exp, expType) =>
|
||||
persistence.Buildingcapture(-1, avatarId, zoneId, buildingId, exp, expType)
|
||||
}
|
||||
)}.foreach(e => query[persistence.Buildingcapture].insertValue(e)))
|
||||
)}.foreach(e => query[persistence.Buildingcapture].insert(
|
||||
_.avatarId -> e.avatarId,
|
||||
_.zoneId -> e.zoneId,
|
||||
_.buildingId -> e.buildingId,
|
||||
_.exp -> e.exp,
|
||||
_.expType -> e.expType
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,10 @@ class HackCaptureActor extends Actor {
|
|||
val faction = GetHackingFaction(target).getOrElse(target.Faction)
|
||||
target.HackedBy = None
|
||||
hackedObjects = remainder
|
||||
val now: Long = System.currentTimeMillis()
|
||||
val facilityHackTime: Long = target.Definition.FacilityHackTime.toMillis
|
||||
val building = target.Owner.asInstanceOf[Building]
|
||||
val hackTime = results.headOption.map { now - _.hack_timestamp }.getOrElse(facilityHackTime)
|
||||
// If LLU exists it was not delivered. Send resecured notifications
|
||||
building.GetFlag.collect {
|
||||
case flag: CaptureFlag => target.Zone.LocalEvents ! CaptureFlagManager.Lost(flag, CaptureFlagLostReasonEnum.Resecured)
|
||||
|
|
@ -99,15 +102,15 @@ class HackCaptureActor extends Actor {
|
|||
target.Faction,
|
||||
faction,
|
||||
hacker,
|
||||
target.Definition.FacilityHackTime.toMillis,
|
||||
System.currentTimeMillis() - results.head.hack_timestamp,
|
||||
facilityHackTime,
|
||||
hackTime,
|
||||
isResecured = true
|
||||
)
|
||||
// Restart the timer in case the object we just removed was the next one scheduled
|
||||
RestartTimer()
|
||||
|
||||
case HackCaptureActor.FlagCaptured(flag) =>
|
||||
log.warn(hackedObjects.toString())
|
||||
log.debug(hackedObjects.toString())
|
||||
val building = flag.Owner.asInstanceOf[Building]
|
||||
val bguid = building.CaptureTerminal.map { _.GUID }
|
||||
hackedObjects.find(entry => bguid.contains(entry.target.GUID)) match {
|
||||
|
|
@ -160,13 +163,16 @@ class HackCaptureActor extends Actor {
|
|||
RestartTimer()
|
||||
spawnCaptureFlag(neighbours, terminal, hackingFaction)
|
||||
true
|
||||
case Some((owner, Some(flag), _)) if hackingFaction == flag.Faction =>
|
||||
case Some((_, Some(flag), _)) if hackingFaction == flag.Faction =>
|
||||
log.error(s"TrySpawnCaptureFlag: flag hacked facility can not be hacked twice by $hackingFaction")
|
||||
false
|
||||
case Some((owner, _, _)) if hackingFaction == terminal.Faction =>
|
||||
log.error(s"TrySpawnCaptureFlag: owning faction and hacking faction match for facility ${owner.Name}; should we be resecuring instead?")
|
||||
false
|
||||
case Some((owner, _, _)) =>
|
||||
log.error(s"TrySpawnCaptureFlag: couldn't find any neighbouring $hackingFaction facilities of ${owner.Name} for LLU hack")
|
||||
case Some((owner, Some(flag), _)) =>
|
||||
log.warn(s"TrySpawnCaptureFlag: couldn't find any neighbouring $hackingFaction facilities of ${owner.Name} for LLU hack")
|
||||
owner.GetFlagSocket.foreach { _.clearOldFlagData() }
|
||||
terminal.Zone.LocalEvents ! CaptureFlagManager.Lost(owner.GetFlag.get, CaptureFlagLostReasonEnum.Ended)
|
||||
terminal.Zone.LocalEvents ! CaptureFlagManager.Lost(flag, CaptureFlagLostReasonEnum.Ended)
|
||||
false
|
||||
case _ =>
|
||||
log.error(s"TrySpawnCaptureFlag: expecting a terminal ${terminal.GUID.guid} with the ctf owning facility")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue