Feeling if held items are particularly hot or cold in examine description (#34875)

* Optimize handle_reactions().

* .

* Little bit faster.

* Faster.

* Bit faster.

* .

* Move these earlier.

* Faster.

* Faster.

* Faster.

* Update Chemistry-Holder.dm

* Remove redundant checks.

* Skip null check.

* Sensing if something is hot by touch.

* Update Chemistry-Holder.dm

* Update items.dm

* Update human_defense.dm

don't need these here

* Update shock.dm

* Update items.dm

* Update items.dm

* Update items.dm

---------

Co-authored-by: Hinaichigo <hinaichigo@github.com>
This commit is contained in:
Hinaichigo
2023-08-29 16:50:06 -04:00
committed by GitHub
parent 30d287578d
commit d7fb715647
4 changed files with 70 additions and 6 deletions

View File

@@ -332,11 +332,46 @@ var/global/objects_thrown_when_explode = FALSE
..(user, size, show_name)
if(price && price > 0)
to_chat(user, "You read '[price] space bucks' on the tag.")
if((cant_drop != FALSE) && user.is_holding_item(src)) //Item can't be dropped, and is either in left or right hand!
to_chat(user, "<span class='danger'>It's stuck to your hands!</span>")
if(user.is_holding_item(src))
if(reagents?.total_volume && isliving(user))
held_examine_temperature_message(user)
if(cant_drop != FALSE) //Item can't be dropped, and is either in left or right hand!
to_chat(user, "<span class='danger'>It's stuck to your hands!</span>")
if(daemon && daemon.flags & DAEMON_EXAMINE)
daemon.examine(user)
/obj/item/proc/held_examine_temperature_message(mob/living/examiner)
#define HEAT_LEVEL_SPAN 20
var/temperature_delta = (reagents.chem_temp - examiner.bodytemperature) * heat_conductivity ** (1/3) //Cubed root to skew it towards being perceptible.
if (ishuman(examiner))
var/mob/living/carbon/human/H = examiner
temperature_delta *= (H.gloves ? H.gloves.heat_conductivity ** (1/3) : 1)
var/safetemp_excursion = examiner.get_safe_temperature_excursion(examiner.bodytemperature + temperature_delta)
if (!examiner.feels_pain() || examiner.has_painkillers())
safetemp_excursion = 0
else if(safetemp_excursion > 0)
safetemp_excursion = min(ceil(safetemp_excursion / HEAT_LEVEL_SPAN), 3)
else if (safetemp_excursion < 0)
safetemp_excursion = max(round(safetemp_excursion / HEAT_LEVEL_SPAN), -3)
switch (safetemp_excursion)
if (0)
if (temperature_delta >= HEAT_LEVEL_SPAN)
to_chat(examiner, "<span class='notice'>It feels warm.</span>")
else if(abs(temperature_delta) >= HEAT_LEVEL_SPAN)
to_chat(examiner, "<span class='notice'>It feels cool.</span>")
if (1)
to_chat(examiner, "<span class='warning'>It feels very hot.</span>")
if (-1)
to_chat(examiner, "<span class='warning'>It feels very cold.</span>")
if (2)
to_chat(examiner, "<span class='warning'>It feels searing hot.</span>")
if (-2)
to_chat(examiner, "<span class='warning'>It feels freezing cold.</span>")
if (3)
to_chat(examiner, "<span class='warning'>It feels blisteringly hot.</span>")
if (-3)
to_chat(examiner, "<span class='warning'>It feels piercingly cold.</span>")
#undef HEAT_LEVEL_SPAN
/obj/item/attack_ai(mob/user as mob)
..()

View File

@@ -593,4 +593,4 @@ emp_act
return PACID
/mob/living/carbon/human/beam_defense(var/obj/effect/beam/B)
return is_wearing_item(/obj/item/clothing/suit/reticulatedvest) ? 0.4 : 1
return is_wearing_item(/obj/item/clothing/suit/reticulatedvest) ? 0.4 : 1

View File

@@ -46,10 +46,9 @@
/mob/living/carbon/proc/handle_shock() //Currently only used for humans
update_pain_level()
/mob/living/carbon/proc/total_painkillers()
/mob/living/proc/total_painkillers()
for(var/datum/reagent/R in reagents.reagent_list)
. += R.pain_resistance
/mob/living/carbon/proc/has_painkillers()
/mob/living/proc/has_painkillers()
return total_painkillers() > 0

View File

@@ -44,3 +44,33 @@ default behaviour is:
/mob/living/proc/isDeadorDying() //returns 1 if dead or in crit
if(stat == DEAD || health <= config.health_threshold_crit)
return TRUE
/mob/living/proc/get_safe_temperature_excursion(the_temp)
//Returns how many degrees K a temperature is outside of the safe range the mob can tolerate. returns 0 if within the safe range. can be negative for cold.
return 0
/mob/living/simple_animal/get_safe_temperature_excursion(the_temp)
if (the_temp > maxbodytemp)
return the_temp - maxbodytemp
else if (the_temp < minbodytemp)
return the_temp - minbodytemp
return 0
/mob/living/carbon/monkey/get_safe_temperature_excursion(the_temp)
if (the_temp > BODYTEMP_HEAT_DAMAGE_LIMIT)
return the_temp - BODYTEMP_HEAT_DAMAGE_LIMIT
else if (the_temp < BODYTEMP_COLD_DAMAGE_LIMIT)
return the_temp - BODYTEMP_COLD_DAMAGE_LIMIT
return 0
/mob/living/carbon/human/get_safe_temperature_excursion(the_temp)
if (species)
if (the_temp > species.heat_level_1)
return the_temp - species.heat_level_1
else if (the_temp < species.cold_level_1)
return the_temp - species.cold_level_1
else if (the_temp > BODYTEMP_HEAT_DAMAGE_LIMIT)
return the_temp - BODYTEMP_HEAT_DAMAGE_LIMIT
else if (the_temp < BODYTEMP_COLD_DAMAGE_LIMIT)
return the_temp - BODYTEMP_COLD_DAMAGE_LIMIT
return 0