var/global/list/seed_types = list() // A list of all seed data. var/global/list/gene_tag_masks = list() // Gene obfuscation for delicious trial and error goodness. // Predefined/roundstart varieties use a string key to make it // easier to grab the new variety when mutating. Post-roundstart // and mutant varieties use their uid converted to a string instead. // Looks like shit but it's sort of necessary. proc/populate_seed_list() // Populate the global seed datum list. for(var/type in typesof(/datum/seed)-/datum/seed) var/datum/seed/S = new type seed_types[S.name] = S S.uid = "[seed_types.len]" S.roundstart = 1 // Make sure any seed packets that were mapped in are updated // correctly (since the seed datums did not exist a tick ago). for(var/obj/item/seeds/S in world) S.update_seed() //Might as well mask the gene types while we're at it. var/list/gene_tags = list("products","consumption","environment","resistance","vigour","flowers") var/list/used_masks = list() while(gene_tags && gene_tags.len) var/gene_tag = pick(gene_tags) var/gene_mask = "[num2hex(rand(0,255))]" while(gene_mask in used_masks) gene_mask = "[num2hex(rand(0,255))]" used_masks += gene_mask gene_tags -= gene_tag gene_tag_masks[gene_tag] = gene_mask /datum/plantgene var/genetype // Label used when applying trait. var/list/values // Values to copy into the target seed datum. /datum/seed //Tracking. var/uid // Unique identifier. var/name // Index for global list. var/seed_name // Plant name for seed packet. var/seed_noun = "seeds" // Descriptor for packet. var/display_name // Prettier name. var/roundstart // If set, seed will not display variety number. // Output. var/list/products // Possible fruit/other product paths. var/list/mutants // Possible predefined mutant varieties, if any. var/list/chems // Chemicals that plant produces in products/injects into victim. var/list/consume_gasses // The plant will absorb these gasses during its life. var/list/exude_gasses // The plant will exude these gasses during its life. //Tolerances. var/requires_nutrients = 1 // The plant can starve. var/nutrient_consumption = 0.25 // Plant eats this much per tick. var/requires_water = 3 // The plant can become dehydrated. var/water_consumption = 1 // Plant drinks this much per tick. var/ideal_heat = 293 // Preferred temperature in Kelvin. var/heat_tolerance = 20 // Departure from ideal that is survivable. var/ideal_light = 8 // Preferred light level in luminosity. var/light_tolerance = 5 // Departure from ideal that is survivable. var/toxins_tolerance = 5 // Resistance to poison. var/lowkpa_tolerance = 25 // Low pressure capacity. var/highkpa_tolerance = 200 // High pressure capacity. var/pest_tolerance = 5 // Threshold for pests to impact health. var/weed_tolerance = 5 // Threshold for weeds to impact health. //General traits. var/endurance = 100 // Maximum plant HP when growing. var/yield = 0 // Amount of product. var/lifespan = 0 // Time before the plant dies. var/maturation = 0 // Time taken before the plant is mature. var/production = 0 // Time before harvesting can be undertaken again. var/growth_stages = 6 // Number of stages the plant passes through before it is mature. var/harvest_repeat = 0 // If 1, this plant will fruit repeatedly.. var/potency = 1 // General purpose plant strength value. var/spread = 0 // 0 limits plant to tray, 1 = creepers, 2 = vines. var/carnivorous = 0 // 0 = none, 1 = eat pests in tray, 2 = eat living things (when a vine). var/parasite = 0 // 0 = no, 1 = gain health from weed level. var/immutable= 0 // If set, plant will never mutate. var/alter_temp // If set, the plant will periodically alter local temp by this amount. // Cosmetics. var/plant_icon // Icon to use for the plant growing in the tray. var/product_icon // Base to use for fruit coming from this plant (if a vine). var/product_colour // Colour to apply to product base (if a vine). var/packet_icon = "seed" // Icon to use for physical seed packet item. var/biolum // Plant is bioluminescent. var/biolum_colour // The colour of the plant's radiance. var/flowers // Plant has a flower overlay. var/flower_icon = "vine_fruit" // Which overlay to use. var/flower_colour // Which colour to use. //Returns a key corresponding to an entry in the global seed list. /datum/seed/proc/get_mutant_variant() if(!mutants || !mutants.len || immutable) return 0 return pick(mutants) //Mutates the plant overall (randomly). /datum/seed/proc/mutate(var/degree,var/turf/source_turf) if(!degree || immutable) return source_turf.visible_message("\blue \The [display_name] quivers!") //This looks like shit, but it's a lot easier to read/change this way. var/total_mutations = rand(1,1+degree) for(var/i = 0;ichanges colour!") else source_turf.visible_message("\blue \The [display_name]'s glow dims...") if(11) if(prob(degree*2)) flowers = !flowers if(flowers) source_turf.visible_message("\blue \The [display_name] sprouts a bevy of flowers!") if(prob(degree*2)) flower_colour = "#[pick(list("FF0000","FF7F00","FFFF00","00FF00","0000FF","4B0082","8F00FF"))]" source_turf.visible_message("\blue \The [display_name]'s flowers changes colour!") else source_turf.visible_message("\blue \The [display_name]'s flowers wither and fall off.") return //Mutates a specific trait/set of traits. /datum/seed/proc/apply_gene(var/datum/plantgene/gene) if(!gene || !gene.values || immutable) return switch(gene.genetype) //Splicing products has some detrimental effects on yield and lifespan. if("products") if(gene.values.len < 6) return yield = round(yield*0.5) endurance = round(endurance*0.5) lifespan = round(lifespan*0.8) if(!products) products = list() products |= gene.values[1] if(!chems) chems = list() for(var/rid in gene.values[2]) var/existing_chem for(var/chem in chems) if(rid == chem) existing_chem = 1 break if(existing_chem) chems[rid][1] = max(1,round((chems[rid][1]+gene.values[2][rid][1])/2)) chems[rid][2] = max(1,round((chems[rid][2]+gene.values[2][rid][2])/2)) else chems[rid] = gene.values[2][rid] var/list/new_gasses = gene.values[3] if(istype(new_gasses)) if(!exude_gasses) exude_gasses = list() exude_gasses |= new_gasses for(var/gas in exude_gasses) exude_gasses[gas] = max(1,round(exude_gasses[gas]*0.8)) alter_temp = gene.values[4] potency = gene.values[5] harvest_repeat = gene.values[6] if("consumption") if(gene.values.len < 7) return consume_gasses = gene.values[1] requires_nutrients = gene.values[2] nutrient_consumption = gene.values[3] requires_water = gene.values[4] water_consumption = gene.values[5] carnivorous = gene.values[6] parasite = gene.values[7] if("environment") if(gene.values.len < 6) return ideal_heat = gene.values[1] heat_tolerance = gene.values[2] ideal_light = gene.values[3] light_tolerance = gene.values[4] lowkpa_tolerance = gene.values[5] highkpa_tolerance = gene.values[6] if("resistance") if(gene.values.len < 3) return toxins_tolerance = gene.values[1] pest_tolerance = gene.values[2] weed_tolerance = gene.values[3] if("vigour") if(gene.values.len < 6) return endurance = gene.values[1] yield = gene.values[2] lifespan = gene.values[3] spread = gene.values[4] maturation = gene.values[5] production = gene.values[6] if("flowers") if(gene.values.len < 7) return product_icon = gene.values[1] product_colour = gene.values[2] biolum = gene.values[3] biolum_colour = gene.values[4] flowers = gene.values[5] flower_icon = gene.values[6] flower_colour = gene.values[7] //Returns a list of the desired trait values. /datum/seed/proc/get_gene(var/genetype) if(!genetype) return 0 var/datum/plantgene/P = new() P.genetype = genetype switch(genetype) if("products") P.values = list( (products ? products : 0), (chems ? chems : 0), (exude_gasses ? exude_gasses : 0), (alter_temp ? alter_temp : 0), (potency ? potency : 0), (harvest_repeat ? harvest_repeat : 0) ) if("consumption") P.values = list( (consume_gasses ? consume_gasses : 0), (requires_nutrients ? requires_nutrients : 0), (nutrient_consumption ? nutrient_consumption : 0), (requires_water ? requires_water : 0), (water_consumption ? water_consumption : 0), (carnivorous ? carnivorous : 0), (parasite ? parasite : 0) ) if("environment") P.values = list( (ideal_heat ? ideal_heat : 0), (heat_tolerance ? heat_tolerance : 0), (ideal_light ? ideal_light : 0), (light_tolerance ? light_tolerance : 0), (lowkpa_tolerance ? lowkpa_tolerance : 0), (highkpa_tolerance ? highkpa_tolerance : 0) ) if("resistance") P.values = list( (toxins_tolerance ? toxins_tolerance : 0), (pest_tolerance ? pest_tolerance : 0), (weed_tolerance ? weed_tolerance : 0) ) if("vigour") P.values = list( (endurance ? endurance : 0), (yield ? yield : 0), (lifespan ? lifespan : 0), (spread ? spread : 0), (maturation ? maturation : 0), (production ? production : 0) ) if("flowers") P.values = list( (product_icon ? product_icon : 0), (product_colour ? product_colour : 0), (biolum ? biolum : 0), (biolum_colour ? biolum_colour : 0), (flowers ? flowers : 0), (flower_icon ? flower_icon : 0), (flower_colour ? flower_colour : 0) ) return (P ? P : 0) //Place the plant products at the feet of the user. /datum/seed/proc/harvest(var/mob/user,var/yield_mod) if(!user) return var/got_product if(!isnull(products) && products.len && yield > 0) got_product = 1 if(!got_product) user << "\red You fail to harvest anything useful." else user << "You harvest from the [display_name]." //This may be a new line. Update the global if it is. if(name == "new line" || !(name in seed_types)) uid = seed_types.len + 1 name = "[uid]" seed_types[name] = src var/total_yield if(isnull(yield_mod) || yield_mod < 1) yield_mod = 0 total_yield = yield else total_yield = max(1,rand(yield_mod,yield_mod+yield)) currently_querying = list() for(var/i = 0;i