local zone maintains information about weapon fire capability per faction

This commit is contained in:
Fate-JH 2025-07-18 23:33:28 -04:00
parent f74da61fa5
commit 75e3a879fb
2 changed files with 34 additions and 2 deletions

View file

@ -2158,8 +2158,8 @@ class ZoningOperations(
tplayer.avatar = avatar tplayer.avatar = avatar
session = session.copy(player = tplayer) session = session.copy(player = tplayer)
//LoadMapMessage causes the client to send BeginZoningMessage, eventually leading to SetCurrentAvatar //LoadMapMessage causes the client to send BeginZoningMessage, eventually leading to SetCurrentAvatar
val weaponsEnabled = !(mapName.equals("map11") || mapName.equals("map12") || mapName.equals("map13")) //val weaponsEnabled = !(mapName.equals("map11") || mapName.equals("map12") || mapName.equals("map13"))
sendResponse(LoadMapMessage(mapName, id, 40100, 25, weaponsEnabled, map.checksum)) sendResponse(LoadMapMessage(mapName, id, 40100, 25, zone.LiveFireAllowed(tplayer.Faction), map.checksum))
if (isAcceptableNextSpawnPoint) { if (isAcceptableNextSpawnPoint) {
//important! the LoadMapMessage must be processed by the client before the avatar is created //important! the LoadMapMessage must be processed by the client before the avatar is created
player.allowInteraction = true player.allowInteraction = true

View file

@ -182,6 +182,12 @@ class Zone(val id: String, val map: ZoneMap, zoneNumber: Int) {
*/ */
private var vehicleEvents: ActorRef = Default.Actor private var vehicleEvents: ActorRef = Default.Actor
/**
* Is any player permitted to engage in weapons discharge in this zone?
*/
private var liveFireAllowed: mutable.HashMap[PlanetSideEmpire.Value, Boolean] =
mutable.HashMap.from(PlanetSideEmpire.values.map { f => (f, true) })
/** /**
* When the zone has completed initializing, fulfill this promise. * When the zone has completed initializing, fulfill this promise.
* @see `init(ActorContext)` * @see `init(ActorContext)`
@ -593,6 +599,32 @@ class Zone(val id: String, val map: ZoneMap, zoneNumber: Int) {
vehicleEvents = bus vehicleEvents = bus
VehicleEvents VehicleEvents
} }
def LiveFireAllowed(): Boolean = liveFireAllowed.exists { case (_, v) => v }
def LiveFireAllowed(faction: PlanetSideEmpire.Value): Boolean = liveFireAllowed.getOrElse(faction, false)
def UpdateLiveFireAllowed(state: Boolean): List[(PlanetSideEmpire.Value, Boolean, Boolean)] = {
val output = liveFireAllowed.map { case (f, v) =>
(f, v == state, state)
}
output.foreach { case (f, _, v) =>
liveFireAllowed.update(f, v)
}
output.toList
}
def UpdateLiveFireAllowed(state: Boolean, faction: PlanetSideEmpire.Value): List[(PlanetSideEmpire.Value, Boolean, Boolean)] = {
val output = liveFireAllowed.map { case (f, v) =>
if (f == faction) {
(f, v == state, state)
} else {
(f, false, v)
}
}
liveFireAllowed.update(faction, state)
output.toList
}
} }
/** /**