From ae17ac061dbbdd521ac7788211861fdcccb3c6d2 Mon Sep 17 00:00:00 2001 From: Anewbe Date: Sat, 27 Aug 2016 15:44:12 -0500 Subject: [PATCH 1/3] Rigs now have suit coolers --- code/modules/clothing/spacesuits/rig/rig.dm | 100 +++++++++++++++++++- html/changelogs/anewbe.yml | 37 ++++++++ 2 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 html/changelogs/anewbe.yml diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm index a8a65a9873a..01246912919 100644 --- a/code/modules/clothing/spacesuits/rig/rig.dm +++ b/code/modules/clothing/spacesuits/rig/rig.dm @@ -15,6 +15,7 @@ req_one_access = list() req_access = list() w_class = 5 + action_button_name = "Toggle Heatsink" // These values are passed on to all component pieces. armor = list(melee = 40, bullet = 5, laser = 20,energy = 5, bomb = 35, bio = 100, rad = 20) @@ -54,6 +55,12 @@ var/image/mob_icon // Holder for on-mob icon. var/list/installed_modules = list() // Power consumption/use bookkeeping. + // Cooling system vars. + var/cooling_on = 0 //is it turned on? + var/max_cooling = 15 // in degrees per second - probably don't need to mess with heat capacity here + var/charge_consumption = 2 // charge per second at max_cooling //more effective on a rig, because it's all built in already + var/thermostat = T20C + // Rig status vars. var/open = 0 // Access panel status. var/locked = 1 // Lock status. @@ -94,6 +101,7 @@ usr << "The access panel is [locked? "locked" : "unlocked"]." usr << "The maintenance panel is [open ? "open" : "closed"]." usr << "Hardsuit systems are [offline ? "offline" : "online"]." + usr << "The cooling stystem is [cooling_on ? "active" : "inactive"]." if(open) usr << "It's equipped with [english_list(installed_modules)]." @@ -302,8 +310,96 @@ piece.item_flags |= (STOPPRESSUREDAMAGE|AIRTIGHT) update_icon(1) -/obj/item/weapon/rig/process() +/obj/item/weapon/rig/ui_action_click() + toggle_cooling(usr) +/obj/item/weapon/rig/proc/toggle_cooling(var/mob/user) + if(cooling_on) + turn_cooling_off() + else + turn_cooling_on() + +/obj/item/weapon/rig/proc/turn_cooling_on() + if(!cell) + return + if(cell.charge <= 0) + usr << "\The [src] has no power!." + return + if(!suit_is_deployed()) + usr << "The hardsuit needs to be deployed first!." + return + + cooling_on = 1 + usr << "You switch \the [src]'s cooling system on." + + +/obj/item/weapon/rig/proc/turn_cooling_off(var/failed) + if(failed) visible_message("\The [src]'s cooling system clicks and whines as it powers down.") + else usr << "You switch \the [src]'s cooling system off." + cooling_on = 0 + +/obj/item/weapon/rig/proc/get_environment_temperature() + if (ishuman(loc)) + var/mob/living/carbon/human/H = loc + if(istype(H.loc, /obj/mecha)) + var/obj/mecha/M = H.loc + return M.return_temperature() + else if(istype(H.loc, /obj/machinery/atmospherics/unary/cryo_cell)) + return H.loc:air_contents.temperature + + var/turf/T = get_turf(src) + if(istype(T, /turf/space)) + return 0 //space has no temperature, this just makes sure the cooling unit works in space + + var/datum/gas_mixture/environment = T.return_air() + if (!environment) + return 0 + + return environment.temperature + +/obj/item/weapon/rig/proc/attached_to_back(mob/M) + if (!ishuman(M)) + return 0 + + var/mob/living/carbon/human/H = M + + if (!H.wear_suit || H.back != src) + return 0 + + return 1 + +/obj/item/weapon/rig/proc/coolingProcess() + if (!cooling_on || !cell) + return + + if (!ismob(loc)) + return + + if (!attached_to_back(loc)) //make sure the rig's not just in their hands + return + + if (!suit_is_deployed()) //inbuilt systems only work on the suit they're designed to work on + return + + var/mob/living/carbon/human/H = loc + + var/efficiency = 1 - H.get_pressure_weakness() //you need to have a good seal for effective cooling + var/env_temp = get_environment_temperature() //wont save you from a fire + var/temp_adj = min(H.bodytemperature - max(thermostat, env_temp), max_cooling) + + if (temp_adj < 0.5) //only cools, doesn't heat, also we don't need extreme precision + return + + var/charge_usage = (temp_adj/max_cooling)*charge_consumption + + H.bodytemperature -= temp_adj*efficiency + + cell.use(charge_usage) + + if(cell.charge <= 0) + turn_cooling_off(1) + +/obj/item/weapon/rig/process() // If we've lost any parts, grab them back. var/mob/living/M for(var/obj/item/piece in list(gloves,boots,helmet,chest)) @@ -312,6 +408,8 @@ M = piece.loc M.unEquip(piece) piece.forceMove(src) + // Run through cooling + coolingProcess() if(!istype(wearer) || loc != wearer || wearer.back != src || canremove || !cell || cell.charge <= 0) if(!cell || cell.charge <= 0) diff --git a/html/changelogs/anewbe.yml b/html/changelogs/anewbe.yml new file mode 100644 index 00000000000..553c159292c --- /dev/null +++ b/html/changelogs/anewbe.yml @@ -0,0 +1,37 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +################################# + +# Your name. +author: Anewbe + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Hardsuits (RIGs) now have an inbuilt suit cooling system, toggled via HUD button. This only works when the hardsuit is fully deployed, and drains charge from its power cell." + From 79b5e3fb59c28fb897c9e7c909816be34378be1c Mon Sep 17 00:00:00 2001 From: Anewbe Date: Sun, 28 Aug 2016 19:13:25 -0500 Subject: [PATCH 2/3] Eliminates colon --- code/modules/clothing/spacesuits/rig/rig.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm index 01246912919..e51c557584b 100644 --- a/code/modules/clothing/spacesuits/rig/rig.dm +++ b/code/modules/clothing/spacesuits/rig/rig.dm @@ -345,7 +345,8 @@ var/obj/mecha/M = H.loc return M.return_temperature() else if(istype(H.loc, /obj/machinery/atmospherics/unary/cryo_cell)) - return H.loc:air_contents.temperature + var/obj/machinery/atmospherics/unary/cryo_cell/cryo = H.loc + return cryo.air_contents.temperature var/turf/T = get_turf(src) if(istype(T, /turf/space)) From e70e841e59c04076cfe4719fe46e79c16c331276 Mon Sep 17 00:00:00 2001 From: Anewbe Date: Sun, 28 Aug 2016 19:32:21 -0500 Subject: [PATCH 3/3] Should clear up the usr issue --- code/modules/clothing/spacesuits/rig/rig.dm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm index e51c557584b..23a5a69039b 100644 --- a/code/modules/clothing/spacesuits/rig/rig.dm +++ b/code/modules/clothing/spacesuits/rig/rig.dm @@ -315,25 +315,25 @@ /obj/item/weapon/rig/proc/toggle_cooling(var/mob/user) if(cooling_on) - turn_cooling_off() + turn_cooling_off(user) else - turn_cooling_on() + turn_cooling_on(user) -/obj/item/weapon/rig/proc/turn_cooling_on() +/obj/item/weapon/rig/proc/turn_cooling_on(var/mob/user) if(!cell) return if(cell.charge <= 0) - usr << "\The [src] has no power!." + user << "\The [src] has no power!." return if(!suit_is_deployed()) - usr << "The hardsuit needs to be deployed first!." + user << "The hardsuit needs to be deployed first!." return cooling_on = 1 usr << "You switch \the [src]'s cooling system on." -/obj/item/weapon/rig/proc/turn_cooling_off(var/failed) +/obj/item/weapon/rig/proc/turn_cooling_off(var/mob/user, var/failed) if(failed) visible_message("\The [src]'s cooling system clicks and whines as it powers down.") else usr << "You switch \the [src]'s cooling system off." cooling_on = 0 @@ -398,7 +398,7 @@ cell.use(charge_usage) if(cell.charge <= 0) - turn_cooling_off(1) + turn_cooling_off(H, 1) /obj/item/weapon/rig/process() // If we've lost any parts, grab them back.