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

feat: separated thermo control & drask coma #6059

Open
wants to merge 15 commits into
base: master220
Choose a base branch
from
7 changes: 6 additions & 1 deletion code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@
#define COMSIG_LIVING_RESTING "living_resting"
///from base of mob/update_transform()
#define COMSIG_LIVING_POST_UPDATE_TRANSFORM "living_post_update_transform"
/// Source: /mob/living/proc/apply_status_effect(datum/status_effect/new_instance)
#define COMSIG_LIVING_GAINED_STATUS_EFFECT "living_gained_status_effect"
/// Source: /mob/living/proc/remove_status_effect(datum/status_effect/existing_effect)
#define COMSIG_LIVING_EARLY_LOST_STATUS_EFFECT "living_early_lost_status_effect" // Called before qdel

///called on /living when someone starts pulling (atom/movable/pulled, state, force)
#define COMSIG_LIVING_START_PULL "living_start_pull"
Expand Down Expand Up @@ -910,7 +914,8 @@
#define COMSIG_HUMAN_REGENERATE_ICONS "human_regenerate_icons"
///From /mob/living/carbon/human/proc/set_species(): (datum/species/old_species)
#define COMSIG_HUMAN_SPECIES_CHANGED "human_species_changed"

/// Source: /mob/living/carbon/human/handle_environment(datum/gas_mixture/environment)
#define COMSIG_HUMAN_EARLY_HANDLE_ENVIRONMENT "human_early_handle_environment"

///from /mob/living/carbon/human/proc/check_shields(): (atom/hit_by, damage, attack_text, attack_type, armour_penetration, damage_type)
#define COMSIG_HUMAN_CHECK_SHIELDS "human_check_shields"
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/organ_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@
/// used for species that can see without eyes
#define NO_VISION_ORGAN "no_vision_organ"

/// Species organs
#define DRASK_LUNGS_COOLING_START_TEMP 280
#define DRASK_LUNGS_COOLING_STOP_TEMP 400
2 changes: 2 additions & 0 deletions code/__DEFINES/status_effects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#define STATUS_EFFECT_REGENERATIVE_CORE /datum/status_effect/regenerative_core

#define STATUS_EFFECT_DRASK_COMA /datum/status_effect/drask_coma

#define STATUS_EFFECT_TERROR_REGEN /datum/status_effect/terror/regeneration //over time healing, 125 HP within 25~ seconds

#define STATUS_EFFECT_TERROR_FOOD_REGEN /datum/status_effect/terror/food_regen //over time healing for mobs to gain full HP within 25~ seconds
Expand Down
45 changes: 45 additions & 0 deletions code/datums/status_effects/buffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -774,3 +774,48 @@
/datum/status_effect/drill_payback/on_remove()
..()
owner.clear_fullscreen("payback")

/datum/status_effect/drask_coma
id = "drask_coma"
tick_interval = 2 SECONDS

var/temp_step
var/cached_sleep_time

/datum/status_effect/drask_coma/on_creation(
mob/living/new_owner,
duration = 300 SECONDS,
temp_step = 10,
)
src.duration = duration
src.temp_step = temp_step

return ..()

/datum/status_effect/drask_coma/on_apply()
to_chat(owner, span_notice("Ваш метаболизм полностью остановлен."))

cached_sleep_time = world.time
owner.AdjustSleeping(duration)
RegisterSignal(owner, COMSIG_MOB_STATCHANGE, PROC_REF(stat_change))

return TRUE

/datum/status_effect/drask_coma/proc/stat_change(datum/source, new_stat, old_stat)
SIGNAL_HANDLER

if(new_stat == CONSCIOUS || new_stat == DEAD)
qdel(src)

/datum/status_effect/drask_coma/tick(seconds_between_ticks)
owner.adjust_bodytemperature(-temp_step)

/datum/status_effect/drask_coma/on_remove()
to_chat(owner, span_notice("Вы чувствуете прилив сил и наконец просыпаетесь."))

var/elapsed_time = world.time - cached_sleep_time

if(elapsed_time < duration)
owner.AdjustSleeping(-(duration - elapsed_time))

UnregisterSignal(owner, COMSIG_MOB_STATCHANGE)
2 changes: 2 additions & 0 deletions code/datums/status_effects/status_effect.dm
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
// Create the status effect with our mob + our arguments
var/datum/status_effect/new_instance = new new_effect(arguments)
if(!QDELETED(new_instance))
SEND_SIGNAL(src, COMSIG_LIVING_GAINED_STATUS_EFFECT, new_instance)
return new_instance


Expand All @@ -265,6 +266,7 @@
. = FALSE
for(var/datum/status_effect/existing_effect as anything in status_effects)
if(existing_effect.id == initial(removed_effect.id) && existing_effect.before_remove(arglist(arguments)))
SEND_SIGNAL(src, COMSIG_LIVING_EARLY_LOST_STATUS_EFFECT, existing_effect)
qdel(existing_effect)
. = TRUE

Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/living/carbon/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@
if(!environment)
return

SEND_SIGNAL(src, COMSIG_HUMAN_EARLY_HANDLE_ENVIRONMENT, environment)

var/loc_temp = get_temperature(environment)
// to_chat(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]")

Expand Down
100 changes: 80 additions & 20 deletions code/modules/mob/living/carbon/human/species/drask.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define DRASK_COOLINGSTARTTEMP 280
#define ENVIRONMENT_COOLINGSTOPTEMP 400
#define DRASK_PITCH_SHIFT -0.1 // a bit lower emotes

/datum/species/drask
Expand Down Expand Up @@ -95,28 +93,40 @@
var/obj/item/organ/internal/eyes/E = H.get_int_organ(/obj/item/organ/internal/eyes)
return E.eye_colour

/datum/species/drask/on_species_gain(mob/living/carbon/human/H)
/datum/species/drask/on_species_gain(mob/living/carbon/human/human)
. = ..()
add_verb(H, /mob/living/carbon/human/proc/emote_hum)

/datum/species/drask/on_species_loss(mob/living/carbon/human/H)
var/datum/action/innate/drask/coma/coma = locate() in human.actions

if(!coma)
coma = new
coma.Grant(human)

add_verb(human, /mob/living/carbon/human/proc/emote_hum)

/datum/species/drask/on_species_loss(mob/living/carbon/human/human)
. = ..()

var/datum/action/innate/drask/coma/coma = locate() in human.actions
coma?.Remove(human)

remove_verb(human, /mob/living/carbon/human/proc/emote_hum)

/datum/species/drask/handle_life(mob/living/carbon/human/human)
. = ..()
remove_verb(H, /mob/living/carbon/human/proc/emote_hum)

/datum/species/drask/handle_life(mob/living/carbon/human/H)
..()
if(H.stat == DEAD)
if(human.stat == DEAD)
return
var/datum/gas_mixture/environment = H.return_air()
if(environment && H.bodytemperature > DRASK_COOLINGSTARTTEMP && environment.temperature <= ENVIRONMENT_COOLINGSTOPTEMP)
H.adjust_bodytemperature(-5)
if(H.bodytemperature < TCRYO)

if(human.bodytemperature < TCRYO)
var/update = NONE
update |= H.heal_overall_damage(2, 4, updating_health = FALSE)
update |= H.heal_damages(tox = 0.5, oxy = 2, clone = 1, updating_health = FALSE)
update |= human.heal_overall_damage(2, 4, updating_health = FALSE)
update |= human.heal_damages(tox = 0.5, oxy = 2, clone = 1, updating_health = FALSE)

if(update)
H.updatehealth()
var/obj/item/organ/external/head/head = H.get_organ(BODY_ZONE_HEAD)
human.updatehealth()

var/obj/item/organ/external/head/head = human.get_organ(BODY_ZONE_HEAD)
head?.undisfigure()

/datum/species/drask/handle_reagents(mob/living/carbon/human/H, datum/reagent/R)
Expand All @@ -127,15 +137,65 @@
if("salglu_solution")
if(prob(33))
H.heal_overall_damage(1, 1, updating_health = FALSE)

H.reagents.remove_reagent(R.id, REAGENTS_METABOLISM * H.metabolism_efficiency * H.digestion_ratio)
return FALSE

return ..()

/datum/action/innate/drask

/datum/action/innate/drask/Grant(mob/user)
. = ..()

if(!. || !isliving(user))
return FALSE

return .

/datum/action/innate/drask/coma
name = "Enter coma"
desc = "Постепенно вводит в состояние комы, понижает температуру тела. Повторная активация способности позволит прервать вход в кому, либо выйти из нее."

button_icon_state = "heal"

COOLDOWN_DECLARE(wake_up_cooldown)

/datum/action/innate/drask/coma/Activate()
var/mob/living/living = owner

if(!living.has_status_effect(STATUS_EFFECT_DRASK_COMA))
handle_activation(living)
return

handle_deactivation(living)

/datum/action/innate/drask/coma/proc/handle_activation(mob/living/living)
if(living.stat)
return FALSE

if(!do_after(living, 5 SECONDS, living, ALL, cancel_on_max = TRUE, max_interact_count = 1))
return FALSE

living.apply_status_effect(STATUS_EFFECT_DRASK_COMA)
COOLDOWN_START(src, wake_up_cooldown, 10 SECONDS)

return TRUE

/datum/action/innate/drask/coma/proc/handle_deactivation(mob/living/living)
if(!COOLDOWN_FINISHED(src, wake_up_cooldown))
to_chat(living, span_warning("Вы не можете пробудиться сейчас."))
return FALSE

if(!do_after(living, 10 SECONDS, living, ALL, cancel_on_max = TRUE, max_interact_count = 1))
return FALSE

living.remove_status_effect(STATUS_EFFECT_DRASK_COMA)

return TRUE

/datum/species/drask/get_emote_pitch(mob/living/carbon/human/H, tolerance)
. = ..()
. += DRASK_PITCH_SHIFT


#undef DRASK_COOLINGSTARTTEMP
#undef ENVIRONMENT_COOLINGSTOPTEMP
#undef DRASK_PITCH_SHIFT
24 changes: 24 additions & 0 deletions code/modules/surgery/organs/lungs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,30 @@
cold_level_3_damage = -COLD_GAS_DAMAGE_LEVEL_3
cold_damage_types = list(BRUTE = 0.5, BURN = 0.25)

var/cooling_start_temp = DRASK_LUNGS_COOLING_START_TEMP
var/cooling_stop_temp = DRASK_LUNGS_COOLING_STOP_TEMP

/obj/item/organ/internal/lungs/drask/insert(mob/living/carbon/target, special = ORGAN_MANIPULATION_DEFAULT)
. = ..()

if(!.)
return FALSE

RegisterSignal(owner, COMSIG_HUMAN_EARLY_HANDLE_ENVIRONMENT, PROC_REF(regulate_temperature))

/obj/item/organ/internal/lungs/drask/proc/regulate_temperature(mob/living/source, datum/gas_mixture/environment)
SIGNAL_HANDLER

if(source.stat == DEAD)
return

if(owner.bodytemperature > cooling_start_temp && environment.temperature <= cooling_stop_temp)
owner.adjust_bodytemperature(-5)

/obj/item/organ/internal/lungs/drask/remove(mob/living/user, special = ORGAN_MANIPULATION_DEFAULT)
UnregisterSignal(owner, COMSIG_HUMAN_EARLY_HANDLE_ENVIRONMENT)
return ..()

/obj/item/organ/internal/lungs/cybernetic
name = "cybernetic lungs"
desc = "A cybernetic version of the lungs found in traditional humanoid entities. It functions the same as an organic lung and is merely meant as a replacement."
Expand Down
Loading
Loading