Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bodytemperature and other fixes #9086

Merged
merged 2 commits into from Apr 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions code/__DEFINES/atmospherics.dm
Expand Up @@ -107,7 +107,4 @@
#define MAX_HIGH_PRESSURE_DAMAGE 4 //This used to be 20... I got this much random rage for some retarded decision by polymorph?! Polymorph now lies in a pool of blood with a katana jammed in his spleen. ~Errorage --PS: The katana did less than 20 damage to him :(
#define LOW_PRESSURE_DAMAGE 2 //The amounb of damage someone takes when in a low pressure area (The pressure threshold is so low that it doesn't make sense to do any calculations, so it just applies this flat value).

#define PRESSURE_SUIT_REDUCTION_COEFFICIENT 0.8 //This is how much (percentual) a suit with the flag STOPSPRESSUREDMAGE reduces pressure.
#define PRESSURE_HEAD_REDUCTION_COEFFICIENT 0.4 //This is how much (percentual) a helmet/hat with the flag STOPSPRESSUREDMAGE reduces pressure.

#define COLD_SLOWDOWN_FACTOR 20 //Humans are slowed by the difference between bodytemp and BODYTEMP_COLD_DAMAGE_LIMIT divided by this
8 changes: 8 additions & 0 deletions code/game/objects/items/weapons/grenades/chem_grenade.dm
Expand Up @@ -211,9 +211,17 @@
reagents.chem_temp = total_temp

/obj/item/weapon/grenade/chem_grenade/proc/can_flood_from(myloc, maxrange)
var/turf/myturf = get_turf(myloc)
var/list/reachable = list(myloc)
for(var/i=1; i<=maxrange; i++)
var/list/turflist = list()
for(var/turf/T in (orange(i, myloc) - orange(i-1, myloc)))
turflist |= T
for(var/turf/T in turflist)
if( !(get_dir(T,myloc) in cardinal) && (abs(T.x - myturf.x) == abs(T.y - myturf.y) ))
turflist.Remove(T)
turflist.Add(T) // we move the purely diagonal turfs to the end of the list.
for(var/turf/T in turflist)
if(T in reachable) continue
for(var/turf/NT in orange(1, T))
if(!(NT in reachable)) continue
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/implants/implant.dm
Expand Up @@ -213,7 +213,7 @@

imp_in.reagents.add_reagent("synaptizine", 10)
imp_in.reagents.add_reagent("omnizine", 10)
imp_in.reagents.add_reagent("morphine", 10)
imp_in.reagents.add_reagent("stimulants", 10)


/obj/item/weapon/implant/emp
Expand Down
9 changes: 4 additions & 5 deletions code/modules/mob/living/carbon/alien/alien.dm
Expand Up @@ -73,22 +73,18 @@

var/loc_temp = get_temperature(environment)

//world << "Loc temp: [loc_temp] - Body temp: [bodytemperature] - Fireloss: [getFireLoss()] - Fire protection: [heat_protection] - Location: [loc] - src: [src]"

// Aliens are now weak to fire.

//After then, it reacts to the surrounding atmosphere based on your thermal protection
if(!on_fire) // If you're on fire, ignore local air temperature
if(loc_temp > bodytemperature)
//Place is hotter than we are
var/thermal_protection = heat_protection //This returns a 0 - 1 value, which corresponds to the percentage of protection based on what you're wearing and what you're exposed to.
var/thermal_protection = heat_protection //This returns a 0 - 1 value, which corresponds to the percentage of heat protection.
if(thermal_protection < 1)
bodytemperature += (1-thermal_protection) * ((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR)
else
bodytemperature += 1 * ((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR)
// bodytemperature -= max((loc_temp - bodytemperature / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM)

// +/- 50 degrees from 310.15K is the 'safe' zone, where no damage is dealt.
if(bodytemperature > 360.15)
//Body temperature is too hot.
throw_alert("alien_fire")
Expand Down Expand Up @@ -134,6 +130,9 @@
bodytemperature += BODYTEMP_HEATING_MAX //If you're on fire, you heat up!
return

/mob/living/carbon/alien/reagent_check(var/datum/reagent/R) //can metabolize all reagents
return 0

/mob/living/carbon/alien/IsAdvancedToolUser()
return has_fine_manipulation

Expand Down
7 changes: 0 additions & 7 deletions code/modules/mob/living/carbon/alien/humanoid/caste/hunter.dm
Expand Up @@ -36,13 +36,6 @@
else
healths.icon_state = "health7"


/mob/living/carbon/alien/humanoid/hunter/handle_environment()
if(m_intent == "run" || resting)
..()
else
adjustToxLoss(-heal_rate)

/mob/living/carbon/alien/humanoid/hunter/movement_delay()
. = -1 //hunters are sanic
. += ..() //but they still need to slow down on stun
Expand Down
3 changes: 0 additions & 3 deletions code/modules/mob/living/carbon/alien/humanoid/humanoid.dm
Expand Up @@ -124,9 +124,6 @@
unEquip(r_store)
unEquip(l_store)

/mob/living/carbon/alien/humanoid/reagent_check(var/datum/reagent/R)
return 0

/mob/living/carbon/alien/humanoid/cuff_resist(obj/item/I)
playsound(src, 'sound/voice/hiss5.ogg', 40, 1, 1) //Alien roars when starting to break free
..(I, cuff_break = 1)
Expand Down
1 change: 0 additions & 1 deletion code/modules/mob/living/carbon/alien/life.dm
Expand Up @@ -30,7 +30,6 @@
//BREATH TEMPERATURE
handle_breath_temperature(breath)


/mob/living/carbon/alien/handle_status_effects()
..()
//natural reduction of movement delay due to stun.
Expand Down
31 changes: 3 additions & 28 deletions code/modules/mob/living/carbon/human/life.dm
Expand Up @@ -52,20 +52,10 @@


/mob/living/carbon/human/calculate_affecting_pressure(var/pressure)
..()
var/pressure_difference = abs( pressure - ONE_ATMOSPHERE )

var/pressure_adjustment_coefficient = 1 //Determins how much the clothing you are wearing protects you in percent.
if(wear_suit && (wear_suit.flags & STOPSPRESSUREDMAGE))
pressure_adjustment_coefficient -= PRESSURE_SUIT_REDUCTION_COEFFICIENT
if(head && (head.flags & STOPSPRESSUREDMAGE))
pressure_adjustment_coefficient -= PRESSURE_HEAD_REDUCTION_COEFFICIENT
pressure_adjustment_coefficient = max(pressure_adjustment_coefficient,0) //So it isn't less than 0
pressure_difference = pressure_difference * pressure_adjustment_coefficient
if(pressure > ONE_ATMOSPHERE)
return ONE_ATMOSPHERE + pressure_difference
if((wear_suit && (wear_suit.flags & STOPSPRESSUREDMAGE)) && (head && (head.flags & STOPSPRESSUREDMAGE)))
return ONE_ATMOSPHERE
else
return ONE_ATMOSPHERE - pressure_difference
return pressure


/mob/living/carbon/human/handle_disabilities()
Expand Down Expand Up @@ -146,21 +136,6 @@
//END FIRE CODE


/mob/living/carbon/human/proc/stabilize_temperature_from_calories()
switch(bodytemperature)
if(-INFINITY to 260.15) //260.15 is 310.15 - 50, the temperature where you start to feel effects.
if(nutrition >= 2) //If we are very, very cold we'll use up quite a bit of nutriment to heat us up.
nutrition -= 2
var/body_temperature_difference = 310.15 - bodytemperature
bodytemperature += max((body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM)
if(260.15 to 360.15)
var/body_temperature_difference = 310.15 - bodytemperature
bodytemperature += body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR
if(360.15 to INFINITY) //360.15 is 310.15 + 50, the temperature where you start to feel effects.
//We totally need a sweat system cause it totally makes sense...~
var/body_temperature_difference = 310.15 - bodytemperature
bodytemperature += min((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), -BODYTEMP_AUTORECOVERY_MINIMUM) //We're dealing with negative numbers

//This proc returns a number made up of the flags for body parts which you are protected on. (such as HEAD, CHEST, GROIN, etc. See setup.dm for the full list)
/mob/living/carbon/human/proc/get_heat_protection_flags(temperature) //Temperature is the temperature you're being exposed to.
var/thermal_protection_flags = 0
Expand Down
12 changes: 6 additions & 6 deletions code/modules/mob/living/carbon/human/species.dm
Expand Up @@ -1143,7 +1143,7 @@
return 1

/datum/species/proc/handle_breath_temperature(datum/gas_mixture/breath, var/mob/living/carbon/human/H) // called by human/life, handles temperatures
if( (abs(310.15 - breath.temperature) > 50) && !(mutations_list[COLDRES] in H.dna.mutations) && !(COLDRES in specflags)) // Hot air hurts :(
if(abs(310.15 - breath.temperature) > 50)

if(!(mutations_list[COLDRES] in H.dna.mutations)) // COLD DAMAGE
switch(breath.temperature)
Expand All @@ -1162,18 +1162,18 @@
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_2, BURN, "head")
if(1000 to INFINITY)
H.apply_damage(HEAT_GAS_DAMAGE_LEVEL_3, BURN, "head")

/datum/species/proc/handle_environment(datum/gas_mixture/environment, var/mob/living/carbon/human/H)
if(!environment)
return

var/loc_temp = H.get_temperature(environment)
//world << "Loc temp: [loc_temp] - Body temp: [bodytemperature] - Fireloss: [getFireLoss()] - Thermal protection: [get_thermal_protection()] - Fire protection: [thermal_protection + add_fire_protection(loc_temp)] - Heat capacity: [environment_heat_capacity] - Location: [loc] - src: [src]"

//Body temperature is adjusted in two steps. Firstly your body tries to stabilize itself a bit.
if(H.stat != 2)
H.stabilize_temperature_from_calories()
//Body temperature is adjusted in two steps. First, your body tries to stabilize itself a bit.
if(H.stat != DEAD)
H.natural_bodytemperature_stabilization()

//After then, it reacts to the surrounding atmosphere based on your thermal protection
//Then, it reacts to the surrounding atmosphere based on your thermal protection
if(!H.on_fire) //If you're on fire, you do not heat up or cool down based on surrounding gases
if(loc_temp < H.bodytemperature)
//Place is colder than we are
Expand Down
24 changes: 17 additions & 7 deletions code/modules/mob/living/carbon/life.dm
Expand Up @@ -238,15 +238,8 @@
if(reagents)
reagents.metabolize(src)

/mob/living/carbon/handle_blood()
return

/mob/living/carbon/handle_random_events()
return

/mob/living/carbon/proc/handle_heart()
return
/mob/living/carbon/handle_environment(var/datum/gas_mixture/environment) return

/mob/living/carbon/handle_stomach()
spawn(0)
Expand Down Expand Up @@ -503,3 +496,20 @@
healths.icon_state = "health6"
else
healths.icon_state = "health7"


//used in human and monkey handle_environment()
/mob/living/carbon/proc/natural_bodytemperature_stabilization()
var/body_temperature_difference = 310.15 - bodytemperature
switch(bodytemperature)
if(-INFINITY to 260.15) //260.15 is 310.15 - 50, the temperature where you start to feel effects.
if(nutrition >= 2) //If we are very, very cold we'll use up quite a bit of nutriment to heat us up.
nutrition -= 2
bodytemperature += max((body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR), BODYTEMP_AUTORECOVERY_MINIMUM)
if(260.15 to 310.15)
bodytemperature += max(body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR, min(body_temperature_difference, BODYTEMP_AUTORECOVERY_MINIMUM/4))
if(310.15 to 360.15)
bodytemperature += min(body_temperature_difference * metabolism_efficiency / BODYTEMP_AUTORECOVERY_DIVISOR, max(body_temperature_difference, -BODYTEMP_AUTORECOVERY_MINIMUM/4))
if(360.15 to INFINITY) //360.15 is 310.15 + 50, the temperature where you start to feel effects.
//We totally need a sweat system cause it totally makes sense...~
bodytemperature += min((body_temperature_difference / BODYTEMP_AUTORECOVERY_DIVISOR), -BODYTEMP_AUTORECOVERY_MINIMUM) //We're dealing with negative numbers
82 changes: 57 additions & 25 deletions code/modules/mob/living/carbon/monkey/life.dm
Expand Up @@ -18,10 +18,6 @@
if(prob(1))
emote(pick("scratch","jump","roll","tail"))

/mob/living/carbon/monkey/calculate_affecting_pressure(var/pressure)
..()
return pressure

/mob/living/carbon/monkey/handle_mutations_and_radiation()

if (radiation)
Expand All @@ -46,23 +42,69 @@
emote("gasp")
..()

/mob/living/carbon/monkey/handle_breath_temperature(datum/gas_mixture/breath)
if(abs(310.15 - breath.temperature) > 50)
switch(breath.temperature)
if(-INFINITY to 120)
adjustFireLoss(3)
if(120 to 200)
adjustFireLoss(1.5)
if(200 to 260)
adjustFireLoss(0.5)
if(360 to 400)
adjustFireLoss(2)
if(400 to 1000)
adjustFireLoss(3)
if(1000 to INFINITY)
adjustFireLoss(8)

/mob/living/carbon/monkey/handle_environment(datum/gas_mixture/environment)
if(!environment)
return
var/environment_heat_capacity = environment.heat_capacity()
if(istype(get_turf(src), /turf/space))
var/turf/heat_turf = get_turf(src)
environment_heat_capacity = heat_turf.heat_capacity

if(!on_fire)
if((environment.temperature > (T0C + 50)) || (environment.temperature < (T0C + 10)))
var/transfer_coefficient = 1
var/loc_temp = get_temperature(environment)

handle_temperature_damage(HEAD, environment.temperature, environment_heat_capacity*transfer_coefficient)
if(stat != DEAD)
natural_bodytemperature_stabilization()

if(!on_fire) //If you're on fire, you do not heat up or cool down based on surrounding gases
if(loc_temp < bodytemperature)
bodytemperature += min(((loc_temp - bodytemperature) / BODYTEMP_COLD_DIVISOR), BODYTEMP_COOLING_MAX)
else
bodytemperature += min(((loc_temp - bodytemperature) / BODYTEMP_HEAT_DIVISOR), BODYTEMP_HEATING_MAX)

if(bodytemperature > BODYTEMP_HEAT_DAMAGE_LIMIT)
switch(bodytemperature)
if(360 to 400)
throw_alert("temp","hot",1)
adjustFireLoss(2)
if(400 to 460)
throw_alert("temp","hot",2)
adjustFireLoss(3)
if(460 to INFINITY)
throw_alert("temp","hot",3)
if(on_fire)
adjustFireLoss(8)
else
adjustFireLoss(3)

else if(bodytemperature < BODYTEMP_COLD_DAMAGE_LIMIT)
if(!istype(loc, /obj/machinery/atmospherics/unary/cryo_cell))
switch(bodytemperature)
if(200 to 260)
throw_alert("temp","cold",1)
adjustFireLoss(0.5)
if(120 to 200)
throw_alert("temp","cold",2)
adjustFireLoss(1.5)
if(-INFINITY to 120)
throw_alert("temp","cold",3)
adjustFireLoss(3)
else
clear_alert("temp")

if(stat != 2)
bodytemperature += 0.1*(environment.temperature - bodytemperature)*environment_heat_capacity/(environment_heat_capacity + 270000)
else
clear_alert("temp")

//Account for massive pressure differences

Expand All @@ -84,14 +126,6 @@

return

/mob/living/carbon/monkey/proc/handle_temperature_damage(body_part, exposed_temperature, exposed_intensity)
if(status_flags & GODMODE) return
var/discomfort = min( abs(exposed_temperature - bodytemperature)*(exposed_intensity)/2000000, 1.0)

if(exposed_temperature > bodytemperature)
adjustFireLoss(20.0*discomfort)
else
adjustFireLoss(5.0*discomfort)

/mob/living/carbon/monkey/handle_hud_icons()

Expand Down Expand Up @@ -120,10 +154,8 @@
if(wear_mask.flags & BLOCK_GAS_SMOKE_EFFECT)
return 1

///FIRE CODE
/mob/living/carbon/monkey/handle_fire()
if(..())
return
adjustFireLoss(6)
bodytemperature += BODYTEMP_HEATING_MAX
return
//END FIRE CODE
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/monkey/monkey.dm
Expand Up @@ -204,6 +204,9 @@
/mob/living/carbon/monkey/IsAdvancedToolUser()//Unless its monkey mode monkeys cant use advanced tools
return 0

/mob/living/carbon/monkey/reagent_check(var/datum/reagent/R) //can metabolize all reagents
return 0

/mob/living/carbon/monkey/canBeHandcuffed()
return 1

Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/living.dm
Expand Up @@ -193,7 +193,7 @@ Sorry Giacom. Please don't be mad :(
//This proc is used for mobs which are affected by pressure to calculate the amount of pressure that actually
//affects them once clothing is factored in. ~Errorage
/mob/living/proc/calculate_affecting_pressure(var/pressure)
return 0
return pressure


//sort of a legacy burn method for /electrocute, /shock, and the e_chair
Expand Down Expand Up @@ -814,4 +814,4 @@ Sorry Giacom. Please don't be mad :(
return initial(pixel_x)

/mob/living/proc/get_standard_pixel_y_offset(lying = 0)
return initial(pixel_y)
return initial(pixel_y)
2 changes: 1 addition & 1 deletion code/modules/mob/living/simple_animal/hostile/mimic.dm
Expand Up @@ -5,7 +5,7 @@
/mob/living/simple_animal/hostile/mimic
name = "crate"
desc = "A rectangular steel crate."
icon = 'icons/obj/storage.dmi'
icon = 'icons/obj/crates.dmi'
icon_state = "crate"
icon_living = "crate"

Expand Down
4 changes: 2 additions & 2 deletions code/modules/reagents/Chemistry-Machinery.dm
Expand Up @@ -592,7 +592,7 @@

/obj/machinery/chem_master/constructable/attackby(var/obj/item/B as obj, var/mob/user as mob, params)

if(default_deconstruction_screwdriver(user, "mixer0_nopower", "mixer0_", B))
if(default_deconstruction_screwdriver(user, "mixer0_nopower", "mixer0", B))
if(beaker)
beaker.loc = src.loc
beaker = null
Expand Down Expand Up @@ -760,7 +760,7 @@ obj/machinery/computer/pandemic/proc/replicator_cooldown(var/waittime)
if(!D)
return
var/name = stripped_input(usr,"Name:","Name the culture",D.name,MAX_NAME_LEN)
if(name == null)
if(name == null || wait)
return
var/obj/item/weapon/reagent_containers/glass/bottle/B = new/obj/item/weapon/reagent_containers/glass/bottle(src.loc)
B.icon_state = "bottle3"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reagent_containers/hypospray.dm
Expand Up @@ -93,7 +93,7 @@

/obj/item/weapon/reagent_containers/hypospray/medipen/stimpack //goliath kiting
name = "stimpack medipen"
desc = "A rapid way to stimulate your body's adrenaline, allowing for freer movement in restrictive armor as well as a ."
desc = "A rapid way to stimulate your body's adrenaline, allowing for freer movement in restrictive armor."
icon_state = "stimpen"
volume = 20
amount_per_transfer_from_this = 20
Expand Down
Binary file modified icons/mob/inhands/items_lefthand.dmi
Binary file not shown.
Binary file modified icons/mob/inhands/items_righthand.dmi
Binary file not shown.