mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-15 08:24:39 +00:00
medkits, and med apps, and respawn tubes, oh my (#368)
This commit is contained in:
parent
a23643b240
commit
39ae77d6f4
2 changed files with 119 additions and 113 deletions
|
|
@ -5,7 +5,7 @@ import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
|
||||||
import akka.actor.Actor
|
import akka.actor.Actor
|
||||||
import net.psforever.objects.{GlobalDefinitions, PlanetSideGameObject, SpawnPoint, Tool}
|
import net.psforever.objects.{GlobalDefinitions, PlanetSideGameObject, SpawnPoint, Tool}
|
||||||
import net.psforever.objects.serverobject.structures.{StructureType, WarpGate}
|
import net.psforever.objects.serverobject.structures.{AmenityOwner, StructureType, WarpGate}
|
||||||
import net.psforever.objects.serverobject.tube.SpawnTube
|
import net.psforever.objects.serverobject.tube.SpawnTube
|
||||||
import net.psforever.objects.vehicles.UtilityType
|
import net.psforever.objects.vehicles.UtilityType
|
||||||
import net.psforever.types.{DriveState, PlanetSideEmpire, Vector3}
|
import net.psforever.types.{DriveState, PlanetSideEmpire, Vector3}
|
||||||
|
|
@ -84,17 +84,15 @@ class ZoneActor(zone : Zone) extends Actor {
|
||||||
case Zone.Lattice.RequestSpawnPoint(zone_number, position, faction, spawn_group) =>
|
case Zone.Lattice.RequestSpawnPoint(zone_number, position, faction, spawn_group) =>
|
||||||
if(zone_number == zone.Number) {
|
if(zone_number == zone.Number) {
|
||||||
ZoneActor.FindLocalSpawnPointsInZone(zone, position, faction, spawn_group) match {
|
ZoneActor.FindLocalSpawnPointsInZone(zone, position, faction, spawn_group) match {
|
||||||
|
case Some(Nil) | None =>
|
||||||
|
sender ! Zone.Lattice.NoValidSpawnPoint(zone_number, Some(spawn_group))
|
||||||
|
|
||||||
case Some(List(tube)) =>
|
case Some(List(tube)) =>
|
||||||
sender ! Zone.Lattice.SpawnPoint(zone.Id, tube)
|
sender ! Zone.Lattice.SpawnPoint(zone.Id, tube)
|
||||||
|
|
||||||
case Some(tubes) =>
|
case Some(tubes) =>
|
||||||
val tube = scala.util.Random.shuffle(
|
val tube = scala.util.Random.shuffle(tubes).head
|
||||||
tubes.filter(sp => !sp.Offline)
|
|
||||||
).head
|
|
||||||
sender ! Zone.Lattice.SpawnPoint(zone.Id, tube)
|
sender ! Zone.Lattice.SpawnPoint(zone.Id, tube)
|
||||||
|
|
||||||
case None =>
|
|
||||||
sender ! Zone.Lattice.NoValidSpawnPoint(zone_number, Some(spawn_group))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { //wrong zone_number
|
else { //wrong zone_number
|
||||||
|
|
@ -225,61 +223,87 @@ object ZoneActor {
|
||||||
* @return na
|
* @return na
|
||||||
*/
|
*/
|
||||||
def FindLocalSpawnPointsInZone(zone : Zone, position : Vector3, faction : PlanetSideEmpire.Value, spawn_group : Int) : Option[List[SpawnPoint]] = {
|
def FindLocalSpawnPointsInZone(zone : Zone, position : Vector3, faction : PlanetSideEmpire.Value, spawn_group : Int) : Option[List[SpawnPoint]] = {
|
||||||
val playerPosition = position.xy
|
(if(spawn_group == 2) {
|
||||||
if(spawn_group == 2) {
|
FindVehicleSpawnPointsInZone(zone, position, faction)
|
||||||
//ams
|
|
||||||
zone.Vehicles
|
|
||||||
.filter(veh =>
|
|
||||||
veh.Definition == GlobalDefinitions.ams &&
|
|
||||||
veh.DeploymentState == DriveState.Deployed &&
|
|
||||||
veh.Faction == faction
|
|
||||||
)
|
|
||||||
.sortBy(veh => Vector3.DistanceSquared(playerPosition, veh.Position.xy))
|
|
||||||
.flatMap(veh => veh.Utilities.values.filter(util => util.UtilType == UtilityType.ams_respawn_tube))
|
|
||||||
.headOption match {
|
|
||||||
case None =>
|
|
||||||
None
|
|
||||||
case Some(util) =>
|
|
||||||
Some(List(util().asInstanceOf[SpawnTube]))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//facilities, towers, and buildings
|
FindBuildingSpawnPointsInZone(zone, position, faction, spawn_group)
|
||||||
val buildingTypeSet = if(spawn_group == 0) {
|
})
|
||||||
Set(StructureType.Facility, StructureType.Tower, StructureType.Building)
|
.headOption match {
|
||||||
}
|
|
||||||
else if(spawn_group == 6) {
|
|
||||||
Set(StructureType.Tower)
|
|
||||||
}
|
|
||||||
else if(spawn_group == 7) {
|
|
||||||
Set(StructureType.Facility, StructureType.Building)
|
|
||||||
}
|
|
||||||
else if(spawn_group == 12) {
|
|
||||||
Set(StructureType.WarpGate)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Set.empty[StructureType.Value]
|
|
||||||
}
|
|
||||||
zone.SpawnGroups()
|
|
||||||
.filter({ case (building, _) =>
|
|
||||||
buildingTypeSet.contains(building.BuildingType) && (building match {
|
|
||||||
case wg : WarpGate =>
|
|
||||||
building.Faction == faction || building.Faction == PlanetSideEmpire.NEUTRAL || wg.Broadcast
|
|
||||||
case _ =>
|
|
||||||
building.Faction == faction
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.toSeq
|
|
||||||
.sortBy({ case (building, _) =>
|
|
||||||
Vector3.DistanceSquared(playerPosition, building.Position.xy)
|
|
||||||
})
|
|
||||||
.headOption match {
|
|
||||||
case None | Some((_, Nil)) =>
|
case None | Some((_, Nil)) =>
|
||||||
None
|
None
|
||||||
case Some((_, tubes)) =>
|
case Some((_, tubes)) =>
|
||||||
Some(tubes)
|
Some(tubes toList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* na
|
||||||
|
* @param zone na
|
||||||
|
* @param position na
|
||||||
|
* @param faction na
|
||||||
|
* @return na
|
||||||
|
*/
|
||||||
|
private def FindVehicleSpawnPointsInZone(zone : Zone, position : Vector3, faction : PlanetSideEmpire.Value) : List[(AmenityOwner, Iterable[SpawnTube])] = {
|
||||||
|
val xy = position.xy
|
||||||
|
//ams
|
||||||
|
zone.Vehicles
|
||||||
|
.filter(veh =>
|
||||||
|
veh.Definition == GlobalDefinitions.ams &&
|
||||||
|
!veh.Destroyed &&
|
||||||
|
veh.DeploymentState == DriveState.Deployed &&
|
||||||
|
veh.Faction == faction
|
||||||
|
)
|
||||||
|
.sortBy(veh => Vector3.DistanceSquared(xy, veh.Position.xy))
|
||||||
|
.map(veh =>
|
||||||
|
(
|
||||||
|
veh,
|
||||||
|
veh.Utilities.values
|
||||||
|
.filter(util => util.UtilType == UtilityType.ams_respawn_tube)
|
||||||
|
.map(_().asInstanceOf[SpawnTube])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* na
|
||||||
|
* @param zone na
|
||||||
|
* @param position na
|
||||||
|
* @param faction na
|
||||||
|
* @param spawn_group na
|
||||||
|
* @return na
|
||||||
|
*/
|
||||||
|
private def FindBuildingSpawnPointsInZone(zone : Zone, position : Vector3, faction : PlanetSideEmpire.Value, spawn_group : Int) : List[(AmenityOwner, Iterable[SpawnPoint])] = {
|
||||||
|
val xy = position.xy
|
||||||
|
//facilities, towers, warp gates, and other buildings
|
||||||
|
val buildingTypeSet = if(spawn_group == 0) {
|
||||||
|
Set(StructureType.Facility, StructureType.Tower, StructureType.Building)
|
||||||
|
}
|
||||||
|
else if(spawn_group == 6) {
|
||||||
|
Set(StructureType.Tower)
|
||||||
|
}
|
||||||
|
else if(spawn_group == 7) {
|
||||||
|
Set(StructureType.Facility, StructureType.Building)
|
||||||
|
}
|
||||||
|
else if(spawn_group == 12) {
|
||||||
|
Set(StructureType.WarpGate)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Set.empty[StructureType.Value]
|
||||||
|
}
|
||||||
|
zone.SpawnGroups()
|
||||||
|
.collect({ case (building, spawns) if
|
||||||
|
buildingTypeSet.contains(building.BuildingType) && (building match {
|
||||||
|
case wg : WarpGate =>
|
||||||
|
building.Faction == faction || building.Faction == PlanetSideEmpire.NEUTRAL || wg.Broadcast
|
||||||
|
case _ =>
|
||||||
|
building.Faction == faction && spawns.nonEmpty && spawns.exists(_.Offline == false)
|
||||||
|
}) => (building, spawns.filter(_.Offline == false))
|
||||||
|
})
|
||||||
|
.toSeq
|
||||||
|
.sortBy({ case (building, _) =>
|
||||||
|
Vector3.DistanceSquared(xy, building.Position.xy)
|
||||||
|
})
|
||||||
|
.toList
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -310,11 +310,13 @@ class WorldSessionActor extends Actor
|
||||||
HandleAvatarServiceResponse(toChannel, guid, reply)
|
HandleAvatarServiceResponse(toChannel, guid, reply)
|
||||||
|
|
||||||
case CommonMessages.Progress(rate, finishedAction, stepAction) =>
|
case CommonMessages.Progress(rate, finishedAction, stepAction) =>
|
||||||
progressBarValue = Some(-rate)
|
if(progressBarValue.isEmpty) {
|
||||||
self ! ProgressEvent(rate, finishedAction, stepAction)
|
progressBarValue = Some(-rate)
|
||||||
|
self ! ProgressEvent(rate, finishedAction, stepAction)
|
||||||
|
}
|
||||||
|
|
||||||
case ProgressEvent(delta, completeAction, tickAction) =>
|
case ProgressEvent(delta, finishedAction, stepAction) =>
|
||||||
HandleProgressChange(delta, completeAction, tickAction)
|
HandleProgressChange(delta, finishedAction, stepAction)
|
||||||
|
|
||||||
case Door.DoorMessage(tplayer, msg, order) =>
|
case Door.DoorMessage(tplayer, msg, order) =>
|
||||||
HandleDoorMessage(tplayer, msg, order)
|
HandleDoorMessage(tplayer, msg, order)
|
||||||
|
|
@ -5259,7 +5261,7 @@ class WorldSessionActor extends Actor
|
||||||
accessedContainer = Some(obj)
|
accessedContainer = Some(obj)
|
||||||
}
|
}
|
||||||
else if(!unk3 && player.isAlive) { //potential kit use
|
else if(!unk3 && player.isAlive) { //potential kit use
|
||||||
equipment match {
|
ValidObject(item_used_guid) match {
|
||||||
case Some(kit : Kit) =>
|
case Some(kit : Kit) =>
|
||||||
player.Find(kit) match {
|
player.Find(kit) match {
|
||||||
case Some(index) =>
|
case Some(index) =>
|
||||||
|
|
@ -5271,20 +5273,15 @@ class WorldSessionActor extends Actor
|
||||||
sendResponse(ChatMsg(ChatMessageType.UNK_225, false, "", s"@TimeUntilNextUse^${5 - (System.currentTimeMillis - whenUsedLastKit) / 1000}~", None))
|
sendResponse(ChatMsg(ChatMessageType.UNK_225, false, "", s"@TimeUntilNextUse^${5 - (System.currentTimeMillis - whenUsedLastKit) / 1000}~", None))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.Find(kit) match {
|
whenUsedLastKit = System.currentTimeMillis
|
||||||
case Some(index) =>
|
player.Slot(index).Equipment = None //remove from slot immediately; must exist on client for next packet
|
||||||
whenUsedLastKit = System.currentTimeMillis
|
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, 0, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
||||||
player.Slot(index).Equipment = None //remove from slot immediately; must exist on client for next packet
|
sendResponse(ObjectDeleteMessage(kit.GUID, 0))
|
||||||
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, 0, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
taskResolver ! GUIDTask.UnregisterEquipment(kit)(continent.GUID)
|
||||||
sendResponse(ObjectDeleteMessage(kit.GUID, 0))
|
player.History(HealFromKit(PlayerSource(player), 25, kit.Definition))
|
||||||
taskResolver ! GUIDTask.UnregisterEquipment(kit)(continent.GUID)
|
player.Health = player.Health + 25
|
||||||
player.History(HealFromKit(PlayerSource(player), 25, kit.Definition))
|
sendResponse(PlanetsideAttributeMessage(avatar_guid, 0, player.Health))
|
||||||
player.Health = player.Health + 25
|
continent.AvatarEvents ! AvatarServiceMessage(continent.Id, AvatarAction.PlanetsideAttribute(avatar_guid, 0, player.Health))
|
||||||
sendResponse(PlanetsideAttributeMessage(avatar_guid, 0, player.Health))
|
|
||||||
continent.AvatarEvents ! AvatarServiceMessage(continent.Id, AvatarAction.PlanetsideAttribute(avatar_guid, 0, player.Health))
|
|
||||||
case None =>
|
|
||||||
log.error(s"UseItem: anticipated a $kit, but can't find it")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(kit.Definition == GlobalDefinitions.super_medkit) {
|
else if(kit.Definition == GlobalDefinitions.super_medkit) {
|
||||||
|
|
@ -5295,20 +5292,15 @@ class WorldSessionActor extends Actor
|
||||||
sendResponse(ChatMsg(ChatMessageType.UNK_225, false, "", s"@TimeUntilNextUse^${1200 - (System.currentTimeMillis - whenUsedLastSMKit) / 1000}~", None))
|
sendResponse(ChatMsg(ChatMessageType.UNK_225, false, "", s"@TimeUntilNextUse^${1200 - (System.currentTimeMillis - whenUsedLastSMKit) / 1000}~", None))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.Find(kit) match {
|
whenUsedLastSMKit = System.currentTimeMillis
|
||||||
case Some(index) =>
|
player.Slot(index).Equipment = None //remove from slot immediately; must exist on client for next packet
|
||||||
whenUsedLastSMKit = System.currentTimeMillis
|
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, 0, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
||||||
player.Slot(index).Equipment = None //remove from slot immediately; must exist on client for next packet
|
sendResponse(ObjectDeleteMessage(kit.GUID, 0))
|
||||||
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, 0, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
taskResolver ! GUIDTask.UnregisterEquipment(kit)(continent.GUID)
|
||||||
sendResponse(ObjectDeleteMessage(kit.GUID, 0))
|
player.History(HealFromKit(PlayerSource(player), 100, kit.Definition))
|
||||||
taskResolver ! GUIDTask.UnregisterEquipment(kit)(continent.GUID)
|
player.Health = player.Health + 100
|
||||||
player.History(HealFromKit(PlayerSource(player), 100, kit.Definition))
|
sendResponse(PlanetsideAttributeMessage(avatar_guid, 0, player.Health))
|
||||||
player.Health = player.Health + 100
|
continent.AvatarEvents ! AvatarServiceMessage(continent.Id, AvatarAction.PlanetsideAttribute(avatar_guid, 0, player.Health))
|
||||||
sendResponse(PlanetsideAttributeMessage(avatar_guid, 0, player.Health))
|
|
||||||
continent.AvatarEvents ! AvatarServiceMessage(continent.Id, AvatarAction.PlanetsideAttribute(avatar_guid, 0, player.Health))
|
|
||||||
case None =>
|
|
||||||
log.error(s"UseItem: anticipated a $kit, but can't find it")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(kit.Definition == GlobalDefinitions.super_armorkit) {
|
else if(kit.Definition == GlobalDefinitions.super_armorkit) {
|
||||||
|
|
@ -5319,20 +5311,15 @@ class WorldSessionActor extends Actor
|
||||||
sendResponse(ChatMsg(ChatMessageType.UNK_225, false, "", s"@TimeUntilNextUse^${1200 - (System.currentTimeMillis - whenUsedLastSAKit) / 1000}~", None))
|
sendResponse(ChatMsg(ChatMessageType.UNK_225, false, "", s"@TimeUntilNextUse^${1200 - (System.currentTimeMillis - whenUsedLastSAKit) / 1000}~", None))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.Find(kit) match {
|
whenUsedLastSAKit = System.currentTimeMillis
|
||||||
case Some(index) =>
|
player.Slot(index).Equipment = None //remove from slot immediately; must exist on client for next packet
|
||||||
whenUsedLastSAKit = System.currentTimeMillis
|
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, 0, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
||||||
player.Slot(index).Equipment = None //remove from slot immediately; must exist on client for next packet
|
sendResponse(ObjectDeleteMessage(kit.GUID, 0))
|
||||||
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, 0, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
taskResolver ! GUIDTask.UnregisterEquipment(kit)(continent.GUID)
|
||||||
sendResponse(ObjectDeleteMessage(kit.GUID, 0))
|
player.History(RepairFromKit(PlayerSource(player), 200, kit.Definition))
|
||||||
taskResolver ! GUIDTask.UnregisterEquipment(kit)(continent.GUID)
|
player.Armor = player.Armor + 200
|
||||||
player.History(RepairFromKit(PlayerSource(player), 200, kit.Definition))
|
sendResponse(PlanetsideAttributeMessage(avatar_guid, 4, player.Armor))
|
||||||
player.Armor = player.Armor + 200
|
continent.AvatarEvents ! AvatarServiceMessage(continent.Id, AvatarAction.PlanetsideAttribute(avatar_guid, 4, player.Armor))
|
||||||
sendResponse(PlanetsideAttributeMessage(avatar_guid, 4, player.Armor))
|
|
||||||
continent.AvatarEvents ! AvatarServiceMessage(continent.Id, AvatarAction.PlanetsideAttribute(avatar_guid, 4, player.Armor))
|
|
||||||
case None =>
|
|
||||||
log.error(s"UseItem: anticipated a $kit, but can't find it")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(kit.Definition == GlobalDefinitions.super_staminakit) {
|
else if(kit.Definition == GlobalDefinitions.super_staminakit) {
|
||||||
|
|
@ -5343,17 +5330,12 @@ class WorldSessionActor extends Actor
|
||||||
sendResponse(ChatMsg(ChatMessageType.UNK_225, false, "", s"@TimeUntilNextUse^${300 - (System.currentTimeMillis - whenUsedLastSSKit) / 1200}~", None))
|
sendResponse(ChatMsg(ChatMessageType.UNK_225, false, "", s"@TimeUntilNextUse^${300 - (System.currentTimeMillis - whenUsedLastSSKit) / 1200}~", None))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.Find(kit) match {
|
whenUsedLastSSKit = System.currentTimeMillis
|
||||||
case Some(index) =>
|
player.Slot(index).Equipment = None //remove from slot immediately; must exist on client for next packet
|
||||||
whenUsedLastSSKit = System.currentTimeMillis
|
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, 0, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
||||||
player.Slot(index).Equipment = None //remove from slot immediately; must exist on client for next packet
|
sendResponse(ObjectDeleteMessage(kit.GUID, 0))
|
||||||
sendResponse(UseItemMessage(avatar_guid, item_used_guid, object_guid, 0, unk3, unk4, unk5, unk6, unk7, unk8, itemType))
|
taskResolver ! GUIDTask.UnregisterEquipment(kit)(continent.GUID)
|
||||||
sendResponse(ObjectDeleteMessage(kit.GUID, 0))
|
player.Stamina = player.Stamina + 100
|
||||||
taskResolver ! GUIDTask.UnregisterEquipment(kit)(continent.GUID)
|
|
||||||
player.Stamina = player.Stamina + 100
|
|
||||||
case None =>
|
|
||||||
log.error(s"UseItem: anticipated a $kit, but can't find it")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue