-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIRROR] DNA Infusion Refactor: Separates DNA Infusion Behavior from …
…DNA Infuser (#2185) (#3061) * DNA Infusion Refactor: Separates DNA Infusion Behavior from DNA Infuser (#82829) ## About The Pull Request - infuser entries global is now an assoc list type -> singleton. makes it easier to pick specific entries as needed - separated infusion behavior onto both movable level (for machine occupants and things that can potentially be infused) and human level (for the actual infusion into a human) - [x] tested ## Why It's Good For The Game Upcoming plans is to fix up maintenance sect's organ replacement system that just so happens to work a lot like how infusions do with actual infusion mechanics, and that requires this prerequisite. In general outside of that vision I see a lot of potential in alternate infusion sources, from wherever they may be. ## Changelog no player side changes, this is a refactor * DNA Infusion Refactor: Separates DNA Infusion Behavior from DNA Infuser --------- Co-authored-by: NovaBot <[email protected]> Co-authored-by: tralezab <[email protected]>
- Loading branch information
1 parent
819095c
commit 95edb4c
Showing
6 changed files
with
100 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
|
||
///returns a boolean whether a machine occupant can be infused | ||
/atom/movable/proc/can_infuse(mob/feedback_target) | ||
if(feedback_target) | ||
balloon_alert(feedback_target, "no dna!") | ||
return FALSE | ||
|
||
/mob/living/can_infuse(mob/feedback_target) | ||
if(feedback_target) | ||
balloon_alert(feedback_target, "dna too simple!") | ||
return FALSE | ||
|
||
/mob/living/carbon/human/can_infuse(mob/feedback_target) | ||
// Checked by can_mutate but explicit feedback for this issue is good | ||
if(HAS_TRAIT(src, TRAIT_BADDNA)) | ||
if(feedback_target) | ||
balloon_alert(feedback_target, "dna is corrupted!") | ||
return FALSE | ||
if(!can_mutate()) | ||
if(feedback_target) | ||
balloon_alert(feedback_target, "dna is missing!") | ||
return FALSE | ||
return TRUE | ||
|
||
///returns /datum/infuser_entry that matches an item being used for infusion, returns a fly mutation on failure | ||
/atom/movable/proc/get_infusion_entry() as /datum/infuser_entry | ||
var/datum/infuser_entry/found | ||
for(var/datum/infuser_entry/entry as anything in flatten_list(GLOB.infuser_entries)) | ||
if(entry.tier == DNA_MUTANT_UNOBTAINABLE) | ||
continue | ||
if(is_type_in_list(src, entry.input_obj_or_mob)) | ||
found = entry | ||
break | ||
if(!found) | ||
found = GLOB.infuser_entries[/datum/infuser_entry/fly] | ||
return found | ||
|
||
/// Attempt to replace/add-to the occupant's organs with "mutated" equivalents. | ||
/// Returns TRUE on success, FALSE on failure. | ||
/// Requires the target mob to have an existing organic organ to "mutate". | ||
// TODO: In the future, this should have more logic: | ||
// - Replace non-mutant organs before mutant ones. | ||
/mob/living/carbon/human/proc/infuse_organ(datum/infuser_entry/entry) | ||
var/obj/item/organ/new_organ = pick_infusion_organ(entry) | ||
if(!new_organ) | ||
return FALSE | ||
// Valid organ successfully picked. | ||
new_organ = new new_organ() | ||
new_organ.replace_into(src) | ||
return TRUE | ||
|
||
/// Picks a random mutated organ from the given infuser entry which is also compatible with this human. | ||
/// Tries to return a typepath of 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. | ||
/mob/living/carbon/human/proc/pick_infusion_organ(datum/infuser_entry/entry) | ||
if(!entry) | ||
return FALSE | ||
var/list/obj/item/organ/potential_new_organs = entry.output_organs.Copy() | ||
// Remove organ typepaths from the list if they're incompatible with target. | ||
for(var/obj/item/organ/new_organ as anything in entry.output_organs) | ||
var/obj/item/organ/old_organ = get_organ_slot(initial(new_organ.slot)) | ||
if(old_organ) | ||
if((old_organ.type != new_organ) && !IS_ROBOTIC_ORGAN(old_organ)) | ||
continue // Old organ can be mutated! | ||
else if(ispath(new_organ, /obj/item/organ/external)) | ||
continue // External organ can be grown! | ||
// Internal organ is either missing, or is non-organic. | ||
potential_new_organs -= new_organ | ||
// Pick a random organ from the filtered list. | ||
if(length(potential_new_organs)) | ||
return pick(potential_new_organs) | ||
return FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters