mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-18 03:26:31 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
169 lines
6.5 KiB
Plaintext
169 lines
6.5 KiB
Plaintext
/obj/machinery/power/energy_accumulator/tesla_coil
|
|
name = "tesla coil"
|
|
desc = "For the union!"
|
|
icon = 'icons/obj/machines/engine/tesla_coil.dmi'
|
|
icon_state = "coil0"
|
|
base_icon_state = "coil"
|
|
|
|
// Executing a traitor caught releasing tesla was never this fun!
|
|
can_buckle = TRUE
|
|
buckle_lying = 0
|
|
buckle_requires_restraints = TRUE
|
|
can_change_cable_layer = TRUE
|
|
|
|
circuit = /obj/item/circuitboard/machine/tesla_coil
|
|
|
|
///Flags of the zap that the coil releases when the wire is pulsed
|
|
var/zap_flags = ZAP_MOB_DAMAGE | ZAP_OBJ_DAMAGE | ZAP_LOW_POWER_GEN
|
|
///Multiplier for power conversion
|
|
var/input_power_multiplier = 1
|
|
///Cooldown between pulsed zaps
|
|
var/zap_cooldown = 100
|
|
///Reference to the last zap done
|
|
var/last_zap = 0
|
|
|
|
//Variables to calculate sound based on stored_energy to give engineers an audioclue of the magnitude of energy production.
|
|
///Calculated range of zap sounds based on power
|
|
var/zap_sound_range = 0
|
|
///Calculated volume of zap sounds based on power
|
|
var/zap_sound_volume = 0
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/anchored
|
|
anchored = TRUE
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/Initialize(mapload)
|
|
. = ..()
|
|
set_wires(new /datum/wires/tesla_coil(src))
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/cable_layer_act(mob/living/user, obj/item/tool)
|
|
if(panel_open)
|
|
return NONE
|
|
if(anchored)
|
|
balloon_alert(user, "unanchor first!")
|
|
return ITEM_INTERACT_BLOCKING
|
|
return ..()
|
|
|
|
/* SKYRAT EDIT CHANGE BEGIN - MOVED TO modular_skyrat/master_files/code/modules/power/tesla/coil.dm
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/RefreshParts()
|
|
. = ..()
|
|
var/power_multiplier = 0
|
|
zap_cooldown = 100
|
|
for(var/datum/stock_part/capacitor/capacitor in component_parts)
|
|
power_multiplier += capacitor.tier
|
|
zap_cooldown -= (capacitor.tier * 20)
|
|
input_power_multiplier = max(1 * (power_multiplier / 8), 0.25) //Max out at 50% efficency.
|
|
*/// SKYRAT EDIT CHANGE END
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/examine(mob/user)
|
|
. = ..()
|
|
if(in_range(user, src) || isobserver(user))
|
|
. += span_notice("The status display reads:<br>" + \
|
|
"Power generation at <b>[input_power_multiplier*100]%</b>.<br>" + \
|
|
"Shock interval at <b>[zap_cooldown*0.1]</b> seconds.<br>" + \
|
|
"Stored <b>[display_energy(get_stored_joules())]</b>.<br>" + \
|
|
"Processing <b>[display_power(processed_energy)]</b>.")
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/set_anchored(anchorvalue)
|
|
. = ..()
|
|
update_cable_icons_on_turf(get_turf(src))
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/wrench_act(mob/living/user, obj/item/tool)
|
|
. = ..()
|
|
default_unfasten_wrench(user, tool)
|
|
return ITEM_INTERACT_SUCCESS
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/update_icon_state()
|
|
. = ..()
|
|
icon_state = "[base_icon_state][panel_open ? "_open" : ""][anchored]"
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/screwdriver_act(mob/living/user, obj/item/tool)
|
|
return default_deconstruction_screwdriver(user, tool)
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/crowbar_act(mob/living/user, obj/item/tool)
|
|
return default_deconstruction_crowbar(user, tool)
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/process(seconds_per_tick)
|
|
. = ..()
|
|
zap_sound_volume = min(energy_to_power(processed_energy) / (4 KILO WATTS), 100) // 1 sound volume per 4kW.
|
|
zap_sound_range = min(energy_to_power(processed_energy) / (80 KILO WATTS), 10) // 1 sound range per 80kW.
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/zap_act(power, zap_flags)
|
|
if(!anchored || panel_open)
|
|
return ..()
|
|
ADD_TRAIT(src, TRAIT_BEING_SHOCKED, WAS_SHOCKED)
|
|
addtimer(TRAIT_CALLBACK_REMOVE(src, TRAIT_BEING_SHOCKED, WAS_SHOCKED), 1 SECONDS)
|
|
flick("[base_icon_state]hit", src)
|
|
if(!(zap_flags & ZAP_GENERATES_POWER)) //Prevent infinite recursive power
|
|
return 0
|
|
if(zap_flags & ZAP_LOW_POWER_GEN)
|
|
power /= 10
|
|
zap_buckle_check(power)
|
|
var/power_removed = powernet ? power * input_power_multiplier : power
|
|
stored_energy += max(power_removed, 0)
|
|
return max(power - power_removed, 0) //You get back the amount we didn't use
|
|
|
|
/obj/machinery/power/energy_accumulator/tesla_coil/proc/zap()
|
|
if((last_zap + zap_cooldown) > world.time || !powernet)
|
|
return FALSE
|
|
last_zap = world.time
|
|
var/power = (powernet.avail) * 0.2 * input_power_multiplier //Always always always use more then you output for the love of god
|
|
power = min(surplus(), power) //Take the smaller of the two
|
|
add_load(power)
|
|
playsound(src.loc, 'sound/effects/magic/lightningshock.ogg', zap_sound_volume, TRUE, zap_sound_range)
|
|
tesla_zap(source = src, zap_range = 10, power = power, cutoff = 1e3, zap_flags = zap_flags)
|
|
zap_buckle_check(power)
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod
|
|
name = "grounding rod"
|
|
desc = "Keeps an area from being fried by Edison's Bane."
|
|
icon = 'icons/obj/machines/engine/tesla_coil.dmi'
|
|
icon_state = "grounding_rod0"
|
|
base_icon_state = "grounding_rod"
|
|
anchored = FALSE
|
|
density = TRUE
|
|
wants_powernet = FALSE
|
|
|
|
circuit = /obj/item/circuitboard/machine/grounding_rod
|
|
|
|
can_buckle = TRUE
|
|
buckle_lying = 0
|
|
buckle_requires_restraints = TRUE
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod/anchored
|
|
anchored = TRUE
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod/examine(mob/user)
|
|
. = ..()
|
|
if(in_range(user, src) || isobserver(user))
|
|
. += span_notice("The status display reads:<br>" + \
|
|
"Recently grounded <b>[display_energy(get_stored_joules())]</b>.<br>" + \
|
|
"This energy would sustainably release <b>[display_power(calculate_sustainable_power(), convert = FALSE)]</b>.")
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod/wrench_act(mob/living/user, obj/item/tool)
|
|
. = ..()
|
|
default_unfasten_wrench(user, tool)
|
|
return ITEM_INTERACT_SUCCESS
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod/update_icon_state()
|
|
. = ..()
|
|
icon_state = "[base_icon_state][panel_open ? "_open" : ""][anchored]"
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod/screwdriver_act(mob/living/user, obj/item/tool)
|
|
return default_deconstruction_screwdriver(user, tool)
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod/crowbar_act(mob/living/user, obj/item/tool)
|
|
return default_deconstruction_crowbar(user, tool)
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod/zap_act(energy, zap_flags)
|
|
if(anchored && !panel_open)
|
|
flick("[base_icon_state]hit", src)
|
|
zap_buckle_check(energy)
|
|
stored_energy += energy
|
|
return 0
|
|
return ..()
|
|
|
|
/obj/machinery/power/energy_accumulator/grounding_rod/release_energy(joules = 0)
|
|
stored_energy -= joules
|
|
processed_energy = joules
|
|
return FALSE //Grounding rods don't release energy to the grid.
|