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

tweak: Реворк СЛР #6621

Draft
wants to merge 2 commits into
base: master220
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,8 @@
#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"
/// Sent from mob/living/carbon/human/do_cpr(): (mob/living/carbon/human/H, new_seconds_of_life)
#define COMSIG_HUMAN_RECEIVE_CPR "human_receieve_cpr"

///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
2 changes: 1 addition & 1 deletion code/__DEFINES/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@

// Defib stats
/// Past this much time the patient is unrecoverable (in deciseconds).
#define DEFIB_TIME_LIMIT (300 SECONDS)
#define BASE_DEFIB_TIME_LIMIT (300 SECONDS)
/// Brain damage starts setting in on the patient after some time left rotting.
#define DEFIB_TIME_LOSS (60 SECONDS)

Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/status_effects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,6 @@
#define STATUS_EFFECT_LAVALAND_VISION /datum/status_effect/lavaland_vision

#define STATUS_EFFECT_TEMPERATURE_STABILIZE /datum/status_effect/temperature_stabilize

/// This status effect allows a mob to be revived with a defibrillator.
#define STATUS_EFFECT_REVIVABLE /datum/status_effect/limited_bonus/revivable
8 changes: 6 additions & 2 deletions code/datums/components/defibrillator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
// Run through some quick failure states after shocking.
var/time_dead = world.time - target.timeofdeath

if((time_dead > DEFIB_TIME_LIMIT) || !target.get_organ_slot(INTERNAL_ORGAN_HEART))
if(!target.is_revivable() || !target.get_organ_slot(INTERNAL_ORGAN_HEART))
defib_ref.atom_say("Реанимация не удалась - обнаружены необратимые повреждения сердца!")
defib_success = FALSE
else if(target.getBruteLoss() >= 180 || target.getFireLoss() >= 180 || target.getCloneLoss() >= 180)
Expand Down Expand Up @@ -258,7 +258,7 @@
target.heal_damages(tox = heal_amount, oxy = heal_amount)

// Inflict some brain damage scaling with time spent dead
var/defib_time_brain_damage = min(100 * time_dead / DEFIB_TIME_LIMIT, 99) // 20 from 1 minute onward, +20 per minute up to 99
var/defib_time_brain_damage = min(100 * time_dead / BASE_DEFIB_TIME_LIMIT, 99) // 20 from 1 minute onward, +20 per minute up to 99
if(time_dead > DEFIB_TIME_LOSS && defib_time_brain_damage > target.getBrainLoss())
target.setBrainLoss(defib_time_brain_damage)

Expand All @@ -276,6 +276,10 @@
SEND_SIGNAL(target, COMSIG_LIVING_MINOR_SHOCK, 100)
if(ishuman(target.pulledby)) // for some reason, pulledby isnt a list despite it being possible to be pulled by multiple people
excess_shock(user, target, target.pulledby, defib_ref)
if(target.receiving_cpr_from)
var/mob/living/carbon/human/H = locateUID(target.receiving_cpr_from)
if(istype(H))
excess_shock(user, target, H, defib_ref)

target.med_hud_set_health()
target.med_hud_set_status()
Expand Down
51 changes: 51 additions & 0 deletions code/datums/status_effects/neutral.dm
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,57 @@
return pick(missed_messages)


/// A status effect that can have a certain amount of "bonus" duration added, which extends the duration every tick,
/// although there is a maximum amount of bonus time that can be active at any given time.
/datum/status_effect/limited_bonus
/// How much extra time has been added
var/bonus_time = 0
/// How much extra time to apply per tick
var/bonus_time_per_tick = 1 SECONDS
/// How much maximum bonus time can be active at once
var/max_bonus_time = 1 MINUTES

/datum/status_effect/limited_bonus/tick()
. = ..()
// Sure, we could do some fancy stuff with clamping, and it'd probably be a little cleaner.
// This keeps the math simple and easier to use later
if(bonus_time > bonus_time_per_tick)
duration += bonus_time_per_tick
bonus_time -= bonus_time_per_tick

/datum/status_effect/limited_bonus/proc/extend(extra_time)
bonus_time = clamp(bonus_time + extra_time, 0, max_bonus_time)

/datum/status_effect/limited_bonus/revivable
id = "revivable"
alert_type = null
status_type = STATUS_EFFECT_UNIQUE
duration = BASE_DEFIB_TIME_LIMIT

/datum/status_effect/limited_bonus/revivable/on_apply()
. = ..()
if(!iscarbon(owner))
return FALSE

RegisterSignal(owner, COMSIG_HUMAN_RECEIVE_CPR, PROC_REF(on_cpr))
RegisterSignal(owner, COMSIG_LIVING_REVIVE, PROC_REF(on_revive))
owner.med_hud_set_status() // update revivability after adding the status effect


/datum/status_effect/limited_bonus/revivable/proc/on_cpr(mob/living/carbon/human/H, new_seconds)
SIGNAL_HANDLER // COMSIG_HUMAN_RECEIVE_CPR
extend(new_seconds)

/datum/status_effect/limited_bonus/revivable/proc/on_revive()
SIGNAL_HANDLER // COMSIG_LIVING_REVIVE
qdel(src)

/datum/status_effect/limited_bonus/revivable/on_remove()
// Update HUDs once the status effect is deleted to show non-revivability
INVOKE_ASYNC(owner, TYPE_PROC_REF(/mob/living, med_hud_set_status))
. = ..()


/datum/status_effect/adaptive_learning
id = "adaptive_learning"
duration = 300
Expand Down
2 changes: 1 addition & 1 deletion code/game/data_huds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
var/mob/living/simple_animal/borer/B = has_brain_worms()
// To the right of health bar
if(stat == DEAD || HAS_TRAIT(src, TRAIT_FAKEDEATH))
var/revivable = timeofdeath && (round(world.time - timeofdeath) < DEFIB_TIME_LIMIT)
var/revivable = is_revivable()
if(!ghost_can_reenter() || suiciding) // DNR or AntagHUD or Suicide
revivable = FALSE
if(revivable)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/scanners.dm
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ REAGENT SCANNER
if(H.timeofdeath && (H.stat == DEAD || HAS_TRAIT(H, TRAIT_FAKEDEATH)))
. += "Время смерти: [station_time_timestamp("hh:mm:ss", H.timeofdeath)]"
var/tdelta = round(world.time - H.timeofdeath)
if(tdelta < DEFIB_TIME_LIMIT && !DNR)
if(H.is_revivable() && !DNR)
. += "<span class='danger'>&emsp;Субъект умер [DisplayTimeText(tdelta)] назад"
. += "&emsp;Дефибриляция возможна!</span>"
else
Expand Down
13 changes: 8 additions & 5 deletions code/modules/mob/living/carbon/alien/alien_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,22 @@

/mob/living/carbon/alien/attack_hand(mob/living/carbon/human/M)
if(..()) //to allow surgery to return properly.
return 0
return FALSE

switch(M.a_intent)
if(INTENT_HELP)
help_shake_act(M)
if(M.on_fire)
pat_out(M)
else
help_shake_act(M)
if(INTENT_GRAB)
grabbedby(M)
if(INTENT_HARM)
M.do_attack_animation(src, ATTACK_EFFECT_PUNCH)
if(INTENT_DISARM)
M.do_attack_animation(src, ATTACK_EFFECT_DISARM)
return 1
return 0
return TRUE
return FALSE


/mob/living/carbon/alien/attack_animal(mob/living/simple_animal/M)
Expand All @@ -70,7 +73,7 @@


/mob/living/carbon/alien/acid_act(acidpwr, acid_volume)
return 0 //aliens are immune to acid.
return FALSE //aliens are immune to acid.

/mob/living/carbon/alien/attack_slime(mob/living/simple_animal/slime/M)
if(..()) //successful slime attack
Expand Down
44 changes: 28 additions & 16 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -238,22 +238,6 @@
span_notice("Вы трясёте [name], пытаясь разбудить [genderize_ru(gender, "его", "её", "его", "их")]."),\
)

else if(on_fire)
var/self_message = span_warning("Вы пытаетесь потушить [name].")
if(prob(30) && ishuman(M)) // 30% chance of burning your hands
var/mob/living/carbon/human/H = M
var/protected = FALSE // Protected from the fire
if((H.gloves?.max_heat_protection_temperature > 360) || HAS_TRAIT(H, TRAIT_RESIST_HEAT))
protected = TRUE
if(!protected)
H.apply_damage(5, BURN, def_zone = H.hand ? BODY_ZONE_PRECISE_L_HAND : BODY_ZONE_PRECISE_R_HAND)
self_message = span_danger("Вы обжигаете свои руки, пытаясь потушить [name]!")
H.update_icons()

M.visible_message(span_warning("[M] пыта[pluralize_ru(M.gender, "ет", "ют")]ся потушить [name]."), self_message)
playsound(get_turf(src), 'sound/weapons/thudswoosh.ogg', 50, 1, -1)
adjust_fire_stacks(-0.5)

// BEGIN HUGCODE - N3X
else
playsound(get_turf(src), 'sound/weapons/thudswoosh.ogg', 50, 1, -1)
Expand All @@ -275,6 +259,34 @@
else if(H.w_uniform)
H.w_uniform.add_fingerprint(M)

/**
* Handles patting out a fire on someone.
*
* Removes 0.5 fire stacks per pat, with a 30% chance of the user burning their hand if they don't have adequate heat resistance.
* Arguments:
* * src - The mob doing the patting
* * target - The mob who is currently on fire
*/
/mob/living/carbon/proc/pat_out(mob/living/target)
if(target == src) // stop drop and roll, no trying to put out fire on yourself for free.
to_chat(src, "<span class='warning'>Stop drop and roll!</span>")
return
var/self_message = span_warning("Вы пытаетесь потушить [name].")
if(prob(30) && ishuman(src)) // 30% chance of burning your hands
var/mob/living/carbon/human/H = src
var/protected = FALSE // Protected from the fire
if((H.gloves?.max_heat_protection_temperature > 360) || HAS_TRAIT(H, TRAIT_RESIST_HEAT))
protected = TRUE

var/obj/item/organ/external/active_hand = H.get_active_hand()
if(active_hand && !protected) // Wouldn't really work without a hand
active_hand.external_receive_damage(0, 5)
self_message = span_danger("Вы обжигаете свои руки, пытаясь потушить [name]!")
H.update_icons()

target.visible_message(span_warning("[target] пыта[pluralize_ru(target.gender, "ет", "ют")]ся потушить [name]."), self_message)
playsound(target, 'sound/weapons/thudswoosh.ogg', 50, TRUE, -1)
target.adjust_fire_stacks(-0.5)

/mob/living/carbon/proc/check_self_for_injuries()
var/mob/living/carbon/human/H = src
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/death.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
if(!.)
return FALSE

if(!gibbed)
apply_status_effect(STATUS_EFFECT_REVIVABLE)

if(reagents)
reagents.death_metabolize(src)

Expand Down
Loading