PSF-LoginServer/src/test/scala/game/GenericCollisionMsgTest.scala
Fate-JH 93a544c07c
Collisions (#932)
* pattern for applying damage to player avatar and player-controlled vehicle collisions

* pattern for applying damage to targets due to collisions, falling damage and crashing damage individually; fields to support these calculations are provided

* modifiers to translate 'small step velocity' to real game velocity, as reported by the HUD; corrections for velocity; corrections for velocity in other packets

* fall damage calculations moved to function

* basic two-body collisions between GUID-identified game entities and a ward against too many collisions in a short amount of time

* bailing mechanics

* vssm for non-driven vehicles

* comment about vehicle state message field

* comments and minor refactoring for current collision damage calc; tank_traps modifier; potential fix for blockmap indexing issue

* fixed cargo/carrier vehicle ops

* corrections to initialization of ce construction items; adjustments to handling of modifiers for collision damage

* modifier change, protection against flight speed and spectator crashes; submerged status is once again known only to the actor

* appeasing the automated tests

* hopefully paced collisions better; re-did how Infantry collisions are calculated, incorporating mass and exo-suit data; kill feed reporting should be better

* adjusted damage values again, focusing on the lesser of or middling results; collision killfeed attribution attempt

* kicking offers bail protection; lowered the artificial modifier for one kind of collision damage calculation

* correction to the local reference map functions

* fixed tests; attempt to zero fall damage distance based on velocity; attempt to block mine damage when spectating
2021-10-05 09:59:49 -04:00

86 lines
2.5 KiB
Scala

// Copyright (c) 2017 PSForever
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.types.{PlanetSideGUID, Vector3}
import scodec.bits._
class GenericCollisionMsgTest extends Specification {
//TODO find a better test later
val string =
hex"3C 92C00000190000001B2A8010932CEF505C70946F00000000000000000000000017725EBC6D6A058000000000000000000000000000003F8FF45140"
"decode" in {
PacketCoding.decodePacket(string).require match {
case GenericCollisionMsg(ct, p, php, ppos, pv, t, thp, tpos, tv, unk2, unk3, unk4) =>
ct mustEqual CollisionIs.OfInfantry
p mustEqual PlanetSideGUID(75)
t mustEqual PlanetSideGUID(0)
php mustEqual 100
thp mustEqual 0
pv.x mustEqual 115.79913f
pv.y mustEqual 85.365166f
pv.z mustEqual -0.046089742f
tv.x mustEqual 0.0f
tv.z mustEqual 0.0f
tv.x mustEqual 0.0f
ppos.x mustEqual 3986.7266f
ppos.y mustEqual 2615.3672f
ppos.z mustEqual 90.625f
tpos.x mustEqual 0.0f
tpos.y mustEqual 0.0f
tpos.z mustEqual 0.0f
unk2 mustEqual 0L
unk3 mustEqual 0L
unk4 mustEqual 1171341310L
case _ =>
ko
}
}
"encode" in {
val msg = GenericCollisionMsg(
CollisionIs.OfInfantry,
PlanetSideGUID(75),
100,
Vector3(3986.7266f, 2615.3672f, 90.625f),
Vector3(115.79913f, 85.365166f, -0.046089742f),
PlanetSideGUID(0),
0,
Vector3(0.0f, 0.0f, 0.0f),
Vector3(0.0f, 0.0f, 0.0f),
0L,
0L,
1171341310L
)
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
//pkt mustEqual string
PacketCoding.decodePacket(pkt).require match {
case GenericCollisionMsg(ct, p, php, ppos, pv, t, thp, tpos, tv, unk2, unk3, unk4) =>
ct mustEqual CollisionIs.OfInfantry
p mustEqual PlanetSideGUID(75)
t mustEqual PlanetSideGUID(0)
php mustEqual 100
thp mustEqual 0
pv.x mustEqual 115.79913f
pv.y mustEqual 85.365166f
pv.z mustEqual -0.046089742f
tv.x mustEqual 0.0f
tv.z mustEqual 0.0f
tv.x mustEqual 0.0f
ppos.x mustEqual 3986.7266f
ppos.y mustEqual 2615.3672f
ppos.z mustEqual 90.625f
tpos.x mustEqual 0.0f
tpos.y mustEqual 0.0f
tpos.z mustEqual 0.0f
unk2 mustEqual 0L
unk3 mustEqual 0L
unk4 mustEqual 1171341310L
case _ =>
ko
}
}
}