Vehicle Loadout Weapon Ammunition (#914)

* correcting vehicle loadout change to account for capacity of weapon magazine, not default ammunition box capacity

* inventory items in vehicle trunks express proper ammunition capacity
This commit is contained in:
Fate-JH 2021-08-25 10:36:33 -04:00 committed by GitHub
parent e0b3ed6fbf
commit 0bbe7e3959
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View file

@ -183,7 +183,7 @@ object Tool {
private var ammoTypeIndex: Int = 0 private var ammoTypeIndex: Int = 0
/** a reference to the actual `AmmoBox` of this slot */ /** a reference to the actual `AmmoBox` of this slot */
private var box: AmmoBox = AmmoBox(AmmoDefinition, fdef.Magazine) private var box: AmmoBox = AmmoBox(AmmoDefinition, MaxMagazine())
private var chamber = fdef.Chamber private var chamber = fdef.Chamber
def AmmoTypeIndex: Int = ammoTypeIndex def AmmoTypeIndex: Int = ammoTypeIndex
@ -223,6 +223,13 @@ object Tool {
Chamber Chamber
} }
def MaxMagazine(): Int = {
fdef.CustomMagazine.get(AmmoType) match {
case Some(value) => value
case None => fdef.Magazine
}
}
def Box: AmmoBox = box def Box: AmmoBox = box
def Box_=(toBox: AmmoBox): Option[AmmoBox] = { def Box_=(toBox: AmmoBox): Option[AmmoBox] = {

View file

@ -178,10 +178,10 @@ class VehicleControl(vehicle: Vehicle)
// (oldWeapons, weapons, afterInventory) // (oldWeapons, weapons, afterInventory)
//TODO for now, just refill ammo; assume weapons stay the same //TODO for now, just refill ammo; assume weapons stay the same
vehicle.Weapons vehicle.Weapons
.collect { case (_, slot : EquipmentSlot) if slot.Equipment.nonEmpty => slot.Equipment.get } .collect { case (_, slot: EquipmentSlot) if slot.Equipment.nonEmpty => slot.Equipment.get }
.collect { .collect {
case weapon : Tool => case weapon: Tool =>
weapon.AmmoSlots.foreach { ammo => ammo.Box.Capacity = ammo.Box.Definition.Capacity } weapon.AmmoSlots.foreach { ammo => ammo.Box.Capacity = ammo.MaxMagazine() }
} }
(Nil, Nil, afterInventory) (Nil, Nil, afterInventory)
} }
@ -486,11 +486,11 @@ class VehicleControl(vehicle: Vehicle)
if (obj.VisibleSlots.contains(slot)) zone.id else channel, if (obj.VisibleSlots.contains(slot)) zone.id else channel,
VehicleAction.SendResponse( VehicleAction.SendResponse(
Service.defaultPlayerGUID, Service.defaultPlayerGUID,
ObjectCreateMessage( ObjectCreateDetailedMessage(
definition.ObjectId, definition.ObjectId,
iguid, iguid,
ObjectCreateMessageParent(oguid, slot), ObjectCreateMessageParent(oguid, slot),
definition.Packet.ConstructorData(item).get definition.Packet.DetailedConstructorData(item).get
) )
) )
) )