mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-28 16:29:15 +00:00
initial work on TargetingInfoMessage packet and working tests; want to try clarify unknown fields before finishing
This commit is contained in:
parent
f1dfc20cb3
commit
6fa701d263
3 changed files with 108 additions and 1 deletions
|
|
@ -414,7 +414,7 @@ object GamePacketOpcode extends Enumeration {
|
|||
case 0x4f => game.LashMessage.decode
|
||||
|
||||
// OPCODES 0x50-5f
|
||||
case 0x50 => noDecoder(TargetingInfoMessage)
|
||||
case 0x50 => game.TargetingInfoMessage.decode
|
||||
case 0x51 => noDecoder(TriggerEffectMessage)
|
||||
case 0x52 => game.WeaponDryFireMessage.decode
|
||||
case 0x53 => noDecoder(DroppodLaunchRequestMessage)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.packet.game
|
||||
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
import shapeless.{::, HNil}
|
||||
|
||||
/**
|
||||
* na
|
||||
* @param target_guid the target
|
||||
* @param unk1 na
|
||||
* @param unk2 na
|
||||
*/
|
||||
final case class TargetInfo(target_guid : PlanetSideGUID,
|
||||
unk1 : Float,
|
||||
unk2 : Float = 0f)
|
||||
|
||||
/**
|
||||
* na
|
||||
* @param target_list a list of targets
|
||||
*/
|
||||
final case class TargetingInfoMessage(target_list : List[TargetInfo])
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = TargetingInfoMessage
|
||||
def opcode = GamePacketOpcode.TargetingInfoMessage
|
||||
def encode = TargetingInfoMessage.encode(this)
|
||||
}
|
||||
|
||||
object TargetingInfoMessage extends Marshallable[TargetingInfoMessage] {
|
||||
private final val unit : Double = 0.0039215689 //common constant for 1/255
|
||||
|
||||
private val info_codec : Codec[TargetInfo] = (
|
||||
("target_guid" | PlanetSideGUID.codec) ::
|
||||
("unk1" | uint8L) ::
|
||||
("unk2" | uint8L)
|
||||
).xmap[TargetInfo] (
|
||||
{
|
||||
case a :: b :: c :: HNil =>
|
||||
val bFloat : Float = (b.toDouble * unit).toFloat
|
||||
val cFloat : Float = (c.toDouble * unit).toFloat
|
||||
TargetInfo(a, bFloat, cFloat)
|
||||
},
|
||||
{
|
||||
case TargetInfo(a, bFloat, cFloat) =>
|
||||
val b : Int = (bFloat.toDouble * 255).toInt
|
||||
val c : Int = (cFloat.toDouble * 255).toInt
|
||||
a :: b :: c :: HNil
|
||||
}
|
||||
)
|
||||
|
||||
implicit val codec : Codec[TargetingInfoMessage] = ("target_list" | listOfN(uint8L, info_codec)).as[TargetingInfoMessage]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue