mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-01-19 18:14:44 +00:00
Packet: AvatarImplantMessage (#108)
* added initial AvatarImplantMessage packet * rebased AvatarImplantMessage and working test * converting implant types * changing format of Enum from axx_bxx to AxxBxx
This commit is contained in:
parent
a6a51009fa
commit
30f679238b
|
|
@ -423,7 +423,7 @@ object GamePacketOpcode extends Enumeration {
|
|||
case 0x56 => noDecoder(GenericObjectActionMessage)
|
||||
case 0x57 => noDecoder(AvatarVehicleTimerMessage)
|
||||
// 0x58
|
||||
case 0x58 => noDecoder(AvatarImplantMessage)
|
||||
case 0x58 => game.AvatarImplantMessage.decode
|
||||
case 0x59 => noDecoder(UnknownMessage89)
|
||||
case 0x5a => noDecoder(DelayedPathMountMsg)
|
||||
case 0x5b => noDecoder(OrbitalShuttleTimeMsg)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
// Copyright (c) 2016 PSForever.net to present
|
||||
package net.psforever.packet.game
|
||||
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
|
||||
/**
|
||||
* An `Enumeration` of the available implants.
|
||||
*/
|
||||
object ImplantType extends Enumeration {
|
||||
type Type = Value
|
||||
val AdvancedRegen,
|
||||
Targeting,
|
||||
AudioAmplifier,
|
||||
DarklightVision,
|
||||
MeleeBooster,
|
||||
PersonalShield,
|
||||
RangeMagnifier,
|
||||
Unknown7,
|
||||
SilentRun,
|
||||
Surge = Value
|
||||
|
||||
implicit val codec = PacketHelpers.createEnumerationCodec(this, uint4L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the state of the implant.<br>
|
||||
* Write better comments.
|
||||
* <br>
|
||||
* Implant:<br>
|
||||
* `
|
||||
* 00 - Regeneration (advanced_regen)<br>
|
||||
* 01 - Enhanced Targeting (targeting)<br>
|
||||
* 02 - Audio Amplifier (audio_amplifier)<br>
|
||||
* 03 - Darklight Vision (darklight_vision)<br>
|
||||
* 04 - Melee Booster (melee_booster)<br>
|
||||
* 05 - Personal Shield (personal_shield)<br>
|
||||
* 06 - Range Magnifier (range_magnifier)<br>
|
||||
* 07 - `None`<br>
|
||||
* 08 - Sensor Shield (silent_run)<br>
|
||||
* 09 - Surge (surge)<br>
|
||||
* `
|
||||
* <br>
|
||||
* Exploration<br>
|
||||
* Where is Second Wind (second_wind)?
|
||||
* @param player_guid the player
|
||||
* @param unk1 na
|
||||
* @param unk2 na
|
||||
* @param implant the implant
|
||||
*/
|
||||
final case class AvatarImplantMessage(player_guid : PlanetSideGUID,
|
||||
unk1 : Int,
|
||||
unk2 : Int,
|
||||
implant : ImplantType.Value)
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = AvatarImplantMessage
|
||||
def opcode = GamePacketOpcode.AvatarImplantMessage
|
||||
def encode = AvatarImplantMessage.encode(this)
|
||||
}
|
||||
|
||||
object AvatarImplantMessage extends Marshallable[AvatarImplantMessage] {
|
||||
implicit val codec : Codec[AvatarImplantMessage] = (
|
||||
("player_guid" | PlanetSideGUID.codec) ::
|
||||
("unk1" | uintL(3)) ::
|
||||
("unk2" | uint2L) ::
|
||||
("implant" | ImplantType.codec)
|
||||
).as[AvatarImplantMessage]
|
||||
}
|
||||
30
common/src/test/scala/game/AvatarImplantMessageTest.scala
Normal file
30
common/src/test/scala/game/AvatarImplantMessageTest.scala
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// 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 AvatarImplantMessageTest extends Specification {
|
||||
val string = hex"58 630C 68 80"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case AvatarImplantMessage(player_guid, unk1, unk2, implant) =>
|
||||
player_guid mustEqual PlanetSideGUID(3171)
|
||||
unk1 mustEqual 3
|
||||
unk2 mustEqual 1
|
||||
implant mustEqual ImplantType.Targeting
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = AvatarImplantMessage(PlanetSideGUID(3171), 3, 1, ImplantType.Targeting)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue