mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-03 12:10:22 +00:00
NTU Related fixes/changes (#308)
* Send map updates when NTU bar changes * Make bases turn neutral when NTU hits 0 * Fix sync of low NTU warning light to players joining zone * Swap IFF Lock logic around to allow for more efficient short circuiting of checks * Small fix to stop player disconnect when hacking an object that no longer has a GUID
This commit is contained in:
parent
16c20eaeac
commit
ebd8170de4
3 changed files with 21 additions and 12 deletions
|
|
@ -9,6 +9,7 @@ import net.psforever.packet.game.UseItemMessage
|
|||
class ResourceSilo extends Amenity {
|
||||
private var chargeLevel : Int = 0
|
||||
private val maximumCharge : Int = 1000
|
||||
|
||||
// For the flashing red light on top of the NTU silo on.
|
||||
// Default to true until charge level can be persisted across restarts as default charge level is 0
|
||||
private var lowNtuWarningOn : Boolean = true
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ package net.psforever.objects.serverobject.resourcesilo
|
|||
import akka.actor.Actor
|
||||
import net.psforever.objects.serverobject.affinity.{FactionAffinity, FactionAffinityBehavior}
|
||||
import net.psforever.objects.serverobject.structures.Building
|
||||
import net.psforever.types.PlanetSideEmpire
|
||||
import services.avatar.{AvatarAction, AvatarServiceMessage}
|
||||
import services.local.{LocalAction, LocalServiceMessage}
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent.duration._
|
||||
|
|
@ -41,6 +43,8 @@ class ResourceSiloControl(resourceSilo : ResourceSilo) extends Actor with Factio
|
|||
|
||||
case ResourceSilo.UpdateChargeLevel(amount: Int) =>
|
||||
val siloChargeBeforeChange = resourceSilo.ChargeLevel
|
||||
val building = resourceSilo.Owner.asInstanceOf[Building]
|
||||
val zone = building.Zone
|
||||
|
||||
// Increase if positive passed in or decrease charge level if negative number is passed in
|
||||
resourceSilo.ChargeLevel += amount
|
||||
|
|
@ -54,12 +58,11 @@ class ResourceSiloControl(resourceSilo : ResourceSilo) extends Actor with Factio
|
|||
log.trace(s"Silo ${resourceSilo.GUID} NTU bar level has changed from ${resourceSilo.CapacitorDisplay} to $ntuBarLevel")
|
||||
resourceSilo.CapacitorDisplay = ntuBarLevel
|
||||
resourceSilo.Owner.Actor ! Building.SendMapUpdate(all_clients = true)
|
||||
val building = resourceSilo.Owner
|
||||
val zone = building.Zone
|
||||
zone.AvatarEvents ! AvatarServiceMessage(
|
||||
zone.Id,
|
||||
AvatarAction.PlanetsideAttribute(resourceSilo.GUID, 45, resourceSilo.CapacitorDisplay)
|
||||
)
|
||||
building.Actor ! Building.SendMapUpdate(all_clients = true)
|
||||
}
|
||||
|
||||
val ntuIsLow = resourceSilo.ChargeLevel.toFloat / resourceSilo.MaximumCharge.toFloat < 0.2f
|
||||
|
|
@ -69,12 +72,11 @@ class ResourceSiloControl(resourceSilo : ResourceSilo) extends Actor with Factio
|
|||
self ! ResourceSilo.LowNtuWarning(enabled = true)
|
||||
}
|
||||
|
||||
val building = resourceSilo.Owner.asInstanceOf[Building]
|
||||
val zone = building.Zone
|
||||
if(resourceSilo.ChargeLevel == 0 && siloChargeBeforeChange > 0) {
|
||||
// Oops, someone let the base run out of power. Shut it all down.
|
||||
//todo: Make base neutral if silo hits zero NTU
|
||||
zone.AvatarEvents ! AvatarServiceMessage(zone.Id, AvatarAction.PlanetsideAttribute(building.GUID, 48, 1))
|
||||
building.Faction = PlanetSideEmpire.NEUTRAL
|
||||
zone.LocalEvents ! LocalServiceMessage(zone.Id, LocalAction.SetEmpire(building.GUID, PlanetSideEmpire.NEUTRAL))
|
||||
building.TriggerZoneMapUpdate()
|
||||
} else if (siloChargeBeforeChange == 0 && resourceSilo.ChargeLevel > 0) {
|
||||
// Power restored. Reactor Online. Sensors Online. Weapons Online. All systems nominal.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue