mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-24 09:03:35 +00:00
Operational vehicle terminals:
Vehicles can now be pulled from assigned and initialized terminals. The vehicle's chosen spawn pad controls (or paces) all aspects of the spawning process. Support Actors ensure that a fully-realized Vehicle will be unloaded and unregistered if left alone, either right after spawning on the pad or after an extended period of time. The latter half of the procedure used for spawning vehicles is a temporary workaround until future analysis and functionality of the server vehicle override packet is incorporated. Weapons: Weapons will now construct their own default magazines thanks to a switch from Ammo.Value to AmmoBoxDefinition in the ToolDefinition. GenericObjectActionMessage : The only thing this packet does, at the moment, is obscure the player when he is being promoted into the owner of a vehicle.
This commit is contained in:
parent
73d0553b2c
commit
5428bbbfbf
57 changed files with 2957 additions and 538 deletions
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects
|
||||
|
||||
/**
|
||||
* Used to initialize the value of a re-usable `Cancellable` object.
|
||||
* By convention, it always acts like it has been cancelled before and can be cancelled.
|
||||
* Should be replaced with pertinent `Cancellable` logic through the initialization of an executor.
|
||||
*/
|
||||
object DefaultCancellable {
|
||||
import akka.actor.Cancellable
|
||||
|
||||
protected class InternalCancellable extends Cancellable {
|
||||
override def cancel : Boolean = true
|
||||
override def isCancelled : Boolean = true
|
||||
}
|
||||
|
||||
final val obj : Cancellable = new InternalCancellable
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ class ExoSuitDefinition(private val suitType : ExoSuitType.Value) {
|
|||
object ExoSuitDefinition {
|
||||
final val Standard = ExoSuitDefinition(ExoSuitType.Standard)
|
||||
Standard.MaxArmor = 50
|
||||
Standard.InventoryScale = new InventoryTile(9,6)
|
||||
Standard.InventoryScale = InventoryTile.Tile96
|
||||
Standard.InventoryOffset = 6
|
||||
Standard.Holster(0, EquipmentSize.Pistol)
|
||||
Standard.Holster(2, EquipmentSize.Rifle)
|
||||
|
|
@ -73,7 +73,7 @@ object ExoSuitDefinition {
|
|||
|
||||
final val Agile = ExoSuitDefinition(ExoSuitType.Agile)
|
||||
Agile.MaxArmor = 100
|
||||
Agile.InventoryScale = new InventoryTile(9,9)
|
||||
Agile.InventoryScale = InventoryTile.Tile99
|
||||
Agile.InventoryOffset = 6
|
||||
Agile.Holster(0, EquipmentSize.Pistol)
|
||||
Agile.Holster(1, EquipmentSize.Pistol)
|
||||
|
|
@ -83,7 +83,7 @@ object ExoSuitDefinition {
|
|||
final val Reinforced = ExoSuitDefinition(ExoSuitType.Reinforced)
|
||||
Reinforced.permission = 1
|
||||
Reinforced.MaxArmor = 200
|
||||
Reinforced.InventoryScale = new InventoryTile(12,9)
|
||||
Reinforced.InventoryScale = InventoryTile.Tile1209
|
||||
Reinforced.InventoryOffset = 6
|
||||
Reinforced.Holster(0, EquipmentSize.Pistol)
|
||||
Reinforced.Holster(1, EquipmentSize.Pistol)
|
||||
|
|
@ -94,7 +94,7 @@ object ExoSuitDefinition {
|
|||
final val Infiltration = ExoSuitDefinition(ExoSuitType.Standard)
|
||||
Infiltration.permission = 1
|
||||
Infiltration.MaxArmor = 0
|
||||
Infiltration.InventoryScale = new InventoryTile(6,6)
|
||||
Infiltration.InventoryScale = InventoryTile.Tile66
|
||||
Infiltration.InventoryOffset = 6
|
||||
Infiltration.Holster(0, EquipmentSize.Pistol)
|
||||
Infiltration.Holster(4, EquipmentSize.Melee)
|
||||
|
|
@ -102,7 +102,7 @@ object ExoSuitDefinition {
|
|||
final val MAX = ExoSuitDefinition(ExoSuitType.MAX)
|
||||
MAX.permission = 1
|
||||
MAX.MaxArmor = 650
|
||||
MAX.InventoryScale = new InventoryTile(16,12)
|
||||
MAX.InventoryScale = InventoryTile.Tile1612
|
||||
MAX.InventoryOffset = 6
|
||||
MAX.Holster(0, EquipmentSize.Max)
|
||||
MAX.Holster(4, EquipmentSize.Melee)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,7 +11,7 @@ import scala.annotation.tailrec
|
|||
/**
|
||||
* From a `Player` their current exo-suit and their `Equipment`, retain a set of instructions to reconstruct this arrangement.<br>
|
||||
* <br>
|
||||
* `InfantryLoadout` objects are composed of the following information, as if a blueprint:<br>
|
||||
* `Loadout` objects are composed of the following information, as if a blueprint:<br>
|
||||
* - the avatar's current exo-suit<br>
|
||||
* - the type of specialization, called a "subtype" (mechanized assault exo-suits only)<br>
|
||||
* - the contents of the avatar's occupied holster slots<br>
|
||||
|
|
@ -28,25 +28,24 @@ import scala.annotation.tailrec
|
|||
* Even a whole blueprint can be denied if the user lacks the necessary exo-suit certification.
|
||||
* A completely new piece of `Equipment` is constructed when the `Loadout` is regurgitated.<br>
|
||||
* <br>
|
||||
* The fifth tab on an `order_terminal` window is for "Favorite" blueprints for `InfantryLoadout` entries.
|
||||
* The fifth tab on an `order_terminal` window is for "Favorite" blueprints for `Loadout` entries.
|
||||
* The ten-long list is initialized with `FavoritesMessage` packets.
|
||||
* Specific entries are loaded or removed using `FavoritesRequest` packets.
|
||||
* @param player the player
|
||||
* @param label the name by which this inventory will be known when displayed in a Favorites list
|
||||
*/
|
||||
class InfantryLoadout(player : Player, private val label : String) {
|
||||
class Loadout(player : Player, private val label : String) {
|
||||
/** the exo-suit */
|
||||
private val exosuit : ExoSuitType.Value = player.ExoSuit
|
||||
/** the MAX specialization, to differentiate the three types of MAXes who all use the same exo-suit name */
|
||||
private val subtype =
|
||||
if(exosuit == ExoSuitType.MAX) {
|
||||
import net.psforever.packet.game.objectcreate.ObjectClass
|
||||
player.Holsters().head.Equipment.get.Definition.ObjectId match {
|
||||
case ObjectClass.trhev_dualcycler | ObjectClass.nchev_scattercannon | ObjectClass.vshev_quasar =>
|
||||
player.Holsters().head.Equipment.get.Definition match {
|
||||
case GlobalDefinitions.trhev_dualcycler | GlobalDefinitions.nchev_scattercannon | GlobalDefinitions.vshev_quasar =>
|
||||
1
|
||||
case ObjectClass.trhev_pounder | ObjectClass.nchev_falcon | ObjectClass.vshev_comet =>
|
||||
case GlobalDefinitions.trhev_pounder | GlobalDefinitions.nchev_falcon | GlobalDefinitions.vshev_comet =>
|
||||
2
|
||||
case ObjectClass.trhev_burster | ObjectClass.nchev_sparrow | ObjectClass.vshev_starfire =>
|
||||
case GlobalDefinitions.trhev_burster | GlobalDefinitions.nchev_sparrow | GlobalDefinitions.vshev_starfire =>
|
||||
3
|
||||
case _ =>
|
||||
0
|
||||
|
|
@ -56,14 +55,14 @@ class InfantryLoadout(player : Player, private val label : String) {
|
|||
0
|
||||
}
|
||||
/** simplified representation of the holster `Equipment` */
|
||||
private val holsters : List[InfantryLoadout.SimplifiedEntry] =
|
||||
InfantryLoadout.packageSimplifications(player.Holsters())
|
||||
private val holsters : List[Loadout.SimplifiedEntry] =
|
||||
Loadout.packageSimplifications(player.Holsters())
|
||||
/** simplified representation of the inventory `Equipment` */
|
||||
private val inventory : List[InfantryLoadout.SimplifiedEntry] =
|
||||
InfantryLoadout.packageSimplifications(player.Inventory.Items.values.toList)
|
||||
private val inventory : List[Loadout.SimplifiedEntry] =
|
||||
Loadout.packageSimplifications(player.Inventory.Items.values.toList)
|
||||
|
||||
/**
|
||||
* The label by which this `InfantryLoadout` is called.
|
||||
* The label by which this `Loadout` is called.
|
||||
* @return the label
|
||||
*/
|
||||
def Label : String = label
|
||||
|
|
@ -87,26 +86,26 @@ class InfantryLoadout(player : Player, private val label : String) {
|
|||
def Subtype : Int = subtype
|
||||
|
||||
/**
|
||||
* The `Equipment` in the `Player`'s holster slots when this `InfantryLoadout` is created.
|
||||
* The `Equipment` in the `Player`'s holster slots when this `Loadout` is created.
|
||||
* @return a `List` of the holster item blueprints
|
||||
*/
|
||||
def Holsters : List[InfantryLoadout.SimplifiedEntry] = holsters
|
||||
def Holsters : List[Loadout.SimplifiedEntry] = holsters
|
||||
|
||||
/**
|
||||
* The `Equipment` in the `Player`'s inventory region when this `InfantryLoadout` is created.
|
||||
* The `Equipment` in the `Player`'s inventory region when this `Loadout` is created.
|
||||
* @return a `List` of the inventory item blueprints
|
||||
*/
|
||||
def Inventory : List[InfantryLoadout.SimplifiedEntry] = inventory
|
||||
def Inventory : List[Loadout.SimplifiedEntry] = inventory
|
||||
}
|
||||
|
||||
object InfantryLoadout {
|
||||
object Loadout {
|
||||
/**
|
||||
* A basic `Trait` connecting all of the `Equipment` blueprints.
|
||||
*/
|
||||
sealed trait Simplification
|
||||
|
||||
/**
|
||||
* An entry in the `InfantryLoadout`, wrapping around a slot index and what is in the slot index.
|
||||
* An entry in the `Loadout`, wrapping around a slot index and what is in the slot index.
|
||||
* @param item the `Equipment`
|
||||
* @param index the slot number where the `Equipment` is to be stowed
|
||||
* @see `InventoryItem`
|
||||
|
|
@ -163,7 +162,7 @@ object InfantryLoadout {
|
|||
* @return a `List` of simplified `Equipment`
|
||||
*/
|
||||
private def packageSimplifications(equipment : List[InventoryItem]) : List[SimplifiedEntry] = {
|
||||
recursiveInventorySimplifications(equipment.iterator)
|
||||
equipment.map(entry => { SimplifiedEntry(buildSimplification(entry.obj), entry.start) })
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -193,23 +192,6 @@ object InfantryLoadout {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse a `Player`'s inventory and transform `Equipment` into simplified blueprints.
|
||||
* @param iter an `Iterator`
|
||||
* @param list an updating `List` of simplified `Equipment` blueprints;
|
||||
* empty, by default
|
||||
* @return a `List` of simplified `Equipment` blueprints
|
||||
*/
|
||||
@tailrec private def recursiveInventorySimplifications(iter : Iterator[InventoryItem], list : List[SimplifiedEntry] = Nil) : List[SimplifiedEntry] = {
|
||||
if(!iter.hasNext) {
|
||||
list
|
||||
}
|
||||
else {
|
||||
val entry = iter.next
|
||||
recursiveInventorySimplifications(iter, list :+ SimplifiedEntry(buildSimplification(entry.obj), entry.start))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ammunition slots are internal connection points where `AmmoBox` units and their characteristics represent a `Tool`'s magazine.
|
||||
* Their simplification process has a layer of complexity that ensures that the content of the slot matches the type of content that should be in the slot.
|
||||
|
|
@ -235,7 +217,7 @@ object InfantryLoadout {
|
|||
else {
|
||||
ShorthandAmmotSlot(
|
||||
entry.AmmoTypeIndex,
|
||||
ShorthandAmmoBox(AmmoBoxDefinition(entry.Tool.Definition.AmmoTypes(entry.Definition.AmmoTypeIndices.head).id), 1)
|
||||
ShorthandAmmoBox(entry.Tool.AmmoTypes(entry.Definition.AmmoTypeIndices.head), 1)
|
||||
)
|
||||
}
|
||||
recursiveFireModeSimplications(iter, list :+ fmodeSimp)
|
||||
|
|
@ -32,7 +32,7 @@ class Player(private val name : String,
|
|||
private var drawnSlot : Int = Player.HandsDownSlot
|
||||
private var lastDrawnSlot : Int = 0
|
||||
|
||||
private val loadouts : Array[Option[InfantryLoadout]] = Array.fill[Option[InfantryLoadout]](10)(None)
|
||||
private val loadouts : Array[Option[Loadout]] = Array.fill[Option[Loadout]](10)(None)
|
||||
|
||||
private var bep : Long = 0
|
||||
private var cep : Long = 0
|
||||
|
|
@ -230,10 +230,10 @@ class Player(private val name : String,
|
|||
}
|
||||
|
||||
def SaveLoadout(label : String, line : Int) : Unit = {
|
||||
loadouts(line) = Some(new InfantryLoadout(this, label))
|
||||
loadouts(line) = Some(new Loadout(this, label))
|
||||
}
|
||||
|
||||
def LoadLoadout(line : Int) : Option[InfantryLoadout] = loadouts(line)
|
||||
def LoadLoadout(line : Int) : Option[Loadout] = loadouts(line)
|
||||
|
||||
def DeleteLoadout(line : Int) : Unit = {
|
||||
loadouts(line) = None
|
||||
|
|
@ -551,7 +551,7 @@ object Player {
|
|||
player.ExoSuit = eSuit
|
||||
//inventory
|
||||
player.Inventory.Clear()
|
||||
player.Inventory.Resize(esuitDef.InventoryScale.width, esuitDef.InventoryScale.height)
|
||||
player.Inventory.Resize(esuitDef.InventoryScale.Width, esuitDef.InventoryScale.Height)
|
||||
player.Inventory.Offset = esuitDef.InventoryOffset
|
||||
//holsters
|
||||
(0 until 5).foreach(index => { player.Slot(index).Size = esuitDef.Holster(index) })
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects
|
||||
|
||||
import net.psforever.objects.definition.{AmmoBoxDefinition, ToolDefinition}
|
||||
import net.psforever.objects.definition.ToolDefinition
|
||||
import net.psforever.objects.equipment.{Ammo, Equipment, FireModeDefinition, FireModeSwitch}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
||||
|
|
@ -13,14 +12,15 @@ import scala.annotation.tailrec
|
|||
* "Tool" is a very mechanical name while this class is intended for various weapons and support items.
|
||||
* The primary trait of a `Tool` is that it has something that counts as an "ammunition,"
|
||||
* depleted as the `Tool` is used, replaceable as long as one has an appropriate type of `AmmoBox` object.
|
||||
* (The former is always called "consuming;" the latter, "reloading.")<br>
|
||||
* <br>
|
||||
* (The former is always called "consuming;" the latter, "reloading.")
|
||||
* Some weapons Chainblade have ammunition but do not consume it.
|
||||
* @param toolDef the `ObjectDefinition` that constructs this item and maintains some of its immutable fields
|
||||
*/
|
||||
class Tool(private val toolDef : ToolDefinition) extends Equipment with FireModeSwitch[FireModeDefinition] {
|
||||
/** index of the current fire mode on the `ToolDefinition`'s list of fire modes */
|
||||
private var fireModeIndex : Int = 0
|
||||
private val ammoSlot : List[Tool.FireModeSlot] = Tool.LoadDefinition(this)
|
||||
/** current ammunition slot being used by this fire mode */
|
||||
private val ammoSlots : List[Tool.FireModeSlot] = Tool.LoadDefinition(this)
|
||||
|
||||
def FireModeIndex : Int = fireModeIndex
|
||||
|
||||
|
|
@ -36,24 +36,24 @@ class Tool(private val toolDef : ToolDefinition) extends Equipment with FireMode
|
|||
FireMode
|
||||
}
|
||||
|
||||
def AmmoTypeIndex : Int = ammoSlot(fireModeIndex).AmmoTypeIndex
|
||||
def AmmoTypeIndex : Int = FireMode.AmmoTypeIndices(AmmoSlot.AmmoTypeIndex)
|
||||
|
||||
def AmmoTypeIndex_=(index : Int) : Int = {
|
||||
ammoSlot(fireModeIndex).AmmoTypeIndex = index % FireMode.AmmoTypeIndices.length
|
||||
AmmoSlot.AmmoTypeIndex = index % FireMode.AmmoTypeIndices.length
|
||||
AmmoTypeIndex
|
||||
}
|
||||
|
||||
def AmmoType : Ammo.Value = toolDef.AmmoTypes(AmmoTypeIndex)
|
||||
def AmmoType : Ammo.Value = toolDef.AmmoTypes(AmmoTypeIndex).AmmoType
|
||||
|
||||
def NextAmmoType : Ammo.Value = {
|
||||
AmmoTypeIndex = AmmoTypeIndex + 1
|
||||
AmmoSlot.AmmoTypeIndex = AmmoSlot.AmmoTypeIndex + 1
|
||||
AmmoType
|
||||
}
|
||||
|
||||
def Magazine : Int = ammoSlot(fireModeIndex).Magazine
|
||||
def Magazine : Int = AmmoSlot.Magazine
|
||||
|
||||
def Magazine_=(mag : Int) : Int = {
|
||||
ammoSlot(fireModeIndex).Magazine = Math.min(Math.max(0, mag), MaxMagazine)
|
||||
AmmoSlot.Magazine = Math.min(Math.max(0, mag), MaxMagazine)
|
||||
Magazine
|
||||
}
|
||||
|
||||
|
|
@ -61,15 +61,15 @@ class Tool(private val toolDef : ToolDefinition) extends Equipment with FireMode
|
|||
|
||||
def NextDischarge : Int = math.min(Magazine, FireMode.Chamber)
|
||||
|
||||
def AmmoSlots : List[Tool.FireModeSlot] = ammoSlot
|
||||
def AmmoSlot : Tool.FireModeSlot = ammoSlots(FireMode.AmmoSlotIndex)
|
||||
|
||||
def MaxAmmoSlot : Int = ammoSlot.length
|
||||
def AmmoSlots : List[Tool.FireModeSlot] = ammoSlots
|
||||
|
||||
def MaxAmmoSlot : Int = ammoSlots.length
|
||||
|
||||
def Definition : ToolDefinition = toolDef
|
||||
|
||||
override def toString : String = {
|
||||
Tool.toString(this)
|
||||
}
|
||||
override def toString : String = Tool.toString(this)
|
||||
}
|
||||
|
||||
object Tool {
|
||||
|
|
@ -77,12 +77,6 @@ object Tool {
|
|||
new Tool(toolDef)
|
||||
}
|
||||
|
||||
def apply(guid : PlanetSideGUID, toolDef : ToolDefinition) : Tool = {
|
||||
val obj = new Tool(toolDef)
|
||||
obj.GUID = guid
|
||||
obj
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the `*Definition` that was provided to this object to initialize its fields and settings.
|
||||
* @param tool the `Tool` being initialized
|
||||
|
|
@ -90,10 +84,10 @@ object Tool {
|
|||
def LoadDefinition(tool : Tool) : List[FireModeSlot] = {
|
||||
val tdef : ToolDefinition = tool.Definition
|
||||
val maxSlot = tdef.FireModes.maxBy(fmode => fmode.AmmoSlotIndex).AmmoSlotIndex
|
||||
buildFireModes(tool, (0 to maxSlot).iterator, tdef.FireModes.toList)
|
||||
buildFireModes(tdef, (0 to maxSlot).iterator, tdef.FireModes.toList)
|
||||
}
|
||||
|
||||
@tailrec private def buildFireModes(tool : Tool, iter : Iterator[Int], fmodes : List[FireModeDefinition], list : List[FireModeSlot] = Nil) : List[FireModeSlot] = {
|
||||
@tailrec private def buildFireModes(tdef : ToolDefinition, iter : Iterator[Int], fmodes : List[FireModeDefinition], list : List[FireModeSlot] = Nil) : List[FireModeSlot] = {
|
||||
if(!iter.hasNext) {
|
||||
list
|
||||
}
|
||||
|
|
@ -101,9 +95,9 @@ object Tool {
|
|||
val index = iter.next
|
||||
fmodes.filter(fmode => fmode.AmmoSlotIndex == index) match {
|
||||
case fmode :: _ =>
|
||||
buildFireModes(tool, iter, fmodes, list :+ new FireModeSlot(tool, fmode))
|
||||
buildFireModes(tdef, iter, fmodes, list :+ new FireModeSlot(tdef, fmode))
|
||||
case Nil =>
|
||||
throw new IllegalArgumentException(s"tool ${tool.Definition.Name} ammo slot #$index is missing a fire mode specification; do not skip")
|
||||
throw new IllegalArgumentException(s"tool ${tdef.Name} ammo slot #$index is missing a fire mode specification; do not skip")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -113,32 +107,45 @@ object Tool {
|
|||
}
|
||||
|
||||
/**
|
||||
* A hidden class that manages the specifics of the given ammunition for the current fire mode of this tool.
|
||||
* It operates much closer to an "ammunition feed" rather than a fire mode.
|
||||
* The relationship to fire modes is at least one-to-one and at most one-to-many.
|
||||
* The `FireModeSlot` can be called the "magazine feed," an abstracted "ammunition slot."
|
||||
* Most weapons will have only one ammunition slot and swap different ammunition into it as needed.
|
||||
* In general to swap ammunition means to unload the onld ammunition and load the new ammunition.
|
||||
* Many weapons also have one ammunition slot and multiple fire modes using the same list of ammunition
|
||||
* This slot manages either of two ammunitions where one does not need to unload to be swapped to the other;
|
||||
* however, the fire mod has most likely been changed.
|
||||
* The Punisher -
|
||||
* six ammunition types in total,
|
||||
* two uniquely different types without unloading,
|
||||
* two exclusive groups of ammunition divided into 2 cycled types and 4 cycled types -
|
||||
* is an example of a weapon that benefits from this implementation.
|
||||
*/
|
||||
class FireModeSlot(private val tool : Tool, private val fdef : FireModeDefinition) {
|
||||
/*
|
||||
By way of demonstration:
|
||||
Suppressors have one fire mode, two types of ammunition, one slot (2)
|
||||
MA Pistols have two fire modes, one type of ammunition, one slot (1)
|
||||
Jackhammers have two fire modes, two types of ammunition, one slot (2)
|
||||
Punishers have two fire modes, five types of ammunition, two slots (2, 3)
|
||||
*/
|
||||
|
||||
/** if this fire mode has multiple types of ammunition */
|
||||
private var ammoTypeIndex : Int = fdef.AmmoTypeIndices.head
|
||||
/** a reference to the actual `AmmoBox` of this slot; will not synch up with `AmmoType` immediately */
|
||||
private var box : AmmoBox = AmmoBox(AmmoBoxDefinition(AmmoType)) //defaults to box of one round of the default type for this slot
|
||||
class FireModeSlot(private val tdef : ToolDefinition, private val fdef : FireModeDefinition) {
|
||||
/**
|
||||
* if this fire mode has multiple types of ammunition
|
||||
* this is the index of the fire mode's ammo List, not a reference to the tool's ammo List
|
||||
*/
|
||||
private var ammoTypeIndex : Int = 0
|
||||
/** a reference to the actual `AmmoBox` of this slot */
|
||||
private var box : AmmoBox = AmmoBox(tdef.AmmoTypes(ammoTypeIndex), fdef.Magazine)
|
||||
|
||||
def AmmoTypeIndex : Int = ammoTypeIndex
|
||||
|
||||
def AmmoTypeIndex_=(index : Int) : Int = {
|
||||
ammoTypeIndex = index
|
||||
ammoTypeIndex = index % fdef.AmmoTypeIndices.length
|
||||
AmmoTypeIndex
|
||||
}
|
||||
|
||||
def AmmoType : Ammo.Value = tool.Definition.AmmoTypes(ammoTypeIndex)
|
||||
/**
|
||||
* This is a reference to the `Ammo.Value` whose `AmmoBoxDefinition` should be loaded into `box`.
|
||||
* It may not be the correct `Ammo.Value` whose `AmmoBoxDefinition` is loaded into `box` such as is the case during ammunition swaps.
|
||||
* Generally, convert from this index, to the index in the fire mode's ammunition list, to the index in the `ToolDefinition`'s ammunition list.
|
||||
* @return the `Ammo` type that should be loaded into the magazine right now
|
||||
*/
|
||||
def AmmoType : Ammo.Value = tdef.AmmoTypes(fdef.AmmoTypeIndices(ammoTypeIndex)).AmmoType
|
||||
|
||||
def AllAmmoTypes : List[Ammo.Value] = {
|
||||
fdef.AmmoTypeIndices.map(index => tdef.AmmoTypes(fdef.AmmoTypeIndices(index)).AmmoType).toList
|
||||
}
|
||||
|
||||
def Magazine : Int = box.Capacity
|
||||
|
||||
|
|
@ -159,7 +166,7 @@ object Tool {
|
|||
}
|
||||
}
|
||||
|
||||
def Tool : Tool = tool
|
||||
def Tool : ToolDefinition = tdef
|
||||
|
||||
def Definition : FireModeDefinition = fdef
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package net.psforever.objects
|
|||
|
||||
import net.psforever.objects.definition.VehicleDefinition
|
||||
import net.psforever.objects.equipment.{Equipment, EquipmentSize}
|
||||
import net.psforever.objects.inventory.GridInventory
|
||||
import net.psforever.objects.inventory.{GridInventory, InventoryTile}
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.objects.vehicles.{AccessPermissionGroup, Seat, Utility, VehicleLockState}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
|
|
@ -480,8 +480,12 @@ object Vehicle {
|
|||
vehicle.Utilities += Utility.Select(i, vehicle)
|
||||
}
|
||||
//trunk
|
||||
vehicle.trunk.Resize(vdef.TrunkSize.width, vdef.TrunkSize.height)
|
||||
vehicle.trunk.Offset = vdef.TrunkOffset
|
||||
vdef.TrunkSize match {
|
||||
case InventoryTile.None => ;
|
||||
case dim =>
|
||||
vehicle.trunk.Resize(dim.Width, dim.Height)
|
||||
vehicle.trunk.Offset = vdef.TrunkOffset
|
||||
}
|
||||
vehicle
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@
|
|||
package net.psforever.objects.definition
|
||||
|
||||
import net.psforever.objects.definition.converter.ToolConverter
|
||||
import net.psforever.objects.equipment.{Ammo, FireModeDefinition}
|
||||
import net.psforever.objects.equipment.FireModeDefinition
|
||||
|
||||
import scala.collection.mutable
|
||||
|
||||
class ToolDefinition(objectId : Int) extends EquipmentDefinition(objectId) {
|
||||
private val ammoTypes : mutable.ListBuffer[Ammo.Value] = new mutable.ListBuffer[Ammo.Value]
|
||||
private val ammoTypes : mutable.ListBuffer[AmmoBoxDefinition] = new mutable.ListBuffer[AmmoBoxDefinition]
|
||||
private val fireModes : mutable.ListBuffer[FireModeDefinition] = new mutable.ListBuffer[FireModeDefinition]
|
||||
Name = "tool"
|
||||
Packet = new ToolConverter()
|
||||
|
||||
def AmmoTypes : mutable.ListBuffer[Ammo.Value] = ammoTypes
|
||||
def AmmoTypes : mutable.ListBuffer[AmmoBoxDefinition] = ammoTypes
|
||||
|
||||
def FireModes : mutable.ListBuffer[FireModeDefinition] = fireModes
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ object Ammo extends Enumeration {
|
|||
final val fluxpod_ammo = Value(310)
|
||||
final val frag_cartridge = Value(327)
|
||||
final val frag_grenade_ammo = Value(331)
|
||||
final val gauss_cannon_ammo = Value(345)
|
||||
final val gauss_cannon_ammo = Value(347)
|
||||
final val grenade = Value(370)
|
||||
final val health_canister = Value(389)
|
||||
final val heavy_grenade_mortar = Value(391)
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ trait FireModeSwitch[Mode] {
|
|||
def FireMode : Mode
|
||||
|
||||
def NextFireMode : Mode
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class GridInventory {
|
|||
* @return the number of free cells
|
||||
*/
|
||||
def Capacity : Int = {
|
||||
TotalCapacity - items.values.foldLeft(0)((cnt, item) => cnt + (item.obj.Tile.width * item.obj.Tile.height))
|
||||
TotalCapacity - items.values.foldLeft(0)((cnt, item) => cnt + (item.obj.Tile.Width * item.obj.Tile.Height))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +112,7 @@ class GridInventory {
|
|||
*/
|
||||
def CheckCollisions(start : Int, item : Equipment) : Try[List[Int]] = {
|
||||
val tile : InventoryTile = item.Tile
|
||||
CheckCollisions(start, tile.width, tile.height)
|
||||
CheckCollisions(start, tile.Width, tile.Height)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -185,8 +185,8 @@ class GridInventory {
|
|||
val itemx : Int = actualItemStart % width
|
||||
val itemy : Int = actualItemStart / width
|
||||
val tile = item.obj.Tile
|
||||
val clipsOnX : Boolean = if(itemx < startx) { itemx + tile.width > startx } else { itemx <= startw }
|
||||
val clipsOnY : Boolean = if(itemy < starty) { itemy + tile.height > starty } else { itemy <= starth }
|
||||
val clipsOnX : Boolean = if(itemx < startx) { itemx + tile.Width > startx } else { itemx <= startw }
|
||||
val clipsOnY : Boolean = if(itemy < starty) { itemy + tile.Height > starty } else { itemy <= starth }
|
||||
if(clipsOnX && clipsOnY) {
|
||||
collisions += item
|
||||
}
|
||||
|
|
@ -237,8 +237,8 @@ class GridInventory {
|
|||
* @return the grid index of the upper left corner where equipment to which the `tile` belongs should be placed
|
||||
*/
|
||||
def Fit(tile : InventoryTile) : Option[Int] = {
|
||||
val tWidth = tile.width
|
||||
val tHeight = tile.height
|
||||
val tWidth = tile.Width
|
||||
val tHeight = tile.Height
|
||||
val gridIter = (0 until (grid.length - (tHeight - 1) * width))
|
||||
.filter(cell => grid(cell) == -1 && (width - cell%width >= tWidth))
|
||||
.iterator
|
||||
|
|
@ -325,7 +325,7 @@ class GridInventory {
|
|||
val card = InventoryItem(obj, start)
|
||||
items += key -> card
|
||||
val tile = obj.Tile
|
||||
SetCells(start, tile.width, tile.height, key)
|
||||
SetCells(start, tile.Width, tile.Height, key)
|
||||
true
|
||||
case _ =>
|
||||
false
|
||||
|
|
@ -348,7 +348,7 @@ class GridInventory {
|
|||
items.remove(key) match {
|
||||
case Some(item) =>
|
||||
val tile = item.obj.Tile
|
||||
SetCells(item.start, tile.width, tile.height)
|
||||
SetCells(item.start, tile.Width, tile.Height)
|
||||
true
|
||||
case None =>
|
||||
false
|
||||
|
|
@ -362,7 +362,7 @@ class GridInventory {
|
|||
case Some(index) =>
|
||||
val item = items.remove(index).get
|
||||
val tile = item.obj.Tile
|
||||
SetCells(item.start, tile.width, tile.height)
|
||||
SetCells(item.start, tile.Width, tile.Height)
|
||||
true
|
||||
case None =>
|
||||
false
|
||||
|
|
@ -492,11 +492,11 @@ object GridInventory {
|
|||
(a, b) => {
|
||||
val aTile = a.obj.Tile
|
||||
val bTile = b.obj.Tile
|
||||
if(aTile.width == bTile.width) {
|
||||
aTile.height > bTile.height
|
||||
if(aTile.Width == bTile.Width) {
|
||||
aTile.Height > bTile.Height
|
||||
}
|
||||
else {
|
||||
aTile.width > bTile.width
|
||||
aTile.Width > bTile.Width
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -513,9 +513,9 @@ object GridInventory {
|
|||
private def sortKnapsack(list : List[InventoryItem], width : Int, height : Int) : Unit = {
|
||||
val root = new KnapsackNode(0, 0, width, height)
|
||||
list.foreach(item => {
|
||||
findKnapsackSpace(root, item.obj.Tile.width, item.obj.Tile.height) match {
|
||||
findKnapsackSpace(root, item.obj.Tile.Width, item.obj.Tile.Height) match {
|
||||
case Some(node) =>
|
||||
splitKnapsackSpace(node, item.obj.Tile.width, item.obj.Tile.height)
|
||||
splitKnapsackSpace(node, item.obj.Tile.Width, item.obj.Tile.Height)
|
||||
item.start = node.y * width + node.x
|
||||
case _ => ;
|
||||
item.start = -1
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package net.psforever.objects.inventory
|
|||
* @param height the height of the tile
|
||||
* @throws IllegalArgumentException if either the width or the height are less than zero
|
||||
*/
|
||||
class InventoryTile(val width : Int, val height : Int) {
|
||||
class InventoryTile(private val width : Int, private val height : Int) {
|
||||
if(width < 0 || height < 0)
|
||||
throw new IllegalArgumentException(s"tile has no area - width: $width, height: $height")
|
||||
|
||||
|
|
@ -19,15 +19,27 @@ class InventoryTile(val width : Int, val height : Int) {
|
|||
|
||||
object InventoryTile {
|
||||
final val None = InventoryTile(0,0) //technically invalid; used to indicate a vehicle with no trunk
|
||||
final val Tile11 = InventoryTile(1,1) //placeholder size
|
||||
final val Tile11 = InventoryTile(1,1) //occasional placeholder
|
||||
final val Tile22 = InventoryTile(2,2) //grenades, boomer trigger
|
||||
final val Tile23 = InventoryTile(2,3) //canister ammo
|
||||
final val Tile42 = InventoryTile(4,2) //medkit
|
||||
final val Tile33 = InventoryTile(3,3) //ammo box, pistols, ace
|
||||
final val Tile44 = InventoryTile(4,4) //large ammo box
|
||||
final val Tile55 = InventoryTile(5,5) //bfr ammo box
|
||||
final val Tile66 = InventoryTile(6,6) //standard assault inventory
|
||||
final val Tile63 = InventoryTile(6,3) //rifles
|
||||
final val Tile93 = InventoryTile(9,3) //long-body weapons
|
||||
final val Tile96 = InventoryTile(9,6) //standard exo-suit
|
||||
final val Tile99 = InventoryTile(9,9) //agile exo-suit
|
||||
final val Tile1107 = InventoryTile(11, 7) //uncommon small trunk capacity - phantasm
|
||||
final val Tile1111 = InventoryTile(11,11) //common small trunk capacity
|
||||
final val Tile1209 = InventoryTile(12, 9) //reinforced exo-suit
|
||||
final val Tile1511 = InventoryTile(15,11) //common medium trunk capacity
|
||||
final val Tile1515 = InventoryTile(15,15) //common large trunk capacity
|
||||
final val Tile1611 = InventoryTile(16,11) //uncommon medium trunk capacity - vulture
|
||||
final val Tile1612 = InventoryTile(16,12) //MAX; uncommon medium trunk capacity - lodestar
|
||||
final val Tile1816 = InventoryTile(18,16) //uncommon massive trunk capacity - galaxy_gunship
|
||||
final val Tile2016 = InventoryTile(20,16) //uncommon massive trunk capacity - apc
|
||||
|
||||
def apply(w : Int, h : Int) : InventoryTile = {
|
||||
new InventoryTile(w, h)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ abstract class PlanetSideServerObject extends PlanetSideGameObject {
|
|||
* @return the current internal `ActorRef`
|
||||
*/
|
||||
def Actor_=(control : ActorRef) : ActorRef = {
|
||||
if(actor == ActorRef.noSender) {
|
||||
if(actor == ActorRef.noSender || control == ActorRef.noSender) {
|
||||
actor = control
|
||||
}
|
||||
actor
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.builders
|
||||
|
||||
import akka.actor.Props
|
||||
import net.psforever.objects.definition.ObjectDefinition
|
||||
import net.psforever.objects.serverobject.pad.{VehicleSpawnControl, VehicleSpawnPad}
|
||||
|
||||
/**
|
||||
* Wrapper `Class` designed to instantiate a `VehicleSpawnPad` server object.
|
||||
* @param spdef an `ObjectDefinition` object ...
|
||||
* @param id the globally unique identifier to which this `VehicleSpawnPad` will be registered
|
||||
*/
|
||||
class VehicleSpawnPadObjectBuilder(private val spdef : ObjectDefinition, private val id : Int) extends ServerObjectBuilder[VehicleSpawnPad] {
|
||||
import akka.actor.ActorContext
|
||||
import net.psforever.objects.guid.NumberPoolHub
|
||||
|
||||
def Build(implicit context : ActorContext, guid : NumberPoolHub) : VehicleSpawnPad = {
|
||||
val obj = VehicleSpawnPad(spdef)
|
||||
guid.register(obj, id) //non-Actor GUID registration
|
||||
obj.Actor = context.actorOf(Props(classOf[VehicleSpawnControl], obj), s"${spdef.Name}_${obj.GUID.guid}")
|
||||
obj
|
||||
}
|
||||
}
|
||||
|
||||
object VehicleSpawnPadObjectBuilder {
|
||||
/**
|
||||
* Overloaded constructor for a `DoorObjectBuilder`.
|
||||
* @param spdef an `ObjectDefinition` object
|
||||
* @param id a globally unique identifier
|
||||
* @return a `VehicleSpawnPadObjectBuilder` object
|
||||
*/
|
||||
def apply(spdef : ObjectDefinition, id : Int) : VehicleSpawnPadObjectBuilder = {
|
||||
new VehicleSpawnPadObjectBuilder(spdef, id)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.pad
|
||||
|
||||
import akka.actor.{Actor, ActorRef, Cancellable}
|
||||
import net.psforever.objects.{DefaultCancellable, Player, Vehicle}
|
||||
import net.psforever.types.Vector3
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
/**
|
||||
* An `Actor` that handles messages being dispatched to a specific `VehicleSpawnPad`.<br>
|
||||
* <br>
|
||||
* A spawn pad receives vehicle orders from an attached `Terminal` object.
|
||||
* At the time when the order is received, the player who submitted the order is completely visible
|
||||
* and waiting back by the said `Terminal` from where the order was submitted.
|
||||
* Assuming no other orders are currently being processed, the repeated self message will retrieve this as the next order.
|
||||
* The player character is first made transparent with a `GenericObjectActionMessage` packet.
|
||||
* The vehicle model itself is then introduced to the game and three things happen with the following order, more or less:<br>
|
||||
* 1. the vehicle is attached to a lifting platform that is designed to introduce the vehicle;<br>
|
||||
* 2. the player is seated in the vehicle's driver seat (seat 0) and is thus declared the owner; <br>
|
||||
* 3. various properties of the player, the vehicle, and the spawn pad itself are set `PlanetsideAttributesMessage`.<br>
|
||||
* When this step is finished, the lifting platform raises the vehicle and the mounted player into the game world.
|
||||
* The vehicle detaches and is made to roll off the spawn pad a certain distance before being released to user control.
|
||||
* That is what is supposed to happen within a certain measure of timing.<br>
|
||||
* <br>
|
||||
* The orders that are submitted to the spawn pad must be composed of at least three elements:
|
||||
* 1. a player, specifically the one that submitted the order and will be declared the "owner;"
|
||||
* 2. a vehicle;
|
||||
* 3. a callback location for sending messages.
|
||||
* @param pad the `VehicleSpawnPad` object being governed
|
||||
*/
|
||||
class VehicleSpawnControl(pad : VehicleSpawnPad) extends Actor {
|
||||
/** an executor for progressing a vehicle order through the normal spawning logic */
|
||||
private var process : Cancellable = DefaultCancellable.obj
|
||||
/** a list of vehicle orders that have been submitted for this spawn pad */
|
||||
private var orders : List[VehicleSpawnControl.OrderEntry] = List.empty[VehicleSpawnControl.OrderEntry]
|
||||
/** the current vehicle order being acted upon */
|
||||
private var trackedOrder : Option[VehicleSpawnControl.OrderEntry] = None
|
||||
/** how many times a spawned vehicle (spatially) disrupted the next vehicle from being spawned */
|
||||
private var blockingViolations : Int = 0
|
||||
private[this] val log = org.log4s.getLogger
|
||||
private[this] def trace(msg : String) : Unit = log.trace(msg)
|
||||
|
||||
|
||||
def receive : Receive = {
|
||||
case VehicleSpawnPad.VehicleOrder(player, vehicle) =>
|
||||
trace(s"order from $player for $vehicle received")
|
||||
orders = orders :+ VehicleSpawnControl.OrderEntry(player, vehicle, sender)
|
||||
if(trackedOrder.isEmpty && orders.length == 1) {
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
|
||||
case VehicleSpawnControl.Process.GetOrder =>
|
||||
process.cancel
|
||||
blockingViolations = 0
|
||||
val (completeOrder, remainingOrders) : (Option[VehicleSpawnControl.OrderEntry], List[VehicleSpawnControl.OrderEntry]) = orders match {
|
||||
case x :: Nil =>
|
||||
(Some(x), Nil)
|
||||
case x :: b =>
|
||||
(Some(x), b)
|
||||
case Nil =>
|
||||
(None, Nil)
|
||||
}
|
||||
orders = remainingOrders
|
||||
completeOrder match {
|
||||
case Some(entry) =>
|
||||
trace(s"processing order $entry")
|
||||
trackedOrder = completeOrder
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
process = context.system.scheduler.scheduleOnce(VehicleSpawnControl.concealPlayerTimeout, self, VehicleSpawnControl.Process.ConcealPlayer)
|
||||
case None => ;
|
||||
}
|
||||
|
||||
case VehicleSpawnControl.Process.ConcealPlayer =>
|
||||
process.cancel
|
||||
trackedOrder match {
|
||||
case Some(entry) =>
|
||||
if(entry.player.isAlive && entry.vehicle.Actor != ActorRef.noSender && entry.sendTo != ActorRef.noSender && entry.player.VehicleSeated.isEmpty) {
|
||||
trace(s"hiding player: ${entry.player}")
|
||||
entry.sendTo ! VehicleSpawnPad.ConcealPlayer
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
process = context.system.scheduler.scheduleOnce(VehicleSpawnControl.loadVehicleTimeout, self, VehicleSpawnControl.Process.LoadVehicle)
|
||||
}
|
||||
else {
|
||||
trace("integral component lost; abort order fulfillment")
|
||||
//TODO Unregister vehicle ... somehow
|
||||
trackedOrder = None
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
case None =>
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
|
||||
case VehicleSpawnControl.Process.LoadVehicle =>
|
||||
process.cancel
|
||||
trackedOrder match {
|
||||
case Some(entry) =>
|
||||
if(entry.vehicle.Actor != ActorRef.noSender && entry.sendTo != ActorRef.noSender) {
|
||||
trace(s"loading vehicle: ${entry.vehicle} defined in order")
|
||||
entry.sendTo ! VehicleSpawnPad.LoadVehicle(entry.vehicle, pad)
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
process = context.system.scheduler.scheduleOnce(VehicleSpawnControl.awaitSeatedTimeout, self, VehicleSpawnControl.Process.AwaitSeated)
|
||||
}
|
||||
else {
|
||||
trace("owner or vehicle lost; abort order fulfillment")
|
||||
//TODO Unregister vehicle ... somehow
|
||||
trackedOrder = None
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
|
||||
case None =>
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
|
||||
case VehicleSpawnControl.Process.AwaitSeated =>
|
||||
process.cancel
|
||||
trackedOrder match {
|
||||
case Some(entry) =>
|
||||
if(entry.sendTo != ActorRef.noSender) {
|
||||
trace("owner seated in vehicle")
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
process = if(entry.player.VehicleOwned.contains(entry.vehicle.GUID)) {
|
||||
entry.sendTo ! VehicleSpawnPad.PlayerSeatedInVehicle(entry.vehicle)
|
||||
context.system.scheduler.scheduleOnce(VehicleSpawnControl.awaitClearanceTimeout, self, VehicleSpawnControl.Process.AwaitClearance)
|
||||
}
|
||||
else {
|
||||
context.system.scheduler.scheduleOnce(VehicleSpawnControl.awaitSeatedTimeout, self, VehicleSpawnControl.Process.AwaitSeated)
|
||||
}
|
||||
}
|
||||
else {
|
||||
trace("owner lost; abort order fulfillment")
|
||||
trackedOrder = None
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
case None =>
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
|
||||
//TODO raise spawn pad rails from ground
|
||||
|
||||
//TODO start auto drive away
|
||||
|
||||
//TODO release auto drive away
|
||||
|
||||
case VehicleSpawnControl.Process.AwaitClearance =>
|
||||
process.cancel
|
||||
trackedOrder match {
|
||||
case Some(entry) =>
|
||||
if(entry.sendTo == ActorRef.noSender || entry.vehicle.Actor == ActorRef.noSender) {
|
||||
trace("integral component lost, but order fulfilled; process next order")
|
||||
trackedOrder = None
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
else if(Vector3.DistanceSquared(entry.vehicle.Position, pad.Position) > 100.0f) { //10m away from pad
|
||||
trace("pad cleared; process next order")
|
||||
trackedOrder = None
|
||||
entry.sendTo ! VehicleSpawnPad.SpawnPadUnblocked(entry.vehicle.GUID)
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
else {
|
||||
trace(s"pad blocked by ${entry.vehicle} ...")
|
||||
blockingViolations += 1
|
||||
entry.sendTo ! VehicleSpawnPad.SpawnPadBlockedWarning(entry.vehicle, blockingViolations)
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
process = context.system.scheduler.scheduleOnce(VehicleSpawnControl.awaitClearanceTimeout, self, VehicleSpawnControl.Process.AwaitClearance)
|
||||
}
|
||||
case None =>
|
||||
self ! VehicleSpawnControl.Process.GetOrder
|
||||
}
|
||||
|
||||
case _ => ;
|
||||
}
|
||||
}
|
||||
|
||||
object VehicleSpawnControl {
|
||||
final val concealPlayerTimeout : FiniteDuration = 2000000000L nanoseconds //2s
|
||||
final val loadVehicleTimeout : FiniteDuration = 1000000000L nanoseconds //1s
|
||||
final val awaitSeatedTimeout : FiniteDuration = 1000000000L nanoseconds //1s
|
||||
final val awaitClearanceTimeout : FiniteDuration = 5000000000L nanoseconds //5s
|
||||
|
||||
/**
|
||||
* An `Enumeration` of the stages of a full vehicle spawning process, associated with certain messages passed.
|
||||
* Some stages are currently TEMPORARY.
|
||||
* @see VehicleSpawnPad
|
||||
*/
|
||||
object Process extends Enumeration {
|
||||
val
|
||||
GetOrder,
|
||||
ConcealPlayer,
|
||||
LoadVehicle,
|
||||
AwaitSeated,
|
||||
AwaitClearance
|
||||
= Value
|
||||
}
|
||||
|
||||
/**
|
||||
* An entry that stores vehicle spawn pad spawning tasks (called "orders").
|
||||
* @param player the player
|
||||
* @param vehicle the vehicle
|
||||
* @param sendTo a callback `Actor` associated with the player (in other words, `WorldSessionActor`)
|
||||
*/
|
||||
private final case class OrderEntry(player : Player, vehicle : Vehicle, sendTo : ActorRef)
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.pad
|
||||
|
||||
import net.psforever.objects.{Player, Vehicle}
|
||||
import net.psforever.objects.definition.ObjectDefinition
|
||||
import net.psforever.objects.serverobject.PlanetSideServerObject
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
|
||||
/**
|
||||
* A structure-owned server object that is a "spawn pad" for vehicles.<br>
|
||||
* <br>
|
||||
* Spawn pads have no purpose on their own but
|
||||
* maintain the operative queue that introduces the vehicle into the game world and applies initial activity to it and
|
||||
* maintain a position and a direction where the vehicle will be made to appear (as a `PlanetSideServerObject`).
|
||||
* The actual functionality managed by this object is wholly found on its accompanying `Actor`.
|
||||
* @param spDef the `ObjectDefinition` that constructs this object and maintains some of its immutable fields
|
||||
* @see `VehicleSpawnControl`
|
||||
*/
|
||||
class VehicleSpawnPad(spDef : ObjectDefinition) extends PlanetSideServerObject {
|
||||
def Definition : ObjectDefinition = spDef
|
||||
}
|
||||
|
||||
object VehicleSpawnPad {
|
||||
|
||||
/**
|
||||
* Communicate to the spawn pad that it should enqueue the following vehicle.
|
||||
* This is the entry point to vehicle spawn pad functionality.
|
||||
* @param player the player who submitted the order (the "owner")
|
||||
* @param vehicle the vehicle produced from the order
|
||||
*/
|
||||
final case class VehicleOrder(player : Player, vehicle : Vehicle)
|
||||
|
||||
/**
|
||||
* The first callback step in spawning the vehicle.
|
||||
* An packet `GenericObjectActionMessage(/player/, 36)`, when used on a player character,
|
||||
* will cause that player character's model to fade into transparency.
|
||||
*/
|
||||
final case class ConcealPlayer()
|
||||
|
||||
/**
|
||||
* A callback step in spawning the vehicle.
|
||||
* The vehicle is properly introduced into the game world.
|
||||
* If information about the vehicle itself that is important to its spawning has not yet been set,
|
||||
* this callback is the last ideal situation to set that properties without having to adjust the vehicle visually.
|
||||
* The primary operation that should occur is a content-appropriate `ObjectCreateMessage` packet and
|
||||
* having the player sit down in the driver's seat (seat 0) of the vehicle.
|
||||
* @param vehicle the vehicle being spawned
|
||||
* @param pad the pad
|
||||
*/
|
||||
final case class LoadVehicle(vehicle : Vehicle, pad : VehicleSpawnPad)
|
||||
|
||||
/**
|
||||
* A TEMPORARY callback step in spawning the vehicle.
|
||||
* From a state of transparency, while the vehicle is attached to the lifting platform of the spawn pad,
|
||||
* the player designated the "owner" by callback is made to sit in the driver's seat (always seat 0).
|
||||
* This message is the next step after that.
|
||||
* @param vehicle the vehicle being spawned
|
||||
*/
|
||||
final case class PlayerSeatedInVehicle(vehicle : Vehicle)
|
||||
|
||||
/**
|
||||
* A TEMPORARY callback step in (successfully) spawning the vehicle.
|
||||
* While the vehicle is still occupying the pad just after being spawned and its driver seat mounted,
|
||||
* that vehicle is considered blocking the pad from being used for further spawning operations.
|
||||
* This message allows the user to be made known about this blockage.
|
||||
* @param vehicle the vehicle
|
||||
* @param warning_count the number of times a warning period has occurred
|
||||
*/
|
||||
final case class SpawnPadBlockedWarning(vehicle : Vehicle, warning_count : Int)
|
||||
|
||||
/**
|
||||
* A TEMPORARY callback step in (successfully) spawning the vehicle.
|
||||
* While the vehicle is still occupying the pad just after being spawned and its driver seat mounted,
|
||||
* that vehicle is considered blocking the pad from being used for further spawning operations.
|
||||
* A timeout will begin counting until the vehicle is despawned automatically for its driver's negligence.
|
||||
* This message is used to clear the deconstruction countdown, primarily.
|
||||
* @param vehicle_guid the vehicle
|
||||
*/
|
||||
final case class SpawnPadUnblocked(vehicle_guid : PlanetSideGUID)
|
||||
|
||||
/**
|
||||
* Overloaded constructor.
|
||||
* @param spDef the spawn pad's definition entry
|
||||
* @return a `VehicleSpawnPad` object
|
||||
*/
|
||||
def apply(spDef : ObjectDefinition) : VehicleSpawnPad = {
|
||||
new VehicleSpawnPad(spDef)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.packet.game.ItemTransactionMessage
|
||||
|
||||
class AirVehicleTerminalDefinition extends TerminalDefinition(43) {
|
||||
Name = "air_vehicle_terminal"
|
||||
|
||||
def Buy(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
flight1Vehicles.get(msg.item_name) match {
|
||||
case Some(vehicle) =>
|
||||
Terminal.BuyVehicle(vehicle(), Nil)
|
||||
case None =>
|
||||
Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.packet.game.ItemTransactionMessage
|
||||
|
||||
class BFRTerminalDefinition extends TerminalDefinition(143) {
|
||||
Name = "bfr_terminal"
|
||||
|
||||
def Buy(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
bfrVehicles.get(msg.item_name) match {
|
||||
case Some(vehicle) =>
|
||||
//Terminal.BuyVehicle(vehicle, Nil)
|
||||
Terminal.NoDeal()
|
||||
case None =>
|
||||
Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ class CertTerminalDefinition extends TerminalDefinition(171) {
|
|||
* @param msg the original packet carrying the request
|
||||
* @return an actionable message that explains how to process the request
|
||||
*/
|
||||
def Sell(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
override def Sell(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
certificationList.get(msg.item_name) match {
|
||||
case Some((cert, cost)) =>
|
||||
Terminal.SellCertification(cert, cost)
|
||||
|
|
@ -89,12 +89,4 @@ class CertTerminalDefinition extends TerminalDefinition(171) {
|
|||
Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This action is not supported by this type of `Terminal`.
|
||||
* @param player the player
|
||||
* @param msg the original packet carrying the request
|
||||
* @return `Terminal.NoEvent` always
|
||||
*/
|
||||
def Loadout(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = Terminal.NoDeal()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.packet.game.ItemTransactionMessage
|
||||
|
||||
class DropshipVehicleTerminalDefinition extends TerminalDefinition(263) {
|
||||
private val flightVehicles = flight1Vehicles ++ flight2Vehicles
|
||||
Name = "dropship_vehicle_terminal"
|
||||
|
||||
def Buy(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
flightVehicles.get(msg.item_name) match {
|
||||
case Some(vehicle) =>
|
||||
Terminal.BuyVehicle(vehicle(), Nil)
|
||||
case None =>
|
||||
Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.packet.game.ItemTransactionMessage
|
||||
|
||||
class GroundVehicleTerminalDefinition extends TerminalDefinition(386) {
|
||||
Name = "ground_vehicle_terminal"
|
||||
|
||||
def Buy(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
groundVehicles.get(msg.item_name) match {
|
||||
case Some(vehicle) =>
|
||||
Terminal.BuyVehicle(vehicle(), Nil)
|
||||
case None =>
|
||||
Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.InfantryLoadout.Simplification
|
||||
import net.psforever.objects.Loadout.Simplification
|
||||
import net.psforever.objects.{Player, Tool}
|
||||
import net.psforever.objects.definition._
|
||||
import net.psforever.objects.equipment.Equipment
|
||||
|
|
@ -13,7 +13,7 @@ import scala.annotation.switch
|
|||
/**
|
||||
* The definition for any `Terminal` that is of a type "order_terminal".
|
||||
* `Buy` and `Sell` `Equipment` items and `AmmoBox` items.
|
||||
* Change `ExoSuitType` and retrieve `InfantryLoadout` entries.
|
||||
* Change `ExoSuitType` and retrieve `Loadout` entries.
|
||||
*/
|
||||
class OrderTerminalDefinition extends TerminalDefinition(612) {
|
||||
Name = "order_terminal"
|
||||
|
|
@ -75,19 +75,19 @@ class OrderTerminalDefinition extends TerminalDefinition(612) {
|
|||
* @param msg the original packet carrying the request
|
||||
* @return an actionable message that explains how to process the request
|
||||
*/
|
||||
def Sell(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
override def Sell(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
Terminal.SellEquipment()
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a `TransactionType.InfantryLoadout` action by the user.
|
||||
* `InfantryLoadout` objects are blueprints composed of exo-suit specifications and simplified `Equipment`-to-slot mappings.
|
||||
* `Loadout` objects are blueprints composed of exo-suit specifications and simplified `Equipment`-to-slot mappings.
|
||||
* If a valid loadout is found, its data is transformed back into actual `Equipment` for return to the user.
|
||||
* @param player the player
|
||||
* @param msg the original packet carrying the request
|
||||
* @return an actionable message that explains how to process the request
|
||||
*/
|
||||
def Loadout(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
override def Loadout(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
if(msg.item_page == 4) { //Favorites tab
|
||||
player.LoadLoadout(msg.unk1) match {
|
||||
case Some(loadout) =>
|
||||
|
|
@ -105,7 +105,7 @@ class OrderTerminalDefinition extends TerminalDefinition(612) {
|
|||
|
||||
/**
|
||||
* Accept a simplified blueprint for some piece of `Equipment` and create an actual piece of `Equipment` based on it.
|
||||
* Used specifically for the reconstruction of `Equipment` via an `InfantryLoadout`.
|
||||
* Used specifically for the reconstruction of `Equipment` via an `Loadout`.
|
||||
* @param entry the simplified blueprint
|
||||
* @return some `Equipment` object
|
||||
* @see `TerminalDefinition.MakeTool`<br>
|
||||
|
|
@ -115,7 +115,7 @@ class OrderTerminalDefinition extends TerminalDefinition(612) {
|
|||
* `TerminalDefinition.MakeKit`
|
||||
*/
|
||||
private def BuildSimplifiedPattern(entry : Simplification) : Equipment = {
|
||||
import net.psforever.objects.InfantryLoadout._
|
||||
import net.psforever.objects.Loadout._
|
||||
entry match {
|
||||
case obj : ShorthandTool =>
|
||||
val ammo : List[AmmoBoxDefinition] = obj.ammo.map(fmode => { fmode.ammo.adef })
|
||||
|
|
|
|||
|
|
@ -136,10 +136,24 @@ object Terminal {
|
|||
final case class SellEquipment() extends Exchange
|
||||
|
||||
import net.psforever.types.CertificationType
|
||||
|
||||
/**
|
||||
* Provide the certification type unlocked by the player.
|
||||
* @param cert the certification unlocked
|
||||
* @param cost the certification point cost
|
||||
*/
|
||||
final case class LearnCertification(cert : CertificationType.Value, cost : Int) extends Exchange
|
||||
|
||||
/**
|
||||
* Provide the certification type freed-up by the player.
|
||||
* @param cert the certification returned
|
||||
* @param cost the certification point cost
|
||||
*/
|
||||
final case class SellCertification(cert : CertificationType.Value, cost : Int) extends Exchange
|
||||
|
||||
import net.psforever.objects.Vehicle
|
||||
final case class BuyVehicle(vehicle : Vehicle, loadout: List[Any]) extends Exchange
|
||||
|
||||
/**
|
||||
* Recover a former exo-suit and `Equipment` configuration that the `Player` possessed.
|
||||
* A result of a processed request.
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ import net.psforever.packet.game.ItemTransactionMessage
|
|||
import net.psforever.types.ExoSuitType
|
||||
|
||||
/**
|
||||
* The definition for any `Terminal`.
|
||||
* The basic definition for any `Terminal`.
|
||||
* @param objectId the object's identifier number
|
||||
*/
|
||||
abstract class TerminalDefinition(objectId : Int) extends ObjectDefinition(objectId) {
|
||||
private[this] val log = org.log4s.getLogger("TerminalDefinition")
|
||||
Name = "terminal"
|
||||
|
||||
/**
|
||||
|
|
@ -22,12 +23,12 @@ abstract class TerminalDefinition(objectId : Int) extends ObjectDefinition(objec
|
|||
/**
|
||||
* The unimplemented functionality for this `Terminal`'s `TransactionType.Sell` activity.
|
||||
*/
|
||||
def Sell(player: Player, msg : ItemTransactionMessage) : Terminal.Exchange
|
||||
def Sell(player: Player, msg : ItemTransactionMessage) : Terminal.Exchange = Terminal.NoDeal()
|
||||
|
||||
/**
|
||||
* The unimplemented functionality for this `Terminal`'s `TransactionType.InfantryLoadout` activity.
|
||||
*/
|
||||
def Loadout(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange
|
||||
def Loadout(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = Terminal.NoDeal()
|
||||
|
||||
/**
|
||||
* A `Map` of information for changing exo-suits.
|
||||
|
|
@ -128,42 +129,42 @@ abstract class TerminalDefinition(objectId : Int) extends ObjectDefinition(objec
|
|||
* value - a curried function that builds the object
|
||||
*/
|
||||
protected val infantryWeapons : Map[String, ()=>Equipment] = Map(
|
||||
"ilc9" -> MakeTool(ilc9, bullet_9mm),
|
||||
"repeater" -> MakeTool(repeater, bullet_9mm),
|
||||
"isp" -> MakeTool(isp, shotgun_shell), //amp
|
||||
"beamer" -> MakeTool(beamer, energy_cell),
|
||||
"suppressor" -> MakeTool(suppressor, bullet_9mm),
|
||||
"anniversary_guna" -> MakeTool(anniversary_guna, anniversary_ammo), //tr stinger
|
||||
"anniversary_gun" -> MakeTool(anniversary_gun, anniversary_ammo), //nc spear
|
||||
"anniversary_gunb" -> MakeTool(anniversary_gunb, anniversary_ammo), //vs eraser
|
||||
"cycler" -> MakeTool(cycler, bullet_9mm),
|
||||
"gauss" -> MakeTool(gauss, bullet_9mm),
|
||||
"pulsar" -> MakeTool(pulsar, energy_cell),
|
||||
"punisher" -> MakeTool(punisher, List(bullet_9mm, rocket)),
|
||||
"flechette" -> MakeTool(flechette, shotgun_shell),
|
||||
"spiker" -> MakeTool(spiker, ancient_ammo_combo),
|
||||
"frag_grenade" -> MakeTool(frag_grenade, frag_grenade_ammo),
|
||||
"jammer_grenade" -> MakeTool(jammer_grenade, jammer_grenade_ammo),
|
||||
"plasma_grenade" -> MakeTool(plasma_grenade, plasma_grenade_ammo),
|
||||
"katana" -> MakeTool(katana, melee_ammo),
|
||||
"chainblade" -> MakeTool(chainblade, melee_ammo),
|
||||
"magcutter" -> MakeTool(magcutter, melee_ammo),
|
||||
"forceblade" -> MakeTool(forceblade, melee_ammo),
|
||||
"mini_chaingun" -> MakeTool(mini_chaingun, bullet_9mm),
|
||||
"r_shotgun" -> MakeTool(r_shotgun, shotgun_shell), //jackhammer
|
||||
"lasher" -> MakeTool(lasher, energy_cell),
|
||||
"maelstrom" -> MakeTool(maelstrom, maelstrom_ammo),
|
||||
"striker" -> MakeTool(striker, striker_missile_ammo),
|
||||
"hunterseeker" -> MakeTool(hunterseeker, hunter_seeker_missile), //phoenix
|
||||
"lancer" -> MakeTool(lancer, lancer_cartridge),
|
||||
"phoenix" -> MakeTool(phoenix, phoenix_missile), //decimator
|
||||
"rocklet" -> MakeTool(rocklet, rocket),
|
||||
"thumper" -> MakeTool(thumper, frag_cartridge),
|
||||
"radiator" -> MakeTool(radiator, ancient_ammo_combo),
|
||||
"heavy_sniper" -> MakeTool(heavy_sniper, bolt), //hsr
|
||||
"bolt_driver" -> MakeTool(bolt_driver, bolt),
|
||||
"oicw" -> MakeTool(oicw, oicw_ammo), //scorpion
|
||||
"flamethrower" -> MakeTool(flamethrower, flamethrower_ammo)
|
||||
"ilc9" -> MakeTool(ilc9),
|
||||
"repeater" -> MakeTool(repeater),
|
||||
"isp" -> MakeTool(isp), //amp
|
||||
"beamer" -> MakeTool(beamer),
|
||||
"suppressor" -> MakeTool(suppressor),
|
||||
"anniversary_guna" -> MakeTool(anniversary_guna), //tr stinger
|
||||
"anniversary_gun" -> MakeTool(anniversary_gun), //nc spear
|
||||
"anniversary_gunb" -> MakeTool(anniversary_gunb), //vs eraser
|
||||
"cycler" -> MakeTool(cycler),
|
||||
"gauss" -> MakeTool(gauss),
|
||||
"pulsar" -> MakeTool(pulsar),
|
||||
"punisher" -> MakeTool(punisher),
|
||||
"flechette" -> MakeTool(flechette),
|
||||
"spiker" -> MakeTool(spiker),
|
||||
"frag_grenade" -> MakeTool(frag_grenade),
|
||||
"jammer_grenade" -> MakeTool(jammer_grenade),
|
||||
"plasma_grenade" -> MakeTool(plasma_grenade),
|
||||
"katana" -> MakeTool(katana),
|
||||
"chainblade" -> MakeTool(chainblade),
|
||||
"magcutter" -> MakeTool(magcutter),
|
||||
"forceblade" -> MakeTool(forceblade),
|
||||
"mini_chaingun" -> MakeTool(mini_chaingun),
|
||||
"r_shotgun" -> MakeTool(r_shotgun), //jackhammer
|
||||
"lasher" -> MakeTool(lasher),
|
||||
"maelstrom" -> MakeTool(maelstrom),
|
||||
"striker" -> MakeTool(striker),
|
||||
"hunterseeker" -> MakeTool(hunterseeker), //phoenix
|
||||
"lancer" -> MakeTool(lancer),
|
||||
"phoenix" -> MakeTool(phoenix), //decimator
|
||||
"rocklet" -> MakeTool(rocklet),
|
||||
"thumper" -> MakeTool(thumper),
|
||||
"radiator" -> MakeTool(radiator),
|
||||
"heavy_sniper" -> MakeTool(heavy_sniper), //hsr
|
||||
"bolt_driver" -> MakeTool(bolt_driver),
|
||||
"oicw" -> MakeTool(oicw), //scorpion
|
||||
"flamethrower" -> MakeTool(flamethrower)
|
||||
)
|
||||
|
||||
/**
|
||||
|
|
@ -176,20 +177,98 @@ abstract class TerminalDefinition(objectId : Int) extends ObjectDefinition(objec
|
|||
"super_medkit" -> MakeKit(super_medkit),
|
||||
"super_armorkit" -> MakeKit(super_armorkit),
|
||||
"super_staminakit" -> MakeKit(super_staminakit),
|
||||
"medicalapplicator" -> MakeTool(medicalapplicator, health_canister),
|
||||
"medicalapplicator" -> MakeTool(medicalapplicator),
|
||||
"bank" -> MakeTool(bank, armor_canister),
|
||||
"nano_dispenser" -> MakeTool(nano_dispenser, armor_canister),
|
||||
"nano_dispenser" -> MakeTool(nano_dispenser),
|
||||
//TODO "ace" -> MakeConstructionItem(ace),
|
||||
//TODO "advanced_ace" -> MakeConstructionItem(advanced_ace),
|
||||
"remote_electronics_kit" -> MakeSimpleItem(remote_electronics_kit),
|
||||
"trek" -> MakeTool(trek, trek_ammo),
|
||||
"trek" -> MakeTool(trek),
|
||||
"command_detonater" -> MakeSimpleItem(command_detonater),
|
||||
"flail_targeting_laser" -> MakeSimpleItem(flail_targeting_laser)
|
||||
)
|
||||
|
||||
/**
|
||||
* A `Map` of operations for producing a ground-based `Vehicle`.
|
||||
* key - an identification string sent by the client
|
||||
* value - a curried function that builds the object
|
||||
*/
|
||||
protected val groundVehicles : Map[String, ()=>Vehicle] = Map(
|
||||
"quadassault" -> MakeVehicle(quadassault),
|
||||
"fury" -> MakeVehicle(fury),
|
||||
"quadstealth" -> MakeVehicle(quadstealth),
|
||||
"ant" -> MakeVehicle(ant),
|
||||
"ams" -> MakeVehicle(ams),
|
||||
"mediumtransport" -> MakeVehicle(mediumtransport),
|
||||
"two_man_assault_buggy" -> MakeVehicle(two_man_assault_buggy),
|
||||
"skyguard" -> MakeVehicle(skyguard),
|
||||
"lightning" -> MakeVehicle(lightning),
|
||||
"threemanheavybuggy" -> MakeVehicle(threemanheavybuggy),
|
||||
"battlewagon" -> MakeVehicle(battlewagon),
|
||||
"apc_tr" -> MakeVehicle(apc_tr),
|
||||
"prowler" -> MakeVehicle(prowler),
|
||||
"twomanheavybuggy" -> MakeVehicle(twomanheavybuggy),
|
||||
"thunderer" -> MakeVehicle(thunderer),
|
||||
"apc_nc" -> MakeVehicle(apc_nc),
|
||||
"vanguard" -> MakeVehicle(vanguard),
|
||||
"twomanhoverbuggy" -> MakeVehicle(twomanhoverbuggy),
|
||||
"aurora" -> MakeVehicle(aurora),
|
||||
"apc_vs" -> MakeVehicle(apc_vs),
|
||||
"magrider" -> MakeVehicle(magrider),
|
||||
"flail" -> MakeVehicle(flail),
|
||||
"switchblade" -> MakeVehicle(switchblade),
|
||||
"router" -> MakeVehicle(router)
|
||||
)
|
||||
|
||||
/**
|
||||
* A `Map` of operations for producing most flight-based `Vehicle`.
|
||||
* key - an identification string sent by the client
|
||||
* value - a curried function that builds the object
|
||||
*/
|
||||
protected val flight1Vehicles : Map[String, ()=>Vehicle] = Map(
|
||||
"mosquito" -> MakeVehicle(mosquito),
|
||||
"lightgunship" -> MakeVehicle(lightgunship),
|
||||
"wasp" -> MakeVehicle(wasp),
|
||||
"phantasm" -> MakeVehicle(phantasm),
|
||||
"vulture" -> MakeVehicle(vulture),
|
||||
"liberator" -> MakeVehicle(liberator)
|
||||
)
|
||||
|
||||
/**
|
||||
* A `Map` of operations for producing a flight-based `Vehicle` specific to the dropship terminal.
|
||||
* key - an identification string sent by the client
|
||||
* value - a curried function that builds the object
|
||||
*/
|
||||
protected val flight2Vehicles : Map[String, ()=>Vehicle] = Map(
|
||||
"dropship" -> MakeVehicle(dropship),
|
||||
"galaxy_gunship" -> MakeVehicle(galaxy_gunship),
|
||||
"lodestar" -> MakeVehicle(lodestar)
|
||||
)
|
||||
|
||||
/**
|
||||
* A `Map` of operations for producing a ground-based `Vehicle` specific to the bfr terminal.
|
||||
* key - an identification string sent by the client
|
||||
* value - a curried function that builds the object
|
||||
*/
|
||||
protected val bfrVehicles : Map[String, ()=>Vehicle] = Map(
|
||||
// "colossus_gunner" -> (()=>Unit),
|
||||
// "colossus_flight" -> (()=>Unit),
|
||||
// "peregrine_gunner" -> (()=>Unit),
|
||||
// "peregrine_flight" -> (()=>Unit),
|
||||
// "aphelion_gunner" -> (()=>Unit),
|
||||
// "aphelion_flight" -> (()=>Unit)
|
||||
)
|
||||
|
||||
/**
|
||||
* Create a new `Tool` from provided `EquipmentDefinition` objects.
|
||||
* @param tdef the `ToolDefinition` objects
|
||||
* @param tdef the `ToolDefinition` object
|
||||
* @return a partial function that, when called, creates the piece of `Equipment`
|
||||
*/
|
||||
protected def MakeTool(tdef : ToolDefinition)() : Tool = MakeTool(tdef, Nil)
|
||||
|
||||
/**
|
||||
* Create a new `Tool` from provided `EquipmentDefinition` objects.
|
||||
* @param tdef the `ToolDefinition` object
|
||||
* @param adef an `AmmoBoxDefinition` object
|
||||
* @return a partial function that, when called, creates the piece of `Equipment`
|
||||
*/
|
||||
|
|
@ -200,24 +279,55 @@ abstract class TerminalDefinition(objectId : Int) extends ObjectDefinition(objec
|
|||
* Only use this function to create default `Tools` with the default parameters.
|
||||
* For example, loadouts can retain `Tool` information that utilizes alternate, valid ammunition types;
|
||||
* and, this method function will not construct a complete object if provided that information.
|
||||
* @param tdef the `ToolDefinition` objects
|
||||
* @param tdef the `ToolDefinition` object
|
||||
* @param adefs a `List` of `AmmoBoxDefinition` objects
|
||||
* @return a curried function that, when called, creates the piece of `Equipment`
|
||||
* @see `GlobalDefinitions`
|
||||
* @see `OrderTerminalDefinition.BuildSimplifiedPattern`
|
||||
*/
|
||||
protected def MakeTool(tdef : ToolDefinition, adefs : List[AmmoBoxDefinition])() : Tool = {
|
||||
protected def MakeTool(tdef : ToolDefinition, adefs : List[AmmoBoxDefinition])() : Tool = {
|
||||
val obj = Tool(tdef)
|
||||
(0 until obj.MaxAmmoSlot).foreach(index => {
|
||||
val aType = adefs(index)
|
||||
val ammo = MakeAmmoBox(aType, Some(obj.Definition.FireModes(index).Magazine)) //make internal magazine, full
|
||||
(obj.AmmoSlots(index).Box = ammo) match {
|
||||
case Some(_) => ; //this means it worked
|
||||
case None =>
|
||||
org.log4s.getLogger("TerminalDefinition").warn(s"plans do not match definition: trying to feed ${ammo.AmmoType} ammunition into Tool (${obj.Definition.ObjectId} @ $index)")
|
||||
adefs match {
|
||||
case _ :: _ =>
|
||||
LoadAmmunitionIntoWeapon(obj, adefs)
|
||||
case Nil => ; //as-is
|
||||
}
|
||||
obj
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a weapon, and custom ammunition profiles, attempt to load those boxes of ammunition into the weapon.<br>
|
||||
* <br>
|
||||
* This is a customization function that should normally go unused.
|
||||
* All of the information necessary to generate a `Tool` from a `Terminal` request should be available on the `ToolDefinition` object.
|
||||
* The ammunition information, regardless of "customization," must satisfy the type limits of the original definition.
|
||||
* As thus, to introduce very strange ammunition to a give `Tool`,
|
||||
* either the definition must be modified or a different definition must be used.
|
||||
* The custom ammunition is organized into order of ammunition slots based on the `FireModeDefinition` objects.
|
||||
* That is:
|
||||
* the first custom element is processed by the first ammunition slot;
|
||||
* the second custom element is processed by the second ammunition slot; and, so forth.
|
||||
* @param weapon the `Tool` object
|
||||
* @param adefs a sequential `List` of ammunition to be loaded into weapon
|
||||
* @see `AmmoBoxDefinition`
|
||||
* @see `FireModeDefinition`
|
||||
*/
|
||||
private def LoadAmmunitionIntoWeapon(weapon : Tool, adefs : List[AmmoBoxDefinition]) : Unit = {
|
||||
val definition = weapon.Definition
|
||||
(0 until math.min(weapon.MaxAmmoSlot, adefs.length)).foreach(index => {
|
||||
val ammoSlot = weapon.AmmoSlots(index)
|
||||
adefs.lift(index) match {
|
||||
case Some(aType) =>
|
||||
ammoSlot.AllAmmoTypes.indexOf(aType.AmmoType) match {
|
||||
case -1 =>
|
||||
log.warn(s"terminal plans do not match definition: can not feed ${aType.AmmoType} ammunition into Tool (${definition.ObjectId} @ ammo $index)")
|
||||
case n =>
|
||||
ammoSlot.AmmoTypeIndex = n
|
||||
ammoSlot.Box = MakeAmmoBox(aType, Some(definition.FireModes(index).Magazine)) //make new internal magazine, full
|
||||
}
|
||||
case None => ;
|
||||
}
|
||||
})
|
||||
obj
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -229,11 +339,12 @@ abstract class TerminalDefinition(objectId : Int) extends ObjectDefinition(objec
|
|||
* @see `GlobalDefinitions`
|
||||
*/
|
||||
protected def MakeAmmoBox(adef : AmmoBoxDefinition, capacity : Option[Int] = None)() : AmmoBox = {
|
||||
val obj = AmmoBox(adef)
|
||||
if(capacity.isDefined) {
|
||||
obj.Capacity = capacity.get
|
||||
capacity match {
|
||||
case Some(cap) =>
|
||||
AmmoBox(adef, cap)
|
||||
case None =>
|
||||
AmmoBox(adef)
|
||||
}
|
||||
obj
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -259,4 +370,12 @@ abstract class TerminalDefinition(objectId : Int) extends ObjectDefinition(objec
|
|||
* @see `GlobalDefinitions`
|
||||
*/
|
||||
protected def MakeConstructionItem(cdef : ConstructionItemDefinition)() : ConstructionItem = ConstructionItem(cdef)
|
||||
|
||||
/**
|
||||
* Create a new `Vehicle` from provided `VehicleDefinition` objects.
|
||||
* @param vdef the `VehicleDefinition` object
|
||||
* @return a curried function that, when called, creates the `Vehicle`
|
||||
* @see `GlobalDefinitions`
|
||||
*/
|
||||
protected def MakeVehicle(vdef : VehicleDefinition)() : Vehicle = Vehicle(vdef)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.objects.serverobject.terminals
|
||||
|
||||
import net.psforever.objects.Player
|
||||
import net.psforever.packet.game.ItemTransactionMessage
|
||||
|
||||
class VehicleTerminalCombinedDefinition extends TerminalDefinition(952) {
|
||||
private val vehicles = groundVehicles ++ flight1Vehicles
|
||||
Name = "vehicle_terminal_combined"
|
||||
|
||||
def Buy(player : Player, msg : ItemTransactionMessage) : Terminal.Exchange = {
|
||||
vehicles.get(msg.item_name) match {
|
||||
case Some(vehicle) =>
|
||||
Terminal.BuyVehicle(vehicle(), Nil)
|
||||
case None =>
|
||||
Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
package net.psforever.objects.zones
|
||||
|
||||
import akka.actor.Actor
|
||||
import net.psforever.objects.serverobject.locks.IFFLock
|
||||
|
||||
/**
|
||||
* na
|
||||
|
|
@ -35,8 +34,9 @@ class ZoneActor(zone : Zone) extends Actor {
|
|||
}
|
||||
})
|
||||
|
||||
//check door to locks association
|
||||
//check door to lock association
|
||||
import net.psforever.objects.serverobject.doors.Door
|
||||
import net.psforever.objects.serverobject.locks.IFFLock
|
||||
map.DoorToLock.foreach({ case((door_guid, lock_guid)) =>
|
||||
try {
|
||||
if(!guid(door_guid).get.isInstanceOf[Door]) {
|
||||
|
|
@ -45,7 +45,7 @@ class ZoneActor(zone : Zone) extends Actor {
|
|||
}
|
||||
catch {
|
||||
case _ : Exception =>
|
||||
slog.error(s"expected a door, but looking for uninitialized object $door_guid")
|
||||
slog.error(s"expected a door at id $door_guid, but looking for uninitialized object")
|
||||
}
|
||||
try {
|
||||
if(!guid(lock_guid).get.isInstanceOf[IFFLock]) {
|
||||
|
|
@ -54,7 +54,31 @@ class ZoneActor(zone : Zone) extends Actor {
|
|||
}
|
||||
catch {
|
||||
case _ : Exception =>
|
||||
slog.error(s"expected an IFF locks, but looking for uninitialized object $lock_guid")
|
||||
slog.error(s"expected an IFF locks at id $lock_guid, but looking for uninitialized object")
|
||||
}
|
||||
})
|
||||
|
||||
//check vehicle terminal to spawn pad association
|
||||
import net.psforever.objects.serverobject.pad.VehicleSpawnPad
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
map.TerminalToSpawnPad.foreach({ case ((term_guid, pad_guid)) =>
|
||||
try {
|
||||
if(!guid(term_guid).get.isInstanceOf[Terminal]) { //TODO check is vehicle terminal
|
||||
slog.error(s"expected id $term_guid to be a terminal, but it was not")
|
||||
}
|
||||
}
|
||||
catch {
|
||||
case _ : Exception =>
|
||||
slog.error(s"expected a terminal at id $term_guid, but looking for uninitialized object")
|
||||
}
|
||||
try {
|
||||
if(!guid(pad_guid).get.isInstanceOf[VehicleSpawnPad]) {
|
||||
slog.error(s"expected id $pad_guid to be a spawn pad, but it was not")
|
||||
}
|
||||
}
|
||||
catch {
|
||||
case _ : Exception =>
|
||||
slog.error(s"expected a spawn pad at id $pad_guid, but looking for uninitialized object")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import net.psforever.objects.serverobject.builders.ServerObjectBuilder
|
|||
*/
|
||||
class ZoneMap(private val name : String) {
|
||||
private var localObjects : List[ServerObjectBuilder[_]] = List()
|
||||
private var linkTerminalPad : Map[Int, Int] = Map()
|
||||
private var linkDoorLock : Map[Int, Int] = Map()
|
||||
private var linkObjectBase : Map[Int, Int] = Map()
|
||||
private var numBases : Int = 0
|
||||
|
|
@ -64,7 +65,13 @@ class ZoneMap(private val name : String) {
|
|||
|
||||
def DoorToLock : Map[Int, Int] = linkDoorLock
|
||||
|
||||
def DoorToLock(door_guid : Int, lock_guid : Int) = {
|
||||
def DoorToLock(door_guid : Int, lock_guid : Int) : Unit = {
|
||||
linkDoorLock = linkDoorLock ++ Map(door_guid -> lock_guid)
|
||||
}
|
||||
|
||||
def TerminalToSpawnPad : Map[Int, Int] = linkTerminalPad
|
||||
|
||||
def TerminalToSpawnPad(terminal_guid : Int, pad_guid : Int) : Unit = {
|
||||
linkTerminalPad = linkTerminalPad ++ Map(terminal_guid -> pad_guid)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,7 +420,7 @@ object GamePacketOpcode extends Enumeration {
|
|||
case 0x53 => noDecoder(DroppodLaunchRequestMessage)
|
||||
case 0x54 => game.HackMessage.decode
|
||||
case 0x55 => noDecoder(DroppodLaunchResponseMessage)
|
||||
case 0x56 => noDecoder(GenericObjectActionMessage)
|
||||
case 0x56 => game.GenericObjectActionMessage.decode
|
||||
case 0x57 => game.AvatarVehicleTimerMessage.decode
|
||||
// 0x58
|
||||
case 0x58 => game.AvatarImplantMessage.decode
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package net.psforever.packet.game
|
||||
|
||||
import net.psforever.packet.{GamePacketOpcode, Marshallable, PlanetSideGamePacket}
|
||||
import scodec.bits.BitVector
|
||||
import scodec.{Attempt, Codec}
|
||||
import scodec.codecs._
|
||||
import shapeless.{::, HNil}
|
||||
|
||||
/**
|
||||
* Dispatched by the server to enact an effect on some game object.
|
||||
* (Write more some other time.)
|
||||
* @param object_guid the target object
|
||||
* @param code the action code
|
||||
*/
|
||||
final case class GenericObjectActionMessage(object_guid : PlanetSideGUID,
|
||||
code : Int)
|
||||
extends PlanetSideGamePacket {
|
||||
type Packet = GenericObjectActionMessage
|
||||
def opcode = GamePacketOpcode.GenericObjectActionMessage
|
||||
def encode = GenericObjectActionMessage.encode(this)
|
||||
}
|
||||
|
||||
object GenericObjectActionMessage extends Marshallable[GenericObjectActionMessage] {
|
||||
implicit val codec : Codec[GenericObjectActionMessage] = (
|
||||
("object_guid" | PlanetSideGUID.codec) ::
|
||||
("code" | uint8L) ::
|
||||
("ex" | bits) //"code" may extract at odd sizes
|
||||
).exmap[GenericObjectActionMessage] (
|
||||
{
|
||||
case guid :: code :: _ :: HNil =>
|
||||
Attempt.Successful(GenericObjectActionMessage(guid, code))
|
||||
},
|
||||
{
|
||||
case GenericObjectActionMessage(guid, code) =>
|
||||
Attempt.Successful(guid :: code :: BitVector.empty :: HNil)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ import scodec.codecs._
|
|||
* `106 - Custom Head`<br>
|
||||
* <br>
|
||||
* Vehicles:<br>
|
||||
* 0 - Vehicle health<br>
|
||||
* 0 - Vehicle base health<br>
|
||||
* 10 - Driver seat permissions (0 = Locked, 1 = Group, 3 = Empire)<br>
|
||||
* 11 - Gunner seat(s) permissions (same)<br>
|
||||
* 12 - Passenger seat(s) permissions (same) <br>
|
||||
|
|
|
|||
|
|
@ -347,6 +347,8 @@ object ObjectClass {
|
|||
final val quadstealth_destroyed = 711
|
||||
final val router = 741
|
||||
final val router_destroyed = 742
|
||||
final val skyguard = 784
|
||||
final val skyguard_destroyed = 785
|
||||
final val switchblade = 847
|
||||
final val switchblade_destroyed = 848
|
||||
final val threemanheavybuggy = 862 //marauder
|
||||
|
|
@ -845,7 +847,7 @@ object ObjectClass {
|
|||
case ObjectClass.lancer => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.lasher => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.liberator_25mm_cannon => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.liberator_bomb_bay => ConstructorData.genericCodec(WeaponData.codec(2), "weapon")
|
||||
case ObjectClass.liberator_bomb_bay => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.liberator_weapon_system => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.lightgunship_weapon_system => ConstructorData.genericCodec(WeaponData.codec(2), "weapon")
|
||||
case ObjectClass.lightning_weapon_system => ConstructorData.genericCodec(WeaponData.codec(2), "weapon")
|
||||
|
|
@ -888,7 +890,7 @@ object ObjectClass {
|
|||
case ObjectClass.rocklet => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.rotarychaingun_mosquito => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.scythe => ConstructorData.genericCodec(WeaponData.codec(2), "weapon")
|
||||
case ObjectClass.skyguard_weapon_system => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.skyguard_weapon_system => ConstructorData.genericCodec(WeaponData.codec(2), "weapon")
|
||||
case ObjectClass.spiker => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.spitfire_aa_weapon => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
case ObjectClass.spitfire_weapon => ConstructorData.genericCodec(WeaponData.codec, "weapon")
|
||||
|
|
@ -1245,6 +1247,8 @@ object ObjectClass {
|
|||
case ObjectClass.quadstealth_destroyed => ConstructorData.genericCodec(DestroyedVehicleData.codec, "wreckage")
|
||||
case ObjectClass.router => ConstructorData.genericCodec(VehicleData.codec(VehicleFormat.Variant), "vehicle")
|
||||
case ObjectClass.router_destroyed => ConstructorData.genericCodec(DestroyedVehicleData.codec, "wreckage")
|
||||
case ObjectClass.skyguard => ConstructorData.genericCodec(VehicleData.codec, "vehicle")
|
||||
case ObjectClass.skyguard_destroyed => ConstructorData.genericCodec(DestroyedVehicleData.codec, "wreckage")
|
||||
case ObjectClass.switchblade => ConstructorData.genericCodec(VehicleData.codec(VehicleFormat.Variant), "vehicle")
|
||||
case ObjectClass.switchblade_destroyed => ConstructorData.genericCodec(DestroyedVehicleData.codec, "wreckage")
|
||||
case ObjectClass.threemanheavybuggy => ConstructorData.genericCodec(VehicleData.codec, "vehicle")
|
||||
|
|
|
|||
|
|
@ -27,6 +27,81 @@ object Prefab {
|
|||
VehicleData(CommonFieldData(loc, faction, 0), 0, health, false, false, driveState, false, false, false, Some(UtilityVehicleData(0)), None)(VehicleFormat.Utility)
|
||||
}
|
||||
|
||||
def apc_nc(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID, weapon3_guid : PlanetSideGUID, ammo3_guid : PlanetSideGUID, weapon4_guid : PlanetSideGUID, ammo4_guid : PlanetSideGUID, weapon5_guid : PlanetSideGUID, ammo5_guid : PlanetSideGUID, weapon6_guid : PlanetSideGUID, ammo6_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemc_nc, weapon1_guid, 11,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_20mm, ammo1_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemb, weapon2_guid, 12,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo2_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systema, weapon3_guid, 13,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo3_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemd_nc, weapon4_guid, 14,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_20mm, ammo4_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_r, weapon5_guid, 15,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo5_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_l, weapon6_guid, 16,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo6_guid, 0, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def apc_tr(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID, weapon3_guid : PlanetSideGUID, ammo3_guid : PlanetSideGUID, weapon4_guid : PlanetSideGUID, ammo4_guid : PlanetSideGUID, weapon5_guid : PlanetSideGUID, ammo5_guid : PlanetSideGUID, weapon6_guid : PlanetSideGUID, ammo6_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemc_tr, weapon1_guid, 11,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_15mm, ammo1_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemb, weapon2_guid, 12,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo2_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systema, weapon3_guid, 13,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo3_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemd_tr, weapon4_guid, 14,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_15mm, ammo4_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_r, weapon5_guid, 15,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo5_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_l, weapon6_guid, 16,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo6_guid, 0, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def apc_vs(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID, weapon3_guid : PlanetSideGUID, ammo3_guid : PlanetSideGUID, weapon4_guid : PlanetSideGUID, ammo4_guid : PlanetSideGUID, weapon5_guid : PlanetSideGUID, ammo5_guid : PlanetSideGUID, weapon6_guid : PlanetSideGUID, ammo6_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemc_vs, weapon1_guid, 11,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.flux_cannon_thresher_battery, ammo1_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemb, weapon2_guid, 12,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo2_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systema, weapon3_guid, 13,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo3_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemd_vs, weapon4_guid, 14,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.flux_cannon_thresher_battery, ammo4_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_r, weapon5_guid, 15,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo5_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_l, weapon6_guid, 16,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo6_guid, 0, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def aurora(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo11_guid : PlanetSideGUID, ammo12_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo21_guid : PlanetSideGUID, ammo22_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 0), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
|
|
@ -118,56 +193,6 @@ object Prefab {
|
|||
)(VehicleFormat.Variant)
|
||||
}
|
||||
|
||||
def juggernaut(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID, weapon3_guid : PlanetSideGUID, ammo3_guid : PlanetSideGUID, weapon4_guid : PlanetSideGUID, ammo4_guid : PlanetSideGUID, weapon5_guid : PlanetSideGUID, ammo5_guid : PlanetSideGUID, weapon6_guid : PlanetSideGUID, ammo6_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemc_tr, weapon1_guid, 11,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_15mm, ammo1_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemb, weapon2_guid, 12,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo2_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systema, weapon3_guid, 13,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo3_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemd_tr, weapon4_guid, 14,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_15mm, ammo4_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_r, weapon5_guid, 15,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo5_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_l, weapon6_guid, 16,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo6_guid, 0, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def leviathan(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID, weapon3_guid : PlanetSideGUID, ammo3_guid : PlanetSideGUID, weapon4_guid : PlanetSideGUID, ammo4_guid : PlanetSideGUID, weapon5_guid : PlanetSideGUID, ammo5_guid : PlanetSideGUID, weapon6_guid : PlanetSideGUID, ammo6_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemc_vs, weapon1_guid, 11,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.flux_cannon_thresher_battery, ammo1_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemb, weapon2_guid, 12,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo2_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systema, weapon3_guid, 13,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo3_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemd_vs, weapon4_guid, 14,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.flux_cannon_thresher_battery, ammo4_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_r, weapon5_guid, 15,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo5_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_l, weapon6_guid, 16,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo6_guid, 0, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def liberator(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID, ammo3_guid : PlanetSideGUID, weapon3_guid : PlanetSideGUID, ammo4_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, Some(VariantVehicleData(0)),
|
||||
Some(InventoryData(
|
||||
|
|
@ -187,8 +212,8 @@ object Prefab {
|
|||
def lightgunship(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.Mobile, false, false, false, Some(VariantVehicleData(0)),
|
||||
Some(InventoryData(
|
||||
InventoryItemData(445, weapon_guid, 1,
|
||||
WeaponData(0x6, 0x8, 0, 16, ammo1_guid, 0, AmmoBoxData(8), 722, ammo2_guid,1, AmmoBoxData(8))
|
||||
InventoryItemData(ObjectClass.lightgunship_weapon_system, weapon_guid, 1,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_20mm, ammo1_guid, 0, AmmoBoxData(8), ObjectClass.reaver_rocket, ammo2_guid,1, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Variant)
|
||||
|
|
@ -270,14 +295,6 @@ object Prefab {
|
|||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def router(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, terminal_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.Mobile, false, false, false, Some(VariantVehicleData(0)),
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.teleportpad_terminal, terminal_guid, 1, CommonTerminalData(faction, 2)) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Variant)
|
||||
}
|
||||
|
||||
def quadassault(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon_guid : PlanetSideGUID, ammo_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 0), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
|
|
@ -292,6 +309,24 @@ object Prefab {
|
|||
VehicleData(CommonFieldData(loc, faction, 0), 0, health, false, false, DriveState.State7, false, false, false, None, None)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def router(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, terminal_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.Mobile, false, false, false, Some(VariantVehicleData(0)),
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.teleportpad_terminal, terminal_guid, 1, CommonTerminalData(faction, 2)) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Variant)
|
||||
}
|
||||
|
||||
def skyguard(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.skyguard_weapon_system, weapon_guid, 2,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.skyguard_flak_cannon_ammo, ammo1_guid, 0, AmmoBoxData(8), ObjectClass.bullet_12mm, ammo2_guid, 1, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def switchblade(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, driveState : DriveState.Value, weapon_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 0), 0, health, false, false, DriveState.State7, true, false, false, Some(VariantVehicleData(0)),
|
||||
Some(InventoryData(
|
||||
|
|
@ -368,31 +403,6 @@ object Prefab {
|
|||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def vindicator(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID, weapon3_guid : PlanetSideGUID, ammo3_guid : PlanetSideGUID, weapon4_guid : PlanetSideGUID, ammo4_guid : PlanetSideGUID, weapon5_guid : PlanetSideGUID, ammo5_guid : PlanetSideGUID, weapon6_guid : PlanetSideGUID, ammo6_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, None,
|
||||
Some(InventoryData(
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemc_nc, weapon1_guid, 11,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_20mm, ammo1_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemb, weapon2_guid, 12,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo2_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systema, weapon3_guid, 13,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_75mm, ammo3_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_weapon_systemd_nc, weapon4_guid, 14,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_20mm, ammo4_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_r, weapon5_guid, 15,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo5_guid, 0, AmmoBoxData(8))
|
||||
) ::
|
||||
InventoryItemData(ObjectClass.apc_ballgun_l, weapon6_guid, 16,
|
||||
WeaponData(0x6, 0x8, 0, ObjectClass.bullet_12mm, ammo6_guid, 0, AmmoBoxData(8))
|
||||
) :: Nil
|
||||
))
|
||||
)(VehicleFormat.Normal)
|
||||
}
|
||||
|
||||
def vulture(loc : PlacementData, faction : PlanetSideEmpire.Value, health : Int, weapon1_guid : PlanetSideGUID, ammo1_guid : PlanetSideGUID, weapon2_guid : PlanetSideGUID, ammo2_guid : PlanetSideGUID, weapon3_guid : PlanetSideGUID, ammo3_guid : PlanetSideGUID) : VehicleData = {
|
||||
VehicleData(CommonFieldData(loc, faction, 2), 0, health, false, false, DriveState.State7, true, false, false, Some(VariantVehicleData(0)),
|
||||
Some(InventoryData(
|
||||
|
|
|
|||
|
|
@ -4,11 +4,41 @@ package net.psforever.types
|
|||
import net.psforever.newcodecs._
|
||||
import scodec.Codec
|
||||
import scodec.codecs._
|
||||
import shapeless.{::, HNil}
|
||||
|
||||
final case class Vector3(x : Float,
|
||||
y : Float,
|
||||
z : Float)
|
||||
z : Float) {
|
||||
/**
|
||||
* Operator override for vector addition, treating `Vector3` objects as actual mathematical vectors.
|
||||
* The application of this overload is "vector1 + vector2."
|
||||
* @param vec the other `Vector3` object
|
||||
* @return a new `Vector3` object with the summed values
|
||||
*/
|
||||
def +(vec : Vector3) : Vector3 = {
|
||||
new Vector3(x + vec.x, y + vec.y, z + vec.z)
|
||||
}
|
||||
|
||||
/**
|
||||
* Operator override for vector subtraction, treating `Vector3` objects as actual mathematical vectors.
|
||||
* The application of this overload is "vector1 - vector2."
|
||||
* @param vec the other `Vector3` object
|
||||
* @return a new `Vector3` object with the difference values
|
||||
*/
|
||||
def -(vec : Vector3) : Vector3 = {
|
||||
new Vector3(x - vec.x, y - vec.y, z - vec.z)
|
||||
}
|
||||
|
||||
/**
|
||||
* Operator override for vector scaling, treating `Vector3` objects as actual mathematical vectors.
|
||||
* The application of this overload is "vector * scalar" exclusively.
|
||||
* "scalar * vector" is invalid.
|
||||
* @param scalar the value to multiply this vector
|
||||
* @return a new `Vector3` object
|
||||
*/
|
||||
def *(scalar : Float) : Vector3 = {
|
||||
new Vector3(x*scalar, y*scalar, z*scalar)
|
||||
}
|
||||
}
|
||||
|
||||
object Vector3 {
|
||||
implicit val codec_pos : Codec[Vector3] = (
|
||||
|
|
@ -28,4 +58,48 @@ object Vector3 {
|
|||
("y" | floatL) ::
|
||||
("z" | floatL)
|
||||
).as[Vector3]
|
||||
|
||||
/**
|
||||
* Calculate the actual distance between two points.
|
||||
* @param pos1 the first point
|
||||
* @param pos2 the second point
|
||||
* @return the distance
|
||||
*/
|
||||
def Distance(pos1 : Vector3, pos2 : Vector3) : Float = {
|
||||
math.sqrt(DistanceSquared(pos1, pos2)).toFloat
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the squared distance between two points.
|
||||
* Though some time is saved care must be taken that any comparative distance is also squared.
|
||||
* @param pos1 the first point
|
||||
* @param pos2 the second point
|
||||
* @return the distance
|
||||
*/
|
||||
def DistanceSquared(pos1 : Vector3, pos2 : Vector3) : Float = {
|
||||
val dvec : Vector3 = pos1 - pos2
|
||||
(dvec.x * dvec.x) + (dvec.y * dvec.y) + (dvec.z * dvec.z)
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the actual magnitude of a vector.
|
||||
* @param vec the vector
|
||||
* @return the magnitude
|
||||
*/
|
||||
def Magnitude(vec : Vector3) : Float = {
|
||||
math.sqrt(MagnitudeSquared(vec)).toFloat
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the squared magnitude of a vector.
|
||||
* Though some time is saved care must be taken that any comparative magnitude is also squared.
|
||||
* @param vec the vector
|
||||
* @return the magnitude
|
||||
*/
|
||||
def MagnitudeSquared(vec : Vector3) : Float = {
|
||||
val dx : Float = vec.x
|
||||
val dy : Float = vec.y
|
||||
val dz : Float = vec.z
|
||||
(dx * dx) + (dy * dy) + (dz * dz)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
68
common/src/test/scala/Vector3Test.scala
Normal file
68
common/src/test/scala/Vector3Test.scala
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.types.Vector3
|
||||
|
||||
class Vector3Test extends Specification {
|
||||
val vec = Vector3(1.3f, -2.6f, 3.9f)
|
||||
|
||||
"Vector3" should {
|
||||
"construct" in {
|
||||
vec.x mustEqual 1.3f
|
||||
vec.y mustEqual -2.6f
|
||||
vec.z mustEqual 3.9f
|
||||
}
|
||||
|
||||
"calculate magnitude (like a vector) 1" in {
|
||||
val obj = Vector3(2.0f, 0.0f, 0.0f)
|
||||
Vector3.Magnitude(obj) mustEqual 2.0f
|
||||
}
|
||||
|
||||
"calculate magnitude (like a vector) 2" in {
|
||||
val obj = Vector3(3.0f, 4.0f, 0.0f)
|
||||
Vector3.Magnitude(obj) mustEqual 5.0f
|
||||
}
|
||||
|
||||
"calculate magnitude (like a vector) 3" in {
|
||||
Vector3.Magnitude(vec) mustEqual 4.864155f
|
||||
}
|
||||
|
||||
"calculate square magnitude (like a vector)" in {
|
||||
Vector3.MagnitudeSquared(vec) mustEqual 23.66f
|
||||
}
|
||||
|
||||
"calculate distance 1" in {
|
||||
val obj1 = Vector3(0.0f, 0.0f, 0.0f)
|
||||
val obj2 = Vector3(2.0f, 0.0f, 0.0f)
|
||||
Vector3.Distance(obj1, obj2) mustEqual 2.0f
|
||||
}
|
||||
|
||||
"calculate distance 2" in {
|
||||
val obj1 = Vector3(0.0f, 0.0f, 0.0f)
|
||||
val obj2 = Vector3(2.0f, 0.0f, 0.0f)
|
||||
Vector3.Distance(obj1, obj2) mustEqual Vector3.Magnitude(obj2)
|
||||
}
|
||||
|
||||
"calculate distance 3" in {
|
||||
val obj1 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
val obj2 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
Vector3.Distance(obj1, obj2) mustEqual 0f
|
||||
}
|
||||
|
||||
"addition" in {
|
||||
val obj1 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
val obj2 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
obj1 + obj2 mustEqual Vector3(6f, 8f, 10f)
|
||||
}
|
||||
|
||||
"subtraction" in {
|
||||
val obj1 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
val obj2 = Vector3(3.0f, 4.0f, 5.0f)
|
||||
obj1 - obj2 mustEqual Vector3(0f, 0f, 0f)
|
||||
}
|
||||
|
||||
"scalar" in {
|
||||
vec * 3f mustEqual Vector3(3.8999999f, -7.7999997f, 11.700001f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class GenericObjectActionMessageTest extends Specification {
|
||||
val string = hex"56 B501 24"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case GenericObjectActionMessage(object_guid, action) =>
|
||||
object_guid mustEqual PlanetSideGUID(437)
|
||||
action mustEqual 36
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = GenericObjectActionMessage(PlanetSideGUID(437), 36)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
@ -40,16 +40,15 @@ class ConverterTest extends Specification {
|
|||
"convert to packet" in {
|
||||
val tdef = ToolDefinition(1076)
|
||||
tdef.Size = EquipmentSize.Rifle
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell_AP
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell_AP
|
||||
tdef.FireModes += new FireModeDefinition
|
||||
tdef.FireModes.head.AmmoTypeIndices += 0
|
||||
tdef.FireModes.head.AmmoTypeIndices += 1
|
||||
tdef.FireModes.head.AmmoSlotIndex = 0
|
||||
tdef.FireModes.head.Magazine = 30
|
||||
val obj : Tool = Tool(tdef)
|
||||
val box = AmmoBox(PlanetSideGUID(90), new AmmoBoxDefinition(Ammo.shotgun_shell.id))
|
||||
obj.AmmoSlots.head.Box = box
|
||||
obj.AmmoSlots.head.Magazine = 30
|
||||
obj.AmmoSlot.Box.GUID = PlanetSideGUID(90)
|
||||
|
||||
obj.Definition.Packet.DetailedConstructorData(obj) match {
|
||||
case Success(pkt) =>
|
||||
|
|
@ -139,24 +138,22 @@ class ConverterTest extends Specification {
|
|||
Give the Player's Holster (2) the Tool
|
||||
Place the remaining AmmoBox into the Player's inventory in the third slot (8)
|
||||
*/
|
||||
val bullet_9mm = AmmoBoxDefinition(28)
|
||||
bullet_9mm.Capacity = 50
|
||||
val box1 = AmmoBox(PlanetSideGUID(90), bullet_9mm)
|
||||
val box2 = AmmoBox(PlanetSideGUID(91), bullet_9mm)
|
||||
val tdef = ToolDefinition(1076)
|
||||
tdef.Name = "sample_weapon"
|
||||
tdef.Size = EquipmentSize.Rifle
|
||||
tdef.AmmoTypes += Ammo.bullet_9mm
|
||||
tdef.AmmoTypes += GlobalDefinitions.bullet_9mm
|
||||
tdef.FireModes += new FireModeDefinition
|
||||
tdef.FireModes.head.AmmoTypeIndices += 0
|
||||
tdef.FireModes.head.AmmoSlotIndex = 0
|
||||
tdef.FireModes.head.Magazine = 18
|
||||
val tool = Tool(PlanetSideGUID(92), tdef)
|
||||
tool.AmmoSlots.head.Box = box1
|
||||
val tool = Tool(tdef)
|
||||
tool.GUID = PlanetSideGUID(92)
|
||||
tool.AmmoSlot.Box.GUID = PlanetSideGUID(90)
|
||||
val obj = Player(PlanetSideGUID(93), "Chord", PlanetSideEmpire.TR, CharacterGender.Male, 0, 5)
|
||||
obj.Slot(2).Equipment = tool
|
||||
obj.Slot(5).Equipment.get.GUID = PlanetSideGUID(94)
|
||||
obj.Inventory += 8 -> box2
|
||||
obj.Inventory += 8 -> AmmoBox(GlobalDefinitions.bullet_9mm)
|
||||
obj.Slot(8).Equipment.get.GUID = PlanetSideGUID(91)
|
||||
obj
|
||||
}
|
||||
val converter = new CharacterSelectConverter
|
||||
|
|
@ -263,7 +260,7 @@ class ConverterTest extends Specification {
|
|||
|
||||
val fury_weapon_systema_def = ToolDefinition(ObjectClass.fury_weapon_systema)
|
||||
fury_weapon_systema_def.Size = EquipmentSize.VehicleWeapon
|
||||
fury_weapon_systema_def.AmmoTypes += Ammo.hellfire_ammo
|
||||
fury_weapon_systema_def.AmmoTypes += GlobalDefinitions.hellfire_ammo
|
||||
fury_weapon_systema_def.FireModes += new FireModeDefinition
|
||||
fury_weapon_systema_def.FireModes.head.AmmoTypeIndices += 0
|
||||
fury_weapon_systema_def.FireModes.head.AmmoSlotIndex = 0
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import net.psforever.objects.GlobalDefinitions._
|
|||
import org.specs2.mutable._
|
||||
|
||||
class EquipmentTest extends Specification {
|
||||
|
||||
"AmmoBox" should {
|
||||
"define" in {
|
||||
val obj = AmmoBoxDefinition(86)
|
||||
|
|
@ -19,8 +18,8 @@ class EquipmentTest extends Specification {
|
|||
|
||||
obj.AmmoType mustEqual Ammo.aphelion_immolation_cannon_ammo
|
||||
obj.Capacity mustEqual 300
|
||||
obj.Tile.width mustEqual InventoryTile.Tile44.width
|
||||
obj.Tile.height mustEqual InventoryTile.Tile44.height
|
||||
obj.Tile.Width mustEqual InventoryTile.Tile44.Width
|
||||
obj.Tile.Height mustEqual InventoryTile.Tile44.Height
|
||||
obj.ObjectId mustEqual 86
|
||||
}
|
||||
|
||||
|
|
@ -58,8 +57,8 @@ class EquipmentTest extends Specification {
|
|||
val obj = ToolDefinition(1076)
|
||||
obj.Name = "sample_weapon"
|
||||
obj.Size = EquipmentSize.Rifle
|
||||
obj.AmmoTypes += Ammo.shotgun_shell
|
||||
obj.AmmoTypes += Ammo.shotgun_shell_AP
|
||||
obj.AmmoTypes += GlobalDefinitions.shotgun_shell
|
||||
obj.AmmoTypes += GlobalDefinitions.shotgun_shell_AP
|
||||
obj.FireModes += new FireModeDefinition
|
||||
obj.FireModes.head.AmmoTypeIndices += 0
|
||||
obj.FireModes.head.AmmoTypeIndices += 1
|
||||
|
|
@ -74,9 +73,10 @@ class EquipmentTest extends Specification {
|
|||
obj.FireModes(1).Magazine = 18
|
||||
obj.Tile = InventoryTile.Tile93
|
||||
obj.ObjectId mustEqual 1076
|
||||
|
||||
obj.Name mustEqual "sample_weapon"
|
||||
obj.AmmoTypes.head mustEqual Ammo.shotgun_shell
|
||||
obj.AmmoTypes(1) mustEqual Ammo.shotgun_shell_AP
|
||||
obj.AmmoTypes.head mustEqual GlobalDefinitions.shotgun_shell
|
||||
obj.AmmoTypes(1) mustEqual GlobalDefinitions.shotgun_shell_AP
|
||||
obj.FireModes.head.AmmoTypeIndices.head mustEqual 0
|
||||
obj.FireModes.head.AmmoTypeIndices(1) mustEqual 1
|
||||
obj.FireModes.head.AmmoSlotIndex mustEqual 0
|
||||
|
|
@ -89,8 +89,8 @@ class EquipmentTest extends Specification {
|
|||
obj.FireModes(1).Chamber mustEqual 3
|
||||
obj.FireModes(1).Magazine mustEqual 18
|
||||
obj.FireModes(1).ResetAmmoIndexOnSwap mustEqual false
|
||||
obj.Tile.width mustEqual InventoryTile.Tile93.width
|
||||
obj.Tile.height mustEqual InventoryTile.Tile93.height
|
||||
obj.Tile.Width mustEqual InventoryTile.Tile93.Width
|
||||
obj.Tile.Height mustEqual InventoryTile.Tile93.Height
|
||||
}
|
||||
|
||||
"construct" in {
|
||||
|
|
@ -118,8 +118,8 @@ class EquipmentTest extends Specification {
|
|||
//explanation: sample_weapon has two fire modes; adjusting the FireMode changes between them
|
||||
val tdef = ToolDefinition(1076)
|
||||
tdef.Size = EquipmentSize.Rifle
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell_AP
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell_AP
|
||||
tdef.FireModes += new FireModeDefinition
|
||||
tdef.FireModes.head.AmmoTypeIndices += 0
|
||||
tdef.FireModes.head.AmmoSlotIndex = 0
|
||||
|
|
@ -149,8 +149,8 @@ class EquipmentTest extends Specification {
|
|||
//explanation: obj has one fire mode and two ammunitions; adjusting the AmmoType changes between them
|
||||
val tdef = ToolDefinition(1076)
|
||||
tdef.Size = EquipmentSize.Rifle
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell
|
||||
tdef.AmmoTypes += Ammo.shotgun_shell_AP
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell
|
||||
tdef.AmmoTypes += GlobalDefinitions.shotgun_shell_AP
|
||||
tdef.FireModes += new FireModeDefinition
|
||||
tdef.FireModes.head.AmmoTypeIndices += 0
|
||||
tdef.FireModes.head.AmmoTypeIndices += 1
|
||||
|
|
@ -168,14 +168,54 @@ class EquipmentTest extends Specification {
|
|||
obj.AmmoTypeIndex mustEqual 0
|
||||
obj.AmmoType mustEqual Ammo.shotgun_shell
|
||||
}
|
||||
|
||||
"multiple ammo types and multiple fire modes, split (Punisher)" in {
|
||||
val obj = Tool(GlobalDefinitions.punisher)
|
||||
//ammo = 0, fmode = 0
|
||||
obj.FireModeIndex mustEqual 0
|
||||
obj.AmmoTypeIndex mustEqual 0
|
||||
obj.AmmoType mustEqual Ammo.bullet_9mm
|
||||
//ammo = 2, fmode = 1
|
||||
obj.NextFireMode
|
||||
obj.FireModeIndex mustEqual 1
|
||||
obj.AmmoTypeIndex mustEqual 2
|
||||
obj.AmmoType mustEqual Ammo.rocket
|
||||
//ammo = 3, fmode = 1
|
||||
obj.NextAmmoType
|
||||
obj.AmmoTypeIndex mustEqual 3
|
||||
obj.AmmoType mustEqual Ammo.frag_cartridge
|
||||
//ammo = 4, fmode = 1
|
||||
obj.NextAmmoType
|
||||
obj.AmmoTypeIndex mustEqual 4
|
||||
obj.AmmoType mustEqual Ammo.jammer_cartridge
|
||||
//ammo = 0, fmode = 0
|
||||
obj.NextFireMode
|
||||
obj.FireModeIndex mustEqual 0
|
||||
obj.AmmoTypeIndex mustEqual 0
|
||||
obj.AmmoType mustEqual Ammo.bullet_9mm
|
||||
//ammo = 1, fmode = 0
|
||||
obj.NextAmmoType
|
||||
obj.AmmoTypeIndex mustEqual 1
|
||||
obj.AmmoType mustEqual Ammo.bullet_9mm_AP
|
||||
//ammo = 5, fmode = 1
|
||||
obj.NextFireMode
|
||||
obj.NextAmmoType
|
||||
obj.FireModeIndex mustEqual 1
|
||||
obj.AmmoTypeIndex mustEqual 5
|
||||
obj.AmmoType mustEqual Ammo.plasma_cartridge
|
||||
//ammo = 2, fmode = 1
|
||||
obj.NextAmmoType
|
||||
obj.AmmoTypeIndex mustEqual 2
|
||||
obj.AmmoType mustEqual Ammo.rocket
|
||||
}
|
||||
}
|
||||
|
||||
"Kit" should {
|
||||
"define" in {
|
||||
val sample = KitDefinition(Kits.medkit)
|
||||
sample.ObjectId mustEqual medkit.ObjectId
|
||||
sample.Tile.width mustEqual medkit.Tile.width
|
||||
sample.Tile.height mustEqual medkit.Tile.height
|
||||
sample.Tile.Width mustEqual medkit.Tile.Width
|
||||
sample.Tile.Height mustEqual medkit.Tile.Height
|
||||
}
|
||||
|
||||
"construct" in {
|
||||
|
|
@ -200,8 +240,8 @@ class EquipmentTest extends Specification {
|
|||
sample.Modes.head mustEqual DeployedItem.tank_traps
|
||||
sample.Modes(1) mustEqual DeployedItem.portable_manned_turret_tr
|
||||
sample.Modes(2) mustEqual DeployedItem.deployable_shield_generator
|
||||
sample.Tile.width mustEqual InventoryTile.Tile63.width
|
||||
sample.Tile.height mustEqual InventoryTile.Tile63.height
|
||||
sample.Tile.Width mustEqual InventoryTile.Tile63.Width
|
||||
sample.Tile.Height mustEqual InventoryTile.Tile63.Height
|
||||
}
|
||||
|
||||
"construct" in {
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(9, 6)
|
||||
obj += 0 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 45
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(0, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.length mustEqual 1
|
||||
|
|
@ -91,8 +91,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(9, 6)
|
||||
obj += 3 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 45
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(3, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.length mustEqual 1
|
||||
|
|
@ -125,8 +125,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(9, 6)
|
||||
obj += 0 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 45
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(0, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.length mustEqual 1
|
||||
|
|
@ -159,8 +159,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(9, 6)
|
||||
obj += 27 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 45
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(27, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.length mustEqual 1
|
||||
|
|
@ -205,8 +205,8 @@ class InventoryTest extends Specification {
|
|||
val obj : GridInventory = GridInventory(12, 9)
|
||||
obj += 39 -> bullet9mmBox1
|
||||
obj.Capacity mustEqual 99 //108 - 9
|
||||
val w = bullet9mmBox2.Tile.width
|
||||
val h = bullet9mmBox2.Tile.height
|
||||
val w = bullet9mmBox2.Tile.Width
|
||||
val h = bullet9mmBox2.Tile.Height
|
||||
val list0 = obj.CheckCollisionsAsList(0, w, h)
|
||||
list0 match {
|
||||
case scala.util.Success(list) => list.isEmpty mustEqual true
|
||||
|
|
|
|||
110
common/src/test/scala/objects/VehicleSpawnPadTest.scala
Normal file
110
common/src/test/scala/objects/VehicleSpawnPadTest.scala
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects
|
||||
|
||||
import akka.actor.{ActorRef, Props}
|
||||
import net.psforever.objects.serverobject.pad.{VehicleSpawnControl, VehicleSpawnPad}
|
||||
import net.psforever.objects.vehicles.VehicleControl
|
||||
import net.psforever.objects.{GlobalDefinitions, Player, Vehicle}
|
||||
import net.psforever.packet.game.PlanetSideGUID
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, Vector3}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
import scala.concurrent.duration.Duration
|
||||
|
||||
class VehicleSpawnPadTest extends Specification {
|
||||
"VehicleSpawnPadDefinition" should {
|
||||
"define" in {
|
||||
GlobalDefinitions.spawn_pad.ObjectId mustEqual 800
|
||||
}
|
||||
}
|
||||
|
||||
"VehicleSpawnPad" should {
|
||||
"construct" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor mustEqual ActorRef.noSender
|
||||
obj.Definition mustEqual GlobalDefinitions.spawn_pad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl1Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"construct" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor = system.actorOf(Props(classOf[VehicleSpawnControl], obj), "door")
|
||||
assert(obj.Actor != ActorRef.noSender)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl2Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"spawn a vehicle" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor = system.actorOf(Props(classOf[VehicleSpawnControl], obj), "door")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
player.Spawn
|
||||
val vehicle = Vehicle(GlobalDefinitions.two_man_assault_buggy)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
vehicle.Actor = system.actorOf(Props(classOf[VehicleControl], vehicle), "vehicle")
|
||||
|
||||
obj.Actor ! VehicleSpawnPad.VehicleOrder(player, vehicle)
|
||||
val reply = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply == VehicleSpawnPad.ConcealPlayer) //explicit: isInstanceOf does not work
|
||||
|
||||
val reply2 = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply2.isInstanceOf[VehicleSpawnPad.LoadVehicle])
|
||||
assert(reply2.asInstanceOf[VehicleSpawnPad.LoadVehicle].vehicle == vehicle)
|
||||
assert(reply2.asInstanceOf[VehicleSpawnPad.LoadVehicle].pad == obj)
|
||||
|
||||
player.VehicleOwned = vehicle
|
||||
val reply3 = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply3.isInstanceOf[VehicleSpawnPad.PlayerSeatedInVehicle])
|
||||
assert(reply3.asInstanceOf[VehicleSpawnPad.PlayerSeatedInVehicle].vehicle == vehicle)
|
||||
|
||||
val reply4 = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply4.isInstanceOf[VehicleSpawnPad.SpawnPadBlockedWarning])
|
||||
assert(reply4.asInstanceOf[VehicleSpawnPad.SpawnPadBlockedWarning].vehicle == vehicle)
|
||||
assert(reply4.asInstanceOf[VehicleSpawnPad.SpawnPadBlockedWarning].warning_count > 0)
|
||||
|
||||
vehicle.Position = Vector3(11f, 0f, 0f) //greater than 10m
|
||||
val reply5 = receiveOne(Duration.create(10000, "ms"))
|
||||
assert(reply5.isInstanceOf[VehicleSpawnPad.SpawnPadUnblocked])
|
||||
assert(reply5.asInstanceOf[VehicleSpawnPad.SpawnPadUnblocked].vehicle_guid == vehicle.GUID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl3Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"not spawn a vehicle if player is dead" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor = system.actorOf(Props(classOf[VehicleSpawnControl], obj), "door")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
val vehicle = Vehicle(GlobalDefinitions.two_man_assault_buggy)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
vehicle.Actor = system.actorOf(Props(classOf[VehicleControl], vehicle), "vehicle")
|
||||
|
||||
obj.Actor ! VehicleSpawnPad.VehicleOrder(player, vehicle)
|
||||
val reply = receiveOne(Duration.create(5000, "ms"))
|
||||
assert(reply == null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleSpawnControl4Test extends ActorTest() {
|
||||
"VehicleSpawnControl" should {
|
||||
"not spawn a vehicle if vehicle Actor is missing" in {
|
||||
val obj = VehicleSpawnPad(GlobalDefinitions.spawn_pad)
|
||||
obj.Actor = system.actorOf(Props(classOf[VehicleSpawnControl], obj), "door")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
player.Spawn
|
||||
val vehicle = Vehicle(GlobalDefinitions.two_man_assault_buggy)
|
||||
vehicle.GUID = PlanetSideGUID(1)
|
||||
|
||||
obj.Actor ! VehicleSpawnPad.VehicleOrder(player, vehicle)
|
||||
val reply = receiveOne(Duration.create(5000, "ms"))
|
||||
assert(reply == null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,8 +44,8 @@ class VehicleTest extends Specification {
|
|||
fury.Weapons.size mustEqual 1
|
||||
fury.Weapons.get(0) mustEqual None
|
||||
fury.Weapons.get(1) mustEqual Some(GlobalDefinitions.fury_weapon_systema)
|
||||
fury.TrunkSize.width mustEqual 11
|
||||
fury.TrunkSize.height mustEqual 11
|
||||
fury.TrunkSize.Width mustEqual 11
|
||||
fury.TrunkSize.Height mustEqual 11
|
||||
fury.TrunkOffset mustEqual 30
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.{GlobalDefinitions, Player, Tool}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class AirVehicleTerminalTest extends Specification {
|
||||
"Air_Vehicle_Terminal" should {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.air_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a reaver ('lightgunship')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.air_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "lightgunship", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.lightgunship
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('reaver')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "reaver", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class DropshipVehicleTerminalTest extends Specification {
|
||||
"Dropship_Vehicle_Terminal" should {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a galaxy ('dropship')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "dropship", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.dropship
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('galaxy')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.dropship_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "galaxy", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class GroundVehicleTerminalTest extends Specification {
|
||||
"Ground_Vehicle_Terminal" should {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a harasser ('two_man_assault_buggy')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.two_man_assault_buggy
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('harasser')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,3 +71,40 @@ class CertTerminalControl3Test extends ActorTest() {
|
|||
assert(reply2.response == Terminal.SellCertification(CertificationType.MediumAssault, 2))
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleTerminalControl1Test extends ActorTest() {
|
||||
"TerminalControl can be used to buy a vehicle ('two_man_assault_buggy')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Actor = system.actorOf(Props(classOf[TerminalControl], terminal), "test-cert-term")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Actor ! Terminal.Request(player, msg)
|
||||
val reply = receiveOne(Duration.create(500, "ms"))
|
||||
assert(reply.isInstanceOf[Terminal.TerminalMessage])
|
||||
val reply2 = reply.asInstanceOf[Terminal.TerminalMessage]
|
||||
assert(reply2.player == player)
|
||||
assert(reply2.msg == msg)
|
||||
assert(reply2.response.isInstanceOf[Terminal.BuyVehicle])
|
||||
val reply3 = reply2.response.asInstanceOf[Terminal.BuyVehicle]
|
||||
assert(reply3.vehicle.Definition == GlobalDefinitions.two_man_assault_buggy)
|
||||
assert(reply3.loadout == Nil) //TODO
|
||||
}
|
||||
}
|
||||
|
||||
class VehicleTerminalControl2Test extends ActorTest() {
|
||||
"TerminalControl can be used to warn about not buy a vehicle ('harasser')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.ground_vehicle_terminal)
|
||||
terminal.Actor = system.actorOf(Props(classOf[TerminalControl], terminal), "test-cert-term")
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Actor ! Terminal.Request(player, msg)
|
||||
val reply = receiveOne(Duration.create(500, "ms"))
|
||||
assert(reply.isInstanceOf[Terminal.TerminalMessage])
|
||||
val reply2 = reply.asInstanceOf[Terminal.TerminalMessage]
|
||||
assert(reply2.player == player)
|
||||
assert(reply2.msg == msg)
|
||||
assert(reply2.response == Terminal.NoDeal())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package objects.terminal
|
||||
|
||||
import akka.actor.ActorRef
|
||||
import net.psforever.objects.{GlobalDefinitions, Player}
|
||||
import net.psforever.objects.serverobject.terminals.Terminal
|
||||
import net.psforever.packet.game.{ItemTransactionMessage, PlanetSideGUID}
|
||||
import net.psforever.types.{CharacterGender, PlanetSideEmpire, TransactionType}
|
||||
import org.specs2.mutable.Specification
|
||||
|
||||
class VehicleTerminalCombinedTest extends Specification {
|
||||
"Ground_Vehicle_Terminal" should {
|
||||
val player = Player("test", PlanetSideEmpire.TR, CharacterGender.Male, 0, 0)
|
||||
|
||||
"construct" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
terminal.Actor mustEqual ActorRef.noSender
|
||||
}
|
||||
|
||||
"player can buy a ground vehicle, the harasser ('two_man_assault_buggy')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "two_man_assault_buggy", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.two_man_assault_buggy
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can buy a flying vehicle, the reaver ('lightgunship')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "lightgunship", 0, PlanetSideGUID(0))
|
||||
val reply = terminal.Request(player, msg)
|
||||
reply.isInstanceOf[Terminal.BuyVehicle] mustEqual true
|
||||
val reply2 = reply.asInstanceOf[Terminal.BuyVehicle]
|
||||
reply2.vehicle.Definition mustEqual GlobalDefinitions.lightgunship
|
||||
reply2.loadout mustEqual Nil //TODO
|
||||
}
|
||||
|
||||
"player can not buy a fake vehicle ('harasser')" in {
|
||||
val terminal = Terminal(GlobalDefinitions.vehicle_terminal_combined)
|
||||
val msg = ItemTransactionMessage(PlanetSideGUID(1), TransactionType.Buy, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
|
||||
terminal.Request(player, msg) mustEqual Terminal.NoDeal()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue