mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-25 09:33:33 +00:00
proper remote projectile handling; allowances for the Decimator alt-fire mode; initial DamageMessage packet and tests; initial DamageFeedbackMessage packet and tests
This commit is contained in:
parent
043512d6a3
commit
693a3a5d78
18 changed files with 421 additions and 245 deletions
68
common/src/test/scala/game/DamageFeedbackMessageTest.scala
Normal file
68
common/src/test/scala/game/DamageFeedbackMessageTest.scala
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class DamageFeedbackMessageTest extends Specification {
|
||||
val string = hex"7b 3d842f610b2040000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case DamageFeedbackMessage(unk1, unk2, unk2a, unk2b, unk2c, unk3, unk3a, unk3b, unk3c, unk3d, unk4, unk5, unk6) =>
|
||||
unk1 mustEqual 3
|
||||
unk2 mustEqual true
|
||||
unk2a.contains(PlanetSideGUID(2913)) mustEqual true
|
||||
unk2b.isEmpty mustEqual true
|
||||
unk2c.isEmpty mustEqual true
|
||||
unk3 mustEqual true
|
||||
unk3a.contains(PlanetSideGUID(2913)) mustEqual true
|
||||
unk3b.isEmpty mustEqual true
|
||||
unk3c.isEmpty mustEqual true
|
||||
unk3d.isEmpty mustEqual true
|
||||
unk4 mustEqual 1
|
||||
unk5 mustEqual 2
|
||||
unk6 mustEqual 0
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, Some(PlanetSideGUID(2913)), None, None, None, 1, 2, 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
||||
"failures" in {
|
||||
//unk2: no parameters
|
||||
DamageFeedbackMessage(3, true, None, None, None, true, Some(PlanetSideGUID(2913)), None, None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
//unk2: two exclusive parameters
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), Some("error"), None, true, Some(PlanetSideGUID(2913)), None, None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, Some(5), true, Some(PlanetSideGUID(2913)), None, None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
DamageFeedbackMessage(3, true, None, Some("error"), Some(5), true, Some(PlanetSideGUID(2913)), None, None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
//unk2: all parameters
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), Some("error"), Some(5), true, Some(PlanetSideGUID(2913)), None, None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
//unk2: mismatched flag for strings
|
||||
DamageFeedbackMessage(3, true, None, None, Some(5), true, Some(PlanetSideGUID(2913)), None, None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
DamageFeedbackMessage(3, false, None, Some("error"), None, true, Some(PlanetSideGUID(2913)), None, None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
|
||||
//unk3: no parameters
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, None, None, None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
//unk3: two exclusive parameters
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, Some(PlanetSideGUID(2913)), Some("error"), None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, Some(PlanetSideGUID(2913)), None, Some(5), None, 1, 2, 0) must throwA[AssertionError]
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, None, Some("error"), Some(5), Some(1), 1, 2, 0) must throwA[AssertionError]
|
||||
//unk3: all parameters
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, Some(PlanetSideGUID(2913)), Some("error"), Some(5), None, 1, 2, 0) must throwA[AssertionError]
|
||||
//unk3: mismatched fields
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, Some(PlanetSideGUID(2913)), None, None, Some(5), 1, 2, 0) must throwA[AssertionError]
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, None, Some("Error"), None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
//unk3: mismatched flag for strings
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, true, None, None, Some(5), None, 1, 2, 0) must throwA[AssertionError]
|
||||
DamageFeedbackMessage(3, true, Some(PlanetSideGUID(2913)), None, None, false, None, Some("error"), None, None, 1, 2, 0) must throwA[AssertionError]
|
||||
}
|
||||
}
|
||||
30
common/src/test/scala/game/DamageMessageTest.scala
Normal file
30
common/src/test/scala/game/DamageMessageTest.scala
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) 2019 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class DamageMessageTest extends Specification {
|
||||
val string = hex"0b610b02610b00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case DamageMessage(guid1, unk1, guid2, unk2) =>
|
||||
guid1 mustEqual PlanetSideGUID(2913)
|
||||
unk1 mustEqual 2
|
||||
guid2 mustEqual PlanetSideGUID(2913)
|
||||
unk2 mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = DamageMessage(PlanetSideGUID(2913), 2, PlanetSideGUID(2913), false)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ class ProjectileStateMessageTest extends Specification {
|
|||
orient mustEqual Vector3(0, 22.5f, 146.25f)
|
||||
sequence mustEqual 2
|
||||
explode mustEqual false
|
||||
unk mustEqual 0
|
||||
unk mustEqual PlanetSideGUID(0)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ class ProjectileStateMessageTest extends Specification {
|
|||
Vector3(0, 22.5f, 146.25f),
|
||||
2,
|
||||
false,
|
||||
0
|
||||
PlanetSideGUID(0)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ import net.psforever.types.{PlanetSideEmpire, Vector3}
|
|||
import org.specs2.mutable._
|
||||
import scodec.bits._
|
||||
|
||||
class TrackedProjectileDataTest extends Specification {
|
||||
class RemoteProjectileDataTest extends Specification {
|
||||
val string_striker_projectile = hex"17 C5000000 A4B 009D 4C129 0CB0A 9814 00 F5 E3 040000666686400"
|
||||
val string_hunter_seeker_missile_projectile = hex"17 c5000000 ca9 ab9e af127 ec465 3723 00 15 c4 2400009a99c9400"
|
||||
|
||||
"TrackedProjectileData" should {
|
||||
"RemoteProjectileData" should {
|
||||
"decode (striker_missile_targeting_projectile)" in {
|
||||
PacketCoding.DecodePacket(string_striker_projectile).require match {
|
||||
case ObjectCreateMessage(len, cls, guid, parent, data) =>
|
||||
|
|
@ -21,7 +21,7 @@ class TrackedProjectileDataTest extends Specification {
|
|||
guid mustEqual PlanetSideGUID(40192)
|
||||
parent.isDefined mustEqual false
|
||||
data match {
|
||||
case TrackedProjectileData(CommonFieldDataWithPlacement(pos, deploy), unk2, lim, unk3, unk4, unk5) =>
|
||||
case RemoteProjectileData(CommonFieldDataWithPlacement(pos, deploy), unk2, lim, unk3, unk4, unk5) =>
|
||||
pos.coord mustEqual Vector3(4644.5938f, 5472.0938f, 82.375f)
|
||||
pos.orient mustEqual Vector3(0, 30.9375f, 171.5625f)
|
||||
deploy.faction mustEqual PlanetSideEmpire.TR
|
||||
|
|
@ -55,7 +55,7 @@ class TrackedProjectileDataTest extends Specification {
|
|||
guid mustEqual PlanetSideGUID(40619)
|
||||
parent.isDefined mustEqual false
|
||||
data match {
|
||||
case TrackedProjectileData(CommonFieldDataWithPlacement(pos, deploy), unk2, lim, unk3, unk4, unk5) =>
|
||||
case RemoteProjectileData(CommonFieldDataWithPlacement(pos, deploy), unk2, lim, unk3, unk4, unk5) =>
|
||||
pos.coord mustEqual Vector3(3621.3672f, 2701.8438f, 140.85938f)
|
||||
pos.orient mustEqual Vector3(0, 300.9375f, 258.75f)
|
||||
deploy.faction mustEqual PlanetSideEmpire.NC
|
||||
|
|
@ -82,7 +82,7 @@ class TrackedProjectileDataTest extends Specification {
|
|||
}
|
||||
|
||||
"encode (striker_missile_targeting_projectile)" in {
|
||||
val obj = TrackedProjectileData(
|
||||
val obj = RemoteProjectileData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(4644.5938f, 5472.0938f, 82.375f, 0f, 30.9375f, 171.5625f),
|
||||
CommonFieldData(PlanetSideEmpire.TR, false, false, true, None, false, None, None, PlanetSideGUID(0))
|
||||
|
|
@ -100,7 +100,7 @@ class TrackedProjectileDataTest extends Specification {
|
|||
}
|
||||
|
||||
"encode (hunter_seeker_missile_projectile)" in {
|
||||
val obj = TrackedProjectileData(
|
||||
val obj = RemoteProjectileData(
|
||||
CommonFieldDataWithPlacement(
|
||||
PlacementData(3621.3672f, 2701.8438f, 140.85938f, 0, 300.9375f, 258.75f),
|
||||
CommonFieldData(PlanetSideEmpire.NC, false, false, true, None, false, None, None, PlanetSideGUID(0))
|
||||
Loading…
Add table
Add a link
Reference in a new issue