Refactors heart attacks, unbreaks incremental cloning

This commit is contained in:
Crazylemon64
2017-04-29 22:22:57 -07:00
parent 2e59984ae9
commit 528e359296
16 changed files with 95 additions and 72 deletions
+1
View File
@@ -640,3 +640,4 @@ proc/dd_sortedObjectList(list/incoming)
// LAZYING PT 2: THE LAZENING
#define LAZYREINITLIST(L) LAZYCLEARLIST(L); LAZYINITLIST(L);
#define LAZYQDELLIST(L) if(L) { for(var/o in L) qdel(o); L.Cut() }
+28 -25
View File
@@ -34,6 +34,7 @@
var/obj/effect/countdown/clonepod/countdown
var/list/brine_types = list("corazone", "salbutamol", "hydrocodone")
var/list/missing_organs
var/organs_number = 0
@@ -86,21 +87,9 @@
/obj/machinery/clonepod/Destroy()
if(connected)
connected.pods -= src
<<<<<<< HEAD
QDEL_NULL(Radio)
QDEL_NULL(countdown)
=======
if(Radio)
qdel(Radio)
Radio = null
if(countdown)
qdel(countdown)
countdown = null
for(var/i in missing_organs)
qdel(i)
LAZYCLEARLIST(missing_organs)
missing_organs = null
>>>>>>> Cloning now puts you together bit by bit
LAZYDESTROYLIST(missing_organs)
return ..()
/obj/machinery/clonepod/RefreshParts()
@@ -280,6 +269,7 @@
H.sync_organ_dna(1) // It's literally a fresh body as you can get, so all organs properly belong to it
H.UpdateAppearance()
check_brine()
//Get the clone body ready
maim_clone(H)
H.Paralyse(4)
@@ -332,21 +322,24 @@
//Slowly get that clone healed and finished.
occupant.adjustCloneLoss(-((speed_coeff/2)))
var/progress = CLONE_INITIAL_DAMAGE - occupant.getCloneLoss()
progress += (100 - MINIMUM_HEAL_LEVEL)
var/milestone = CLONE_INITIAL_DAMAGE / organs_number
var/installed = organs_number - LAZYLEN(missing_organs)
// For human species that lack non-vital parts for some weird reason
if(organs_number)
var/progress = CLONE_INITIAL_DAMAGE - occupant.getCloneLoss()
progress += (100 - MINIMUM_HEAL_LEVEL)
var/milestone = CLONE_INITIAL_DAMAGE / organs_number
// Doing this as a #define so that the value can change when evaluated multiple times
#define INSTALLED (organs_number - LAZYLEN(missing_organs))
while((progress / milestone) > installed && LAZYLEN(missing_organs))
var/obj/item/organ/I = pick_n_take(missing_organs)
I.replaced(occupant)
while((progress / milestone) > INSTALLED && LAZYLEN(missing_organs))
var/obj/item/organ/I = pick_n_take(missing_organs)
I.replaced(occupant)
#undef INSTALLED
//Premature clones may have brain damage.
occupant.adjustBrainLoss(-((speed_coeff/20)*efficiency))
//So clones don't die of oxyloss in a running pod.
if(occupant.reagents.get_reagent_amount("salbutamol") < 5)
occupant.reagents.add_reagent("salbutamol", 5)
check_brine()
//Also heal some oxyloss ourselves just in case!!
occupant.adjustOxyLoss(-4)
@@ -562,7 +555,10 @@
var/obj/item/organ/O = o
if(!istype(O) || O.vital)
continue
var/obj/item/I = O.remove(H, TRUE)
// Let's non-specially remove all non-vital organs
// What could possibly go wrong
var/obj/item/I = O.remove(H)
// Make this support stuff that turns into items when removed
I.forceMove(src)
missing_organs += I
@@ -570,12 +566,19 @@
var/static/list/zones = list("r_arm", "l_arm", "r_leg", "l_leg")
for(var/zone in zones)
var/obj/item/organ/external/E = H.get_organ(zone)
var/obj/item/I = E.remove(H, TRUE)
var/obj/item/I = E.remove(H)
I.forceMove(src)
missing_organs += I
organs_number = LAZYLEN(missing_organs)
/obj/machinery/clonepod/proc/check_brine()
// Clones are in a pickled bath of mild chemicals, keeping
// them alive, despite their lack of internal organs
for(var/bt in brine_types)
if(occupant.reagents.get_reagent_amount(bt) < 1)
occupant.reagents.add_reagent(bt, 1)
/*
* Diskette Box
*/
+1 -1
View File
@@ -240,7 +240,7 @@ REAGENT SCANNER
if(H.species.exotic_blood)
user.show_message("<span class='warning'>Subject possesses exotic blood.</span>")
user.show_message("<span class='warning'>Exotic blood type: [blood_type].</span>")
if(H.heart_attack && H.stat != DEAD)
if(H.undergoing_cardiac_arrest() && H.stat != DEAD)
user.show_message("<span class='userdanger'>Subject suffering from heart attack: Apply defibrillator immediately.</span>")
user.show_message("<span class='notice'>Subject's pulse: <font color='[H.pulse == PULSE_THREADY || H.pulse == PULSE_NONE ? "red" : "blue"]'>[H.get_pulse(GETPULSE_TOOL)] bpm.</font></span>")
var/implant_detect
+6 -6
View File
@@ -330,8 +330,8 @@
H.updatehealth() //forces health update before next life tick
playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1)
H.emote("gasp")
if(!H.heart_attack && (prob(10) || defib.combat)) // Your heart explodes.
H.heart_attack = 1
if(!H.undergoing_cardiac_arrest() && (prob(10) || defib.combat)) // Your heart explodes.
H.set_heartattack(TRUE)
add_logs(user, M, "stunned", object="defibrillator")
defib.deductcharge(revivecost)
cooldown = 1
@@ -368,7 +368,7 @@
busy = 0
update_icon()
return
if(H.heart_attack)
if(H.undergoing_cardiac_arrest())
if(!H.get_int_organ(/obj/item/organ/internal/heart) && !H.get_int_organ(/obj/item/organ/internal/brain/slime)) //prevents defibing someone still alive suffering from a heart attack attack if they lack a heart
user.visible_message("<span class='boldnotice'>[defib] buzzes: Resuscitation failed - Failed to pick up any heart electrical activity.</span>")
playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0)
@@ -376,7 +376,7 @@
update_icon()
return
else
H.heart_attack = 0
H.set_heartattack(FALSE)
user.visible_message("<span class='boldnotice'>[defib] pings: Cardiac arrhythmia corrected.</span>")
M.visible_message("<span class='warning'>[M]'s body convulses a bit.")
playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1)
@@ -474,8 +474,8 @@
H.adjustStaminaLoss(50)
H.Weaken(5)
H.updatehealth() //forces health update before next life tick
if(!H.heart_attack && prob(10)) // Your heart explodes.
H.heart_attack = 1
if(!H.undergoing_cardiac_arrest() && prob(10)) // Your heart explodes.
H.set_heartattack(TRUE)
playsound(get_turf(src), 'sound/machines/defib_zap.ogg', 50, 1, -1)
H.emote("gasp")
add_logs(user, M, "stunned", object="defibrillator")
@@ -20,7 +20,6 @@
var/pulse = PULSE_NORM //current pulse level
var/heart_attack = 0
var/wetlevel = 0 //how wet the mob is
var/oxygen_alert = 0
@@ -29,4 +28,4 @@
var/fire_alert = 0
var/failed_last_breath = 0 //This is used to determine if the mob failed a breath. If they did fail a brath, they will attempt to breathe each tick, otherwise just once per 4 ticks.
var/co2overloadtime = null
var/co2overloadtime = null
@@ -99,7 +99,7 @@
stat = DEAD
SetDizzy(0)
SetJitter(0)
heart_attack = 0
set_heartattack(FALSE)
//Handle species-specific deaths.
if(species) species.handle_death(src)
@@ -759,9 +759,9 @@
if(species)
species_siemens_coeff = species.siemens_coeff
siemens_coeff = gloves_siemens_coeff * species_siemens_coeff
if(heart_attack)
if(undergoing_cardiac_arrest())
if(shock_damage * siemens_coeff >= 1 && prob(25))
heart_attack = 0
set_heartattack(FALSE)
if(stat == CONSCIOUS)
to_chat(src, "<span class='notice'>You feel your heart beating again!</span>")
. = ..()
+30 -7
View File
@@ -1032,7 +1032,7 @@
if(stat == DEAD)
return PULSE_NONE //that's it, you're dead, nothing can influence your pulse
if(heart_attack)
if(undergoing_cardiac_arrest())
return PULSE_NONE
var/temp = PULSE_NORM
@@ -1175,14 +1175,37 @@
return stuttering
/mob/living/carbon/human/proc/can_heartattack()
if(species.flags & NO_BLOOD)
return FALSE
return TRUE
/mob/living/carbon/human/proc/undergoing_cardiac_arrest()
if(!can_heartattack())
return FALSE
var/obj/item/organ/internal/heart/heart = get_int_organ(/obj/item/organ/internal/heart)
if(istype(heart) && heart.beating)
return FALSE
return TRUE
/mob/living/carbon/human/proc/set_heartattack(status)
if(!can_heartattack())
return FALSE
var/obj/item/organ/internal/heart/heart = get_int_organ(/obj/item/organ/internal/heart)
if(!istype(heart))
return FALSE
heart.beating = !status
/mob/living/carbon/human/proc/handle_heartattack()
if(!heart_attack)
if(!can_heartattack() || !undergoing_cardiac_arrest() || reagents.has_reagent("corazone"))
return
else
AdjustLoseBreath(2, bound_lower = 0, bound_upper = 3)
adjustOxyLoss(5)
Paralyse(4)
adjustBruteLoss(2)
AdjustLoseBreath(2, bound_lower = 0, bound_upper = 3)
adjustOxyLoss(5)
Paralyse(4)
adjustBruteLoss(2)
+1 -1
View File
@@ -377,7 +377,6 @@
if(iscarbon(src))
var/mob/living/carbon/C = src
C.handcuffed = initial(C.handcuffed)
C.heart_attack = 0
for(var/datum/disease/D in C.viruses)
D.cure(0)
@@ -385,6 +384,7 @@
// restore all of the human's blood and reset their shock stage
if(ishuman(src))
human_mob = src
human_mob.set_heartattack(FALSE)
human_mob.restore_blood()
human_mob.shock_stage = 0
human_mob.decaylevel = 0
@@ -141,11 +141,11 @@
can_synth = 0
/datum/reagent/concentrated_initro/on_mob_life(mob/living/M)
if(volume >=5)
if(volume >= 5)
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(!H.heart_attack)
H.heart_attack = 1 // rip in pepperoni
if(!H.undergoing_cardiac_arrest())
H.set_heartattack(TRUE) // rip in pepperoni
//virus foods
@@ -183,4 +183,4 @@
/datum/reagent/plasma_dust/plasmavirusfood/weak
name = "weakened virus plasma"
id = "weakplasmavirusfood"
color = "#CEC3C6" // rgb: 206,195,198
color = "#CEC3C6" // rgb: 206,195,198
@@ -772,8 +772,8 @@
M.Weaken(1)
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(!H.heart_attack)
H.heart_attack = 1
if(!H.undergoing_cardiac_arrest())
H.set_heartattack(TRUE)
..()
/datum/reagent/fungus
@@ -847,7 +847,7 @@
if(volume >= 5 && !istype(T, /turf/space))
new /obj/effect/decal/cleanable/vomit/green(T)
playsound(T, 'sound/effects/splat.ogg', 50, 1, -3)
////Lavaland Flora Reagents////
/datum/reagent/consumable/entpoly
@@ -878,7 +878,7 @@
if(!light_activated)
M.set_light(2)
light_activated = 1
..()
..()
/datum/reagent/consumable/tinlux/on_mob_delete(mob/living/M)
M.set_light(0)
@@ -894,4 +894,4 @@
if(prob(80))
M.adjustBruteLoss(-1 * REAGENTS_EFFECT_MULTIPLIER)
M.adjustFireLoss(-1 * REAGENTS_EFFECT_MULTIPLIER)
..()
..()
@@ -1023,3 +1023,11 @@
/datum/reagent/medicine/earthsblood/overdose_process(mob/living/M)
M.SetHallucinate(min(max(0, M.hallucination + 10), 50))
M.adjustToxLoss(5 * REAGENTS_EFFECT_MULTIPLIER)
/datum/reagent/medicine/corazone
name = "Corazone"
id = "corazone"
description = "A medication used to treat pain, fever, and inflammation, along with heart attacks."
color = "#F5F5F5"
// This reagent's effects are handled in heart attack handling code
@@ -648,8 +648,8 @@
M.Weaken(2)
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(!H.heart_attack)
H.heart_attack = 1 // rip in pepperoni
if(!H.undergoing_cardiac_arrest())
H.set_heartattack(TRUE) // rip in pepperoni
..()
/datum/reagent/pancuronium
@@ -1090,4 +1090,4 @@
shock_timer = 0
M.electrocute_act(rand(5,20), "Teslium in their body", 1, 1) //Override because it's caused from INSIDE of you
playsound(M, "sparks", 50, 1)
..()
..()
@@ -249,9 +249,9 @@
if(istype(owner, /mob/living/carbon/human))
var/mob/living/carbon/human/H = owner
if(H.stat != DEAD && prob(50 / severity))
H.heart_attack = 1
H.set_heartattack(TRUE)
spawn(600 / severity)
H.heart_attack = 0
H.set_heartattack(FALSE)
if(H.stat == CONSCIOUS)
to_chat(H, "<span class='notice'>You feel your heart beating again!</span>")
+1 -1
View File
@@ -286,7 +286,7 @@ var/list/organ_cache = list()
/obj/item/organ/internal/heart/emp_act(intensity)
if(owner && robotic == 2)
owner.heart_attack = 1
Stop() // In the name of looooove~!
owner.visible_message("<span class='danger'>[owner] clutches their chest and gasps!</span>","<span class='userdanger'>You clutch your chest in pain!</span>")
else if(owner && robotic == 1)
take_damage(11,1)
+1 -12
View File
@@ -165,11 +165,9 @@
. = ..()
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(H.stat == DEAD || H.heart_attack)
if(H.stat == DEAD)
Stop()
return
if(!special)
H.heart_attack = 1
spawn(120)
if(!owner)
@@ -183,15 +181,6 @@
if(!owner)
Stop()
/obj/item/organ/internal/heart/insert(mob/living/carbon/M, special = 0)
..()
if(ishuman(M) && beating)
var/mob/living/carbon/human/H = M
if(H.heart_attack)
H.heart_attack = 0
return
/obj/item/organ/internal/heart/proc/Stop()
beating = 0
update_icon()