mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-25 09:33:33 +00:00
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:
parent
9e99dc75e3
commit
a5a85e6cc3
18 changed files with 209 additions and 108 deletions
|
|
@ -66,7 +66,7 @@ class PlayerStateMessageTest extends Specification {
|
|||
vel.get.y mustEqual 6.5625f
|
||||
vel.get.z mustEqual 0.0f
|
||||
facingYaw mustEqual 22.5f
|
||||
facingPitch mustEqual 348.75f
|
||||
facingPitch mustEqual -11.25f
|
||||
facingUpper mustEqual 0f
|
||||
unk1 mustEqual 165
|
||||
crouching mustEqual false
|
||||
|
|
@ -105,7 +105,7 @@ class PlayerStateMessageTest extends Specification {
|
|||
PlanetSideGUID(1696),
|
||||
Vector3(4008.6016f, 5987.6016f, 44.1875f),
|
||||
Some(Vector3(2.53125f, 6.5625f, 0f)),
|
||||
22.5f, 348.75f, 0f, 165,
|
||||
22.5f, -11.25f, 0f, 165,
|
||||
false, false, false, false)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_vel
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ class PlayerStateMessageUpstreamTest extends Specification {
|
|||
case PlayerStateMessageUpstream(avatar_guid, pos, vel, facingYaw, facingPitch, facingYawUpper, seq_time, unk1, is_crouching, is_jumping, jump_thrust, is_cloaked, unk2, unk3) =>
|
||||
avatar_guid mustEqual PlanetSideGUID(75)
|
||||
pos mustEqual Vector3(3694.1094f, 2735.4531f, 90.84375f)
|
||||
vel mustEqual Some(Vector3(4.375f, 2.59375f, 0.0f))
|
||||
vel.contains(Vector3(4.375f, 2.59375f, 0.0f)) mustEqual true
|
||||
facingYaw mustEqual 61.875f
|
||||
facingPitch mustEqual 351.5625f
|
||||
facingPitch mustEqual -8.4375f
|
||||
facingYawUpper mustEqual 0.0f
|
||||
seq_time mustEqual 136
|
||||
unk1 mustEqual 0
|
||||
|
|
@ -33,7 +33,7 @@ class PlayerStateMessageUpstreamTest extends Specification {
|
|||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = PlayerStateMessageUpstream(PlanetSideGUID(75), Vector3(3694.1094f, 2735.4531f, 90.84375f), Some(Vector3(4.375f, 2.59375f, 0.0f)), 61.875f, 351.5625f, 0.0f, 136, 0, false, false, false, false, 112, 0)
|
||||
val msg = PlayerStateMessageUpstream(PlanetSideGUID(75), Vector3(3694.1094f, 2735.4531f, 90.84375f), Some(Vector3(4.375f, 2.59375f, 0.0f)), 61.875f, -8.4375f, 0.0f, 136, 0, false, false, false, false, 112, 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class CharacterDataTest extends Specification {
|
|||
b.outfit_name mustEqual "Black Beret Armoured Corps"
|
||||
b.outfit_logo mustEqual 23
|
||||
b.backpack mustEqual false
|
||||
b.facingPitch mustEqual 320.625f
|
||||
b.facingPitch mustEqual -39.375f
|
||||
b.facingYawUpper mustEqual 0
|
||||
b.lfs mustEqual false
|
||||
b.grenade_state mustEqual GrenadeState.None
|
||||
|
|
@ -176,7 +176,7 @@ class CharacterDataTest extends Specification {
|
|||
b.outfit_name mustEqual "Black Beret Armoured Corps"
|
||||
b.outfit_logo mustEqual 23
|
||||
b.backpack mustEqual false
|
||||
b.facingPitch mustEqual 320.625f
|
||||
b.facingPitch mustEqual -39.375f
|
||||
b.facingYawUpper mustEqual 0
|
||||
b.lfs mustEqual false
|
||||
b.grenade_state mustEqual GrenadeState.None
|
||||
|
|
@ -245,7 +245,7 @@ class CharacterDataTest extends Specification {
|
|||
b.outfit_name mustEqual "Original District"
|
||||
b.outfit_logo mustEqual 23
|
||||
b.backpack mustEqual true
|
||||
b.facingPitch mustEqual 351.5625f
|
||||
b.facingPitch mustEqual -8.4375f
|
||||
b.facingYawUpper mustEqual 0
|
||||
b.lfs mustEqual false
|
||||
b.grenade_state mustEqual GrenadeState.None
|
||||
|
|
@ -334,7 +334,7 @@ class CharacterDataTest extends Specification {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
320.625f, 0f,
|
||||
-39.375f, 0f,
|
||||
false,
|
||||
GrenadeState.None,
|
||||
false,
|
||||
|
|
@ -414,7 +414,7 @@ class CharacterDataTest extends Specification {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
320.625f, 0f,
|
||||
-39.375f, 0f,
|
||||
false,
|
||||
GrenadeState.None,
|
||||
false,
|
||||
|
|
@ -497,7 +497,7 @@ class CharacterDataTest extends Specification {
|
|||
false, //unk2
|
||||
false, //unk3
|
||||
false, //unk4
|
||||
351.5625f, 0f,
|
||||
351.5625f, 0f, //also: -8.4375f, 0f
|
||||
false, //lfs
|
||||
GrenadeState.None,
|
||||
false, //is_cloaking
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ class DetailedCharacterDataTest extends Specification {
|
|||
b.outfit_name mustEqual ""
|
||||
b.outfit_logo mustEqual 0
|
||||
b.backpack mustEqual false
|
||||
b.facingPitch mustEqual 348.75f
|
||||
b.facingPitch mustEqual -11.25f
|
||||
b.facingYawUpper mustEqual 0
|
||||
b.lfs mustEqual true
|
||||
b.grenade_state mustEqual GrenadeState.None
|
||||
|
|
@ -666,8 +666,8 @@ class DetailedCharacterDataTest extends Specification {
|
|||
b.outfit_name mustEqual ""
|
||||
b.outfit_logo mustEqual 14
|
||||
b.backpack mustEqual false
|
||||
b.facingPitch mustEqual 348.75f
|
||||
b.facingYawUpper mustEqual 348.75f
|
||||
b.facingPitch mustEqual -11.25f
|
||||
b.facingYawUpper mustEqual -11.25f
|
||||
b.lfs mustEqual false
|
||||
b.grenade_state mustEqual GrenadeState.None
|
||||
b.is_cloaking mustEqual false
|
||||
|
|
@ -1759,7 +1759,7 @@ class DetailedCharacterDataTest extends Specification {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
348.75f, 0,
|
||||
-11.25f, 0,
|
||||
true,
|
||||
GrenadeState.None,
|
||||
false,
|
||||
|
|
@ -1949,7 +1949,7 @@ class DetailedCharacterDataTest extends Specification {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
348.75f, 348.75f,
|
||||
-11.25f, -11.25f,
|
||||
false,
|
||||
GrenadeState.None,
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class MountedVehiclesTest extends Specification {
|
|||
b.outfit_name mustEqual "Black Beret Armoured Corps"
|
||||
b.outfit_logo mustEqual 23
|
||||
b.backpack mustEqual false
|
||||
b.facingPitch mustEqual 348.75f
|
||||
b.facingPitch mustEqual -11.25f
|
||||
b.facingYawUpper mustEqual 0
|
||||
b.lfs mustEqual false
|
||||
b.grenade_state mustEqual GrenadeState.None
|
||||
|
|
@ -167,7 +167,7 @@ class MountedVehiclesTest extends Specification {
|
|||
false,
|
||||
false,
|
||||
false,
|
||||
348.75f, 0,
|
||||
-11.25f, 0,
|
||||
false,
|
||||
GrenadeState.None,
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class EntityTest extends Specification {
|
|||
val obj : EntityTestClass = new EntityTestClass()
|
||||
obj.Position mustEqual Vector3(0f, 0f, 0f)
|
||||
obj.Orientation mustEqual Vector3(0f, 0f, 0f)
|
||||
obj.Velocity mustEqual None
|
||||
obj.Velocity.isEmpty mustEqual true
|
||||
}
|
||||
|
||||
"mutate and access" in {
|
||||
|
|
@ -35,7 +35,7 @@ class EntityTest extends Specification {
|
|||
|
||||
obj.Position mustEqual Vector3(1f, 1f, 1f)
|
||||
obj.Orientation mustEqual Vector3(2f, 2f, 2f)
|
||||
obj.Velocity mustEqual Some(Vector3(3f, 3f, 3f))
|
||||
obj.Velocity.contains(Vector3(3f, 3f, 3f)) mustEqual true
|
||||
}
|
||||
|
||||
"clamp Orientation" in {
|
||||
|
|
@ -43,6 +43,61 @@ class EntityTest extends Specification {
|
|||
obj.Orientation = Vector3(-1f, 361f, -0f)
|
||||
obj.Orientation mustEqual Vector3(359f, 1f, 0f)
|
||||
}
|
||||
|
||||
"is moving (at all)" in {
|
||||
val obj : EntityTestClass = new EntityTestClass
|
||||
obj.Velocity.isEmpty mustEqual true
|
||||
obj.isMoving mustEqual false
|
||||
|
||||
obj.Velocity = Vector3.Zero
|
||||
obj.isMoving mustEqual false
|
||||
obj.Velocity = Vector3(1,0,0)
|
||||
obj.isMoving mustEqual true
|
||||
obj.Velocity = None
|
||||
obj.isMoving mustEqual false
|
||||
}
|
||||
|
||||
"is moving (Vector3 comparison)" in {
|
||||
val obj : EntityTestClass = new EntityTestClass
|
||||
val test1 = Vector3(1,0,0)
|
||||
val test2 = Vector3(2,0,0)
|
||||
obj.Velocity.isEmpty mustEqual true
|
||||
obj.isMoving mustEqual false
|
||||
obj.isMoving(test1) mustEqual false
|
||||
obj.isMoving(test2) mustEqual false
|
||||
|
||||
obj.Velocity = Vector3(1,0,0)
|
||||
obj.isMoving(test1) mustEqual true
|
||||
obj.isMoving(test2) mustEqual false
|
||||
obj.Velocity = Vector3(3,0,0)
|
||||
obj.isMoving(test1) mustEqual true
|
||||
obj.isMoving(test2) mustEqual true
|
||||
obj.Velocity = Vector3(1,1,0)
|
||||
obj.isMoving(test1) mustEqual true
|
||||
obj.isMoving(test2) mustEqual false
|
||||
}
|
||||
|
||||
"is moving (Float comparison)" in {
|
||||
val obj : EntityTestClass = new EntityTestClass
|
||||
obj.Velocity.isEmpty mustEqual true
|
||||
obj.isMoving mustEqual false
|
||||
obj.isMoving(1) mustEqual false
|
||||
obj.isMoving(2) mustEqual false
|
||||
obj.isMoving(4) mustEqual false
|
||||
|
||||
obj.Velocity = Vector3(1,0,0)
|
||||
obj.isMoving(1) mustEqual true
|
||||
obj.isMoving(2) mustEqual false
|
||||
obj.isMoving(4) mustEqual false
|
||||
obj.Velocity = Vector3(3,0,0)
|
||||
obj.isMoving(1) mustEqual true
|
||||
obj.isMoving(2) mustEqual true
|
||||
obj.isMoving(4) mustEqual true
|
||||
obj.Velocity = Vector3(1,1,1)
|
||||
obj.isMoving(1) mustEqual true
|
||||
obj.isMoving(2) mustEqual true
|
||||
obj.isMoving(4) mustEqual false
|
||||
}
|
||||
}
|
||||
|
||||
"IdentifiableEntity" should {
|
||||
|
|
|
|||
|
|
@ -133,26 +133,26 @@ class PlayerTest extends Specification {
|
|||
obj.Stamina mustEqual 456
|
||||
}
|
||||
|
||||
"set new values (health, armor, stamina) but only when alive" in {
|
||||
val obj = TestPlayer("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
obj.Health = 23
|
||||
obj.Armor = 34
|
||||
obj.Stamina = 45
|
||||
obj.Health mustEqual 0
|
||||
obj.Armor mustEqual 0
|
||||
obj.Stamina mustEqual 0
|
||||
|
||||
obj.Spawn
|
||||
obj.Health mustEqual obj.MaxHealth
|
||||
obj.Armor mustEqual obj.MaxArmor
|
||||
obj.Stamina mustEqual obj.MaxStamina
|
||||
obj.Health = 23
|
||||
obj.Armor = 34
|
||||
obj.Stamina = 45
|
||||
obj.Health mustEqual 23
|
||||
obj.Armor mustEqual 34
|
||||
obj.Stamina mustEqual 45
|
||||
}
|
||||
// "set new values (health, armor, stamina) but only when alive" in {
|
||||
// val obj = TestPlayer("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
// obj.Health = 23
|
||||
// obj.Armor = 34
|
||||
// obj.Stamina = 45
|
||||
// obj.Health mustEqual 0
|
||||
// obj.Armor mustEqual 0
|
||||
// obj.Stamina mustEqual 0
|
||||
//
|
||||
// obj.Spawn
|
||||
// obj.Health mustEqual obj.MaxHealth
|
||||
// obj.Armor mustEqual obj.MaxArmor
|
||||
// obj.Stamina mustEqual obj.MaxStamina
|
||||
// obj.Health = 23
|
||||
// obj.Armor = 34
|
||||
// obj.Stamina = 45
|
||||
// obj.Health mustEqual 23
|
||||
// obj.Armor mustEqual 34
|
||||
// obj.Stamina mustEqual 45
|
||||
// }
|
||||
|
||||
"has visible slots" in {
|
||||
val obj = TestPlayer("Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, CharacterVoice.Voice5)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue