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.
This commit is contained in:
BurgerLUA
2018-11-21 21:49:32 +01:00
committed by Werner
parent 44fe6c35f4
commit d4f8e6a6bc
3 changed files with 50 additions and 9 deletions
+5 -3
View File
@@ -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
@@ -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