From 59bc3157f4c931b006029175c821f69ef14e55f0 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Tue, 7 Jan 2025 20:35:45 -0600 Subject: [PATCH] More minor fixes (#3916) ## About The Pull Request Fixes dumb compile warning that annoys me, and optimizes APC process since it was apparently wasting time logging every single APC process tick for feedback, which... no. Not necessary. ## Why It's Good For The Game Small improvements are good ## Changelog :cl: /:cl: --------- Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> --- code/modules/mob/living/silicon/robot/life.dm | 2 +- .../computers/item/computer_power.dm | 4 +- code/modules/power/apc.dm | 41 +++++++++++------- code/modules/power/cell.dm | 4 +- code/modules/power/lighting.dm | 2 +- code/modules/recycling/disposal/bin.dm | 2 +- code/modules/surgery/organs/lungs.dm | 43 ------------------- 7 files changed, 32 insertions(+), 66 deletions(-) diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index 123726ce3c01..987b8b6c2a32 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -21,7 +21,7 @@ if(cell.charge <= 100) uneq_all() var/amt = clamp((lamp_enabled * lamp_intensity),1,cell.charge) //Lamp will use a max of 5 charge, depending on brightness of lamp. If lamp is off, borg systems consume 1 point of charge, or the rest of the cell if it's lower than that. - cell.use(amt) //Usage table: 1/tick if off/lowest setting, 4 = 4/tick, 6 = 8/tick, 8 = 12/tick, 10 = 16/tick + cell.use(amt, FALSE) //Usage table: 1/tick if off/lowest setting, 4 = 4/tick, 6 = 8/tick, 8 = 12/tick, 10 = 16/tick else uneq_all() low_power_mode = TRUE diff --git a/code/modules/modular_computers/computers/item/computer_power.dm b/code/modules/modular_computers/computers/item/computer_power.dm index d3c65f86ec35..8e5a8e2d0a21 100644 --- a/code/modules/modular_computers/computers/item/computer_power.dm +++ b/code/modules/modular_computers/computers/item/computer_power.dm @@ -13,10 +13,10 @@ if(battery_module && battery_module.battery && battery_module.battery.charge) var/obj/item/stock_parts/cell/cell = battery_module.battery - if(cell.use(amount * GLOB.CELLRATE)) + if(cell.use(amount * GLOB.CELLRATE, FALSE)) return TRUE else // Discharge the cell anyway. - cell.use(min(amount*GLOB.CELLRATE, cell.charge)) + cell.use(min(amount*GLOB.CELLRATE, cell.charge), FALSE) return FALSE return FALSE diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 48651a3146c4..a3cedcd401ea 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -286,7 +286,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25) has_electronics = APC_ELECTRONICS_SECURED // is starting with a power cell installed, create it and set its charge level if(cell_type) - cell = new cell_type + cell = new cell_type(src) cell.charge = start_charge * cell.maxcharge / 100 // (convert percentage to actual value) var/area/A = loc.loc @@ -1310,7 +1310,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25) if(cell && !shorted) // draw power from cell as before to power the area var/cellused = min(cell.charge, GLOB.CELLRATE * lastused_total) // clamp deduction to a max, amount left in cell - cell.use(cellused) + cell.use(cellused, FALSE) if(excess > lastused_total) // if power excess recharge the cell // by the same amount just used @@ -1345,23 +1345,33 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25) lighting = autoset(lighting, AUTOSET_FORCE_OFF) environ = autoset(environ, AUTOSET_FORCE_OFF) area.poweralert(0, src) - else if(cell.percent() < 15 && longtermpower < 0) // <15%, turn off lighting & equipment - equipment = autoset(equipment, AUTOSET_OFF) - lighting = autoset(lighting, AUTOSET_OFF) - environ = autoset(environ, AUTOSET_ON) - area.poweralert(0, src) - else if(cell.percent() < 30 && longtermpower < 0) // <30%, turn off equipment + else if(longtermpower < 0) + switch(cell.percent()) + if(0 to 15) + equipment = autoset(equipment, AUTOSET_OFF) + lighting = autoset(lighting, AUTOSET_OFF) + environ = autoset(environ, AUTOSET_ON) + area.poweralert(0, src) + if(15 to 30) + equipment = autoset(equipment, AUTOSET_OFF) + lighting = autoset(lighting, AUTOSET_ON) + environ = autoset(environ, AUTOSET_ON) + area.poweralert(0, src) + if(30 to 75) + equipment = autoset(equipment, AUTOSET_ON) + lighting = autoset(lighting, AUTOSET_ON) + environ = autoset(environ, AUTOSET_ON) + area.poweralert(0, src) + if(75 to 100) + equipment = autoset(equipment, AUTOSET_ON) + lighting = autoset(lighting, AUTOSET_ON) + environ = autoset(environ, AUTOSET_ON) + area.poweralert(1, src) + else equipment = autoset(equipment, AUTOSET_ON) lighting = autoset(lighting, AUTOSET_ON) environ = autoset(environ, AUTOSET_ON) - area.poweralert(0, src) - else // otherwise all can be on - equipment = autoset(equipment, 1) - lighting = autoset(lighting, 1) - environ = autoset(environ, 1) area.poweralert(1, src) - if(cell.percent() > 75) - area.poweralert(1, src) // now trickle-charge the cell if(chargemode && charging == APC_CHARGING && operating) @@ -1397,7 +1407,6 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, 25) chargecount = 0 else // no cell, switch everything off - charging = APC_NOT_CHARGING chargecount = 0 equipment = autoset(equipment, AUTOSET_FORCE_OFF) diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index 0e29e53da52e..d4a17523255d 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -76,14 +76,14 @@ return 100*charge/maxcharge // use power from a cell -/obj/item/stock_parts/cell/use(amount) +/obj/item/stock_parts/cell/use(amount, log = TRUE) if(rigged && amount > 0) explode() return 0 if(charge < amount) return 0 charge = (charge - amount) - if(!istype(loc, /obj/machinery/power/apc)) + if(log) SSblackbox.record_feedback("tally", "cell_used", 1, type) return 1 diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index 662bdbecc572..8b7ab2fa3b53 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -634,7 +634,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small/built, 28) visible_message("[src] short-circuits from too powerful of a power cell!") burn_out() return FALSE - cell.use(pwr) + cell.use(pwr, FALSE) set_light(brightness * bulb_emergency_brightness_mul, max(bulb_emergency_pow_min, bulb_emergency_pow_mul * (cell.charge / cell.maxcharge)), bulb_emergency_colour) return TRUE diff --git a/code/modules/recycling/disposal/bin.dm b/code/modules/recycling/disposal/bin.dm index 111428528242..793edb4a84da 100644 --- a/code/modules/recycling/disposal/bin.dm +++ b/code/modules/recycling/disposal/bin.dm @@ -432,7 +432,7 @@ if(air_contents.return_pressure() >= SEND_PRESSURE) full_pressure = TRUE pressure_charging = FALSE - update_appearance() + update_appearance(UPDATE_OVERLAYS) return /obj/machinery/disposal/bin/get_remote_view_fullscreens(mob/user) diff --git a/code/modules/surgery/organs/lungs.dm b/code/modules/surgery/organs/lungs.dm index 14fd951e0e9a..5a0d20e23ca3 100644 --- a/code/modules/surgery/organs/lungs.dm +++ b/code/modules/surgery/organs/lungs.dm @@ -461,22 +461,17 @@ if(!HAS_TRAIT(breather, TRAIT_RESISTCOLD)) // COLD DAMAGE var/cold_modifier = breather.dna.species.coldmod var/breath_effect_prob = 0 - var/part_count = 0 if(breath_temperature < cold_level_3_threshold) breather.apply_damage(cold_level_3_damage * cold_modifier, cold_damage_type, spread_damage = TRUE) breath_effect_prob = 100 - part_count = 8 if(breath_temperature > cold_level_3_threshold && breath_temperature < cold_level_2_threshold) breather.apply_damage(cold_level_2_damage * cold_modifier, cold_damage_type, spread_damage = TRUE) breath_effect_prob = 75 - part_count = 5 if(breath_temperature > cold_level_2_threshold && breath_temperature < cold_level_1_threshold) breather.apply_damage(cold_level_1_damage * cold_modifier, cold_damage_type, spread_damage = TRUE) breath_effect_prob = 50 - part_count = 3 if(breath_temperature > cold_level_1_threshold) breath_effect_prob = 25 - part_count = 2 if(breath_temperature < cold_level_1_threshold) if(prob(sqrt(breath_effect_prob) * 6)) @@ -484,7 +479,6 @@ else if(breath_temperature < chlly_threshold) if(!breath_effect_prob) breath_effect_prob = 20 - part_count = 1 if(prob(sqrt(breath_effect_prob) * 6)) to_chat(breather, "You feel [chilly_message] in your [name].") if(breath_temperature < chlly_threshold) @@ -525,43 +519,6 @@ // The air you breathe out should match your body temperature breath.set_temperature(breather.bodytemperature) -/// Creates a particle effect off the mouth of the passed mob. -/obj/item/organ/lungs/proc/emit_breath_particle(mob/living/carbon/human/breather, particle_type, part_count) - ASSERT(ispath(particle_type, /particles)) - - var/obj/effect/abstract/particle_holder/holder = new(breather, particle_type) - var/particles/breath_particle = holder.particles - var/breath_dir = breather.dir - - var/list/particle_grav = list(0, 0.1, 0) - var/list/particle_pos = list(0, 10, 0) - if(breath_dir & NORTH) - particle_grav[2] = 0.2 - breath_particle.rotation = pick(-45, 45) - // Layer it behind the mob since we're facing away from the camera - holder.pixel_w -= 4 - holder.pixel_y += 4 - if(breath_dir & WEST) - particle_grav[1] = -0.2 - particle_pos[1] = -5 - breath_particle.rotation = -45 - if(breath_dir & EAST) - particle_grav[1] = 0.2 - particle_pos[1] = 5 - breath_particle.rotation = 45 - if(breath_dir & SOUTH) - particle_grav[2] = 0.2 - breath_particle.rotation = pick(-45, 45) - // Shouldn't be necessary but just for parity - holder.pixel_w += 4 - holder.pixel_y -= 4 - - breath_particle.gravity = particle_grav - breath_particle.position = particle_pos - breath_particle.count = part_count - - QDEL_IN(holder, breath_particle.lifespan) - /obj/item/organ/lungs/on_life() . = ..() if(failed && !(organ_flags & ORGAN_FAILING))