diff --git a/code/controllers/master_controller.dm b/code/controllers/master_controller.dm index bad82b9e8e0..74761c9ed11 100644 --- a/code/controllers/master_controller.dm +++ b/code/controllers/master_controller.dm @@ -357,16 +357,10 @@ datum/controller/game_controller/proc/process_pipenets() continue pipe_networks.Cut(i,i+1) -datum/controller/game_controller/proc/process_powernets() +/datum/controller/game_controller/proc/process_powernets() last_thing_processed = /datum/powernet - var/i = 1 - while(i<=powernets.len) - var/datum/powernet/Powernet = powernets[i] - if(Powernet) - Powernet.reset() - i++ - continue - powernets.Cut(i,i+1) + for(var/datum/powernet/Powernet in powernets) + Powernet.reset() datum/controller/game_controller/proc/process_nano() var/i = 1 diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index f5c9edb9bf1..b3edbae7872 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -206,7 +206,7 @@ return /area/proc/updateicon() - if ((fire || eject || party) && ((!requires_power)?(!requires_power):power_environ))//If it doesn't require power, can still activate this proc. + if ((fire || eject || party) && (!requires_power||power_environ) && !lighting_space)//If it doesn't require power, can still activate this proc. if(fire && !eject && !party) icon_state = "blue" /*else if(atmosalm && !fire && !eject && !party) @@ -234,6 +234,8 @@ return 1 if(master.always_unpowered) return 0 + if(src.lighting_space) + return 0 // Nope sorry switch(chan) if(EQUIP) return master.power_equip @@ -245,12 +247,10 @@ return 0 // called when power status changes - /area/proc/power_change() - master.powerupdate = 2 for(var/area/RA in related) for(var/obj/machinery/M in RA) // for each machine in the area - M.power_change() // reverify power status (to update icons etc.) + M.power_change() // reverify power status (to update icons etc.) if (fire || eject || party) RA.updateicon() @@ -265,7 +265,6 @@ used += master.used_environ if(TOTAL) used += master.used_light + master.used_equip + master.used_environ - return used /area/proc/clear_usage() diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index ab4cebe6cc2..bdb1345f3ee 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -396,29 +396,30 @@ if (istype(W, /obj/item/weapon/crowbar) && opened) if (has_electronics==1) if (terminal) - user << "\red Disconnect wires first." + user << "Disconnect wires first." return playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1) user << "You are trying to remove the power control board..." //lpeters - fixed grammar issues if(do_after(user, 50)) - has_electronics = 0 - if ((stat & BROKEN) || malfhack) - user.visible_message(\ - "\red [user.name] has broken the power control board inside [src.name]!",\ - "You broke the charred power control board and remove the remains.", - "You hear a crack!") - //ticker.mode:apcs-- //XSI said no and I agreed. -rastaf0 - else - user.visible_message(\ - "\red [user.name] has removed the power control board from [src.name]!",\ - "You remove the power control board.") - new /obj/item/weapon/module/power_control(loc) + if (has_electronics==1) + has_electronics = 0 + if ((stat & BROKEN) || malfhack) + user.visible_message(\ + "[user.name] has broken the power control board inside [src.name]!",\ + "You broke the charred power control board and remove the remains.", + "You hear a crack!") + //ticker.mode:apcs-- //XSI said no and I agreed. -rastaf0 + else + user.visible_message(\ + "[user.name] has removed the power control board from [src.name]!",\ + "You remove the power control board.") + new /obj/item/weapon/module/power_control(loc) else if (opened!=2) //cover isn't removed opened = 0 update_icon() else if (istype(W, /obj/item/weapon/crowbar) && !((stat & BROKEN) || malfhack) ) if(coverlocked && !(stat & MAINT)) - user << "\red The cover is locked and cannot be opened." + user << "The cover is locked and cannot be opened." return else opened = 1 @@ -429,20 +430,20 @@ return else if (stat & MAINT) - user << "\red There is no connector for your power cell." + user << "There is no connector for your power cell." return user.drop_item() W.loc = src cell = W user.visible_message(\ - "\red [user.name] has inserted the power cell to [src.name]!",\ - "You insert the power cell.") + "[user.name] has inserted the power cell to [src.name]!",\ + "You insert the power cell.") chargecount = 0 update_icon() else if (istype(W, /obj/item/weapon/screwdriver)) // haxing if(opened) if (cell) - user << "\red Close the APC first." //Less hints more mystery! + user << "Close the APC first." //Less hints more mystery! return else if (has_electronics==1 && terminal) @@ -456,7 +457,7 @@ playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) user << "You unfasten the electronics." else /* has_electronics==0 */ - user << "\red There is nothing to secure." + user << "There is nothing to secure." return update_icon() else if(emagged) @@ -481,7 +482,7 @@ user << "You [ locked ? "lock" : "unlock"] the APC interface." update_icon() else - user << "\red Access denied." + user << "Access denied." else if (istype(W, /obj/item/weapon/card/emag) && !(emagged || malfhack)) // trying to unlock with an emag card if(opened) user << "You must close the cover to swipe an ID card." @@ -495,10 +496,10 @@ if(prob(50)) emagged = 1 locked = 0 - user << "You emag the APC interface." + user << "You emag the APC interface." update_icon() else - user << "You fail to [ locked ? "unlock" : "lock"] the APC interface." + user << "You fail to [ locked ? "unlock" : "lock"] the APC interface." else if (istype(W, /obj/item/stack/cable_coil) && !terminal && opened && has_electronics!=2) if (src.loc:intact) user << "You must remove the floor plating in front of the APC first." @@ -507,7 +508,8 @@ if(C.get_amount() < 10) user << "You need ten lengths of cable for APC." return - user << "You start adding cables to the APC frame..." + user.visible_message("[user.name] adds cables to the APC frame.", \ + "You start adding cables to the APC frame...") playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) if(do_after(user, 20)) if (C.amount >= 10 && !terminal && opened && has_electronics != 2) @@ -520,58 +522,62 @@ return C.use(10) user.visible_message(\ - "\red [user.name] has added cables to the APC frame!",\ + "[user.name] has added cables to the APC frame!",\ "You add cables to the APC frame.") make_terminal() terminal.connect_to_network() else if (istype(W, /obj/item/weapon/wirecutters) && terminal && opened && has_electronics!=2) if (src.loc:intact) - user << "\red You must remove the floor plating in front of the APC first." + user << "You must remove the floor plating in front of the APC first." return - user << "You begin to cut the cables..." + user.visible_message("[user.name] dismantles the power terminal from [src].", \ + "You begin to cut the cables...") playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) if(do_after(user, 50)) - if (prob(50) && electrocute_mob(usr, terminal.powernet, terminal)) - var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread - s.set_up(5, 1, src) - s.start() - return - new /obj/item/stack/cable_coil(loc,10) - user.visible_message(\ - "\red [user.name] cut the cables and dismantled the power terminal.",\ - "You cut the cables and dismantle the power terminal.") - del(terminal) // qdel + if(terminal && opened && has_electronics!=2) + if (prob(50) && electrocute_mob(usr, terminal.powernet, terminal)) + var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread + s.set_up(5, 1, src) + s.start() + return + new /obj/item/stack/cable_coil(loc,10) + user << "You cut the cables and dismantle the power terminal." + del(terminal) // qdel else if (istype(W, /obj/item/weapon/module/power_control) && opened && has_electronics==0 && !((stat & BROKEN) || malfhack)) - user << "You trying to insert the power control board into the frame..." + user.visible_message("[user.name] inserts the power control board into [src].", \ + "You start to insert the power control board into the frame...") playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) if(do_after(user, 10)) - has_electronics = 1 - user << "You place the power control board inside the frame." - del(W) // qdel + if(has_electronics==0) + has_electronics = 1 + user << "You place the power control board inside the frame." + del(W) // qdel else if (istype(W, /obj/item/weapon/module/power_control) && opened && has_electronics==0 && ((stat & BROKEN) || malfhack)) - user << "\red You cannot put the board inside, the frame is damaged." + user << "You cannot put the board inside, the frame is damaged." return else if (istype(W, /obj/item/weapon/weldingtool) && opened && has_electronics==0 && !terminal) var/obj/item/weapon/weldingtool/WT = W if (WT.get_fuel() < 3) - user << "\blue You need more welding fuel to complete this task." + user << "You need more welding fuel to complete this task." return - user << "You start welding the APC frame..." + user.visible_message("[user.name] welds [src].", \ + "You start welding the APC frame...", \ + "You hear welding.") playsound(src.loc, 'sound/items/Welder.ogg', 50, 1) if(do_after(user, 50)) if(!src || !WT.remove_fuel(3, user)) return if (emagged || malfhack || (stat & BROKEN) || opened==2) new /obj/item/stack/sheet/metal(loc) user.visible_message(\ - "\red [src] has been cut apart by [user.name] with the weldingtool.",\ - "You disassembled the broken APC frame.",\ - "\red You hear welding.") + "[src] has been cut apart by [user.name] with the weldingtool.",\ + "You disassembled the broken APC frame.",\ + "You hear welding.") else new /obj/item/apc_frame(loc) user.visible_message(\ - "\red [src] has been cut from the wall by [user.name] with the weldingtool.",\ - "You cut the APC frame from the wall.",\ - "\red You hear welding.") + "[src] has been cut from the wall by [user.name] with the weldingtool.",\ + "You cut the APC frame from the wall.",\ + "You hear welding.") del(src) // qdel return else if (istype(W, /obj/item/apc_frame) && opened && emagged) @@ -579,18 +585,19 @@ if (opened==2) opened = 1 user.visible_message(\ - "\red [user.name] has replaced the damaged APC frontal panel with a new one.",\ - "You replace the damaged APC frontal panel with a new one.") + "[user.name] has replaced the damaged APC frontal panel with a new one.",\ + "You replace the damaged APC frontal panel with a new one.") del(W) // qdel update_icon() else if (istype(W, /obj/item/apc_frame) && opened && ((stat & BROKEN) || malfhack)) if (has_electronics) - user << "You cannot repair this APC until you remove the electronics still inside." + user << "You cannot repair this APC until you remove the electronics still inside." return - user << "You begin to replace the damaged APC frame..." + user.visible_message("[user.name] replaces the damaged APC frame with a new one.",\ + "You begin to replace the damaged APC frame...") if(do_after(user, 50)) user.visible_message(\ - "\red [user.name] has replaced the damaged APC frame with new one.",\ + "[user.name] has replaced the damaged APC frame with new one.",\ "You replace the damaged APC frame with new one.") del(W) // qdel stat &= ~BROKEN @@ -606,8 +613,8 @@ && W.w_class >= 3.0 \ && prob(20) ) opened = 2 - user.visible_message("\red The APC cover was knocked down with the [W.name] by [user.name]!", \ - "\red You knock down the APC cover with your [W.name]!", \ + user.visible_message("The APC cover was knocked down with the [W.name] by [user.name]!", \ + "You knock down the APC cover with your [W.name]!", \ "You hear bang") update_icon() else @@ -617,8 +624,8 @@ (istype(W, /obj/item/device/multitool) || \ istype(W, /obj/item/weapon/wirecutters) || istype(W, /obj/item/device/assembly/signaler))) return src.attack_hand(user) - user.visible_message("\red The [src.name] has been hit with the [W.name] by [user.name]!", \ - "\red You hit the [src.name] with your [W.name]!", \ + user.visible_message("The [src.name] has been hit with the [W.name] by [user.name]!", \ + "You hit the [src.name] with your [W.name]!", \ "You hear bang") // attack with hand - remove cell (if cover open) or interact with the APC @@ -687,7 +694,8 @@ cell.updateicon() src.cell = null - user.visible_message("\red [user.name] removes the power cell from [src.name]!", "You remove the power cell.") + user.visible_message("[user.name] removes the power cell from [src.name]!",\ + "You remove the power cell.") //user << "You remove the power cell." charging = 0 src.update_icon() @@ -751,7 +759,7 @@ ), list( "title" = "Lighting", - "powerLoad" = round(lastused_equip), + "powerLoad" = round(lastused_light), "status" = lighting, "topicParams" = list( "auto" = list("lgt" = 3), @@ -761,7 +769,7 @@ ), list( "title" = "Environment", - "powerLoad" = round(lastused_light), + "powerLoad" = round(lastused_environ), "status" = environ, "topicParams" = list( "auto" = list("env" = 3), @@ -810,20 +818,18 @@ /obj/machinery/power/apc/proc/can_use(mob/user as mob, var/loud = 0) //used by attack_hand() and Topic() if (user.stat) - user << "\red You must be conscious to use this [src]!" + user << "You must be conscious to use [src]!" return 0 if(!user.client) return 0 - if ( ! (istype(user, /mob/living/carbon/human) || \ - istype(user, /mob/living/silicon) || \ - istype(user, /mob/living/carbon/monkey)) ) - user << "\red You don't have the dexterity to use this [src]!" + if(!user.IsAdvancedToolUser()) + user << "You don't have the dexterity to use [src]!" return 0 if(user.restrained()) - user << "\red You must have free hands to use this [src]" + user << "You must have free hands to use [src]." return 0 if(user.lying) - user << "\red You must stand to use this [src]!" + user << "You must stand to use [src]!" return 0 if (istype(user, /mob/living/silicon)) var/mob/living/silicon/ai/AI = user @@ -837,7 +843,7 @@ ) \ ) if(!loud) - user << "\red \The [src] have AI control disabled!" + user << "\The [src] have AI control disabled!" return 0 else if ((!in_range(src, user) || !istype(src.loc, /turf))) @@ -846,11 +852,10 @@ var/mob/living/carbon/human/H = user if (istype(H)) if(H.getBrainLoss() >= 60) - for(var/mob/M in viewers(src, null)) - M << "\red [H] stares cluelessly at [src] and drools." + H.visible_message("[H] stares cluelessly at [src] and drools.") return 0 else if(prob(H.getBrainLoss())) - user << "\red You momentarily forget how to use [src]." + user << "You momentarily forget how to use [src]." return 0 return 1 @@ -998,7 +1003,7 @@ point.the_disk = A //The pinpointer tracks the AI back into its core. else - src.occupier << "\red Primary core damaged, unable to return core processes." + src.occupier << "Primary core damaged, unable to return core processes." if(forced) src.occupier.loc = src.loc src.occupier.death() @@ -1025,8 +1030,8 @@ var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread s.set_up(3, 1, src) s.start() - for(var/mob/M in viewers(src)) - M.show_message("\red The [src.name] suddenly lets out a blast of smoke and some sparks!", 3, "\red You hear sizzling electronics.", 2) + visible_message("The [src.name] suddenly lets out a blast of smoke and some sparks!", \ + "You hear sizzling electronics.") /obj/machinery/power/apc/surplus() @@ -1062,7 +1067,6 @@ use_power(src.environ_consumption, ENVIRON) area.calc_lighting() */ - lastused_light = area.usage(LIGHT) lastused_equip = area.usage(EQUIP) lastused_environ = area.usage(ENVIRON) diff --git a/code/modules/power/batteryrack.dm b/code/modules/power/batteryrack.dm index 0555f0af86d..08d1e652b46 100644 --- a/code/modules/power/batteryrack.dm +++ b/code/modules/power/batteryrack.dm @@ -239,17 +239,15 @@ var/last_overcharge = overcharge_percent if(terminal) - var/excess = terminal.surplus() + if(chargemode) + var/target_load = min((capacity-charge)/SMESRATE, chargelevel) // charge at set rate, limited to spare capacity + var/actual_load = add_load(target_load) // add the load to the terminal side network + charge += actual_load * SMESRATE // increase the charge - if(charging) - if(excess >= 0) // if there's power available, try to charge - var/load = min((capacity * 1.5 - charge)/SMESRATE, chargelevel) // charge at set rate, limited to spare capacity - load = add_load(load) // add the load to the terminal side network - charge += load * SMESRATE // increase the charge - - - else // if not enough capacity - charging = 0 // stop charging + if (actual_load >= target_load) // did the powernet have enough power available for us? + charging = 1 + else + charging = 0 else if (chargemode && excess > 0 && excess >= chargelevel) diff --git a/code/modules/power/powernet.dm b/code/modules/power/powernet.dm index f321c52a3ff..c6e0a12e17d 100644 --- a/code/modules/power/powernet.dm +++ b/code/modules/power/powernet.dm @@ -16,9 +16,9 @@ powernets -= src /datum/powernet/proc/draw_power(var/amount) - var/drained = min(amount, avail) - load += drained - return drained + var/draw = min(amount, avail - load, 0) + load += draw + return draw /datum/powernet/proc/is_empty() return !cables.len && !nodes.len