mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-20 02:24:45 +00:00
Reviving a player will drain 25 rounds after revival is complete, instead of on each progress tick (#505)
This commit is contained in:
parent
d1e7d8f8e0
commit
5437b3f068
|
|
@ -28,12 +28,10 @@ object Players {
|
||||||
def RevivingTickAction(target : Player, user : Player, item : Tool)(progress : Float) : Boolean = {
|
def RevivingTickAction(target : Player, user : Player, item : Tool)(progress : Float) : Boolean = {
|
||||||
if(!target.isAlive && !target.isBackpack &&
|
if(!target.isAlive && !target.isBackpack &&
|
||||||
user.isAlive && !user.isMoving &&
|
user.isAlive && !user.isMoving &&
|
||||||
user.Slot(user.DrawnSlot).Equipment.contains(item) && item.Magazine > 0 &&
|
user.Slot(user.DrawnSlot).Equipment.contains(item) && item.Magazine >= 25 &&
|
||||||
Vector3.Distance(target.Position, user.Position) < target.Definition.RepairDistance) {
|
Vector3.Distance(target.Position, user.Position) < target.Definition.RepairDistance) {
|
||||||
val magazine = item.Discharge
|
|
||||||
val events = target.Zone.AvatarEvents
|
val events = target.Zone.AvatarEvents
|
||||||
val uname = user.Name
|
val uname = user.Name
|
||||||
events ! AvatarServiceMessage(uname, AvatarAction.SendResponse(Service.defaultPlayerGUID, InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine)))
|
|
||||||
events ! AvatarServiceMessage(uname, AvatarAction.SendResponse(Service.defaultPlayerGUID, RepairMessage(target.GUID, progress.toInt)))
|
events ! AvatarServiceMessage(uname, AvatarAction.SendResponse(Service.defaultPlayerGUID, RepairMessage(target.GUID, progress.toInt)))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
@ -48,10 +46,13 @@ object Players {
|
||||||
* @see `AvatarResponse.Revive`
|
* @see `AvatarResponse.Revive`
|
||||||
* @param target the player being revived
|
* @param target the player being revived
|
||||||
* @param medic the name of the player doing the reviving
|
* @param medic the name of the player doing the reviving
|
||||||
|
* @param item the tool being used to revive the target player
|
||||||
*/
|
*/
|
||||||
def FinishRevivingPlayer(target : Player, medic : String)() : Unit = {
|
def FinishRevivingPlayer(target : Player, medic : String, item : Tool)() : Unit = {
|
||||||
val name = target.Name
|
val name = target.Name
|
||||||
log.info(s"$medic had revived $name")
|
log.info(s"$medic had revived $name")
|
||||||
|
val magazine = item.Discharge(Some(25))
|
||||||
|
target.Zone.AvatarEvents ! AvatarServiceMessage(medic, AvatarAction.SendResponse(Service.defaultPlayerGUID, InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine)))
|
||||||
target.Zone.AvatarEvents ! AvatarServiceMessage(name, AvatarAction.Revive(target.GUID))
|
target.Zone.AvatarEvents ! AvatarServiceMessage(name, AvatarAction.Revive(target.GUID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,9 +97,9 @@ class Tool(private val toolDef : ToolDefinition) extends Equipment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def Discharge : Int = {
|
def Discharge(rounds : Option[Int] = None) : Int = {
|
||||||
lastDischarge = System.nanoTime()
|
lastDischarge = System.nanoTime()
|
||||||
Magazine = FireMode.Discharge(this)
|
Magazine = FireMode.Discharge(this, rounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
def LastDischarge : Long = {
|
def LastDischarge : Long = {
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ class PlayerControl(player : Player) extends Actor
|
||||||
val guid = player.GUID
|
val guid = player.GUID
|
||||||
if(!(player.isMoving || user.isMoving)) { //only allow stationary heals
|
if(!(player.isMoving || user.isMoving)) { //only allow stationary heals
|
||||||
val newHealth = player.Health = originalHealth + 10
|
val newHealth = player.Health = originalHealth + 10
|
||||||
val magazine = item.Discharge
|
val magazine = item.Discharge()
|
||||||
events ! AvatarServiceMessage(uname, AvatarAction.SendResponse(Service.defaultPlayerGUID, InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine.toLong)))
|
events ! AvatarServiceMessage(uname, AvatarAction.SendResponse(Service.defaultPlayerGUID, InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine.toLong)))
|
||||||
events ! AvatarServiceMessage(zone.Id, AvatarAction.PlanetsideAttributeToAll(guid, 0, newHealth))
|
events ! AvatarServiceMessage(zone.Id, AvatarAction.PlanetsideAttributeToAll(guid, 0, newHealth))
|
||||||
player.History(HealFromEquipment(PlayerSource(player), PlayerSource(user), newHealth - originalHealth, GlobalDefinitions.medicalapplicator))
|
player.History(HealFromEquipment(PlayerSource(player), PlayerSource(user), newHealth - originalHealth, GlobalDefinitions.medicalapplicator))
|
||||||
|
|
@ -142,7 +142,7 @@ class PlayerControl(player : Player) extends Actor
|
||||||
item.Magazine >= 25) {
|
item.Magazine >= 25) {
|
||||||
sender ! CommonMessages.Progress(
|
sender ! CommonMessages.Progress(
|
||||||
4,
|
4,
|
||||||
Players.FinishRevivingPlayer(player, user.Name),
|
Players.FinishRevivingPlayer(player, user.Name, item),
|
||||||
Players.RevivingTickAction(player, user, item)
|
Players.RevivingTickAction(player, user, item)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -160,7 +160,7 @@ class PlayerControl(player : Player) extends Actor
|
||||||
val guid = player.GUID
|
val guid = player.GUID
|
||||||
if(!(player.isMoving || user.isMoving)) { //only allow stationary repairs
|
if(!(player.isMoving || user.isMoving)) { //only allow stationary repairs
|
||||||
val newArmor = player.Armor = originalArmor + Repairable.Quality + RepairValue(item) + definition.RepairMod
|
val newArmor = player.Armor = originalArmor + Repairable.Quality + RepairValue(item) + definition.RepairMod
|
||||||
val magazine = item.Discharge
|
val magazine = item.Discharge()
|
||||||
events ! AvatarServiceMessage(uname, AvatarAction.SendResponse(Service.defaultPlayerGUID, InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine.toLong)))
|
events ! AvatarServiceMessage(uname, AvatarAction.SendResponse(Service.defaultPlayerGUID, InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine.toLong)))
|
||||||
events ! AvatarServiceMessage(zone.Id, AvatarAction.PlanetsideAttributeToAll(guid, 4, player.Armor))
|
events ! AvatarServiceMessage(zone.Id, AvatarAction.PlanetsideAttributeToAll(guid, 4, player.Armor))
|
||||||
player.History(RepairFromEquipment(PlayerSource(player), PlayerSource(user), newArmor - originalArmor, GlobalDefinitions.bank))
|
player.History(RepairFromEquipment(PlayerSource(player), PlayerSource(user), newArmor - originalArmor, GlobalDefinitions.bank))
|
||||||
|
|
|
||||||
|
|
@ -83,10 +83,15 @@ class FireModeDefinition {
|
||||||
/**
|
/**
|
||||||
* Shoot a weapon, remove an anticipated amount of ammunition.
|
* Shoot a weapon, remove an anticipated amount of ammunition.
|
||||||
* @param weapon the weapon
|
* @param weapon the weapon
|
||||||
|
* @param rounds The number of rounds to remove, if specified
|
||||||
* @return the size of the weapon's magazine after discharge
|
* @return the size of the weapon's magazine after discharge
|
||||||
*/
|
*/
|
||||||
def Discharge(weapon : Tool) : Int = {
|
def Discharge(weapon : Tool, rounds : Option[Int] = None) : Int = {
|
||||||
weapon.Magazine - Rounds
|
val dischargedAmount = rounds match {
|
||||||
|
case Some(rounds : Int) => rounds
|
||||||
|
case _ => Rounds
|
||||||
|
}
|
||||||
|
weapon.Magazine - dischargedAmount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +105,7 @@ class PelletFireModeDefinition extends FireModeDefinition {
|
||||||
* @param weapon the weapon
|
* @param weapon the weapon
|
||||||
* @return the size of the weapon's magazine after discharge
|
* @return the size of the weapon's magazine after discharge
|
||||||
*/
|
*/
|
||||||
override def Discharge(weapon : Tool) : Int = {
|
override def Discharge(weapon : Tool, rounds : Option[Int] = None) : Int = {
|
||||||
val ammoSlot = weapon.AmmoSlot
|
val ammoSlot = weapon.AmmoSlot
|
||||||
val magazine = weapon.Magazine
|
val magazine = weapon.Magazine
|
||||||
val chamber : Int = ammoSlot.Chamber = ammoSlot.Chamber - 1
|
val chamber : Int = ammoSlot.Chamber = ammoSlot.Chamber - 1
|
||||||
|
|
@ -128,7 +133,7 @@ class InfiniteFireModeDefinition extends FireModeDefinition {
|
||||||
* @return the size of the weapon's magazine after discharge;
|
* @return the size of the weapon's magazine after discharge;
|
||||||
* will always return 1
|
* will always return 1
|
||||||
*/
|
*/
|
||||||
override def Discharge(weapon : Tool) : Int = 1
|
override def Discharge(weapon : Tool, rounds : Option[Int] = None) : Int = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
class DamageModifiers extends DamageProfile {
|
class DamageModifiers extends DamageProfile {
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ trait RepairableEntity extends Repairable {
|
||||||
val updatedHealth = if(!(player.isMoving(1f) || target.isMoving(1f))) { //only allow stationary repairs within margin of error
|
val updatedHealth = if(!(player.isMoving(1f) || target.isMoving(1f))) { //only allow stationary repairs within margin of error
|
||||||
val newHealth = target.Health = originalHealth + Repairable.Quality + RepairValue(item) + definition.RepairMod
|
val newHealth = target.Health = originalHealth + Repairable.Quality + RepairValue(item) + definition.RepairMod
|
||||||
val zoneId = zone.Id
|
val zoneId = zone.Id
|
||||||
val magazine = item.Discharge
|
val magazine = item.Discharge()
|
||||||
events ! AvatarServiceMessage(name, AvatarAction.SendResponse(Service.defaultPlayerGUID, InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine.toLong)))
|
events ! AvatarServiceMessage(name, AvatarAction.SendResponse(Service.defaultPlayerGUID, InventoryStateMessage(item.AmmoSlot.Box.GUID, item.GUID, magazine.toLong)))
|
||||||
if(target.Destroyed) {
|
if(target.Destroyed) {
|
||||||
if(newHealth >= definition.RepairRestoresAt) {
|
if(newHealth >= definition.RepairRestoresAt) {
|
||||||
|
|
|
||||||
|
|
@ -308,10 +308,10 @@ class EquipmentTest extends Specification {
|
||||||
"discharge (1)" in {
|
"discharge (1)" in {
|
||||||
val obj = Tool(GlobalDefinitions.punisher)
|
val obj = Tool(GlobalDefinitions.punisher)
|
||||||
obj.Magazine mustEqual 30
|
obj.Magazine mustEqual 30
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 29
|
obj.Magazine mustEqual 29
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 27
|
obj.Magazine mustEqual 27
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,20 +320,20 @@ class EquipmentTest extends Specification {
|
||||||
obj.Magazine mustEqual 12
|
obj.Magazine mustEqual 12
|
||||||
obj.AmmoSlot.Chamber mustEqual 8
|
obj.AmmoSlot.Chamber mustEqual 8
|
||||||
|
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 12
|
obj.Magazine mustEqual 12
|
||||||
obj.AmmoSlot.Chamber mustEqual 7
|
obj.AmmoSlot.Chamber mustEqual 7
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 12
|
obj.Magazine mustEqual 12
|
||||||
obj.AmmoSlot.Chamber mustEqual 5
|
obj.AmmoSlot.Chamber mustEqual 5
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 12
|
obj.Magazine mustEqual 12
|
||||||
obj.AmmoSlot.Chamber mustEqual 1
|
obj.AmmoSlot.Chamber mustEqual 1
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 11
|
obj.Magazine mustEqual 11
|
||||||
obj.AmmoSlot.Chamber mustEqual 8
|
obj.AmmoSlot.Chamber mustEqual 8
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,10 @@ class FireModeTest extends Specification {
|
||||||
obj.FireMode.Chamber mustEqual 1
|
obj.FireMode.Chamber mustEqual 1
|
||||||
|
|
||||||
obj.Magazine mustEqual 16
|
obj.Magazine mustEqual 16
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 15
|
obj.Magazine mustEqual 15
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 13
|
obj.Magazine mustEqual 13
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -84,17 +84,17 @@ class FireModeTest extends Specification {
|
||||||
obj.FireMode.Chamber mustEqual 8
|
obj.FireMode.Chamber mustEqual 8
|
||||||
|
|
||||||
obj.Magazine mustEqual 12
|
obj.Magazine mustEqual 12
|
||||||
obj.Discharge //1
|
obj.Discharge() //1
|
||||||
obj.Magazine mustEqual 12
|
obj.Magazine mustEqual 12
|
||||||
obj.Discharge //2
|
obj.Discharge() //2
|
||||||
obj.Discharge //3
|
obj.Discharge() //3
|
||||||
obj.Magazine mustEqual 12
|
obj.Magazine mustEqual 12
|
||||||
obj.Discharge //4
|
obj.Discharge() //4
|
||||||
obj.Discharge //5
|
obj.Discharge() //5
|
||||||
obj.Discharge //6
|
obj.Discharge() //6
|
||||||
obj.Discharge //7
|
obj.Discharge() //7
|
||||||
obj.Magazine mustEqual 12
|
obj.Magazine mustEqual 12
|
||||||
obj.Discharge //8
|
obj.Discharge() //8
|
||||||
obj.Magazine mustEqual 11
|
obj.Magazine mustEqual 11
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -117,10 +117,10 @@ class FireModeTest extends Specification {
|
||||||
obj.FireMode.Chamber mustEqual 1
|
obj.FireMode.Chamber mustEqual 1
|
||||||
|
|
||||||
obj.Magazine mustEqual 1
|
obj.Magazine mustEqual 1
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 1
|
obj.Magazine mustEqual 1
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Discharge
|
obj.Discharge()
|
||||||
obj.Magazine mustEqual 1
|
obj.Magazine mustEqual 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5595,7 +5595,7 @@ class WorldSessionActor extends Actor
|
||||||
}
|
}
|
||||||
else if(!player.isAlive) { //proper internal accounting, but no projectile
|
else if(!player.isAlive) { //proper internal accounting, but no projectile
|
||||||
prefire = shooting.orElse(Some(weapon_guid))
|
prefire = shooting.orElse(Some(weapon_guid))
|
||||||
tool.Discharge
|
tool.Discharge()
|
||||||
projectiles(projectile_guid.guid - Projectile.BaseUID) = None
|
projectiles(projectile_guid.guid - Projectile.BaseUID) = None
|
||||||
shotsWhileDead += 1
|
shotsWhileDead += 1
|
||||||
}
|
}
|
||||||
|
|
@ -5606,7 +5606,7 @@ class WorldSessionActor extends Actor
|
||||||
}
|
}
|
||||||
|
|
||||||
prefire = shooting.orElse(Some(weapon_guid))
|
prefire = shooting.orElse(Some(weapon_guid))
|
||||||
tool.Discharge //always
|
tool.Discharge() //always
|
||||||
val projectileIndex = projectile_guid.guid - Projectile.BaseUID
|
val projectileIndex = projectile_guid.guid - Projectile.BaseUID
|
||||||
val projectilePlace = projectiles(projectileIndex)
|
val projectilePlace = projectiles(projectileIndex)
|
||||||
if(projectilePlace match {
|
if(projectilePlace match {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue