Skip to content

Commit

Permalink
Lots of fixes (#866)
Browse files Browse the repository at this point in the history
* fix admin outfit equip failing on ipcs

* fix vox blood not being instanced

* fix head surgery

* make brain revival surgery easier

* fixes

* unfuck stripping

* fix tables

* nerf nicotine

* fix for real

* unit test basic surgery

* whoops lol
  • Loading branch information
Kapu1178 authored Mar 4, 2024
1 parent 0e3f829 commit b14240d
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 21 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/bodyparts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define DROPLIMB_THRESHOLD_DESTROY 1

/// The amount of time an organ has to be dead for it to be unrecoverable
#define ORGAN_RECOVERY_THRESHOLD (5 MINUTES)
#define ORGAN_RECOVERY_THRESHOLD (10 MINUTES)

//Bodypart flags
#define BP_BLEEDING (1<<0)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/verbs/selectequipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
qdel(item)

var/obj/item/organ/brain/human_brain = human_target.getorganslot(BRAIN)
human_brain.destroy_all_skillchips() // get rid of skillchips to prevent runtimes
human_brain?.destroy_all_skillchips() // get rid of skillchips to prevent runtimes

if(dresscode != "Naked")
human_target.equipOutfit(dresscode)
Expand Down
4 changes: 1 addition & 3 deletions code/modules/mob/living/brain/brain_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@
updating_health = FALSE // Brainloss isn't apart of tox loss, so never update health here.
. = ..()
if(. >= 20) //This probably won't be triggered by oxyloss or mercury. Probably.
var/damage_secondary = . * 0.2
var/damage_secondary = min(. * 0.2, 20)
if (owner)
owner.flash_act(visual = TRUE)
owner.blur_eyes(.)
Expand All @@ -420,10 +420,8 @@
else
if(owner)
owner.revive()
owner.grab_ghost()
else if(brainmob)
brainmob.revive()
brainmob.grab_ghost()
return

/obj/item/organ/brain/before_organ_replacement(obj/item/organ/replacement)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,9 @@

/mob/living/carbon/human/mouse_buckle_handling(mob/living/M, mob/living/user)
var/obj/item/hand_item/grab/G = is_grabbing(M)
if(combat_mode)
return FALSE

if(!G || G.current_grab.damage_stage != GRAB_AGGRESSIVE || stat != CONSCIOUS)
return FALSE

Expand Down
7 changes: 3 additions & 4 deletions code/modules/mob/living/carbon/human/human_stripping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ GLOBAL_LIST_INIT(strippable_human_items, create_strippable_list(list(
return FALSE

var/obj/item/hand_item/grab/G = user.is_grabbing(src)
if (G && G.current_grab.damage_stage != GRAB_AGGRESSIVE)
if(!G)
return TRUE

if (ishuman(user))
var/mob/living/carbon/human/human_user = user
return !human_user.can_be_firemanned(src)
if ((G.current_grab.damage_stage == GRAB_AGGRESSIVE) && !combat_mode) // Do not conflict with fireman carrying
return FALSE

/datum/strippable_item/mob_item_slot/eyes
key = STRIPPABLE_ITEM_EYES
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/species_types/vox.dm
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@
return to_add

/datum/species/vox/get_random_blood_type()
return /datum/blood/universal/vox
return GET_BLOOD_REF(/datum/blood/universal/vox)
1 change: 1 addition & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@
update_eye_blur()
clear_alert(ALERT_NOT_ENOUGH_OXYGEN)
reload_fullscreen()
to_chat(src, span_obviousnotice("A rapidly growing speck of white floods your vision as the spark of life returns!"))
. = TRUE

if(excess_healing)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/chemistry/reagents/drug_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
overdose_threshold = 30
metabolization_rate = 0.01

addiction_types = list(/datum/addiction/nicotine = 18) // 7.2 per 2 seconds
addiction_types = list(/datum/addiction/nicotine = 12)

//Nicotine is used as a pesticide IRL.
/datum/reagent/drug/nicotine/on_hydroponics_apply(obj/item/seeds/myseed, datum/reagents/chems, obj/machinery/hydroponics/mytray, mob/user)
Expand Down
5 changes: 5 additions & 0 deletions code/modules/surgery/bodyparts/injuries.dm
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,16 @@

var/smol_threshold = minimum_break_damage * 0.4
var/beeg_threshold = minimum_break_damage * 0.6
// Clamp it to the largest that the wound can be
beeg_threshold = min(beeg_threshold, incision.damage_list[1])

if(!(incision.autoheal_cutoff == 0)) //not clean incision
smol_threshold *= 1.5
beeg_threshold = max(beeg_threshold, min(beeg_threshold * 1.5, incision.damage_list[1])) //wounds can't achieve bigger

if(incision.damage >= smol_threshold) //smol incision
. = SURGERY_OPEN

if(incision.damage >= beeg_threshold) //beeg incision
. = SURGERY_RETRACTED
if(encased && (bodypart_flags & BP_BROKEN_BONES))
Expand Down
6 changes: 4 additions & 2 deletions code/modules/surgery/machines/vitals_monitor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define BRAIN_ALERT 2
#define LUNGS_ALERT 3

DEFINE_INTERACTABLE(/obj/machinery/vitals_monitor)

/obj/machinery/vitals_monitor
name = "vitals monitor"
desc = "A bulky yet mobile machine, showing some odd graphs."
Expand Down Expand Up @@ -101,11 +103,11 @@
if (read_alerts)
alerts[PULSE_ALERT] = "Cardiac flatline detected!"

if (PULSE_SLOW, PULSE_NORM,)
if (PULSE_SLOW, PULSE_NORM)
. += emissive_appearance(icon, "pulse_normal")
. += image(icon, icon_state = "pulse_normal")
if (beep)
playsound(src, 'sound/machines/quiet_beep.ogg', 40)
playsound(src, 'sound/machines/quiet_beep.ogg', 30)

if (PULSE_FAST, PULSE_2FAST)
. += emissive_appearance(icon, "pulse_veryfast")
Expand Down
9 changes: 5 additions & 4 deletions code/modules/surgery/new_surgery/internal_organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
name = "Brain revival"
desc = "Utilizes the incredible power of Alkysine to restore the spark of life."
allowed_tools = list(
/obj/item/reagent_containers/glass/beaker = 100,
/obj/item/reagent_containers/glass = 100,
)
min_duration = 100
max_duration = 150
Expand All @@ -354,7 +354,8 @@

/datum/surgery_step/internal/brain_revival/pre_surgery_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
. = FALSE
var/obj/item/reagent_containers/glass/beaker/S = tool

var/obj/item/reagent_containers/glass/S = tool
if(!S.reagents.has_reagent(/datum/reagent/medicine/alkysine, 10))
to_chat(user, span_warning("\The [S] doesn't contain enough alkysine!"))
return
Expand All @@ -373,15 +374,15 @@

/datum/surgery_step/internal/brain_revival/succeed_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
var/obj/item/reagent_containers/glass/beaker/S = tool
if(!S.reagents.has_reagent(/datum/reagent/medicine/alkysine, 10))
if(!S.reagents.has_reagent(/datum/reagent/medicine/alkysine, 5))
return

var/obj/item/bodypart/head/head = target.get_bodypart(BODY_ZONE_HEAD)
var/obj/item/organ/brain/brain = locate() in head?.contained_organs
if(!head || !brain)
return

S.reagents.remove_reagent(/datum/reagent/medicine/alkysine, 10)
S.reagents.remove_reagent(/datum/reagent/medicine/alkysine, 5)
brain.setOrganDamage(0)
..()

Expand Down
9 changes: 8 additions & 1 deletion code/modules/surgery/organs/_organ.dm
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,18 @@ INITIALIZE_IMMEDIATE(/obj/item/organ)

/// Can this organ be revived from the dead?
/obj/item/organ/proc/can_recover()
if(maxHealth < 0)
return FALSE

// You can always repair a cyber organ
if((organ_flags & ORGAN_SYNTHETIC))
return TRUE

return ((maxHealth > 0) && (!(organ_flags & ORGAN_DEAD) || time_of_death >= (world.time - ORGAN_RECOVERY_THRESHOLD)))
if(organ_flags & ORGAN_DEAD)
if(world.time >= (time_of_death + ORGAN_RECOVERY_THRESHOLD))
return FALSE

return TRUE

/// Called by Insert() if the organ is vital and the target is dead.
/obj/item/organ/proc/attempt_vital_organ_revival(mob/living/carbon/human/owner)
Expand Down
6 changes: 3 additions & 3 deletions code/modules/tables/tables_racks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
COMSIG_CARBON_DISARM_COLLIDE = PROC_REF(table_carbon),
COMSIG_ATOM_ENTERED = PROC_REF(on_crossed),
COMSIG_ATOM_EXIT = PROC_REF(check_exit),
COMSIG_ATOM_EXITTED = PROC_REF(on_uncrossed),
COMSIG_ATOM_EXITED = PROC_REF(on_uncrossed),
)

AddElement(/datum/element/connect_loc, loc_connections)
Expand Down Expand Up @@ -251,7 +251,7 @@
if(!HAS_TRAIT(crossed_by, TRAIT_TABLE_RISEN))
ADD_TRAIT(crossed_by, TRAIT_TABLE_RISEN, TRAIT_GENERIC)

/obj/structure/table/proc/on_uncrossed(atom/movable/gone, direction)
/obj/structure/table/proc/on_uncrossed(datum/source, atom/movable/gone, direction)
SIGNAL_HANDLER
if(!isliving(gone))
return
Expand Down Expand Up @@ -894,7 +894,7 @@
else
return ..()

/obj/structure/table/optable/on_uncrossed(atom/movable/gone, direction)
/obj/structure/table/optable/on_uncrossed(datum/source, atom/movable/gone, direction)
. = ..()
if(gone == patient)
set_patient(null)
Expand Down
39 changes: 39 additions & 0 deletions code/modules/unit_tests/surgeries.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,42 @@
hemostat.melee_attack_chain(user, patient)

TEST_ASSERT(BP.get_damage() <= BP.max_damage * 0.25, "Chest did not heal to less than [BP.max_damage/2], healed to [BP.get_damage()]")

/datum/unit_test/test_retraction/Run()
var/mob/living/carbon/human/patient = allocate(/mob/living/carbon/human)
var/mob/living/carbon/human/user = allocate(/mob/living/carbon/human)
var/obj/structure/table/table = allocate(/obj/structure/table/optable)
var/obj/item/scalpel/scalpel = allocate(__IMPLIED_TYPE__)
var/obj/item/retractor/retractor = allocate(__IMPLIED_TYPE__)
var/obj/item/circular_saw/saw = allocate(__IMPLIED_TYPE__)

table.forceMove(get_turf(patient)) //Not really needed but it silences the linter and gives insurance
patient.set_lying_down()

for(var/zone in list(BODY_ZONE_HEAD, BODY_ZONE_CHEST, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM))
var/obj/item/bodypart/BP = patient.get_bodypart(zone)

user.zone_selected = zone
user.desired_surgery = /datum/surgery_step/generic_organic/incise
user.put_in_active_hand(scalpel)
scalpel.melee_attack_chain(user, patient)

TEST_ASSERT(BP.how_open() == SURGERY_OPEN, "[parse_zone(zone)] was not incised.")

user.desired_surgery = /datum/surgery_step/generic_organic/retract_skin
user.drop_all_held_items()
user.put_in_active_hand(retractor)
retractor.melee_attack_chain(user, patient)

TEST_ASSERT(BP.how_open() == SURGERY_RETRACTED, "[parse_zone(zone)]'s incision was not widened (Openness: [BP.how_open()]).")

if(BP.encased)
user.desired_surgery = /datum/surgery_step/open_encased
user.drop_all_held_items()
user.put_in_active_hand(saw)
saw.melee_attack_chain(user, patient)

TEST_ASSERT(BP.how_open() == SURGERY_DEENCASED, "[parse_zone(zone)] was not de-encased (Openness: [BP.how_open()]).")

user.drop_all_held_items()
patient.fully_heal()

0 comments on commit b14240d

Please sign in to comment.