Skip to content

Commit

Permalink
Organ movement refactor *Un-nullspaces your organs* [MDB IGNORE] #255…
Browse files Browse the repository at this point in the history
…30 (#42)

* Organ movement refactor *Un-nullspaces your organs*

* Fix conflicts

I checked the conflicts on the two weird conflicts and no previous TG pr touches them i assume its just github being github because those shoulden't be conflicts *shrug

* Fix #1 uhh...this is going to be a long one

* Fix #2 Modular Movement Flags

* Fix #3 It builds now

* Fix #4 Oh god it builds now, I missed some things

* Fix #5 No more Runtimesplosion Now time for Synths

* Fix #6 Shut up CI Where did you even come from

* Fix #7 Didn't I fix you already?

* Update language.dm

* Fix Opfor jank

* Revert "Fix Opfor jank"

This reverts commit 6af2fd71d85e6be58890f27f4f32bf92cfcb00fb.

* Revert "Revert "Fix Opfor jank""

This reverts commit cbd72277afd05f30a0b6f499a8162412fe3663ea.

* Update module_template.md

* Revert "Revert "Revert "Fix Opfor jank"""

This reverts commit 71ae4c10d8e9876c97f67278c55caa994b26a7dc.

* Fixing a runtime with H.A.R.S. (#80772)

The brain gets moved into the chest with H.A.R.S. now, but the bodypart
insertion and removal procs for it still asume it can only be found in
the head. This should fix it. For the sake of preventing similar issues
in the future, I've also updated the pretty-much-identical versions for
ears, eyes and tongue.

I've checked, and the brain var is only used by the head for visuals and
examine strings.

* Modular updates

* Fix synths not dying after being debrained

* Update brain.dm

* Update cortical_borer.dm

* Revert "Fixing a runtime with H.A.R.S. (#80772)"

This reverts commit 225035c2101d0e8946f7ef8cb375b68f2d25533a.

* Update dismemberment.dm

---------

Co-authored-by: Time-Green <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
Co-authored-by: Ghom <[email protected]>
  • Loading branch information
5 people authored and Iajret committed Jan 10, 2024
1 parent f659481 commit 237f8e0
Show file tree
Hide file tree
Showing 118 changed files with 933 additions and 838 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/organ_movement.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// Delete the organ if replaced
#define DELETE_IF_REPLACED (1<<0)
/// When deleting a brain, we don't delete the identity and the player can keep playing
#define NO_ID_TRANSFER (1<<1)
2 changes: 2 additions & 0 deletions code/__DEFINES/traits/sources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -275,5 +275,7 @@

#define ANALYZER_TRAIT "analyzer_trait"

/// Trait from an organ being inside a bodypart
#define ORGAN_INSIDE_BODY_TRAIT "organ_inside_body"
/// Trait when something was labelled by a pen.
#define PEN_LABEL_TRAIT "pen_label"
5 changes: 0 additions & 5 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,6 @@ GLOBAL_LIST_EMPTY(species_list)
if(isliving(occupant))
mob_occupant = occupant

else if(isbodypart(occupant))
var/obj/item/bodypart/head/head = occupant

mob_occupant = head.brainmob

else if(isorgan(occupant))
var/obj/item/organ/internal/brain/brain = occupant
mob_occupant = brain.brainmob
Expand Down
4 changes: 4 additions & 0 deletions code/datums/ai/generic/generic_behaviors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@
continue
if(thing.IsObscured())
continue
if(isitem(thing))
var/obj/item/item = thing
if(item.item_flags & ABSTRACT)
continue
possible_targets += thing
if(!possible_targets.len)
finish_action(controller, FALSE)
Expand Down
18 changes: 9 additions & 9 deletions code/datums/bodypart_overlays/mutant_bodypart_overlay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,26 @@
CRASH("External organ has no feature list, it will render invisible")

///Give the organ its color. Force will override the existing one.
/datum/bodypart_overlay/mutant/proc/inherit_color(obj/item/bodypart/ownerlimb, force)
if(isnull(ownerlimb))
/datum/bodypart_overlay/mutant/proc/inherit_color(obj/item/bodypart/bodypart_owner, force)
if(isnull(bodypart_owner))
draw_color = null
alpha = 255 // NOVA EDIT - Mutant bodyparts transparency are based on limb transparency
alpha = 255 // NOVA EDIT ADDITION - Mutant bodyparts transparency are based on limb transparency
return TRUE

if(draw_color && !force)
return FALSE

alpha = ownerlimb.alpha // NOVA EDIT - Mutant bodyparts transparency are based on limb transparency
alpha = bodypart_owner.alpha // NOVA EDIT ADDITION - Mutant bodyparts transparency are based on limb transparency
switch(color_source)
if(ORGAN_COLOR_OVERRIDE)
draw_color = override_color(ownerlimb.draw_color)
draw_color = override_color(bodypart_owner.draw_color)
if(ORGAN_COLOR_INHERIT)
draw_color = ownerlimb.draw_color
draw_color = bodypart_owner.draw_color
if(ORGAN_COLOR_HAIR)
if(!ishuman(ownerlimb.owner))
if(!ishuman(bodypart_owner.owner))
return
var/mob/living/carbon/human/human_owner = ownerlimb.owner
var/obj/item/bodypart/head/my_head = human_owner.get_bodypart(BODY_ZONE_HEAD) //not always the same as ownerlimb
var/mob/living/carbon/human/human_owner = bodypart_owner.owner
var/obj/item/bodypart/head/my_head = human_owner.get_bodypart(BODY_ZONE_HEAD) //not always the same as bodypart_owner
//head hair color takes priority, owner hair color is a backup if we lack a head or something
if(my_head)
draw_color = my_head.hair_color
Expand Down
4 changes: 4 additions & 0 deletions code/datums/components/crafting/crafting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
for(var/atom/movable/AM in range(radius_range, a))
if((AM.flags_1 & HOLOGRAM_1) || (blacklist && (AM.type in blacklist)))
continue
if(isitem(AM))
var/obj/item/item = AM
if(item.item_flags & ABSTRACT) //let's not tempt fate, shall we?
continue
. += AM

/datum/component/personal_crafting/proc/get_surroundings(atom/a, list/blacklist=null)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/diseases/gastrolisis.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
var/obj/item/organ/internal/eyes/eyes = locate(/obj/item/organ/internal/eyes/snail) in affected_mob.organs
if(!eyes && SPT_PROB(2.5, seconds_per_tick))
var/obj/item/organ/internal/eyes/snail/new_eyes = new()
new_eyes.Insert(affected_mob, drop_if_replaced = TRUE)
new_eyes.Insert(affected_mob)
affected_mob.visible_message(span_warning("[affected_mob]'s eyes fall out, with snail eyes taking its place!"), \
span_userdanger("You scream in pain as your eyes are pushed out by your new snail eyes!"))
affected_mob.emote("scream")
Expand Down
1 change: 0 additions & 1 deletion code/datums/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block())
update_body(is_creating = TRUE)
update_mutations_overlay()// no lizard with human hulk overlay please.


/mob/proc/has_dna()
return

Expand Down
4 changes: 3 additions & 1 deletion code/datums/mutations/body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -524,14 +524,16 @@

var/obj/item/organ/internal/brain/brain = owner.get_organ_slot(ORGAN_SLOT_BRAIN)
if(brain)
brain.Remove(owner, special = TRUE)
brain.zone = BODY_ZONE_CHEST
brain.Insert(owner, special = TRUE)

var/obj/item/bodypart/head/head = owner.get_bodypart(BODY_ZONE_HEAD)
if(head)
owner.visible_message(span_warning("[owner]'s head splatters with a sickening crunch!"), ignored_mobs = list(owner))
new /obj/effect/gibspawner/generic(get_turf(owner), owner)
head.dismember(dam_type = BRUTE, silent = TRUE)
head.drop_organs()
head.dismember(dam_type = BRUTE, silent = TRUE)
qdel(head)
RegisterSignal(owner, COMSIG_ATTEMPT_CARBON_ATTACH_LIMB, PROC_REF(abort_attachment))

Expand Down
2 changes: 1 addition & 1 deletion code/datums/quirks/negative_quirks/junkie.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
smoker_lungs = /obj/item/organ/internal/lungs/smoker_lungs
if(!isnull(smoker_lungs))
smoker_lungs = new smoker_lungs
smoker_lungs.Insert(carbon_holder, special = TRUE, drop_if_replaced = FALSE)
smoker_lungs.Insert(carbon_holder, special = TRUE, movement_flags = DELETE_IF_REPLACED)

/datum/quirk/item_quirk/junkie/smoker/process(seconds_per_tick)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/quirks/negative_quirks/prosthetic_organ.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
medical_record_text = "During physical examination, patient was found to have a low-budget prosthetic [slot_string]. \
<b>Removal of these organs is known to be dangerous to the patient as well as the practitioner.</b>"
old_organ = human_holder.get_organ_slot(organ_slot)
if(prosthetic.Insert(human_holder, special = TRUE, drop_if_replaced = TRUE))
if(prosthetic.Insert(human_holder, special = TRUE))
old_organ.moveToNullspace()
STOP_PROCESSING(SSobj, old_organ)

Expand Down
2 changes: 1 addition & 1 deletion code/datums/quirks/negative_quirks/tin_man.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
for(var/organ_slot in possible_organ_slots)
var/organ_path = possible_organ_slots[organ_slot]
var/obj/item/organ/new_organ = new organ_path()
new_organ.Insert(human_holder, special = TRUE, drop_if_replaced = FALSE)
new_organ.Insert(human_holder, special = TRUE, movement_flags = DELETE_IF_REPLACED)

/datum/quirk/tin_man/post_add()
to_chat(quirk_holder, span_boldannounce("Most of your internal organs have been replaced with surplus prosthetics. They are fragile and will easily come apart under duress. \
Expand Down
2 changes: 1 addition & 1 deletion code/datums/station_traits/positive_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
ai.eyeobj.relay_speech = TRUE //surveillance upgrade. the ai gets cybernetics too.
return
var/obj/item/organ/internal/cybernetic = new cybernetic_type()
cybernetic.Insert(spawned, special = TRUE, drop_if_replaced = FALSE)
cybernetic.Insert(spawned, special = TRUE, movement_flags = DELETE_IF_REPLACED)

/datum/station_trait/luxury_escape_pods
name = "Luxury Escape Pods"
Expand Down
2 changes: 1 addition & 1 deletion code/datums/status_effects/neutral.dm
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@
return
if(prob(1))//low chance of the alternative reality returning to monkey
var/obj/item/organ/external/tail/monkey/monkey_tail = new ()
monkey_tail.Insert(human_mob, drop_if_replaced = FALSE)
monkey_tail.Insert(human_mob, movement_flags = DELETE_IF_REPLACED)
var/datum/species/human_species = human_mob.dna?.species
if(human_species)
human_species.randomize_active_features(human_mob)
Expand Down
23 changes: 14 additions & 9 deletions code/game/machinery/dna_infuser/organ_sets/carp_organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
AddElement(/datum/element/noticable_organ, "teeth are big and sharp.", BODY_ZONE_PRECISE_MOUTH)
AddElement(/datum/element/organ_set_bonus, /datum/status_effect/organ_set_bonus/carp)

/obj/item/organ/internal/tongue/carp/on_insert(mob/living/carbon/tongue_owner)
/obj/item/organ/internal/tongue/carp/on_mob_insert(mob/living/carbon/tongue_owner, special, movement_flags)
. = ..()
if(!ishuman(tongue_owner))
return
Expand All @@ -57,12 +57,14 @@
return
var/datum/species/rec_species = human_receiver.dna.species
rec_species.update_no_equip_flags(tongue_owner, rec_species.no_equip_flags | ITEM_SLOT_MASK)
var/obj/item/bodypart/head/head = human_receiver.get_bodypart(BODY_ZONE_HEAD)
head.unarmed_damage_low = 10
head.unarmed_damage_high = 15
head.unarmed_effectiveness = 15

/obj/item/organ/internal/tongue/carp/on_remove(mob/living/carbon/tongue_owner)
/obj/item/organ/internal/tongue/carp/on_bodypart_insert(obj/item/bodypart/limb)
. = ..()
limb.unarmed_damage_low = 10
limb.unarmed_damage_high = 15
limb.unarmed_effectiveness = 15

/obj/item/organ/internal/tongue/carp/on_mob_remove(mob/living/carbon/tongue_owner)
. = ..()
if(!ishuman(tongue_owner))
return
Expand All @@ -71,7 +73,10 @@
return
var/datum/species/rec_species = human_receiver.dna.species
rec_species.update_no_equip_flags(tongue_owner, initial(rec_species.no_equip_flags))
var/obj/item/bodypart/head/head = human_receiver.get_bodypart(BODY_ZONE_HEAD)

/obj/item/organ/internal/tongue/carp/on_bodypart_remove(obj/item/bodypart/head)
. = ..()

head.unarmed_damage_low = initial(head.unarmed_damage_low)
head.unarmed_damage_high = initial(head.unarmed_damage_high)
head.unarmed_effectiveness = initial(head.unarmed_effectiveness)
Expand Down Expand Up @@ -110,13 +115,13 @@
AddElement(/datum/element/organ_set_bonus, /datum/status_effect/organ_set_bonus/carp)
AddElement(/datum/element/noticable_organ, "seem%PRONOUN_S unable to stay still.")

/obj/item/organ/internal/brain/carp/on_insert(mob/living/carbon/brain_owner)
/obj/item/organ/internal/brain/carp/on_mob_insert(mob/living/carbon/brain_owner)
. = ..()
cooldown_timer = addtimer(CALLBACK(src, PROC_REF(unsatisfied_nomad)), cooldown_time, TIMER_STOPPABLE|TIMER_OVERRIDE|TIMER_UNIQUE)
RegisterSignal(brain_owner, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(satisfied_nomad))

//technically you could get around the mood issue by extracting and reimplanting the brain but it will be far easier to just go one z there and back
/obj/item/organ/internal/brain/carp/on_remove(mob/living/carbon/brain_owner)
/obj/item/organ/internal/brain/carp/on_mob_remove(mob/living/carbon/brain_owner)
. = ..()
UnregisterSignal(brain_owner, COMSIG_MOVABLE_Z_CHANGED)
deltimer(cooldown_timer)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/dna_infuser/organ_sets/fox_organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

//NOVA EDIT REMOVAL BEGIN - CUSTOMIZATION
/*
/obj/item/organ/internal/ears/fox/on_insert(mob/living/carbon/human/ear_owner)
/obj/item/organ/internal/ears/fox/on_mob_insert(mob/living/carbon/human/ear_owner)
. = ..()
if(istype(ear_owner) && ear_owner.dna)
color = ear_owner.hair_color
ear_owner.dna.features["ears"] = ear_owner.dna.species.mutant_bodyparts["ears"] = "Fox"
ear_owner.dna.update_uf_block(DNA_EARS_BLOCK)
ear_owner.update_body()
/obj/item/organ/internal/ears/fox/on_remove(mob/living/carbon/human/ear_owner)
/obj/item/organ/internal/ears/fox/on_mob_remove(mob/living/carbon/human/ear_owner)
. = ..()
if(istype(ear_owner) && ear_owner.dna)
color = ear_owner.hair_color
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/dna_infuser/organ_sets/goliath_organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
AddElement(/datum/element/noticable_organ, "arm is just a mass of plate and tendrils.", BODY_ZONE_CHEST)
AddElement(/datum/element/organ_set_bonus, /datum/status_effect/organ_set_bonus/goliath)

/obj/item/organ/internal/brain/goliath/on_insert(mob/living/carbon/brain_owner)
/obj/item/organ/internal/brain/goliath/on_mob_insert(mob/living/carbon/brain_owner)
. = ..()
if(!ishuman(brain_owner))
return
Expand All @@ -78,7 +78,7 @@
hammer = new/obj/item/goliath_infuser_hammer
brain_owner.put_in_hands(hammer)

/obj/item/organ/internal/brain/goliath/on_remove(mob/living/carbon/brain_owner)
/obj/item/organ/internal/brain/goliath/on_mob_remove(mob/living/carbon/brain_owner)
. = ..()
UnregisterSignal(brain_owner)
if(!ishuman(brain_owner))
Expand Down
12 changes: 6 additions & 6 deletions code/game/machinery/dna_infuser/organ_sets/gondola_organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ Fluoride Stare: After someone says 5 words, blah blah blah...
AddElement(/datum/element/organ_set_bonus, /datum/status_effect/organ_set_bonus/gondola)
AddElement(/datum/element/noticable_organ, "radiate%PRONOUN_S an aura of serenity.")

/obj/item/organ/internal/heart/gondola/Insert(mob/living/carbon/receiver, special, drop_if_replaced)
/obj/item/organ/internal/heart/gondola/Insert(mob/living/carbon/receiver, special, movement_flags)
. = ..()
if(!(FACTION_HOSTILE in receiver.faction))
factions_to_remove += FACTION_HOSTILE
if(!(FACTION_MINING in receiver.faction))
factions_to_remove += FACTION_MINING
receiver.faction |= list(FACTION_HOSTILE, FACTION_MINING)

/obj/item/organ/internal/heart/gondola/Remove(mob/living/carbon/heartless, special)
/obj/item/organ/internal/heart/gondola/Remove(mob/living/carbon/heartless, special, movement_flags)
. = ..()
for(var/faction in factions_to_remove)
heartless.faction -= faction
Expand All @@ -63,11 +63,11 @@ Fluoride Stare: After someone says 5 words, blah blah blah...
AddElement(/datum/element/noticable_organ, "mouth is permanently affixed into a relaxed smile.", BODY_ZONE_PRECISE_MOUTH)
AddElement(/datum/element/organ_set_bonus, /datum/status_effect/organ_set_bonus/gondola)

/obj/item/organ/internal/tongue/gondola/Insert(mob/living/carbon/tongue_owner, special, drop_if_replaced)
/obj/item/organ/internal/tongue/gondola/Insert(mob/living/carbon/tongue_owner, special, movement_flags)
. = ..()
tongue_owner.add_mood_event("gondola_zen", /datum/mood_event/gondola_serenity)

/obj/item/organ/internal/tongue/gondola/Remove(mob/living/carbon/tongue_owner, special)
/obj/item/organ/internal/tongue/gondola/Remove(mob/living/carbon/tongue_owner, special, movement_flags)
tongue_owner.clear_mood_event("gondola_zen")
return ..()

Expand All @@ -89,7 +89,7 @@ Fluoride Stare: After someone says 5 words, blah blah blah...
AddElement(/datum/element/noticable_organ, "right arm has small needles breaching the skin all over it.", BODY_ZONE_R_ARM)
pax_hugs = new

/obj/item/organ/internal/liver/gondola/Insert(mob/living/carbon/liver_owner, special, drop_if_replaced)
/obj/item/organ/internal/liver/gondola/Insert(mob/living/carbon/liver_owner, special, movement_flags)
. = ..()
var/has_left = liver_owner.has_left_hand(check_disabled = FALSE)
var/has_right = liver_owner.has_right_hand(check_disabled = FALSE)
Expand All @@ -104,7 +104,7 @@ Fluoride Stare: After someone says 5 words, blah blah blah...
RegisterSignal(liver_owner, COMSIG_HUMAN_EQUIPPING_ITEM, PROC_REF(on_owner_equipping_item))
RegisterSignal(liver_owner, COMSIG_LIVING_TRY_PULL, PROC_REF(on_owner_try_pull))

/obj/item/organ/internal/liver/gondola/Remove(mob/living/carbon/liver_owner, special)
/obj/item/organ/internal/liver/gondola/Remove(mob/living/carbon/liver_owner, special, movement_flags)
. = ..()
pax_hugs.remove(liver_owner)
UnregisterSignal(liver_owner, list(COMSIG_HUMAN_EQUIPPING_ITEM, COMSIG_LIVING_TRY_PULL))
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/dna_infuser/organ_sets/rat_organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
AddElement(/datum/element/organ_set_bonus, /datum/status_effect/organ_set_bonus/rat)
AddElement(/datum/element/noticable_organ, "hunch%PRONOUN_ES over unnaturally!")

/obj/item/organ/internal/heart/rat/on_insert(mob/living/carbon/receiver)
/obj/item/organ/internal/heart/rat/on_mob_insert(mob/living/carbon/receiver)
. = ..()
if(!. || !ishuman(receiver))
return
Expand All @@ -75,7 +75,7 @@
if(human_receiver.physiology)
human_receiver.physiology.damage_resistance -= 50

/obj/item/organ/internal/heart/rat/on_remove(mob/living/carbon/heartless, special)
/obj/item/organ/internal/heart/rat/on_mob_remove(mob/living/carbon/heartless, special)
. = ..()
if(!ishuman(heartless))
return
Expand Down Expand Up @@ -113,11 +113,11 @@
if(message == "hi?")
speech_args[SPEECH_MESSAGE] = "Um... cheesed to meet you?"

/obj/item/organ/internal/tongue/rat/on_insert(mob/living/carbon/tongue_owner, special, drop_if_replaced)
/obj/item/organ/internal/tongue/rat/on_mob_insert(mob/living/carbon/tongue_owner, special, movement_flags)
. = ..()
RegisterSignal(tongue_owner, COMSIG_CARBON_ITEM_GIVEN, PROC_REF(its_on_the_mouse))

/obj/item/organ/internal/tongue/rat/on_remove(mob/living/carbon/tongue_owner)
/obj/item/organ/internal/tongue/rat/on_mob_remove(mob/living/carbon/tongue_owner)
. = ..()
UnregisterSignal(tongue_owner, COMSIG_CARBON_ITEM_GIVEN)

Expand Down
Loading

0 comments on commit 237f8e0

Please sign in to comment.