mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-28 10:31:59 +00:00
* Adds in the smoothbore disablers. * Resolve merge conflicts + ammo HUD stuff * No better way to do this than a skyrat edit since the proc sleeps * Fixes a changed path --------- Co-authored-by: CRITAWAKETS <sebastienracicot@hotmail.com> Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
61 lines
2.4 KiB
Plaintext
61 lines
2.4 KiB
Plaintext
// Cranking feature on the laser musket and smoothbore disabler, could probably be used on more than guns
|
|
/datum/component/crank_recharge
|
|
/// Our cell to charge
|
|
var/obj/item/stock_parts/cell/charging_cell
|
|
/// How much charge we give our cell on each crank
|
|
var/charge_amount
|
|
/// How long is the cooldown time between each charge
|
|
var/cooldown_time
|
|
/// The sound used when charging, renember to adjust the cooldown time to keep it sensible
|
|
var/charge_sound
|
|
/// How long is the cooldown between charging sounds
|
|
var/charge_sound_cooldown_time
|
|
/// Are we currently charging
|
|
var/is_charging = FALSE
|
|
COOLDOWN_DECLARE(charge_sound_cooldown)
|
|
|
|
/datum/component/crank_recharge/Initialize(charging_cell, charge_amount = 500, cooldown_time = 2 SECONDS, charge_sound = 'sound/weapons/laser_crank.ogg', charge_sound_cooldown_time = 1.8 SECONDS)
|
|
. = ..()
|
|
if(!isitem(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
if(isnull(charging_cell) || !istype(charging_cell, /obj/item/stock_parts/cell))
|
|
return COMPONENT_INCOMPATIBLE
|
|
src.charging_cell = charging_cell
|
|
src.charge_amount = charge_amount
|
|
src.cooldown_time = cooldown_time
|
|
src.charge_sound = charge_sound
|
|
src.charge_sound_cooldown_time = charge_sound_cooldown_time
|
|
|
|
/datum/component/crank_recharge/RegisterWithParent()
|
|
. = ..()
|
|
RegisterSignal(parent, COMSIG_ITEM_ATTACK_SELF, PROC_REF(on_attack_self))
|
|
|
|
/datum/component/crank_recharge/UnregisterFromParent()
|
|
. = ..()
|
|
UnregisterSignal(parent, COMSIG_ITEM_ATTACK_SELF)
|
|
|
|
/datum/component/crank_recharge/proc/on_attack_self(obj/source, mob/living/user as mob)
|
|
SIGNAL_HANDLER
|
|
|
|
INVOKE_ASYNC(src, PROC_REF(crank), source, user) //game doesnt like signal handler and do afters mingling
|
|
|
|
/datum/component/crank_recharge/proc/crank(obj/source, mob/user)
|
|
if(charging_cell.charge >= charging_cell.maxcharge)
|
|
source.balloon_alert(user, "already charged!")
|
|
return
|
|
if(is_charging)
|
|
return
|
|
is_charging = TRUE
|
|
if(COOLDOWN_FINISHED(src, charge_sound_cooldown))
|
|
COOLDOWN_START(src, charge_sound_cooldown, charge_sound_cooldown_time)
|
|
playsound(source, charge_sound, 40)
|
|
source.balloon_alert(user, "charging...")
|
|
if(!do_after(user, cooldown_time, source, interaction_key = DOAFTER_SOURCE_CHARGE_CRANKRECHARGE))
|
|
is_charging = FALSE
|
|
return
|
|
charging_cell.give(charge_amount)
|
|
SEND_SIGNAL(parent, COMSIG_UPDATE_AMMO_HUD) // SKYRAT EDIT ADDITION - AMMO COUNT HUD
|
|
source.update_appearance()
|
|
is_charging = FALSE
|
|
source.balloon_alert(user, "charged")
|