From d29f7fcc2be00172ad8c019d2c051ee41509553a Mon Sep 17 00:00:00 2001 From: CRITAWAKETS Date: Tue, 12 Mar 2024 16:32:52 -0400 Subject: [PATCH] Convect is now limited in its temperature bounds and heating/cooling per cast. (#450) * Convect is now clamped to prevent mana and atmos exploits. * Makes the clamp not allow deleting or creating energy. --- .../modules/magic/story_spells/convect.dm | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/maplestation_modules/code/modules/magic/story_spells/convect.dm b/maplestation_modules/code/modules/magic/story_spells/convect.dm index 979d49a09215..8a575719a6a3 100644 --- a/maplestation_modules/code/modules/magic/story_spells/convect.dm +++ b/maplestation_modules/code/modules/magic/story_spells/convect.dm @@ -43,6 +43,12 @@ spell_requirements = SPELL_REQUIRES_NO_ANTIMAGIC var/temperature_for_cast = 25 + //Maximum temperature change able to be chosen when casting + var/maximum_temperature_delta = 50 + //Minimum temperature the spell can reach + var/minimum_temperature_atmos = T0C - 50 + //Maximum temperature the spell can reach + var/maximum_temperature_atmos = T0C + 100 /datum/action/cooldown/spell/pointed/convect/New(Target, original) . = ..() @@ -61,7 +67,7 @@ /// Asks the owner for a number via TGUI. If the number isn't 0 or null, sets it to our temperature. /datum/action/cooldown/spell/pointed/convect/proc/get_new_cast_temperature() - var/temperature = tgui_input_number(owner, "How many degrees (kelvin) do you wish to shift temperature by?", "Convect", null, max_value = INFINITY, min_value = -INFINITY, timeout = 5 SECONDS) + var/temperature = tgui_input_number(owner, "How many degrees (kelvin) do you wish to shift temperature by?", "Convect", null, max_value = maximum_temperature_delta, min_value = -maximum_temperature_delta, timeout = 5 SECONDS) if (!temperature) return FALSE temperature_for_cast = temperature @@ -97,10 +103,28 @@ var/datum/gas_mixture/air = cast_on.return_air() var/datum/gas_mixture/turf_air = turf_target?.return_air() if (air && air != turf_air) // if this has air and we arent a turf - air.temperature = max(air.temperature + temperature_for_cast, 0) //this sucks. + if(air.temperature + temperature_for_cast >= maximum_temperature_atmos && temperature_for_cast <= 0) //veeery hot + air.temperature = max(air.temperature + temperature_for_cast, minimum_temperature_atmos) + else if(air.temperature + temperature_for_cast <= minimum_temperature_atmos && temperature_for_cast > 0) //veeery cold + air.temperature = min(air.temperature + temperature_for_cast, maximum_temperature_atmos) + else if(air.temperature + temperature_for_cast >= maximum_temperature_atmos && temperature_for_cast > 0) //These else if blocks suck. Why air doesn't have a proc to set temperature is byond me + air.temperature = maximum_temperature_atmos + else if(air.temperature + temperature_for_cast <= minimum_temperature_atmos && temperature_for_cast <= 0) + air.temperature = minimum_temperature_atmos + else + air.temperature = clamp(air.temperature + temperature_for_cast, minimum_temperature_atmos, maximum_temperature_atmos) //don't want fusion temperatures in your pocket now dont you air.react(cast_on) if (isturf(cast_on) && turf_air) - turf_air.temperature = max(turf_air.temperature + temperature_for_cast, 0) + if(turf_air.temperature + temperature_for_cast >= maximum_temperature_atmos && temperature_for_cast <= 0) + turf_air.temperature = max(turf_air.temperature + temperature_for_cast, minimum_temperature_atmos) + else if(turf_air.temperature + temperature_for_cast <= minimum_temperature_atmos && temperature_for_cast > 0) + turf_air.temperature = min(turf_air.temperature + temperature_for_cast, maximum_temperature_atmos) + else if(turf_air.temperature + temperature_for_cast >= maximum_temperature_atmos && temperature_for_cast > 0) + turf_air.temperature = maximum_temperature_atmos + else if(turf_air.temperature + temperature_for_cast <= minimum_temperature_atmos && temperature_for_cast <= 0) + turf_air.temperature = minimum_temperature_atmos + else + turf_air.temperature = clamp(turf_air.temperature + temperature_for_cast, minimum_temperature_atmos, maximum_temperature_atmos) turf_air.react(turf_target) turf_target?.air_update_turf()