From d4f8e6a6bcbcfc5e66e618cea8d0f3f3f8c25a93 Mon Sep 17 00:00:00 2001 From: BurgerLUA Date: Wed, 21 Nov 2018 12:49:32 -0800 Subject: [PATCH] Temperature Fixes (#5639) There was a dumb bug with a poor implementation with thermal energy which caused issues with phoron salt explosion calculations. This fixes it. --- code/modules/reagents/Chemistry-Recipes.dm | 8 ++-- .../modules/reagents/Chemistry-Temperature.dm | 13 ++++--- .../burgerbb - temperature fixes.yml | 38 +++++++++++++++++++ 3 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 html/changelogs/burgerbb - temperature fixes.yml diff --git a/code/modules/reagents/Chemistry-Recipes.dm b/code/modules/reagents/Chemistry-Recipes.dm index cb9762c199a..e91972ad138 100644 --- a/code/modules/reagents/Chemistry-Recipes.dm +++ b/code/modules/reagents/Chemistry-Recipes.dm @@ -2965,7 +2965,7 @@ catalysts = list("water" = 1) mix_message = "The solution begins to freeze." -/datum/chemical_reaction/cryosurfactant_cooling_water/on_reaction(var/datum/reagents/holder, var/created_volume) +/datum/chemical_reaction/cryosurfactant_cooling_water/on_reaction(var/datum/reagents/holder, var/created_volume, var/created_thermal_energy) holder.del_reagent("cryosurfactant") holder.add_thermal_energy(-created_volume*500) @@ -3039,9 +3039,11 @@ /datum/chemical_reaction/phoron_salt_coldfire/on_reaction(var/datum/reagents/holder, var/created_volume, var/created_thermal_energy) var/turf/location = get_turf(holder.my_atom) - var/explosion_mod = 1 + max(0,32*(1 - (created_thermal_energy/28000))*min(1,created_volume/120)) * 10 + var/thermal_energy_mod = max(0,1 - (max(0,created_thermal_energy)/28000)) + var/volume_mod = min(1,created_volume/120) + var/explosion_mod = 3 + (thermal_energy_mod*volume_mod*320) var/datum/effect/effect/system/reagents_explosion/e = new() e.set_up(explosion_mod, location, 0, 0) e.start() - holder.clear_reagents() + holder.del_reagent("phoron_salt") return \ No newline at end of file diff --git a/code/modules/reagents/Chemistry-Temperature.dm b/code/modules/reagents/Chemistry-Temperature.dm index 9734dae2375..16d158731fd 100644 --- a/code/modules/reagents/Chemistry-Temperature.dm +++ b/code/modules/reagents/Chemistry-Temperature.dm @@ -65,11 +65,6 @@ /datum/reagents/proc/set_temperature(var/new_temperature) return add_thermal_energy(-get_thermal_energy() + get_thermal_energy_change(0,new_temperature) ) -/datum/reagents/proc/equalize_thermal_energy() - var/thermal_energy_to_add = get_thermal_energy() - for(var/datum/reagent/R in reagent_list) - R.add_thermal_energy(-R.get_thermal_energy() + (thermal_energy_to_add * (1/reagent_list.len)) ) - /datum/reagents/proc/equalize_temperature() var/total_thermal_energy = 0 @@ -83,9 +78,15 @@ R.set_thermal_energy( total_thermal_energy * (R.get_heat_capacity()/total_heat_capacity) ) /datum/reagents/proc/add_thermal_energy(var/thermal_energy_to_add) + var/total_energy_added = 0 + var/total_heat_capacity = 0 + for(var/datum/reagent/R in reagent_list) - total_energy_added += R.add_thermal_energy(thermal_energy_to_add * (1/reagent_list.len)) + total_heat_capacity += R.get_heat_capacity() + + for(var/datum/reagent/R in reagent_list) + total_energy_added += R.add_thermal_energy(thermal_energy_to_add * (R.get_heat_capacity()/total_heat_capacity) ) return total_energy_added diff --git a/html/changelogs/burgerbb - temperature fixes.yml b/html/changelogs/burgerbb - temperature fixes.yml new file mode 100644 index 00000000000..f4a481947d2 --- /dev/null +++ b/html/changelogs/burgerbb - temperature fixes.yml @@ -0,0 +1,38 @@ +################################ +# 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 +# balance +################################# + +# Your name. +author: BurgerBB + +# 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: + - bugfix: "Fixes thermal energy transfer issues with reagents, and makes it more like reality instead of uneducated science." + - balance: "Increases the minimum explosion power of phoron salts from 1 to 3, equivalent to a 1 tile wide light explosion." \ No newline at end of file