mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-04-26 22:35:23 +00:00
Merge pull request #436 from Mazo/hold-the-door
Doors should no longer close if any alive player is still within range
This commit is contained in:
commit
377b6aaef7
2 changed files with 26 additions and 5 deletions
|
|
@ -2,8 +2,9 @@
|
||||||
package services.local.support
|
package services.local.support
|
||||||
|
|
||||||
import akka.actor.{Actor, Cancellable}
|
import akka.actor.{Actor, Cancellable}
|
||||||
import net.psforever.objects.DefaultCancellable
|
import net.psforever.objects.{DefaultCancellable, Player}
|
||||||
import net.psforever.objects.serverobject.doors.Door
|
import net.psforever.objects.serverobject.doors.Door
|
||||||
|
import net.psforever.objects.serverobject.structures.Building
|
||||||
import net.psforever.objects.zones.Zone
|
import net.psforever.objects.zones.Zone
|
||||||
import net.psforever.types.{PlanetSideGUID, Vector3}
|
import net.psforever.types.{PlanetSideGUID, Vector3}
|
||||||
|
|
||||||
|
|
@ -37,9 +38,29 @@ class DoorCloseActor() extends Actor {
|
||||||
val (doorsToClose2, doorsLeftOpen2) = doorsToClose1.partition(entry => {
|
val (doorsToClose2, doorsLeftOpen2) = doorsToClose1.partition(entry => {
|
||||||
entry.door.Open match {
|
entry.door.Open match {
|
||||||
case Some(player) =>
|
case Some(player) =>
|
||||||
// If the player that opened the door is far enough away, or they're dead / backpacked, close the door
|
// If the player that opened the door is far enough away, or they're dead,
|
||||||
var playerIsBackpackInZone = entry.zone.Corpses.contains(player)
|
var openerIsGone = Vector3.MagnitudeSquared(entry.door.Position - player.Position) > 25.5 || !player.isAlive
|
||||||
Vector3.MagnitudeSquared(entry.door.Position - player.Position) > 25.5 || playerIsBackpackInZone
|
|
||||||
|
if(openerIsGone) {
|
||||||
|
// Check nobody else is nearby to hold the door opens
|
||||||
|
val playersToCheck : List[Player] = if(entry.door.Owner.isInstanceOf[Building] && entry.door.Owner.asInstanceOf[Building].Definition.SOIRadius > 0) {
|
||||||
|
entry.door.Owner.asInstanceOf[Building].PlayersInSOI
|
||||||
|
} else {
|
||||||
|
entry.zone.LivePlayers
|
||||||
|
}
|
||||||
|
|
||||||
|
playersToCheck
|
||||||
|
.filter(x => x.isAlive && Vector3.MagnitudeSquared(entry.door.Position - x.Position) < 25.5)
|
||||||
|
.headOption match {
|
||||||
|
case Some(newOpener) =>
|
||||||
|
// Another player is near the door, keep it open
|
||||||
|
entry.door.Open = newOpener
|
||||||
|
openerIsGone = false
|
||||||
|
case _ => ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openerIsGone
|
||||||
case None =>
|
case None =>
|
||||||
// Door should not be open. Mark it to be closed.
|
// Door should not be open. Mark it to be closed.
|
||||||
true
|
true
|
||||||
|
|
|
||||||
|
|
@ -8608,7 +8608,7 @@ class WorldSessionActor extends Actor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the corpse has been well-lootedP, it has no items in its primary holsters nor any items in its inventory.
|
* If the corpse has been well-looted, it has no items in its primary holsters nor any items in its inventory.
|
||||||
* @param obj the corpse
|
* @param obj the corpse
|
||||||
* @return `true`, if the `obj` is actually a corpse and has no objects in its holsters or backpack;
|
* @return `true`, if the `obj` is actually a corpse and has no objects in its holsters or backpack;
|
||||||
* `false`, otherwise
|
* `false`, otherwise
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue