[MIRROR] Fix: DNA Infuser & Infusions [MDB IGNORE] (#18748)

* Fix: DNA Infuser & Infusions

* Fixes the damn conflict

* Fix: DNA Infuser Organ Filtering (#72745)

## About The Pull Request

My PR #72688 was merged mid-review. This is a followup PR to fix the
buggy code which was introduced by myself in between testing a naive
approach to organ filtering. The code does not work due to my own
oversight, as I was attempting to test buggy code in
`/obj/machinery/dna_infuser/proc/infuse_organ` when the prior PR was
merged.

I took this chance to simplify the code more, and I added an additional
proc to the DNA Infuser to replace inline code, `pick_organ`. The proc
picks a random mutated organ from the infuser entry which is also
compatible with the target mob. If none of the organs are compatible,
then the infusion still pricks you with needles but nearly-silently
fails by omitting the "You feel yourself becoming..." chat message.

`pick_organ` tries to return a valid mutant organ if all of the
following criteria are true:
1. Target must have a pre-existing organ in the same organ slot as the
new organ;
   - Or, the new organ must be external.
2. Target's pre-existing organ must be organic / not robotic.
3. Target must not have the same/identical organ.

## Why It's Good For The Game

The DNA Infuser should filter organs depending on whether or not the
occupant has one already, if it is organic, and if it doesn't exist the
occupant can still get an external organ (such as a cat tail). This PR
introduces algorithmically correct code to filter the organs, and fixes
bugs introduced by my prior PR which caused the proc to throw a runtime.

## Changelog

🆑 A.C.M.O.
fix: Fixed buggy organ filtering code in the DNA Infuser which stopped
it from infusing organs.
/🆑

Co-authored-by: Dani Glore <fantasticdragons@gmail.com>
Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-01-23 23:18:50 +01:00
committed by GitHub
parent 093d930b47
commit 8fcac218c1
5 changed files with 117 additions and 73 deletions
+5 -5
View File
@@ -6,9 +6,10 @@
/datum/element/noticable_organ
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
// "[they] [desc here]", shows on examining someone with an infused organ.
/// "[they]|[their] [desc here]", shows on examining someone with an infused organ.
/// Uses a possessive pronoun (His/Her/Their) if a body zone is given, or a singular pronoun (He/She/They) otherwise.
var/infused_desc
///Which body zone has to be exposed. If none is set, this is always noticable.
/// Which body zone has to be exposed. If none is set, this is always noticable, and the description pronoun becomes singular instead of possesive.
var/body_zone
/datum/element/noticable_organ/Attach(datum/target, infused_desc, body_zone)
@@ -42,7 +43,6 @@
/datum/element/noticable_organ/proc/on_receiver_examine(mob/living/carbon/examined, mob/user, list/examine_list)
SIGNAL_HANDLER
var/list/covered = examined.get_covered_body_zones()
if(!body_zone || (body_zone in covered))
if(body_zone && (body_zone in examined.get_covered_body_zones()))
return
examine_list += span_notice("[examined.p_they(TRUE)] [infused_desc]")
examine_list += span_notice("[body_zone ? examined.p_their(TRUE) : examined.p_they(TRUE)] [infused_desc]")