Upper Body Angle (#292)

* constrain angles on specialized yaw and pitch fields

* integrated new Angular Codec into OCM and OCDM of avatar; corrected tests; wrote shortcut for whether a unit is moving (under its own power)

* apply clamp

* Accessed containers while moving

Removed unintentional code duplication outside of conditional.
This commit is contained in:
Fate-JH 2019-11-29 11:14:25 -05:00 committed by GitHub
parent 9e99dc75e3
commit a5a85e6cc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 209 additions and 108 deletions

View file

@ -54,7 +54,7 @@ import services.local.{LocalAction, LocalResponse, LocalServiceMessage, LocalSer
import services.chat._
import services.vehicle.support.TurretUpgrader
import services.vehicle.{VehicleAction, VehicleResponse, VehicleServiceMessage, VehicleServiceResponse}
import services.teamwork.{SquadAction => SquadServiceAction, SquadServiceMessage, SquadServiceResponse, SquadResponse, SquadService}
import services.teamwork.{SquadResponse, SquadService, SquadServiceMessage, SquadServiceResponse, SquadAction => SquadServiceAction}
import scala.collection.mutable.LongMap
import scala.concurrent.duration._
@ -64,6 +64,7 @@ import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
import scala.util.Success
import akka.pattern.ask
import net.psforever.objects.entity.{SimpleWorldEntity, WorldEntity}
import net.psforever.objects.vehicles.Utility.InternalTelepad
import services.local.support.{HackCaptureActor, RouterTelepadActivation}
import services.support.SupportActor
@ -1441,7 +1442,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
(distanceSq < 10000 && time > 500) ||
(distanceSq < 160000 && (
(is_jumping || time < 200)) ||
((vel.isEmpty || Vector3.MagnitudeSquared(vel.get).toInt == 0) && time > 2000) ||
(!WorldEntity.isMoving(vel) && time > 2000) ||
(time > 1000)) ||
(distanceSq > 160000 && time > 5000)) {
sendResponse(
@ -3893,7 +3894,8 @@ class WorldSessionActor extends Actor with MDCContextAware {
timeSurge = 0
}
}
if (vel.isEmpty && player.Stamina != player.MaxStamina) {
val isMoving = WorldEntity.isMoving(vel)
if (!isMoving && player.Stamina < player.MaxStamina) {
player.Stamina = player.Stamina + 1
avatarService ! AvatarServiceMessage(player.Continent, AvatarAction.PlanetsideAttributeSelf(player.GUID, 2, player.Stamina))
}
@ -3907,7 +3909,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
player.Jumping = is_jumping
player.Cloaked = player.ExoSuit == ExoSuitType.Infiltration && is_cloaking
if(vel.isDefined && usingMedicalTerminal.isDefined) {
if(isMoving && usingMedicalTerminal.isDefined) {
continent.GUID(usingMedicalTerminal) match {
case Some(term : Terminal with ProximityUnit) =>
StopUsingProximityUnit(term)
@ -3916,7 +3918,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
}
accessedContainer match {
case Some(veh : Vehicle) =>
if(vel.isDefined || Vector3.DistanceSquared(player.Position, veh.Position) > 100) {
if(isMoving || Vector3.DistanceSquared(player.Position, veh.Position) > 100) {
val guid = player.GUID
sendResponse(UnuseItemMessage(guid, veh.GUID))
sendResponse(UnuseItemMessage(guid, guid))
@ -3925,7 +3927,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
accessedContainer = None
}
case Some(container) => //just in case
if(vel.isDefined) {
if(isMoving) {
val guid = player.GUID
// If the container is a corpse and gets removed just as this runs it can cause a client disconnect, so we'll check the container has a GUID first.
if(container.HasGUID) {
@ -4885,7 +4887,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
if (tool.Definition == GlobalDefinitions.bank) {
continent.GUID(object_guid) match {
case Some(tplayer: Player) =>
if (player.GUID != tplayer.GUID && Vector3.Distance(player.Position, tplayer.Position) < 5 && player.Faction == tplayer.Faction && player.Velocity.isEmpty && tplayer.MaxArmor > 0 && tplayer.Armor < tplayer.MaxArmor) {
if (player.GUID != tplayer.GUID && Vector3.Distance(player.Position, tplayer.Position) < 5 && player.Faction == tplayer.Faction && !player.isMoving && tplayer.MaxArmor > 0 && tplayer.Armor < tplayer.MaxArmor) {
tplayer.Armor += 15
tool.Discharge
sendResponse(InventoryStateMessage(tool.AmmoSlot.Box.GUID, obj.GUID, tool.Magazine))
@ -4893,7 +4895,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
sendResponse(RepairMessage(object_guid, RepairPercent))
avatarService ! AvatarServiceMessage(tplayer.Continent, AvatarAction.PlanetsideAttributeToAll(tplayer.GUID, 4, tplayer.Armor))
} else if (player.GUID == tplayer.GUID && player.Velocity.isEmpty && tplayer.MaxArmor > 0) {
} else if (player.GUID == tplayer.GUID && !player.isMoving && tplayer.MaxArmor > 0) {
player.Armor += 15
tool.Discharge
sendResponse(InventoryStateMessage(tool.AmmoSlot.Box.GUID, obj.GUID, tool.Magazine))
@ -4904,7 +4906,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
} else if (tool.Definition == GlobalDefinitions.medicalapplicator) {
continent.GUID(object_guid) match {
case Some(tplayer: Player) =>
if (player.GUID != tplayer.GUID && Vector3.Distance(player.Position, tplayer.Position) < 5 && player.Faction == tplayer.Faction && player.Velocity.isEmpty && tplayer.MaxHealth > 0 && tplayer.Health < tplayer.MaxHealth) {
if (player.GUID != tplayer.GUID && Vector3.Distance(player.Position, tplayer.Position) < 5 && player.Faction == tplayer.Faction && !player.isMoving && tplayer.MaxHealth > 0 && tplayer.Health < tplayer.MaxHealth) {
if(tplayer.isAlive) {
tplayer.Health += 10
} else {
@ -4912,7 +4914,6 @@ class WorldSessionActor extends Actor with MDCContextAware {
//todo: @NotEnoughAmmoToRevive=You do not have enough medical energy to revive this corpse.
tplayer.Health += 4 // 4 health per tick = 5 second revive timer from 0 health
}
tool.Discharge
sendResponse(InventoryStateMessage(tool.AmmoSlot.Box.GUID, obj.GUID, tool.Magazine))
val repairPercent: Int = tplayer.Health * 100 / tplayer.MaxHealth
@ -4926,8 +4927,8 @@ class WorldSessionActor extends Actor with MDCContextAware {
if(tplayer.isAlive) {
avatarService ! AvatarServiceMessage(tplayer.Continent, AvatarAction.PlanetsideAttributeToAll(tplayer.GUID, 0, tplayer.Health))
}
} else if (player.GUID == tplayer.GUID && player.Velocity.isEmpty && tplayer.MaxHealth > 0 && player.isAlive) {
tplayer.Health += 10
} else if (player.GUID == tplayer.GUID && !player.isMoving && tplayer.MaxHealth > 0 && player.isAlive) {
player.Health += 10
tool.Discharge
sendResponse(InventoryStateMessage(tool.AmmoSlot.Box.GUID, obj.GUID, tool.Magazine))
avatarService ! AvatarServiceMessage(player.Continent, AvatarAction.PlanetsideAttributeToAll(player.GUID, 0, player.Health))
@ -5059,7 +5060,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
equipment.get.Definition match {
case GlobalDefinitions.nano_dispenser =>
//TODO repairing behavior
if (player.Velocity.isEmpty && Vector3.Distance(player.Position, obj.Position) < 5) {
if (!player.isMoving && Vector3.Distance(player.Position, obj.Position) < 5) {
if (obj.Health < obj.MaxHealth) {
obj.Health += 48
// sendResponse(QuantityUpdateMessage(PlanetSideGUID(8214),ammo_quantity_left))
@ -5434,7 +5435,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
}
val (angle, attribution, acceptableDistanceToOwner) = obj match {
case p : Player =>
(p.Orientation, tool.Definition.ObjectId, 10f) //TODO upper body facing
(SimpleWorldEntity.validateOrientationEntry(p.Orientation + Vector3.z(p.FacingYawUpper)), tool.Definition.ObjectId, 10f)
case v : Vehicle if v.Definition.CanFly =>
(tool.Orientation, obj.Definition.ObjectId, 1000f) //TODO this is too simplistic to find proper angle
case _ : Vehicle =>