Overwrite shortcut slots 2/3/4 with installed implants, and allow active implants to be reactivated

This commit is contained in:
Mazo 2020-03-29 23:14:16 +01:00
parent 4b25205c32
commit 9d3a163545
3 changed files with 32 additions and 2 deletions

View file

@ -44,9 +44,12 @@ class PlayerControl(player : Player) extends Actor
implantSlot.Active = false
player.Zone.AvatarEvents ! AvatarServiceMessage(player.Zone.Id, AvatarAction.PlanetsideAttribute(player.GUID, 28, player.Implant(slot).id * 2)) // Deactivation sound / effect
player.Zone.AvatarEvents ! AvatarServiceMessage(player.Zone.Id, AvatarAction.DeactivateImplantSlot(player.GUID, slot))
} else if (status == 1 && implantSlot.Initialized && !implantSlot.Active && !player.Fatigued) {
} else if (status == 1 && implantSlot.Initialized && !player.Fatigued) {
implantSlot.Installed match {
case Some(implant: ImplantDefinition) =>
if(implantSlot.Active) {
log.warn(s"Implant ${slot} is already active, but activating again")
}
implantSlot.Active = true
if (implant.ActivationStaminaCost >= 0) {
@ -61,6 +64,9 @@ class PlayerControl(player : Player) extends Actor
player.Zone.AvatarEvents ! AvatarServiceMessage(player.Zone.Id, AvatarAction.ActivateImplantSlot(player.GUID, slot))
}
}
else {
log.warn(s"Can't handle ImplantActivation: Player GUID: ${player.GUID} Slot ${slot} Status: ${status} Initialized: ${implantSlot.Initialized} Active: ${implantSlot.Active} Fatigued: ${player.Fatigued}")
}
case Player.UninitializeImplant(slot: Int) => {
PlayerControl.UninitializeImplant(player, slot)

View file

@ -2,7 +2,7 @@
package net.psforever.packet.game
import net.psforever.packet.{GamePacketOpcode, Marshallable, PacketHelpers, PlanetSideGamePacket}
import net.psforever.types.PlanetSideGUID
import net.psforever.types.{ImplantType, PlanetSideGUID}
import scodec.Codec
import scodec.codecs._
@ -85,6 +85,23 @@ final case class CreateShortcutMessage(player_guid : PlanetSideGUID,
object Shortcut extends Marshallable[Shortcut] {
// Convenient predefined Shortcuts for the Medkit and Implants
/**
A map to convert between ImplantTypes and Implant Shortcuts
*/
final lazy val ImplantsMap = Map(
ImplantType.AdvancedRegen->REGENERATION,
ImplantType.Targeting->ENHANCED_TARGETING,
ImplantType.AudioAmplifier->AUDIO_AMPLIFIER,
ImplantType.DarklightVision->DARKLIGHT_VISION,
ImplantType.MeleeBooster->MELEE_BOOSTER,
ImplantType.PersonalShield->PERSONAL_SHIELD,
ImplantType.RangeMagnifier->RANGE_MAGNIFIER,
ImplantType.SecondWind->SECOND_WIND,
ImplantType.SilentRun->SENSOR_SHIELD,
ImplantType.Surge->SURGE
)
/**
* Preset for the Audio Amplifier implant. */
final val AUDIO_AMPLIFIER : Some[Shortcut] = Some(Shortcut(2, "audio_amplifier"))

View file

@ -3374,7 +3374,14 @@ class WorldSessionActor extends Actor
player.Actor ! Player.ImplantInitializationStart(slot)
}
//TODO if this implant is Installed but does not have shortcut, add to a free slot or write over slot 61/62/63
// for now, just write into slots 2, 3 and 4
Shortcut.ImplantsMap(implantSlot.Implant) match {
case Some(shortcut : Shortcut) =>
sendResponse(CreateShortcutMessage(guid, slot + 2, 0, addShortcut = true, Some(shortcut)))
case _ => log.warn(s"Could not find shortcut for implant ${implantSlot.Implant.toString()}")
}
})
sendResponse(PlanetsideAttributeMessage(PlanetSideGUID(0), 82, 0))
//TODO if Medkit does not have shortcut, add to a free slot or write over slot 64
sendResponse(CreateShortcutMessage(guid, 1, 0, true, Shortcut.MEDKIT))