mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-19 18:14:44 +00:00
Packet: HitHint (#107)
* initial HitHint packet and tests * rebased and updated HitHint packet and tests * field are known
This commit is contained in:
parent
30f679238b
commit
2307d6a431
|
|
@ -330,7 +330,7 @@ object GamePacketOpcode extends Enumeration {
|
|||
// 0x08
|
||||
case 0x08 => game.PlayerStateMessage.decode
|
||||
case 0x09 => game.HitMessage.decode
|
||||
case 0x0a => noDecoder(HitHint)
|
||||
case 0x0a => game.HitHint.decode
|
||||
case 0x0b => noDecoder(DamageMessage)
|
||||
case 0x0c => noDecoder(DestroyMessage)
|
||||
case 0x0d => game.ReloadMessage.decode
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) 2016 PSForever.net to present
|
||||
package net.psforever.packet.game
|
||||
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
|
||||
/**
|
||||
* Dispatched by the server to indicate a target or source of damage affecting the player.<br>
|
||||
* <br>
|
||||
* When a source is provided, and within render distance, the player will be shown a fading, outwards drifting, red tick mark.
|
||||
* The location and movement of the mark will indicate a general direction towards the source.
|
||||
* If the option `Game/Show Damage Flash` is set, the player's screen will flash red briefly when a mark is displayed.<br>
|
||||
* <br>
|
||||
* For while some mark is being displayed, the player will also make a grunt of pain.
|
||||
* @param source_guid the source of implied damage
|
||||
* @param player_guid the player
|
||||
*/
|
||||
final case class HitHint(source_guid : PlanetSideGUID,
|
||||
player_guid : PlanetSideGUID)
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = HitHint
|
||||
def opcode = GamePacketOpcode.HitHint
|
||||
def encode = HitHint.encode(this)
|
||||
}
|
||||
|
||||
object HitHint extends Marshallable[HitHint] {
|
||||
implicit val codec : Codec[HitHint] = (
|
||||
("source_guid" | PlanetSideGUID.codec) ::
|
||||
("player_guid" | PlanetSideGUID.codec)
|
||||
).as[HitHint]
|
||||
}
|
||||
28
common/src/test/scala/game/HitHintTest.scala
Normal file
28
common/src/test/scala/game/HitHintTest.scala
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2016 PSForever.net to present
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class HitHintTest extends Specification {
|
||||
val string = hex"0A 460B 0100"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case HitHint(source, player) =>
|
||||
source mustEqual PlanetSideGUID(2886)
|
||||
player mustEqual PlanetSideGUID(1)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = HitHint(PlanetSideGUID(2886), PlanetSideGUID(1))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue