Skip to content

Commit

Permalink
More minor fixes (#3916)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## 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:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Co-authored-by: FalloutFalcon <[email protected]>
  • Loading branch information
MarkSuckerberg and FalloutFalcon authored Jan 8, 2025
1 parent b9cc7f5 commit 59bc315
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 66 deletions.
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/robot/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
41 changes: 25 additions & 16 deletions code/modules/power/apc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/power/cell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small/built, 28)
visible_message("<span class='warning'>[src] short-circuits from too powerful of a power cell!</span>")
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

Expand Down
2 changes: 1 addition & 1 deletion code/modules/recycling/disposal/bin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
43 changes: 0 additions & 43 deletions code/modules/surgery/organs/lungs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -461,30 +461,24 @@
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))
to_chat(breather, "<span class='warning'>You feel [cold_message] in your [name]!</span>")
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, "<span class='warning'>You feel [chilly_message] in your [name].</span>")
if(breath_temperature < chlly_threshold)
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 59bc315

Please sign in to comment.