Packet: Planetsideattributemessage (#119)

* initial PlanetsideAttributeMessage packet work

* Update with comments from a little search.
This commit is contained in:
SouNourS 2017-03-11 03:50:38 +01:00 committed by pschord
parent 039f0e55a0
commit 6798ec546c
4 changed files with 94 additions and 1 deletions

View file

@ -370,7 +370,7 @@ object GamePacketOpcode extends Enumeration {
case 0x29 => game.ChangeShortcutBankMessage.decode
case 0x2a => game.ObjectAttachMessage.decode
case 0x2b => noDecoder(UnknownMessage43)
case 0x2c => noDecoder(PlanetsideAttributeMessage)
case 0x2c => game.PlanetsideAttributeMessage.decode
case 0x2d => game.RequestDestroyMessage.decode
case 0x2e => noDecoder(UnknownMessage46)
case 0x2f => game.CharacterCreateRequestMessage.decode

View file

@ -0,0 +1,59 @@
// 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._
/**
* Attribute Type:<br>
* Server to client : <br>
* `0 - health`<br>
* `1 - healthMax`<br>
* `2 - stamina`<br>
* `3 - staminaMax`<br>
* `4 - armor`<br>
* `5 - armorMax`<br>
* `14 - Something with grief`<br>
* `15 - Weapon Lock. Value exemple : 600 to have 1 min lock. Max possible is 30min lock`<br>
* `17 - BEP. Value seems to be the same as BattleExperienceMessage`<br>
* `18 - CEP.`<br>
* `19 - Anchors. Value is 0 to disengage, 1 to engage.`<br>
* `24 - Certifications`<br>
* `29 - Visible ?! That's not the cloaked effect, Maybe for spectator mode ?. Value is 0 to visible, 1 to invisible.`<br>
* `35 - BR. Value is the BR`<br>
* `36 - CR. Value is the CR`<br>
* `53 - LFS. Value is 1 to flag LFS`<br>
* `54 - Player "Aura". Values are : 0 for nothing, 1 for plasma, 2 for ancient, 3 for plasma + ancient,<br>
* 4 for LLU?, 5 for plasma + LLU?, 6 for ancient + LLU?, 7 for plasma + ancient + LLU?, 8 for fire,<br>
* 9 for plasma + fire, 10 for ancient + fire, 11 for plasma + ancient + fire,<br>
* 12 for LLU? + fire, 13 for plasma + LLU? + fire, 14 for ancient + LLU? + fire,<br>
* 15 for plasma + ancient + LLU? + fire,`<br>
* `55 - "Someone is attempting to Heal you". Value is 1`<br>
* `56 - "Someone is attempting to Repair you". Value is 1`<br>
* `73 - "You are locked into the Core Beam. Charging your Module now.". Value is 1 to active`<br>
* `77 - Cavern Facility Captures. Value is the number of captures`<br>
* `78 - Cavern Kills. Value is the number of kills`<br>
* `106 - Custom Head`
* Client to Server : <br>
* `106 - Custom Head`
* @param player_guid the player
* @param attribute_type na
* @param attribute_value na
*/
final case class PlanetsideAttributeMessage(player_guid : PlanetSideGUID,
attribute_type : Int,
attribute_value : Long)
extends PlanetSideGamePacket {
type Packet = PlanetsideAttributeMessage
def opcode = GamePacketOpcode.PlanetsideAttributeMessage
def encode = PlanetsideAttributeMessage.encode(this)
}
object PlanetsideAttributeMessage extends Marshallable[PlanetsideAttributeMessage] {
implicit val codec : Codec[PlanetsideAttributeMessage] = (
("player_guid" | PlanetSideGUID.codec) ::
("attribute_type" | uint8L) ::
("attribute_value" | uint32L)
).as[PlanetsideAttributeMessage]
}

View file

@ -0,0 +1,30 @@
// Copyright (c) 2017 PSForever
package game
import org.specs2.mutable.Specification
import net.psforever.packet.PacketCoding
import net.psforever.packet.game._
import scodec.bits._
class PlanetsideAttributeMessageTest extends Specification {
val string = hex"2c d9040458000000"
"decode" in {
PacketCoding.DecodePacket(string).require match {
case PlanetsideAttributeMessage(player_guid, attribute_type, attribute_value) =>
player_guid mustEqual PlanetSideGUID(1241)
attribute_type mustEqual 4
attribute_value mustEqual 88
case _ =>
ko
}
}
"encode" in {
val msg = PlanetsideAttributeMessage(PlanetSideGUID(1241), 4, 88)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string
}
}

View file

@ -392,6 +392,10 @@ class WorldSessionActor extends Actor with MDCContextAware {
case msg @ BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
log.info("BindPlayerMessage: " + msg)
case msg @ PlanetsideAttributeMessage(avatar_guid, attribute_type, attribute_value) =>
log.info("PlanetsideAttributeMessage: "+msg)
sendResponse(PacketCoding.CreateGamePacket(0,PlanetsideAttributeMessage(avatar_guid, attribute_type, attribute_value)))
case default => log.error(s"Unhandled GamePacket ${pkt}")
}