From c7deeb930ef85a6df77f5319b4fc3b15fb439d2a Mon Sep 17 00:00:00 2001 From: RustingWithYou <63625389+RustingWithYou@users.noreply.github.com> Date: Thu, 24 Nov 2022 10:32:09 +1300 Subject: [PATCH] Floral Somatoray Gene Targeting (#15111) --- aurorastation.dme | 1 + code/controllers/subsystems/plants.dm | 18 ++- code/modules/hydroponics/seed_gene_mut.dm | 136 ++++++++++++++++++ code/modules/hydroponics/seed_machines.dm | 4 +- code/modules/hydroponics/trays/tray.dm | 11 +- .../projectiles/guns/energy/special.dm | 20 ++- .../modules/projectiles/projectile/special.dm | 8 ++ html/changelogs/RustingWithYou.yml | 41 ++++++ 8 files changed, 231 insertions(+), 8 deletions(-) create mode 100644 code/modules/hydroponics/seed_gene_mut.dm create mode 100644 html/changelogs/RustingWithYou.yml diff --git a/aurorastation.dme b/aurorastation.dme index 76601204f9c..803df123ec9 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -1936,6 +1936,7 @@ #include "code\modules\hydroponics\grown_inedible.dm" #include "code\modules\hydroponics\grown_predefined.dm" #include "code\modules\hydroponics\seed.dm" +#include "code\modules\hydroponics\seed_gene_mut.dm" #include "code\modules\hydroponics\seed_machines.dm" #include "code\modules\hydroponics\seed_mobs.dm" #include "code\modules\hydroponics\seed_packets.dm" diff --git a/code/controllers/subsystems/plants.dm b/code/controllers/subsystems/plants.dm index 5b255d89604..db208b73e42 100644 --- a/code/controllers/subsystems/plants.dm +++ b/code/controllers/subsystems/plants.dm @@ -13,6 +13,9 @@ var/list/plant_icon_cache = list() // Stores images of growth, fruits and seeds. var/list/plant_sprites = list() // List of all harvested product sprites. var/list/plant_product_sprites = list() // List of all growth sprites plus number of growth stages. + var/list/gene_masked_list = list() // Stores list of masked genes rather than recreating it later + var/list/plant_gene_datums = list() // Stores gene masked list as datums + var/list/processing = list() var/list/current = list() @@ -54,6 +57,7 @@ S.roundstart = 1 //Might as well mask the gene types while we're at it. + var/list/gene_datums = list() var/list/used_masks = list() var/list/plant_traits = ALL_GENES while(plant_traits && plant_traits.len) @@ -63,9 +67,19 @@ while(gene_mask in used_masks) gene_mask = "[uppertext(num2hex(rand(0,255), 0))]" + var/decl/plantgene/G + + for(var/D in gene_datums) + var/decl/plantgene/P = gene_datums[D] + if(gene_tag == P.gene_tag) + G = P + gene_datums -=D + used_masks += gene_mask plant_traits -= gene_tag - gene_tag_masks[gene_tag] = gene_mask + gene_tag_masks[gene_mask] = gene_tag + plant_gene_datums[gene_mask] = G + gene_masked_list += (list(list("tag" = gene_tag, "mask" = gene_mask))) ..() @@ -77,6 +91,8 @@ src.plant_icon_cache = SSplants.plant_icon_cache src.plant_sprites = SSplants.plant_sprites src.plant_product_sprites = SSplants.plant_product_sprites + src.gene_masked_list = SSplants.gene_masked_list + src.plant_gene_datums = SSplants.plant_gene_datums /datum/controller/subsystem/plants/fire(resumed = 0) if (!resumed) diff --git a/code/modules/hydroponics/seed_gene_mut.dm b/code/modules/hydroponics/seed_gene_mut.dm new file mode 100644 index 00000000000..d44c8d74d07 --- /dev/null +++ b/code/modules/hydroponics/seed_gene_mut.dm @@ -0,0 +1,136 @@ +/datum/seed/proc/diverge_mutate_gene(var/decl/plantgene/G, var/turf/T) + if(!istype(G)) + log_debug("Attempted to mutate [src] with a non-plantgene var.") + return src + + var/datum/seed/S = diverge() //Let's not modify all of the seeds. + T.visible_message("\The [S.display_name] quivers!") //Mimicks the normal mutation. + G.mutate(S, T) + + return S + +/decl/plantgene + var/gene_tag + +/decl/plantgene/biochem + gene_tag = GENE_BIOCHEMISTRY + +/decl/plantgene/hardiness + gene_tag = GENE_HARDINESS + +/decl/plantgene/environment + gene_tag = GENE_ENVIRONMENT + +/decl/plantgene/metabolism + gene_tag = GENE_METABOLISM + +/decl/plantgene/structure + gene_tag = GENE_STRUCTURE + +/decl/plantgene/diet + gene_tag = GENE_DIET + +/decl/plantgene/pigment + gene_tag = GENE_PIGMENT + +/decl/plantgene/output + gene_tag = GENE_OUTPUT + +/decl/plantgene/atmosphere + gene_tag = GENE_ATMOSPHERE + +/decl/plantgene/vigour + gene_tag = GENE_VIGOUR + +/decl/plantgene/fruit + gene_tag = GENE_FRUIT + +/decl/plantgene/special + gene_tag = GENE_SPECIAL + + +/decl/plantgene/proc/mutate(var/datum/seed/S) + return + +/decl/plantgene/biochem/mutate(var/datum/seed/S) + S.set_trait(TRAIT_POTENCY, S.get_trait(TRAIT_POTENCY)+rand(-20,20),200, 0) + +/decl/plantgene/hardiness/mutate(var/datum/seed/S) + if(prob(60)) + S.set_trait(TRAIT_TOXINS_TOLERANCE, S.get_trait(TRAIT_TOXINS_TOLERANCE)+rand(-2,2),10,0) + if(prob(60)) + S.set_trait(TRAIT_PEST_TOLERANCE, S.get_trait(TRAIT_PEST_TOLERANCE)+rand(-2,2),10,0) + if(prob(60)) + S.set_trait(TRAIT_WEED_TOLERANCE, S.get_trait(TRAIT_WEED_TOLERANCE)+rand(-2,2),10,0) + if(prob(60)) + S.set_trait(TRAIT_ENDURANCE, S.get_trait(TRAIT_ENDURANCE)+rand(-5,5),100,0) + +/decl/plantgene/environment/mutate(var/datum/seed/S) + if(prob(60)) + S.set_trait(TRAIT_IDEAL_HEAT, S.get_trait(TRAIT_IDEAL_HEAT)+rand(-2,2),10,0) + if(prob(60)) + S.set_trait(TRAIT_IDEAL_LIGHT, S.get_trait(TRAIT_IDEAL_LIGHT)+rand(-2,2),10,0) + if(prob(60)) + S.set_trait(TRAIT_LIGHT_TOLERANCE, S.get_trait(TRAIT_LIGHT_TOLERANCE)+rand(-5,5),100,0) + +/decl/plantgene/metabolism/mutate(var/datum/seed/S) + if(prob(65)) + S.set_trait(TRAIT_REQUIRES_NUTRIENTS, S.get_trait(TRAIT_REQUIRES_NUTRIENTS)+rand(-2,2),10,0) + if(prob(65)) + S.set_trait(TRAIT_REQUIRES_WATER, S.get_trait(TRAIT_REQUIRES_WATER)+rand(-2,2),10,0) + if(prob(40)) + S.set_trait(TRAIT_ALTER_TEMP, S.get_trait(TRAIT_ALTER_TEMP)+rand(-5,5),100,0) + +/decl/plantgene/diet/mutate(var/datum/seed/S) + if(prob(60)) + S.set_trait(TRAIT_CARNIVOROUS, S.get_trait(TRAIT_CARNIVOROUS)+rand(-1,1),2,0) + if(prob(60)) + S.set_trait(TRAIT_PARASITE, !S.get_trait(TRAIT_PARASITE)) + if(prob(65)) + S.set_trait(TRAIT_NUTRIENT_CONSUMPTION, S.get_trait(TRAIT_NUTRIENT_CONSUMPTION)+rand(-0.1,0.1),5,0) + if(prob(65)) + S.set_trait(TRAIT_WATER_CONSUMPTION, S.get_trait(TRAIT_WATER_CONSUMPTION)+rand(-1,1),50,0) + +/decl/plantgene/output/mutate(var/datum/seed/S, var/turf/T) + if(prob(50)) + S.set_trait(TRAIT_BIOLUM, !S.get_trait(TRAIT_BIOLUM)) + if(S.get_trait(TRAIT_BIOLUM)) + T.visible_message("\The [S.display_name] begins to glow!") + if(prob(50)) + S.set_trait(TRAIT_BIOLUM_COLOUR,get_random_colour(0,75,190)) + T.visible_message("\The [S.display_name]'s glow changes colour!") + else + T.visible_message("\The [S.display_name]'s glow dims...") + if(prob(60)) + S.set_trait(TRAIT_PRODUCES_POWER, !S.get_trait(TRAIT_PRODUCES_POWER)) + +/decl/plantgene/atmosphere/mutate(var/datum/seed/S) + if(prob(60)) + S.set_trait(TRAIT_TOXINS_TOLERANCE, S.get_trait(TRAIT_TOXINS_TOLERANCE)+rand(-2,2),10,0) + if(prob(60)) + S.set_trait(TRAIT_PEST_TOLERANCE, S.get_trait(TRAIT_PEST_TOLERANCE)+rand(-2,2),10,0) + if(prob(60)) + S.set_trait(TRAIT_WEED_TOLERANCE, S.get_trait(TRAIT_WEED_TOLERANCE)+rand(-2,2),10,0) + if(prob(60)) + S.set_trait(TRAIT_ENDURANCE, S.get_trait(TRAIT_ENDURANCE)+rand(-5,5),100,0) + +/decl/plantgene/vigour/mutate(var/datum/seed/S, var/turf/T) + if(prob(65)) + S.set_trait(TRAIT_PRODUCTION, S.get_trait(TRAIT_PRODUCTION)+rand(-1,1),10,0) + if(prob(65)) + S.set_trait(TRAIT_MATURATION, S.get_trait(TRAIT_MATURATION)+rand(-1,1),30,0) + if(prob(55)) + S.set_trait(TRAIT_SPREAD, S.get_trait(TRAIT_SPREAD)+rand(-1,1),2,0) + T.visible_message("\The [S.display_name] spasms visibly, shifting in the tray.") + +/decl/plantgene/fruit/mutate(var/datum/seed/S) + if(prob(65)) + S.set_trait(TRAIT_STINGS, !S.get_trait(TRAIT_STINGS)) + if(prob(65)) + S.set_trait(TRAIT_EXPLOSIVE, !S.get_trait(TRAIT_EXPLOSIVE)) + if(prob(65)) + S.set_trait(TRAIT_JUICY, !S.get_trait(TRAIT_JUICY)) + +/decl/plantgene/special/mutate(var/datum/seed/S) + if(prob(65)) + S.set_trait(TRAIT_TELEPORTING, !S.get_trait(TRAIT_TELEPORTING)) \ No newline at end of file diff --git a/code/modules/hydroponics/seed_machines.dm b/code/modules/hydroponics/seed_machines.dm index 39b598d7a8f..d99045c63ea 100644 --- a/code/modules/hydroponics/seed_machines.dm +++ b/code/modules/hydroponics/seed_machines.dm @@ -142,9 +142,7 @@ var/list/data = list() - var/list/geneMasks[0] - for(var/gene_tag in SSplants.gene_tag_masks) - geneMasks.Add(list(list("tag" = gene_tag, "mask" = SSplants.gene_tag_masks[gene_tag]))) + var/list/geneMasks = SSplants.gene_masked_list data["geneMasks"] = geneMasks data["activity"] = active diff --git a/code/modules/hydroponics/trays/tray.dm b/code/modules/hydroponics/trays/tray.dm index 24cc962d39a..1a6e4fe2aec 100644 --- a/code/modules/hydroponics/trays/tray.dm +++ b/code/modules/hydroponics/trays/tray.dm @@ -211,9 +211,14 @@ return //Override for somatoray projectiles. - if(istype(Proj ,/obj/item/projectile/energy/floramut) && prob(20)) - mutate(1) - return + if(istype(Proj ,/obj/item/projectile/energy/floramut)&& prob(20)) + if(istype(Proj, /obj/item/projectile/energy/floramut/gene)) + var/obj/item/projectile/energy/floramut/gene/G = Proj + if(seed) + seed = seed.diverge_mutate_gene(G.gene, get_turf(loc)) //get_turf just in case it's not in a turf. + else + mutate(1) + return else if(istype(Proj ,/obj/item/projectile/energy/florayield) && prob(20)) yield_mod = min(10,yield_mod+rand(1,2)) return diff --git a/code/modules/projectiles/guns/energy/special.dm b/code/modules/projectiles/guns/energy/special.dm index bddf264fcd0..8e51e14fbd5 100644 --- a/code/modules/projectiles/guns/energy/special.dm +++ b/code/modules/projectiles/guns/energy/special.dm @@ -24,10 +24,12 @@ origin_tech = list(TECH_MATERIAL = 2, TECH_BIO = 3, TECH_POWER = 3) modifystate = "floramut" self_recharge = 1 + var/decl/plantgene/gene = null firemodes = list( list(mode_name="induce mutations", projectile_type=/obj/item/projectile/energy/floramut, modifystate="floramut"), - list(mode_name="increase yield", projectile_type=/obj/item/projectile/energy/florayield, modifystate="florayield") + list(mode_name="increase yield", projectile_type=/obj/item/projectile/energy/florayield, modifystate="florayield"), + list(mode_name="induce specific mutations", projectile_type=/obj/item/projectile/energy/floramut/gene, modifystate="floramut"), ) needspin = FALSE @@ -40,6 +42,22 @@ return ..() +/obj/item/gun/energy/floragun/verb/select_gene() + set name = "Select Gene" + set category = "Object" + set src in view(1) + + var/genemask = input("Choose a gene to modify.") as null|anything in SSplants.plant_gene_datums + + if(!genemask) + return + + gene = SSplants.plant_gene_datums[genemask] + + to_chat(usr, SPAN_INFO("You set \the [src]\s targeted genetic area to [genemask].")) + + return + /obj/item/gun/energy/meteorgun name = "meteor gun" desc = "For the love of god, make sure you're aiming this the right way!" diff --git a/code/modules/projectiles/projectile/special.dm b/code/modules/projectiles/projectile/special.dm index c4bb828cc9a..3394dff080a 100644 --- a/code/modules/projectiles/projectile/special.dm +++ b/code/modules/projectiles/projectile/special.dm @@ -140,6 +140,14 @@ nodamage = 1 check_armor = "energy" +/obj/item/projectile/energy/floramut/gene + name = "gamma somatoray" + icon_state = "energy2" + damage = 0 + damage_type = TOX + nodamage = TRUE + var/decl/plantgene/gene = null + /obj/item/projectile/energy/floramut/on_hit(var/atom/target, var/blocked = 0) var/mob/living/M = target if(ishuman(target)) diff --git a/html/changelogs/RustingWithYou.yml b/html/changelogs/RustingWithYou.yml new file mode 100644 index 00000000000..a2265bbe14f --- /dev/null +++ b/html/changelogs/RustingWithYou.yml @@ -0,0 +1,41 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: RustingWithYou + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - tweak: "Allows the floral somatoray to mutate specific genes"