Files
Alexis 21b4095dfd [MDB IGNORE] [IDB IGNORE] Upstream Sync - 04/17/2026 (#5453)
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>
2026-05-16 00:56:00 +02:00

167 lines
6.3 KiB
Plaintext

// Ethereals:
/// How long it takes an ethereal to drain or charge APCs. Also used as a spam limiter.
#define ETHEREAL_APC_DRAIN_TIME (3 SECONDS)
/// How much power ethereals gain/drain from APCs.
#define ETHEREAL_APC_POWER_GAIN (0.1 * STANDARD_ETHEREAL_CHARGE)
/// Delay between ethereal action and balloon alert, to avoid colliding with previously queued balloon alerts.
#define ETHEREAL_APC_ALERT_DELAY (0.75 SECONDS)
/obj/machinery/power/apc/attack_hand_secondary(mob/user, list/modifiers)
. = ..()
if(!can_interact(user))
return
if(!user.can_perform_action(src, ALLOW_SILICON_REACH) || !isturf(loc))
return
if(!ishuman(user))
return
var/mob/living/carbon/human/human_user = user
var/obj/item/organ/stomach/ethereal/maybe_ethereal_stomach = human_user.get_organ_slot(ORGAN_SLOT_STOMACH)
if(!istype(maybe_ethereal_stomach))
togglelock(user)
else
if(maybe_ethereal_stomach.cell.charge() >= ETHEREAL_CHARGE_NORMAL)
togglelock(user)
ethereal_interact(human_user, maybe_ethereal_stomach, modifiers)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/// Special behavior for when an ethereal interacts with an APC.
/obj/machinery/power/apc/proc/ethereal_interact(mob/living/carbon/human/user, obj/item/organ/stomach/ethereal/used_stomach, list/modifiers)
if(!LAZYACCESS(modifiers, RIGHT_CLICK))
return
if(isnull(cell))
return
if(used_stomach.drain_time > world.time)
return
if(user.combat_mode)
discharge_to_ethereal(user, used_stomach)
else
charge_from_ethereal(user, used_stomach)
/// Handles discharging our internal cell to an ethereal and their stomach
/obj/machinery/power/apc/proc/discharge_to_ethereal(mob/living/carbon/human/user, obj/item/organ/stomach/ethereal/used_stomach)
var/half_max_charge = cell.max_charge() / 2
// Ethereals can't drain APCs under half charge, so that they are forced to look to alternative power sources if the station is running low
if(cell.charge() < half_max_charge)
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, balloon_alert), user, "safeties prevent draining!"), ETHEREAL_APC_ALERT_DELAY)
return
var/obj/item/stock_parts/power_store/stomach_cell = used_stomach.cell
used_stomach.drain_time = world.time + ETHEREAL_APC_DRAIN_TIME
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, balloon_alert), user, "draining power..."), ETHEREAL_APC_ALERT_DELAY)
while(do_after(user, ETHEREAL_APC_DRAIN_TIME, target = src))
if(isnull(used_stomach) || (used_stomach != user.get_organ_slot(ORGAN_SLOT_STOMACH)))
balloon_alert(user, "stomach removed!?")
return
if(isnull(cell))
balloon_alert(user, "cell removed!")
return
if(cell.charge() < half_max_charge)
balloon_alert(user, "safeties kicked in!")
return
var/our_available_charge = cell.charge() - half_max_charge
var/stomach_used_charge = stomach_cell.used_charge()
var/potential_charge = min(our_available_charge, stomach_used_charge)
var/to_drain = min(ETHEREAL_APC_POWER_GAIN, potential_charge)
var/energy_drained = cell.use(to_drain, force = TRUE)
used_stomach.adjust_charge(energy_drained)
if(stomach_cell.used_charge() <= 0)
balloon_alert(user, "your charge is full!")
return
if(cell.charge() <= 0)
balloon_alert(user, "apc is empty!")
return
/// Handles charging our internal cell from an ethereal and their stomach
/obj/machinery/power/apc/proc/charge_from_ethereal(mob/living/carbon/human/user, obj/item/organ/stomach/ethereal/used_stomach)
if(cell.charge() >= cell.max_charge())
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, balloon_alert), user, "apc full!"), ETHEREAL_APC_ALERT_DELAY)
return
var/obj/item/stock_parts/power_store/stomach_cell = used_stomach.cell
if(stomach_cell.charge() <= 0)
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, balloon_alert), user, "charge is too low!"), ETHEREAL_APC_ALERT_DELAY)
return
used_stomach.drain_time = world.time + ETHEREAL_APC_DRAIN_TIME
addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, balloon_alert), user, "transferring power..."), ETHEREAL_APC_ALERT_DELAY)
if(!do_after(user, ETHEREAL_APC_DRAIN_TIME, target = src))
return
if(isnull(used_stomach) || (used_stomach != user.get_organ_slot(ORGAN_SLOT_STOMACH)))
balloon_alert(user, "stomach removed!?")
return
if(isnull(cell))
balloon_alert(user, "cell removed!")
return
var/stomach_charge = stomach_cell.charge()
var/our_used_charge = cell.used_charge()
var/potential_charge = min(stomach_charge, our_used_charge)
var/to_drain = min(ETHEREAL_APC_POWER_GAIN, potential_charge)
var/energy_drained = used_stomach.adjust_charge(-to_drain)
cell.give(-energy_drained)
if(cell.used_charge() <= 0)
balloon_alert(user, "apc is full!")
return
if(stomach_cell.charge() <= 0)
balloon_alert(user, "out of charge!")
return
// attack with hand - remove cell (if cover open) or interact with the APC
/obj/machinery/power/apc/attack_hand(mob/user, list/modifiers)
. = ..()
if(.)
return
if(opened && (!issilicon(user)))
if(cell)
user.visible_message(span_notice("[user] removes \the [cell] from [src]!"))
balloon_alert(user, "cell removed")
user.put_in_hands(cell)
return
if((machine_stat & MAINT) && !opened) //no board; no interface
return
/obj/machinery/power/apc/blob_act(obj/structure/blob/B)
atom_break()
/obj/machinery/power/apc/take_damage(damage_amount, damage_type = BRUTE, damage_flag = "", sound_effect = TRUE, attack_dir, armor_penetration = 0)
// APC being at 0 integrity doesnt delete it outright. Combined with take_damage this might cause runtimes.
if(machine_stat & BROKEN && atom_integrity <= 0)
if(sound_effect)
play_attack_sound(damage_amount, damage_type, damage_flag)
return
return ..()
/obj/machinery/power/apc/run_atom_armor(damage_amount, damage_type, damage_flag = 0, attack_dir)
if(machine_stat & BROKEN)
return damage_amount
. = ..()
/obj/machinery/power/apc/proc/can_use(mob/user, loud = 0) //used by attack_hand() and Topic()
if(isAdminGhostAI(user))
return TRUE
if(!HAS_SILICON_ACCESS(user))
return TRUE
. = TRUE
if(isAI(user) || iscyborg(user))
if(aidisabled)
. = FALSE
else if(istype(malfai) && !(malfai == user || (user in malfai.connected_robots)))
. = FALSE
if (!. && !loud)
balloon_alert(user, "it's disabled!")
return .
/obj/machinery/power/apc/shock(mob/living/shocking, chance, shock_source, siemens_coeff)
if(isalien(shocking))
return FALSE
shock_source = src
return ..()
#undef ETHEREAL_APC_DRAIN_TIME
#undef ETHEREAL_APC_POWER_GAIN
#undef ETHEREAL_APC_ALERT_DELAY