Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOUNTY] Adds random mutations to DNA disk maints loot #5690

Merged
merged 6 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/_globalvars/lists/maintenance_loot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ GLOBAL_LIST_INIT(trash_loot, list(//junk: useless, very easy to get, or ghetto c
/obj/item/trash/candle = 1,

/obj/item/c_tube = 1,
/obj/item/disk/data = 1,
/obj/item/disk/data/random = 1, // monkestation edit: use random dna data disks
/obj/item/folder/yellow = 1,
/obj/item/hand_labeler = 1,
/obj/item/paper = 1,
Expand Down
8 changes: 8 additions & 0 deletions code/game/machinery/computer/dna_console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,14 @@

var/datum/mutation/human/A = new HM.type(MUT_EXTRA, null, HM)
stored_mutations += A

// monkestationn start: mark as discovered when saving from disk
var/datum/mutation/human/mutation_type = A.type
if(stored_research && !(mutation_type in stored_research.discovered_mutations))
stored_research.discovered_mutations += mutation_type
say("Successfully unlocked [A.name].")
// monkestationn end

to_chat(usr,span_notice("Mutation successfully stored."))
return

Expand Down
1 change: 1 addition & 0 deletions code/game/objects/effects/spawners/random/techstorage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
spawn_all_loot = FALSE
loot = list(
/obj/item/disk/data = 49,
/obj/item/disk/data/random = 5, // monkestation edit: add random dna data disks (this is a weighted list, it does NOT have to add up to 50 lol)
/obj/item/disk/nuclear/fake/obvious = 1,
)

Expand Down
33 changes: 33 additions & 0 deletions monkestation/code/datums/mutations.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/datum/mutation/human
/// This mutation cannot appear in random DNA disks.
/// This is separate from the `locked` var so that otherwise locked mutations can appear in them.
var/random_locked = FALSE

/datum/mutation/human/proc/valid_chromosome_types()
. = list()
if(can_chromosome == CHROMOSOME_NEVER)
return

if(stabilizer_coeff != -1)
. += /obj/item/chromosome/stabilizer
if(synchronizer_coeff != -1)
. += /obj/item/chromosome/synchronizer
if(power_coeff != -1)
. += /obj/item/chromosome/power
if(energy_coeff != -1)
. += /obj/item/chromosome/energy

/datum/mutation/human/bad_dna
random_locked = TRUE

/datum/mutation/human/race
random_locked = TRUE

/datum/mutation/human/chameleon/changeling
random_locked = TRUE

/datum/mutation/human/xray
random_locked = TRUE

/datum/mutation/human/laser_eyes
random_locked = TRUE
61 changes: 61 additions & 0 deletions monkestation/code/game/machinery/dna_scanner.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/// The weight used to pick a positive mutation.
#define POSITIVE_WEIGHT 5
/// The weight used to pick a neutral mutation.
#define NEUTRAL_WEIGHT 2
/// The weight used to pick a negative mutation.
#define NEGATIVE_WEIGHT 2
/// The percent chance that a mutation will have a random (non-stabilizer) chromosome applied, if applicable
#define CHROMOSOME_PROB 70
/// The percent chance that a mutation will have a stabilizer chromosome applied, if another chromosome wasn't already applied.
#define STABILIZER_PROB 15

/obj/item/disk/data/random
name = "old DNA data disk"
desc = "A dust-caked disk with DNA mutation info on it. Wonder what it has..."
read_only = TRUE
/// A weighted list of mutations, albeit a two layered one, so it will do a weighted pick for mutation quality, then pick a mutation of that quality.
var/static/list/mutation_weights

/obj/item/disk/data/random/Initialize(mapload)
. = ..()
if(isnull(mutation_weights))
mutation_weights = initialize_mutation_weights()

var/mutation_type = pick_weight_recursive(mutation_weights)
var/datum/mutation/human/mutation = new mutation_type(GET_INITIALIZED_MUTATION(mutation_type))
roll_for_chromosome(mutation)?.apply(mutation)
mutations += mutation

/// Randomly returns a valid initialized chromosome or null.
/obj/item/disk/data/random/proc/roll_for_chromosome(datum/mutation/human/mutation) as /obj/item/chromosome
RETURN_TYPE(/obj/item/chromosome)
var/chromosome_type
var/list/valid_chromosomes = mutation.valid_chromosome_types() - /obj/item/chromosome/stabilizer
if(length(valid_chromosomes) && prob(CHROMOSOME_PROB))
chromosome_type = pick(valid_chromosomes)
else if(prob(STABILIZER_PROB) && mutation.stabilizer_coeff != -1)
chromosome_type = /obj/item/chromosome/stabilizer
if(chromosome_type)
return new chromosome_type

/// Returns a (recursive) weighted list of mutations.
/obj/item/disk/data/random/proc/initialize_mutation_weights() as /list
RETURN_TYPE(/list)
. = list()
.[get_non_random_locked_mutations(GLOB.good_mutations)] = POSITIVE_WEIGHT
.[get_non_random_locked_mutations(GLOB.not_good_mutations)] = NEUTRAL_WEIGHT
.[get_non_random_locked_mutations(GLOB.bad_mutations)] = NEGATIVE_WEIGHT

/// Returns a list of the typepaths of mutations in the given list without the random_locked var enabled.
/obj/item/disk/data/random/proc/get_non_random_locked_mutations(list/mutations) as /list
RETURN_TYPE(/list)
. = list()
for(var/datum/mutation/human/mutation as anything in mutations)
if(!mutation.random_locked)
.[mutation.type] = isnull(mutation.species_allowed) ? 2 : 3

#undef STABILIZER_PROB
#undef CHROMOSOME_PROB
#undef NEGATIVE_WEIGHT
#undef NEUTRAL_WEIGHT
#undef POSITIVE_WEIGHT
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5957,6 +5957,7 @@
#include "monkestation\code\datums\http.dm"
#include "monkestation\code\datums\interaction_particle.dm"
#include "monkestation\code\datums\meta_tokens.dm"
#include "monkestation\code\datums\mutations.dm"
#include "monkestation\code\datums\patreon_data.dm"
#include "monkestation\code\datums\ruins.dm"
#include "monkestation\code\datums\stamina_container.dm"
Expand Down Expand Up @@ -6084,6 +6085,7 @@
#include "monkestation\code\game\machinery\bomb_actualizer.dm"
#include "monkestation\code\game\machinery\cloning.dm"
#include "monkestation\code\game\machinery\deployable.dm"
#include "monkestation\code\game\machinery\dna_scanner.dm"
#include "monkestation\code\game\machinery\exp_cloner.dm"
#include "monkestation\code\game\machinery\launch_pad.dm"
#include "monkestation\code\game\machinery\player_hologram.dm"
Expand Down
Loading