mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-07-13 07:24:53 +00:00
working version; all checks pass
This commit is contained in:
parent
ce165aa9a5
commit
008cb4e919
3 changed files with 62 additions and 48 deletions
|
|
@ -6,7 +6,7 @@ import scodec.Codec
|
||||||
import scodec.codecs._
|
import scodec.codecs._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a quick-use button for the hotbar.<br>
|
* Details regarding this shortcut.
|
||||||
* <br>
|
* <br>
|
||||||
* Purpose:<br>
|
* Purpose:<br>
|
||||||
* `advanced_regen` (regeneration)<br>
|
* `advanced_regen` (regeneration)<br>
|
||||||
|
|
@ -20,52 +20,65 @@ import scodec.codecs._
|
||||||
* `shortcut_macro`<br>
|
* `shortcut_macro`<br>
|
||||||
* `silent_run` (sensor shield)<br>
|
* `silent_run` (sensor shield)<br>
|
||||||
* `surge`<br>
|
* `surge`<br>
|
||||||
* `targeting`
|
* `targeting` (enchanced targetting)
|
||||||
* @param player_guid the player
|
|
||||||
* @param slot the hotbar slot number (one-indexed)
|
|
||||||
* @param unk1 na
|
|
||||||
* @param unk2 na
|
|
||||||
* @param purpose the primary purpose/use of this shortcut
|
* @param purpose the primary purpose/use of this shortcut
|
||||||
* @param effect1 for macros, a three letter acronym displayed in the hotbar
|
* @param effect1 for macros, a three letter acronym displayed in the hotbar
|
||||||
* @param effect2 for macros, the chat message content
|
* @param effect2 for macros, the chat message content
|
||||||
*/
|
*/
|
||||||
//TODO must handle case 0x28 xxxx 01 00 00 for moving shortcuts
|
final case class Shortcut(purpose : String,
|
||||||
|
effect1 : String = "",
|
||||||
|
effect2 : String = "")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manipulate a quick-use button for the hotbar.
|
||||||
|
* <br>
|
||||||
|
* na
|
||||||
|
* @param player_guid the player
|
||||||
|
* @param slot the hotbar slot number (one-indexed)
|
||||||
|
* @param unk1 na
|
||||||
|
* @param unk2 na
|
||||||
|
* @param shortcut optional; details about the shortcut to be created
|
||||||
|
*/
|
||||||
final case class CreateShortcutMessage(player_guid : PlanetSideGUID,
|
final case class CreateShortcutMessage(player_guid : PlanetSideGUID,
|
||||||
slot : Int,
|
slot : Int,
|
||||||
unk1 : Int,
|
unk1 : Int,
|
||||||
unk2 : Int,
|
unk2 : Int,
|
||||||
purpose : String = "",
|
shortcut : Option[Shortcut] = None)
|
||||||
effect1 : String = "",
|
|
||||||
effect2 : String = "")
|
|
||||||
extends PlanetSideGamePacket {
|
extends PlanetSideGamePacket {
|
||||||
type Packet = CreateShortcutMessage
|
type Packet = CreateShortcutMessage
|
||||||
def opcode = GamePacketOpcode.CreateShortcutMessage
|
def opcode = GamePacketOpcode.CreateShortcutMessage
|
||||||
def encode = CreateShortcutMessage.encode(this)
|
def encode = CreateShortcutMessage.encode(this)
|
||||||
}
|
}
|
||||||
//*
|
|
||||||
object CreateShortcutMessage extends Marshallable[CreateShortcutMessage] {
|
object Shortcut extends Marshallable[Shortcut] {
|
||||||
implicit val codec : Codec[CreateShortcutMessage] = (
|
// Needs to be Marshallable[T] for .as[T] to work its magic on the type of the codec Codec[T]
|
||||||
("player_guid" | PlanetSideGUID.codec) ::
|
implicit val codec : Codec[Shortcut] = (
|
||||||
("slot" | uint8L) ::
|
("purpose" | PacketHelpers.encodedStringAligned(5)) ::
|
||||||
("unk1" | uint8L) ::
|
|
||||||
("unk2" | uintL(3)) ::
|
|
||||||
("purpose" | PacketHelpers.encodedStringAligned(5)) ::
|
|
||||||
("effect1" | PacketHelpers.encodedWideString) ::
|
("effect1" | PacketHelpers.encodedWideString) ::
|
||||||
("effect2" | PacketHelpers.encodedWideString)
|
("effect2" | PacketHelpers.encodedWideString)
|
||||||
).as[CreateShortcutMessage]
|
).as[Shortcut]
|
||||||
|
|
||||||
|
// Convenient predefined Shortcuts for the Medkit and Implants
|
||||||
|
final val AUDIO_AMPLIFIER : Shortcut = Shortcut("audio_amplifier")
|
||||||
|
final val DARKLIGHT_VISION : Shortcut = Shortcut("darklight_vision")
|
||||||
|
final val ENHANCED_TARGETING = Shortcut("targeting")
|
||||||
|
final val MEDKIT : Shortcut = Shortcut("medkit")
|
||||||
|
final val MELEE_BOOSTER : Shortcut = Shortcut("melee_booster")
|
||||||
|
final val PERSONAL_SHIELD : Shortcut = Shortcut("personal_shield")
|
||||||
|
final val RANGE_MAGNIFIER : Shortcut = Shortcut("range_magnifier")
|
||||||
|
final val REGENERATION : Shortcut = Shortcut("advanced_regen")
|
||||||
|
final val SECOND_WIND : Shortcut = Shortcut("second_wind")
|
||||||
|
final val SENSOR_SHIELD : Shortcut = Shortcut("silent_run")
|
||||||
|
final val SURGE : Shortcut = Shortcut("surge")
|
||||||
}
|
}
|
||||||
// */
|
|
||||||
/*
|
|
||||||
object CreateShortcutMessage extends Marshallable[CreateShortcutMessage] {
|
object CreateShortcutMessage extends Marshallable[CreateShortcutMessage] {
|
||||||
implicit val codec : Codec[CreateShortcutMessage] = (
|
implicit val codec : Codec[CreateShortcutMessage] = (
|
||||||
("player_guid" | PlanetSideGUID.codec) ::
|
("player_guid" | PlanetSideGUID.codec) ::
|
||||||
("slot" | uint8L) ::
|
("slot" | uint8L) ::
|
||||||
("unk1" | uint8L) ::
|
("unk1" | uint8L) ::
|
||||||
("unk2" | uintL(3)) >>:~ ( value =>
|
(("unk2" | uintL(3)) >>:~ { value =>
|
||||||
conditional(value.last > 0, "purpose" | PacketHelpers.encodedStringAligned(5)) ::
|
conditional(value > 0, "shortcut" | Shortcut.codec).hlist
|
||||||
conditional(value.last > 0, "effect1" | PacketHelpers.encodedWideString) ::
|
})
|
||||||
conditional(value.last > 0, "effect2" | PacketHelpers.encodedWideString)
|
|
||||||
)
|
|
||||||
).as[CreateShortcutMessage]
|
).as[CreateShortcutMessage]
|
||||||
}
|
}
|
||||||
// */
|
|
||||||
|
|
|
||||||
|
|
@ -307,14 +307,15 @@ class GamePacketTest extends Specification {
|
||||||
|
|
||||||
"decode (medkit)" in {
|
"decode (medkit)" in {
|
||||||
PacketCoding.DecodePacket(stringMedkit).require match {
|
PacketCoding.DecodePacket(stringMedkit).require match {
|
||||||
case CreateShortcutMessage(player_guid, slot, unk1, unk2, purpose, effect1, effect2) =>
|
case CreateShortcutMessage(player_guid, slot, unk1, unk2, shortcut) =>
|
||||||
player_guid mustEqual PlanetSideGUID(4210)
|
player_guid mustEqual PlanetSideGUID(4210)
|
||||||
slot mustEqual 1
|
slot mustEqual 1
|
||||||
unk1 mustEqual 0
|
unk1 mustEqual 0
|
||||||
unk2 mustEqual 4
|
unk2 mustEqual 4
|
||||||
purpose mustEqual "medkit"
|
shortcut.isDefined mustEqual true
|
||||||
effect1 mustEqual ""
|
shortcut.get.purpose mustEqual "medkit"
|
||||||
effect2 mustEqual ""
|
shortcut.get.effect1 mustEqual ""
|
||||||
|
shortcut.get.effect2 mustEqual ""
|
||||||
case default =>
|
case default =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
|
|
@ -322,14 +323,15 @@ class GamePacketTest extends Specification {
|
||||||
|
|
||||||
"decode (implant)" in {
|
"decode (implant)" in {
|
||||||
PacketCoding.DecodePacket(stringImplant).require match {
|
PacketCoding.DecodePacket(stringImplant).require match {
|
||||||
case CreateShortcutMessage(player_guid, slot, unk1, unk2, purpose, effect1, effect2) =>
|
case CreateShortcutMessage(player_guid, slot, unk1, unk2, shortcut) =>
|
||||||
player_guid mustEqual PlanetSideGUID(4210)
|
player_guid mustEqual PlanetSideGUID(4210)
|
||||||
slot mustEqual 4
|
slot mustEqual 4
|
||||||
unk1 mustEqual 0
|
unk1 mustEqual 0
|
||||||
unk2 mustEqual 6
|
unk2 mustEqual 6
|
||||||
purpose mustEqual "surge"
|
shortcut.isDefined mustEqual true
|
||||||
effect1 mustEqual ""
|
shortcut.get.purpose mustEqual "surge"
|
||||||
effect2 mustEqual ""
|
shortcut.get.effect1 mustEqual ""
|
||||||
|
shortcut.get.effect2 mustEqual ""
|
||||||
case default =>
|
case default =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
|
|
@ -337,14 +339,15 @@ class GamePacketTest extends Specification {
|
||||||
|
|
||||||
"decode (macro)" in {
|
"decode (macro)" in {
|
||||||
PacketCoding.DecodePacket(stringMacro).require match {
|
PacketCoding.DecodePacket(stringMacro).require match {
|
||||||
case CreateShortcutMessage(player_guid, slot, unk1, unk2, purpose, effect1, effect2) =>
|
case CreateShortcutMessage(player_guid, slot, unk1, unk2, shortcut) =>
|
||||||
player_guid mustEqual PlanetSideGUID(1356)
|
player_guid mustEqual PlanetSideGUID(1356)
|
||||||
slot mustEqual 8
|
slot mustEqual 8
|
||||||
unk1 mustEqual 0
|
unk1 mustEqual 0
|
||||||
unk2 mustEqual 5
|
unk2 mustEqual 5
|
||||||
purpose mustEqual "shortcut_macro"
|
shortcut.isDefined mustEqual true
|
||||||
effect1 mustEqual "NTU"
|
shortcut.get.purpose mustEqual "shortcut_macro"
|
||||||
effect2 mustEqual "/platoon Incoming NTU spam!"
|
shortcut.get.effect1 mustEqual "NTU"
|
||||||
|
shortcut.get.effect2 mustEqual "/platoon Incoming NTU spam!"
|
||||||
case default =>
|
case default =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
|
|
@ -352,42 +355,40 @@ class GamePacketTest extends Specification {
|
||||||
|
|
||||||
"decode (remove)" in {
|
"decode (remove)" in {
|
||||||
PacketCoding.DecodePacket(stringRemove).require match {
|
PacketCoding.DecodePacket(stringRemove).require match {
|
||||||
case CreateShortcutMessage(player_guid, slot, unk1, unk2, purpose, effect1, effect2) =>
|
case CreateShortcutMessage(player_guid, slot, unk1, unk2, shortcut) =>
|
||||||
player_guid mustEqual PlanetSideGUID(1356)
|
player_guid mustEqual PlanetSideGUID(1356)
|
||||||
slot mustEqual 1
|
slot mustEqual 1
|
||||||
unk1 mustEqual 0
|
unk1 mustEqual 0
|
||||||
unk2 mustEqual 0
|
unk2 mustEqual 0
|
||||||
purpose mustEqual ""
|
shortcut.isDefined mustEqual false
|
||||||
effect1 mustEqual ""
|
|
||||||
effect2 mustEqual ""
|
|
||||||
case default =>
|
case default =>
|
||||||
ko
|
ko
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode (medkit)" in {
|
"encode (medkit)" in {
|
||||||
val msg = CreateShortcutMessage(PlanetSideGUID(4210), 1, 0, 4, "medkit")
|
val msg = CreateShortcutMessage(PlanetSideGUID(4210), 1, 0, 4, Some(Shortcut("medkit")))
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual stringMedkit
|
pkt mustEqual stringMedkit
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode (implant)" in {
|
"encode (implant)" in {
|
||||||
val msg = CreateShortcutMessage(PlanetSideGUID(4210), 4, 0, 6, "surge")
|
val msg = CreateShortcutMessage(PlanetSideGUID(4210), 4, 0, 6, Some(Shortcut("surge")))
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual stringImplant
|
pkt mustEqual stringImplant
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode (macro)" in {
|
"encode (macro)" in {
|
||||||
val msg = CreateShortcutMessage(PlanetSideGUID(1356), 8, 0, 5, "shortcut_macro", "NTU", "/platoon Incoming NTU spam!")
|
val msg = CreateShortcutMessage(PlanetSideGUID(1356), 8, 0, 5, Some(Shortcut("shortcut_macro", "NTU", "/platoon Incoming NTU spam!")))
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual stringMacro
|
pkt mustEqual stringMacro
|
||||||
}
|
}
|
||||||
|
|
||||||
"encode (remove)" in {
|
"encode (remove)" in {
|
||||||
val msg = CreateShortcutMessage(PlanetSideGUID(1356), 1, 0, 0, "")
|
val msg = CreateShortcutMessage(PlanetSideGUID(1356), 1, 0, 0)
|
||||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||||
|
|
||||||
pkt mustEqual stringRemove
|
pkt mustEqual stringRemove
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ class WorldSessionActor extends Actor with MDCContextAware {
|
||||||
true))) //Boosted generator room pain field
|
true))) //Boosted generator room pain field
|
||||||
|
|
||||||
sendResponse(PacketCoding.CreateGamePacket(0, SetCurrentAvatarMessage(PlanetSideGUID(guid),0,0)))
|
sendResponse(PacketCoding.CreateGamePacket(0, SetCurrentAvatarMessage(PlanetSideGUID(guid),0,0)))
|
||||||
sendResponse(PacketCoding.CreateGamePacket(0, CreateShortcutMessage(PlanetSideGUID(guid), 1, 0, 6, "medkit")))
|
sendResponse(PacketCoding.CreateGamePacket(0, CreateShortcutMessage(PlanetSideGUID(guid), 1, 0, 6, Some(Shortcut.MEDKIT))))
|
||||||
|
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue