PSF-LoginServer/src/main/scala/net/psforever/objects/Tools.scala
Fate-JH 78f970a4ac
Spud Gun (#572)
* initial spiker logic for charging mechanic; it's functional but doesn't work exactly by the numbers say it should

* no damage degrade for radial damage; charge mode features, including damage on the projectile and fire mode on the weapon; the Spiker's damage output is pretty close to accurate

* ammunition drain timer works correctly; no need for the progress completion function; new formatting sucks

* dial back on fire mode changes; stop excessive weapon discharge case; comments

* master merge; test fix (when did it change?)

* test repair; fixed unintentional side-effect of instantiation of StanDamProf
2020-09-05 09:08:18 -04:00

37 lines
1.2 KiB
Scala

// Copyright (c) 2020 PSForever
package net.psforever.objects
import net.psforever.objects.equipment.ChargeFireModeDefinition
import net.psforever.packet.game.QuantityUpdateMessage
import net.psforever.services.Service
import net.psforever.services.avatar.{AvatarAction, AvatarServiceMessage}
object Tools {
/**
*
* @param player the player performing the revive action
* @param tool the tool being used to execute the attack;
* should have a selected chargeable fire mode
* @param progress the current progress value
* @see `ChargeFireModeDefinition`
* @see `QuantityUpdateMessage`
* @return `true`, if the next cycle of progress should occur;
* `false`, otherwise
*/
def ChargeFireMode(player: Player, tool: Tool)(progress: Float): Boolean = {
tool.FireMode match {
case mode: ChargeFireModeDefinition if tool.Magazine > 0 =>
val magazine = tool.Magazine -= mode.RoundsPerInterval
player.Zone.AvatarEvents ! AvatarServiceMessage(
player.Name,
AvatarAction.SendResponse(
Service.defaultPlayerGUID,
QuantityUpdateMessage(tool.AmmoSlot.Box.GUID, magazine)
)
)
player.isAlive
case _ =>
false
}
}
}