diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index bf66362d..e38a7a6e 100644 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -889,6 +889,7 @@ obj/item/storage/belt/slut/ComponentInitialize() content_overlays = TRUE /obj/item/storage/belt/botany/New() + . = ..() if(prob(1)) new/obj/item/storage/belt/botany/fancy(loc) qdel(src) diff --git a/code/modules/hydroponics/biogenerator.dm b/code/modules/hydroponics/biogenerator.dm index ac750a04..02c3ccbc 100644 --- a/code/modules/hydroponics/biogenerator.dm +++ b/code/modules/hydroponics/biogenerator.dm @@ -67,7 +67,7 @@ return /obj/machinery/biogenerator/attackby(obj/item/O, mob/user, params) - if(user.a_intent == INTENT_HARM) + if(user.a_intent != INTENT_HELP) return ..() if(processing) diff --git a/code/modules/hydroponics/hydro_chemreact.dm b/code/modules/hydroponics/hydro_chemreact.dm new file mode 100644 index 00000000..9d39f067 --- /dev/null +++ b/code/modules/hydroponics/hydro_chemreact.dm @@ -0,0 +1,262 @@ +/obj/machinery/hydroponics/proc/applyChemicals(datum/reagents/S, mob/user) + if(!myseed) + return + myseed.on_chem_reaction(S) //In case seeds have some special interactions with special chems, currently only used by vines + + // Requires 5 mutagen to possibly change species.// Poor man's mutagen. + if(S.has_reagent(/datum/reagent/toxin/mutagen, 5) || S.has_reagent(/datum/reagent/radium, 10) || S.has_reagent(/datum/reagent/uranium, 10)) + switch(rand(100)) + if(91 to 100) + adjustHealth(-10) + to_chat(user, "The plant shrivels and burns.") + if(81 to 90) + mutatespecie() + if(66 to 80) + hardmutate() + if(41 to 65) + mutate() + if(21 to 41) + to_chat(user, "The plants don't seem to react...") + if(11 to 20) + mutateweed() + if(1 to 10) + mutatepest(user) + else + to_chat(user, "Nothing happens...") + + // 2 or 1 units is enough to change the yield and other stats.// Can change the yield and other stats, but requires more than mutagen + else if(S.has_reagent(/datum/reagent/toxin/mutagen, 2) || S.has_reagent(/datum/reagent/radium, 5) || S.has_reagent(/datum/reagent/uranium, 5)) + hardmutate() + else if(S.has_reagent(/datum/reagent/toxin/mutagen, 1) || S.has_reagent(/datum/reagent/radium, 2) || S.has_reagent(/datum/reagent/uranium, 2)) + mutate() + + + // After handling the mutating, we now handle the damage from adding crude radioactives... + if(S.has_reagent(/datum/reagent/uranium, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/uranium) * 1)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/uranium) * 2)) + if(S.has_reagent(/datum/reagent/radium, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/radium) * 1)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/radium) * 3)) // Radium is harsher (OOC: also easier to produce) + + + // Nutriments + if(S.has_reagent(/datum/reagent/plantnutriment/eznutriment, 1)) + yieldmod = 1 + mutmod = 1 + adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/eznutriment) * 1)) + if(S.has_reagent(/datum/reagent/plantnutriment/left4zednutriment, 1)) + yieldmod = 0 + mutmod = 2 + adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/left4zednutriment) * 1)) + if(S.has_reagent(/datum/reagent/plantnutriment/robustharvestnutriment, 1)) + yieldmod = 1.3 + mutmod = 0 + adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/robustharvestnutriment) * 1)) + + if(S.has_reagent(/datum/reagent/plantnutriment/endurogrow, 1)) + var/total_transferred = S.get_reagent_amount(/datum/reagent/plantnutriment/endurogrow) + if(total_transferred >= 20) + myseed.adjust_potency(-round(total_transferred / 10)) + myseed.adjust_yield(round(total_transferred / 20)) + myseed.adjust_endurance(round(total_transferred / 30)) + else + to_chat(user, "The plants don't seem to react...") + + if(S.has_reagent(/datum/reagent/plantnutriment/liquidearthquake, 1)) + var/total_transferred = S.get_reagent_amount(/datum/reagent/plantnutriment/liquidearthquake) + if(total_transferred >= 20) + myseed.adjust_weed_chance(round(total_transferred / 10)) + myseed.adjust_weed_rate(round(total_transferred / 20)) + myseed.adjust_production(round(total_transferred / 30)) + else + to_chat(user, "The plants don't seem to react...") + + // Ambrosia Gaia produces earthsblood. + if(S.has_reagent(/datum/reagent/medicine/earthsblood)) + self_sufficiency_progress += S.get_reagent_amount(/datum/reagent/medicine/earthsblood) + if(self_sufficiency_progress >= self_sufficiency_req) + become_self_sufficient() + else if(!self_sustaining) + to_chat(user, "[src] warms as it might on a spring day under a genuine Sun.") + + // Antitoxin binds shit pretty well. So the tox goes significantly down + if(S.has_reagent(/datum/reagent/medicine/charcoal, 1)) + adjustToxic(-round(S.get_reagent_amount(/datum/reagent/medicine/charcoal) * 2)) + + // Toxins, not good for anything + if(S.has_reagent(/datum/reagent/toxin, 1)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin) * 2)) + + // Milk is good for humans, but bad for plants. The sugars canot be used by plants, and the milk fat fucks up growth. Not shrooms though. I can't deal with this now... + if(S.has_reagent(/datum/reagent/consumable/milk, 1)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/milk) * 0.1)) + adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/milk) * 0.9)) + + // Beer is a chemical composition of alcohol and various other things. It's a shitty nutrient but hey, it's still one. Also alcohol is bad, mmmkay? + if(S.has_reagent(/datum/reagent/consumable/ethanol/beer, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.05)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.25)) + adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.7)) + + // Fluorine one of the most corrosive and deadly gasses + if(S.has_reagent(/datum/reagent/fluorine, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/fluorine) * 2)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/fluorine) * 2.5)) + adjustWater(-round(S.get_reagent_amount(/datum/reagent/fluorine) * 0.5)) + adjustWeeds(-rand(1,4)) + + // Chlorine one of the most corrosive and deadly gasses + if(S.has_reagent(/datum/reagent/chlorine, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/chlorine) * 1)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/chlorine) * 1.5)) + adjustWater(-round(S.get_reagent_amount(/datum/reagent/chlorine) * 0.5)) + adjustWeeds(-rand(1,3)) + + // White Phosphorous + water -> phosphoric acid. That's not a good thing really. + // Phosphoric salts are beneficial though. And even if the plant suffers, in the long run the tray gets some nutrients. The benefit isn't worth that much. + if(S.has_reagent(/datum/reagent/phosphorus, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.75)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.1)) + adjustWater(-round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.5)) + adjustWeeds(-rand(1,2)) + + // Plants should not have sugar, they can't use it and it prevents them getting water/nutients, it is good for mold though... + if(S.has_reagent(/datum/reagent/consumable/sugar, 1)) + adjustWeeds(rand(1,2)) + adjustPests(rand(1,2)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/sugar) * 0.1)) + + // It is water! + if(S.has_reagent(/datum/reagent/water, 1)) + adjustWater(round(S.get_reagent_amount(/datum/reagent/water) * 1)) + + // Holy water. Mostly the same as water, it also heals the plant a little with the power of the spirits~ + if(S.has_reagent(/datum/reagent/water/holywater, 1)) + adjustWater(round(S.get_reagent_amount(/datum/reagent/water/holywater) * 1)) + adjustHealth(round(S.get_reagent_amount(/datum/reagent/water/holywater) * 0.1)) + + // A variety of nutrients are dissolved in club soda, without sugar. + // These nutrients include carbon, oxygen, hydrogen, phosphorous, potassium, sulfur and sodium, all of which are needed for healthy plant growth. + if(S.has_reagent(/datum/reagent/consumable/sodawater, 1)) + adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 1)) + adjustHealth(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 0.1)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 0.1)) + + // Sulphuric Acid + if(S.has_reagent(/datum/reagent/toxin/acid, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/acid) * 1)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/acid) * 1.5)) + adjustWeeds(-rand(1,2)) + + // Acid + if(S.has_reagent(/datum/reagent/toxin/acid/fluacid, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/acid/fluacid) * 2)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/acid/fluacid) * 3)) + adjustWeeds(-rand(1,4)) + + // Plant-B-Gone is just as bad + if(S.has_reagent(/datum/reagent/toxin/plantbgone, 1)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone) * 5)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone) * 6)) + adjustWeeds(-rand(4,8)) + + // Napalm, not known for being good for anything organic + if(S.has_reagent(/datum/reagent/napalm, 1)) + if(!(myseed.resistance_flags & FIRE_PROOF)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/napalm) * 6)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/napalm) * 7)) + adjustWeeds(-rand(5,9)) + + //Weed Spray + if(S.has_reagent(/datum/reagent/toxin/plantbgone/weedkiller, 1)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone/weedkiller) * 0.5)) + //old toxicity was 4, each spray is default 10 (minimal of 5) so 5 and 2.5 are the new ammounts + adjustWeeds(-rand(1,2)) + + //Pest Spray + if(S.has_reagent(/datum/reagent/toxin/pestkiller, 1)) + adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/pestkiller) * 0.5)) + adjustPests(-rand(1,2)) + + // Healing + if(S.has_reagent(/datum/reagent/medicine/cryoxadone, 1)) + adjustHealth(round(S.get_reagent_amount(/datum/reagent/medicine/cryoxadone) * 3)) + adjustToxic(-round(S.get_reagent_amount(/datum/reagent/medicine/cryoxadone) * 3)) + + // Ammonia is bad ass. + if(S.has_reagent(/datum/reagent/ammonia, 1)) + adjustHealth(round(S.get_reagent_amount(/datum/reagent/ammonia) * 0.5)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/ammonia) * 1)) + if(myseed) + myseed.adjust_yield(round(S.get_reagent_amount(/datum/reagent/ammonia) * 0.01)) + + // Saltpetre is used for gardening IRL, to simplify highly, it speeds up growth and strengthens plants + if(S.has_reagent(/datum/reagent/saltpetre, 1)) + var/salt = S.get_reagent_amount(/datum/reagent/saltpetre) + adjustHealth(round(salt * 0.25)) + if (myseed) + myseed.adjust_production(-round(salt/100)-prob(salt%100)) + myseed.adjust_potency(round(salt*0.5)) + // Ash is also used IRL in gardening, as a fertilizer enhancer and weed killer + if(S.has_reagent(/datum/reagent/ash, 1)) + adjustHealth(round(S.get_reagent_amount(/datum/reagent/ash) * 0.25)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/ash) * 0.5)) + adjustWeeds(-1) + + // Diethylamine is more bad ass, and pests get hurt by the corrosive nature of it, not the plant. + if(S.has_reagent(/datum/reagent/diethylamine, 1)) + adjustHealth(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 1)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 2)) + if(myseed) + myseed.adjust_yield(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 0.02)) + adjustPests(-rand(1,2)) + + // Enduro Grow sacrifices potency + yield for endurance + if(S.has_reagent(/datum/reagent/plantnutriment/endurogrow, 1)) + myseed.adjust_potency(-round(S.get_reagent_amount(/datum/reagent/plantnutriment/endurogrow) * 0.1)) + myseed.adjust_yield(-round(S.get_reagent_amount(/datum/reagent/plantnutriment/endurogrow) * 0.075)) + myseed.adjust_endurance(round(S.get_reagent_amount(/datum/reagent/plantnutriment/endurogrow) * 0.35)) + + // Liquid Earthquake increases production speed but increases weeds + if(S.has_reagent(/datum/reagent/plantnutriment/liquidearthquake, 1)) + myseed.adjust_weed_rate(round(S.get_reagent_amount(/datum/reagent/plantnutriment/liquidearthquake) * 0.1)) + myseed.adjust_weed_chance(round(S.get_reagent_amount(/datum/reagent/plantnutriment/liquidearthquake) * 0.3)) + myseed.adjust_production(round(S.get_reagent_amount(/datum/reagent/plantnutriment/liquidearthquake) * 0.075)) + + // Nutriment Compost, effectively + if(S.has_reagent(/datum/reagent/consumable/nutriment, 1)) + adjustHealth(round(S.get_reagent_amount(/datum/reagent/consumable/nutriment) * 0.5)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/nutriment) * 1)) + + // Virusfood Compost for EVERYTHING + if(S.has_reagent(/datum/reagent/toxin/mutagen/mutagenvirusfood, 1)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/toxin/mutagen/mutagenvirusfood) * 0.5)) + adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/mutagen/mutagenvirusfood) * 0.5)) + + // Blood + if(S.has_reagent(/datum/reagent/blood, 1)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/blood) * 1)) + adjustPests(rand(2,4)) + + // Strange reagent + if(S.has_reagent(/datum/reagent/medicine/strange_reagent, 1)) + spawnplant() + + // Adminordrazine the best stuff there is. For testing/debugging. + if(S.has_reagent(/datum/reagent/medicine/adminordrazine, 1)) + adjustWater(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1)) + adjustHealth(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1)) + adjustNutri(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1)) + adjustPests(-rand(1,5)) + adjustWeeds(-rand(1,5)) + if(S.has_reagent(/datum/reagent/medicine/adminordrazine, 5)) + switch(rand(100)) + if(66 to 100) + mutatespecie() + if(33 to 65) + mutateweed() + if(1 to 32) + mutatepest(user) + else + to_chat(user, "Nothing happens...") \ No newline at end of file diff --git a/code/modules/hydroponics/hydroitemdefines.dm b/code/modules/hydroponics/hydroitemdefines.dm index 9655b138..4537d91b 100644 --- a/code/modules/hydroponics/hydroitemdefines.dm +++ b/code/modules/hydroponics/hydroitemdefines.dm @@ -10,6 +10,12 @@ w_class = WEIGHT_CLASS_TINY slot_flags = ITEM_SLOT_BELT materials = list(MAT_METAL=30, MAT_GLASS=20) + var/scan_mode = FALSE + +/obj/item/plant_analyzer/attack_self(mob/user) + . = ..() + scan_mode = !scan_mode + to_chat(user, "You switch [src] to [scan_mode ? "scan for chemical reagents and traits" : "scan for plant growth statistics"].") // ************************************* // Hydroponics Tools diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm index a3ff3884..fd684a1e 100644 --- a/code/modules/hydroponics/hydroponics.dm +++ b/code/modules/hydroponics/hydroponics.dm @@ -6,45 +6,52 @@ pixel_z = 8 obj_flags = CAN_BE_HIT | UNIQUE_RENAME circuit = /obj/item/circuitboard/machine/hydroponics - var/waterlevel = 100 //The amount of water in the tray (max 100) + var/waterlevel = 100 //The amount of water in the tray var/maxwater = 100 //The maximum amount of water in the tray - var/nutrilevel = 10 //The amount of nutrient in the tray (max 10) + var/nutrilevel = 10 //The amount of nutrient in the tray var/maxnutri = 10 //The maximum nutrient of water in the tray - var/pestlevel = 0 //The amount of pests in the tray (max 10) - var/weedlevel = 0 //The amount of weeds in the tray (max 10) + var/pestlevel = 0 //The amount of pests in the tray + var/weedlevel = 0 //The amount of weeds in the tray var/yieldmod = 1 //Nutriment's effect on yield var/mutmod = 1 //Nutriment's effect on mutations var/toxic = 0 //Toxicity in the tray? var/age = 0 //Current age - var/dead = 0 //Is it dead? + var/dead = FALSE //Is it dead? var/plant_health //Its health var/lastproduce = 0 //Last time it was harvested var/lastcycle = 0 //Used for timing of cycles. var/cycledelay = 200 //About 10 seconds / cycle - var/harvest = 0 //Ready to harvest? + var/harvest = FALSE //Ready to harvest? var/obj/item/seeds/myseed = null //The currently planted seed var/rating = 1 - var/unwrenchable = 1 + var/unwrenchable = TRUE var/recent_bee_visit = FALSE //Have we been visited by a bee recently, so bees dont overpollinate one plant + var/mob/lastuser //Last user to add reagents to a tray. Mostly for logging. + var/self_sustaining = FALSE //If the tray generates nutrients and water on its own var/using_irrigation = FALSE //If the tray is connected to other trays via irrigation hoses var/self_sufficiency_req = 20 //Required total dose to make a self-sufficient hydro tray. 1:1 with earthsblood. var/self_sufficiency_progress = 0 - var/self_sustaining = FALSE //If the tray generates nutrients and water on its own - /obj/machinery/hydroponics/constructable name = "hydroponics tray" icon = 'icons/obj/hydroponics/equipment.dmi' icon_state = "hydrotray3" +/obj/machinery/hydroponics/constructable/ComponentInitialize() + . = ..() + AddComponent(/datum/component/simple_rotation, ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS, null, CALLBACK(src, .proc/can_be_rotated)) + +/obj/machinery/hydroponics/constructable/proc/can_be_rotated(mob/user, rotation_type) + return !anchored + /obj/machinery/hydroponics/constructable/RefreshParts() var/tmp_capacity = 0 for (var/obj/item/stock_parts/matter_bin/M in component_parts) tmp_capacity += M.rating for (var/obj/item/stock_parts/manipulator/M in component_parts) rating = M.rating - maxwater = tmp_capacity * 50 // Up to 300 - maxnutri = tmp_capacity * 5 // Up to 30 + maxwater = tmp_capacity * 50 // Up to 400 + maxnutri = (tmp_capacity * 5) + 10 // Up to 50 Maximum /obj/machinery/hydroponics/Destroy() if(myseed) @@ -57,12 +64,7 @@ // handle opening the panel if(default_deconstruction_screwdriver(user, icon_state, icon_state, I)) return - - // handle deconstructing the machine, if permissible - if (I.tool_behaviour == TOOL_CROWBAR && using_irrigation) - to_chat(user, "Disconnect the hoses first!") - return - else if(default_deconstruction_crowbar(I)) + if(default_deconstruction_crowbar(I)) return return ..() @@ -75,21 +77,22 @@ var/atom/a = processing_atoms[1] for(var/step_dir in GLOB.cardinals) var/obj/machinery/hydroponics/h = locate() in get_step(a, step_dir) - // Soil plots aren't dense + if(h && h.using_irrigation && h.density && !(h in connected) && !(h in processing_atoms)) processing_atoms += h + processing_atoms -= a connected += a return connected - /obj/machinery/hydroponics/bullet_act(obj/item/projectile/Proj) //Works with the Somatoray to modify plant variables. if(!myseed) return ..() if(istype(Proj , /obj/item/projectile/energy/floramut)) mutate() + return BULLET_ACT_HIT else if(istype(Proj , /obj/item/projectile/energy/florayield)) return myseed.bullet_act(Proj) else @@ -104,7 +107,7 @@ if(self_sustaining) adjustNutri(1) adjustWater(rand(3,5)) - adjustWeeds(-2) + adjustWeeds(-4) //Was -2. People keep getting confused as to why gaia isn't completely removing weeds adjustPests(-2) adjustToxic(-2) @@ -118,10 +121,10 @@ needs_update = 1 + //Nutrients////////////////////////////////////////////////////////////// - // Nutrients deplete slowly - if(prob(50)) - adjustNutri(-1 / rating) + // Nutrients should deplete at a constant rate + adjustNutri(-1 / rating) // Lack of nutrients hurts non-weeds if(nutrilevel <= 0 && !myseed.get_gene(/datum/plant_gene/trait/plant_type/weed_hardy)) @@ -141,16 +144,19 @@ //Water////////////////////////////////////////////////////////////////// // Drink random amount of water - adjustWater(-rand(1,6) / rating) + if(waterlevel > 10) + adjustWater(-rand(3,4) / rating) + else + adjustWater(-1 / rating) //Deplete water slower if we're dry. Just for some realism // If the plant is dry, it loses health pretty fast, unless mushroom - if(waterlevel <= 10 && !myseed.get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism)) + if(waterlevel <= 15 && !myseed.get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism)) adjustHealth(-rand(0,1) / rating) if(waterlevel <= 0) adjustHealth(-rand(0,2) / rating) // Sufficient water level and nutrient level = plant healthy but also spawns weeds - else if(waterlevel > 10 && nutrilevel > 0) + else if(waterlevel > 15 && nutrilevel > 0) adjustHealth(rand(1,2) / rating) if(myseed && prob(myseed.weed_chance)) adjustWeeds(myseed.weed_rate) @@ -204,19 +210,20 @@ // If the plant is too old, lose health fast if(age > myseed.lifespan) - adjustHealth(-rand(1,5) / rating) + adjustHealth(-rand(3,5) / rating) // Harvest code if(age > myseed.production && (age - lastproduce) > myseed.production && (!harvest && !dead)) - nutrimentMutation() + if(age > myseed.production*2) //Start mutating stats every process cycle if we can be harvested, only after a while + nutrimentMutation() if(myseed && myseed.yield != -1) // Unharvestable shouldn't be harvested - harvest = 1 + harvest = TRUE else lastproduce = age if(prob(5)) // On each tick, there's a 5 percent chance the pest population will increase adjustPests(1 / rating) else - if(waterlevel > 10 && nutrilevel > 0 && prob(10)) // If there's no plant, the percentage chance is 10% + if(waterlevel > 10 && reagents.total_volume > 0 && prob(10)) // If there's no plant, the percentage chance is 10% adjustWeeds(1 / rating) // Weeeeeeeeeeeeeeedddssss @@ -238,22 +245,22 @@ return /obj/machinery/hydroponics/proc/nutrimentMutation() - if (mutmod == 0) - return - if (mutmod == 1) - if(prob(80)) //80% - mutate() - else if(prob(75)) //15% - hardmutate() - return - if (mutmod == 2) - if(prob(50)) //50% - mutate() - else if(prob(50)) //25% - hardmutate() - else if(prob(50)) //12.5% - mutatespecie() - return + switch (mutmod) + + //0 does nothing + + if(1) + if(prob(80)) + mutate() + else if(prob(75)) //15% + hardmutate() + if(2) + if(prob(50)) + mutate() + else if(prob(50)) //25% + hardmutate() + else if(prob(50)) //12.5% + mutatespecie() return /obj/machinery/hydroponics/update_icon() @@ -301,7 +308,7 @@ else plant_overlay.icon_state = myseed.icon_harvest else - var/t_growthstate = min(round((age / myseed.maturation) * myseed.growthstages), myseed.growthstages) + var/t_growthstate = clamp(round((age / myseed.maturation) * myseed.growthstages), 1, myseed.growthstages) plant_overlay.icon_state = "[myseed.icon_grow][t_growthstate]" add_overlay(plant_overlay) @@ -344,6 +351,9 @@ . += "It's filled with weeds!" if(pestlevel >= 5) . += "It's filled with tiny worms!" + to_chat(user, "" ) + + /obj/machinery/hydroponics/proc/weedinvasion() // If a weed growth is sufficient, this happens. dead = 0 @@ -379,7 +389,11 @@ pestlevel = 0 // Reset update_icon() visible_message("The [oldPlantName] is overtaken by some [myseed.plantname]!") - + name = "hydroponics tray ([myseed.plantname])" + if(myseed.product) + desc = initial(myseed.product.desc) + else + desc = initial(desc) /obj/machinery/hydroponics/proc/mutate(lifemut = 2, endmut = 5, productmut = 1, yieldmut = 2, potmut = 25, wrmut = 2, wcmut = 5, traitmut = 0) // Mutates the current seed if(!myseed) @@ -413,7 +427,7 @@ sleep(5) // Wait a while update_icon() visible_message("[oldPlantName] suddenly mutates into [myseed.plantname]!") - + name = myseed ? "[initial(name)] ([myseed.plantname])" : initial(name) /obj/machinery/hydroponics/proc/mutateweed() // If the weeds gets the mutagent instead. Mind you, this pretty much destroys the old plant if( weedlevel > 5 ) @@ -436,15 +450,14 @@ else to_chat(usr, "The few weeds in [src] seem to react, but only for a moment...") - -/obj/machinery/hydroponics/proc/plantdies() // OH NOES!!!!! I put this all in one function to make things easier +/obj/machinery/hydroponics/proc/plantdies() plant_health = 0 - harvest = 0 + harvest = FALSE pestlevel = 0 // Pests die + lastproduce = 0 if(!dead) update_icon() - dead = 1 - + dead = TRUE /obj/machinery/hydroponics/proc/mutatepest(mob/user) @@ -456,250 +469,6 @@ else to_chat(user, "The pests seem to behave oddly, but quickly settle down...") -/obj/machinery/hydroponics/proc/applyChemicals(datum/reagents/S, mob/user) - if(myseed) - myseed.on_chem_reaction(S) //In case seeds have some special interactions with special chems, currently only used by vines - - // Requires 5 mutagen to possibly change species.// Poor man's mutagen. - if(S.has_reagent(/datum/reagent/toxin/mutagen, 5) || S.has_reagent(/datum/reagent/radium, 10) || S.has_reagent(/datum/reagent/uranium, 10)) - switch(rand(100)) - if(91 to 100) - adjustHealth(-10) - to_chat(user, "The plant shrivels and burns.") - if(81 to 90) - mutatespecie() - if(66 to 80) - hardmutate() - if(41 to 65) - mutate() - if(21 to 41) - to_chat(user, "The plants don't seem to react...") - if(11 to 20) - mutateweed() - if(1 to 10) - mutatepest(user) - else - to_chat(user, "Nothing happens...") - - // 2 or 1 units is enough to change the yield and other stats.// Can change the yield and other stats, but requires more than mutagen - else if(S.has_reagent(/datum/reagent/toxin/mutagen, 2) || S.has_reagent(/datum/reagent/radium, 5) || S.has_reagent(/datum/reagent/uranium, 5)) - hardmutate() - else if(S.has_reagent(/datum/reagent/toxin/mutagen, 1) || S.has_reagent(/datum/reagent/radium, 2) || S.has_reagent(/datum/reagent/uranium, 2)) - mutate() - - // After handling the mutating, we now handle the damage from adding crude radioactives... - if(S.has_reagent(/datum/reagent/uranium, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/uranium) * 1)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/uranium) * 2)) - if(S.has_reagent(/datum/reagent/radium, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/radium) * 1)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/radium) * 3)) // Radium is harsher (OOC: also easier to produce) - - // Nutriments - if(S.has_reagent(/datum/reagent/plantnutriment/eznutriment, 1)) - yieldmod = 1 - mutmod = 1 - adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/eznutriment) * 1)) - - if(S.has_reagent(/datum/reagent/plantnutriment/left4zednutriment, 1)) - yieldmod = 0 - mutmod = 2 - adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/left4zednutriment) * 1)) - - if(S.has_reagent(/datum/reagent/plantnutriment/robustharvestnutriment, 1)) - yieldmod = 1.3 - mutmod = 0 - adjustNutri(round(S.get_reagent_amount(/datum/reagent/plantnutriment/robustharvestnutriment) *1 )) - - // Ambrosia Gaia produces earthsblood. - if(S.has_reagent(/datum/reagent/medicine/earthsblood)) - self_sufficiency_progress += S.get_reagent_amount(/datum/reagent/medicine/earthsblood) - if(self_sufficiency_progress >= self_sufficiency_req) - become_self_sufficient() - else if(!self_sustaining) - to_chat(user, "[src] warms as it might on a spring day under a genuine Sun.") - - // Antitoxin binds shit pretty well. So the tox goes significantly down - if(S.has_reagent(/datum/reagent/medicine/charcoal, 1)) - adjustToxic(-round(S.get_reagent_amount(/datum/reagent/medicine/charcoal) * 2)) - - // Toxins, not good for anything - if(S.has_reagent(/datum/reagent/toxin, 1)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin) * 2)) - - // Milk is good for humans, but bad for plants. The sugars canot be used by plants, and the milk fat fucks up growth. Not shrooms though. I can't deal with this now... - if(S.has_reagent(/datum/reagent/consumable/milk, 1)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/milk) * 0.1)) - adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/milk) * 0.9)) - - // Beer is a chemical composition of alcohol and various other things. It's a shitty nutrient but hey, it's still one. Also alcohol is bad, mmmkay? - if(S.has_reagent(/datum/reagent/consumable/ethanol/beer, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.05)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.25)) - adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/ethanol/beer) * 0.7)) - - // Fluorine one of the most corrosive and deadly gasses - if(S.has_reagent(/datum/reagent/fluorine, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/fluorine) * 2)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/fluorine) * 2.5)) - adjustWater(-round(S.get_reagent_amount(/datum/reagent/fluorine) * 0.5)) - adjustWeeds(-rand(1,4)) - - // Chlorine one of the most corrosive and deadly gasses - if(S.has_reagent(/datum/reagent/chlorine, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/chlorine) * 1)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/chlorine) * 1.5)) - adjustWater(-round(S.get_reagent_amount(/datum/reagent/chlorine) * 0.5)) - adjustWeeds(-rand(1,3)) - - // White Phosphorous + water -> phosphoric acid. That's not a good thing really. - // Phosphoric salts are beneficial though. And even if the plant suffers, in the long run the tray gets some nutrients. The benefit isn't worth that much. - if(S.has_reagent(/datum/reagent/phosphorus, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.75)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.1)) - adjustWater(-round(S.get_reagent_amount(/datum/reagent/phosphorus) * 0.5)) - adjustWeeds(-rand(1,2)) - - // Plants should not have sugar, they can't use it and it prevents them getting water/nutients, it is good for mold though... - if(S.has_reagent(/datum/reagent/consumable/sugar, 1)) - adjustWeeds(rand(1,2)) - adjustPests(rand(1,2)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/sugar) * 0.1)) - - // It is water! - if(S.has_reagent(/datum/reagent/water, 1)) - adjustWater(round(S.get_reagent_amount(/datum/reagent/water) * 1)) - - // Holy water. Mostly the same as water, it also heals the plant a little with the power of the spirits~ - if(S.has_reagent(/datum/reagent/water/holywater, 1)) - adjustWater(round(S.get_reagent_amount(/datum/reagent/water/holywater) * 1)) - adjustHealth(round(S.get_reagent_amount(/datum/reagent/water/holywater) * 0.1)) - - // A variety of nutrients are dissolved in club soda, without sugar. - // These nutrients include carbon, oxygen, hydrogen, phosphorous, potassium, sulfur and sodium, all of which are needed for healthy plant growth. - if(S.has_reagent(/datum/reagent/consumable/sodawater, 1)) - adjustWater(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 1)) - adjustHealth(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 0.1)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/sodawater) * 0.1)) - - // Sulphuric Acid - if(S.has_reagent(/datum/reagent/toxin/acid, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/acid) * 1)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/acid) * 1.5)) - adjustWeeds(-rand(1,2)) - - // Acid - if(S.has_reagent(/datum/reagent/toxin/acid/fluacid, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/acid/fluacid) * 2)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/acid/fluacid) * 3)) - adjustWeeds(-rand(1,4)) - - // Plant-B-Gone is just as bad - if(S.has_reagent(/datum/reagent/toxin/plantbgone, 1)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone) * 5)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone) * 6)) - adjustWeeds(-rand(4,8)) - - // Napalm, not known for being good for anything organic - if(S.has_reagent(/datum/reagent/napalm, 1)) - if(!(myseed.resistance_flags & FIRE_PROOF)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/napalm) * 6)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/napalm) * 7)) - adjustWeeds(-rand(5,9)) - - //Weed Spray - if(S.has_reagent(/datum/reagent/toxin/plantbgone/weedkiller, 1)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/plantbgone/weedkiller) * 0.5)) - //old toxicity was 4, each spray is default 10 (minimal of 5) so 5 and 2.5 are the new ammounts - adjustWeeds(-rand(1,2)) - - //Pest Spray - if(S.has_reagent(/datum/reagent/toxin/pestkiller, 1)) - adjustToxic(round(S.get_reagent_amount(/datum/reagent/toxin/pestkiller) * 0.5)) - adjustPests(-rand(1,2)) - - // Healing - if(S.has_reagent(/datum/reagent/medicine/cryoxadone, 1)) - adjustHealth(round(S.get_reagent_amount(/datum/reagent/medicine/cryoxadone) * 3)) - adjustToxic(-round(S.get_reagent_amount(/datum/reagent/medicine/cryoxadone) * 3)) - - // Ammonia is bad ass. - if(S.has_reagent(/datum/reagent/ammonia, 1)) - adjustHealth(round(S.get_reagent_amount(/datum/reagent/ammonia) * 0.5)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/ammonia) * 1)) - if(myseed) - myseed.adjust_yield(round(S.get_reagent_amount(/datum/reagent/ammonia) * 0.01)) - - // Saltpetre is used for gardening IRL, to simplify highly, it speeds up growth and strengthens plants - if(S.has_reagent(/datum/reagent/saltpetre, 1)) - var/salt = S.get_reagent_amount(/datum/reagent/saltpetre) - adjustHealth(round(salt * 0.25)) - if (myseed) - myseed.adjust_production(-round(salt/100)-prob(salt%100)) - myseed.adjust_potency(round(salt*0.5)) - // Ash is also used IRL in gardening, as a fertilizer enhancer and weed killer - if(S.has_reagent(/datum/reagent/ash, 1)) - adjustHealth(round(S.get_reagent_amount(/datum/reagent/ash) * 0.25)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/ash) * 0.5)) - adjustWeeds(-1) - - // Diethylamine is more bad ass, and pests get hurt by the corrosive nature of it, not the plant. - if(S.has_reagent(/datum/reagent/diethylamine, 1)) - adjustHealth(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 1)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 2)) - if(myseed) - myseed.adjust_yield(round(S.get_reagent_amount(/datum/reagent/diethylamine) * 0.02)) - adjustPests(-rand(1,2)) - - // Enduro Grow sacrifices potency + yield for endurance - if(S.has_reagent(/datum/reagent/plantnutriment/endurogrow, 1)) - myseed.adjust_potency(-round(S.get_reagent_amount(/datum/reagent/plantnutriment/endurogrow) * 0.1)) - myseed.adjust_yield(-round(S.get_reagent_amount(/datum/reagent/plantnutriment/endurogrow) * 0.075)) - myseed.adjust_endurance(round(S.get_reagent_amount(/datum/reagent/plantnutriment/endurogrow) * 0.35)) - - // Liquid Earthquake increases production speed but increases weeds - if(S.has_reagent(/datum/reagent/plantnutriment/liquidearthquake, 1)) - myseed.adjust_weed_rate(round(S.get_reagent_amount(/datum/reagent/plantnutriment/liquidearthquake) * 0.1)) - myseed.adjust_weed_chance(round(S.get_reagent_amount(/datum/reagent/plantnutriment/liquidearthquake) * 0.3)) - myseed.adjust_production(round(S.get_reagent_amount(/datum/reagent/plantnutriment/liquidearthquake) * 0.075)) - - // Nutriment Compost, effectively - if(S.has_reagent(/datum/reagent/consumable/nutriment, 1)) - adjustHealth(round(S.get_reagent_amount(/datum/reagent/consumable/nutriment) * 0.5)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/consumable/nutriment) * 1)) - - // Virusfood Compost for EVERYTHING - if(S.has_reagent(/datum/reagent/toxin/mutagen/mutagenvirusfood, 1)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/toxin/mutagen/mutagenvirusfood) * 0.5)) - adjustHealth(-round(S.get_reagent_amount(/datum/reagent/toxin/mutagen/mutagenvirusfood) * 0.5)) - - // Blood - if(S.has_reagent(/datum/reagent/blood, 1)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/blood) * 1)) - adjustPests(rand(2,4)) - - // Strange reagent - if(S.has_reagent(/datum/reagent/medicine/strange_reagent, 1)) - spawnplant() - - // Adminordrazine the best stuff there is. For testing/debugging. - if(S.has_reagent(/datum/reagent/medicine/adminordrazine, 1)) - adjustWater(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1)) - adjustHealth(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1)) - adjustNutri(round(S.get_reagent_amount(/datum/reagent/medicine/adminordrazine) * 1)) - adjustPests(-rand(1,5)) - adjustWeeds(-rand(1,5)) - if(S.has_reagent(/datum/reagent/medicine/adminordrazine, 5)) - switch(rand(100)) - if(66 to 100) - mutatespecie() - if(33 to 65) - mutateweed() - if(1 to 32) - mutatepest(user) - else - to_chat(user, "Nothing happens...") - /obj/machinery/hydroponics/attackby(obj/item/O, mob/user, params) //Called when mob user "attacks" it with object O if(istype(O, /obj/item/reagent_containers) ) // Syringe stuff (and other reagent containers now too) @@ -722,6 +491,10 @@ var/transfer_amount if(istype(reagent_source, /obj/item/reagent_containers/food/snacks) || istype(reagent_source, /obj/item/reagent_containers/pill)) + if(istype(reagent_source, /obj/item/reagent_containers/food/snacks)) + var/obj/item/reagent_containers/food/snacks/R = reagent_source + if (R.trash) + R.generate_trash(get_turf(user)) visi_msg="[user] composts [reagent_source], spreading it through [target]" transfer_amount = reagent_source.reagents.total_volume else @@ -733,43 +506,39 @@ syr.mode = 0 else if(istype(reagent_source, /obj/item/reagent_containers/spray/)) visi_msg="[user] sprays [target] with [reagent_source]" - playsound(loc, 'sound/effects/spray3.ogg', 50, 1, -6) - irrigate = 1 + //playsound(loc, 'sound/effect/spray3.ogg', 50, 1, 6) //this sound displeases my ears immensely else if(transfer_amount) // Droppers, cans, beakers, what have you. visi_msg="[user] uses [reagent_source] on [target]" irrigate = 1 // Beakers, bottles, buckets, etc. if(reagent_source.is_drainable()) - playsound(loc, 'sound/effects/slosh.ogg', 25, 1) + if(irrigate && transfer_amount > 30 && reagent_source.reagents.total_volume >= 30 && using_irrigation) trays = FindConnected() if (trays.len > 1) - visi_msg += ", setting off the irrigation system" + visi_msg += ", setting off the irrigation system." + playsound(loc, 'sound/effects/slosh.ogg', 25, TRUE) if(visi_msg) - visible_message("[visi_msg].") + visible_message("[visi_msg]") var/split = round(transfer_amount/trays.len) + for(var/obj/machinery/hydroponics/H in trays) //cause I don't want to feel like im juggling 15 tamagotchis and I can get to my real work of ripping flooring apart in hopes of validating my life choices of becoming a space-gardener - var/datum/reagents/S = new /datum/reagents() //This is a strange way, but I don't know of a better one so I can't fix it at the moment... S.my_atom = H - reagent_source.reagents.trans_to(S,split) if(istype(reagent_source, /obj/item/reagent_containers/food/snacks) || istype(reagent_source, /obj/item/reagent_containers/pill)) qdel(reagent_source) - - H.applyChemicals(S, user) - + lastuser = user S.clear_reagents() qdel(S) H.update_icon() if(reagent_source) // If the source wasn't composted and destroyed reagent_source.update_icon() - return 1 else if(istype(O, /obj/item/seeds) && !istype(O, /obj/item/seeds/sample)) if(!myseed) @@ -778,22 +547,38 @@ if(!user.transferItemToLoc(O, src)) return to_chat(user, "You plant [O].") - dead = 0 + dead = FALSE myseed = O + name = myseed ? "[initial(name)] ([myseed.plantname])" : initial(name) age = 1 plant_health = myseed.endurance lastcycle = world.time update_icon() + return else to_chat(user, "[src] already has seeds in it!") + return else if(istype(O, /obj/item/plant_analyzer)) + var/obj/item/plant_analyzer/P_analyzer = O if(myseed) - to_chat(user, "*** [myseed.plantname] ***" ) - to_chat(user, "- Plant Age: [age]") - var/list/text_string = myseed.get_analyzer_text() - if(text_string) - to_chat(user, text_string) + if(!P_analyzer.scan_mode) + to_chat(user, "*** [myseed.plantname] ***" ) + to_chat(user, "- Plant Age: [age]") + var/list/text_string = myseed.get_analyzer_text() + if(text_string) + to_chat(user, text_string) + to_chat(user, "*---------*") + else + to_chat(user, "- Plant Reagents -") + to_chat(user, "*---------*") + if(!LAZYLEN(myseed.reagents_add)) + to_chat(user, "- No reagents -") + to_chat(user, "*---------*") + return + for(var/datum/plant_gene/reagent/G in myseed.genes) + to_chat(user, "- [G.get_name()] -") + to_chat(user, "*---------*") else to_chat(user, "No plant found.") to_chat(user, "- Weed level: [weedlevel] / 10") @@ -802,6 +587,7 @@ to_chat(user, "- Water level: [waterlevel] / [maxwater]") to_chat(user, "- Nutrition level: [nutrilevel] / [maxnutri]") to_chat(user, "") + return else if(istype(O, /obj/item/cultivator)) if(weedlevel > 0) @@ -845,6 +631,8 @@ harvest = FALSE //To make sure they can't just put in another seed and insta-harvest it qdel(myseed) myseed = null + name = initial(name) + desc = initial(desc) weedlevel = 0 //Has a side effect of cleaning up those nasty weeds update_icon() @@ -869,20 +657,22 @@ if(issilicon(user)) //How does AI know what plant is? return if(harvest) - return myseed.harvest(user) + myseed.harvest(user) + return else if(dead) - dead = 0 + dead = FALSE to_chat(user, "You remove the dead plant from [src].") qdel(myseed) myseed = null update_icon() + name = myseed ? "[initial(name)] ([myseed.plantname])" : initial(name) else if(user) examine(user) /obj/machinery/hydroponics/proc/update_tray(mob/user) - harvest = 0 + harvest = FALSE lastproduce = age if(istype(myseed, /obj/item/seeds/replicapod)) to_chat(user, "You harvest from the [myseed.plantname].") @@ -893,31 +683,33 @@ if(!myseed.get_gene(/datum/plant_gene/trait/repeated_harvest)) qdel(myseed) myseed = null - dead = 0 + dead = FALSE + name = myseed ? "[initial(name)] ([myseed.plantname])" : initial(name) + desc = initial(desc) update_icon() /// Tray Setters - The following procs adjust the tray or plants variables, and make sure that the stat doesn't go out of bounds./// /obj/machinery/hydroponics/proc/adjustNutri(adjustamt) - nutrilevel = CLAMP(nutrilevel + adjustamt, 0, maxnutri) + nutrilevel = clamp(nutrilevel + adjustamt, 0, maxnutri) /obj/machinery/hydroponics/proc/adjustWater(adjustamt) - waterlevel = CLAMP(waterlevel + adjustamt, 0, maxwater) + waterlevel = clamp(waterlevel + adjustamt, 0, maxwater) if(adjustamt>0) adjustToxic(-round(adjustamt/4))//Toxicity dilutation code. The more water you put in, the lesser the toxin concentration. /obj/machinery/hydroponics/proc/adjustHealth(adjustamt) if(myseed && !dead) - plant_health = CLAMP(plant_health + adjustamt, 0, myseed.endurance) + plant_health = clamp(plant_health + adjustamt, 0, myseed.endurance) /obj/machinery/hydroponics/proc/adjustToxic(adjustamt) - toxic = CLAMP(toxic + adjustamt, 0, 100) + toxic = clamp(toxic + adjustamt, 0, 100) /obj/machinery/hydroponics/proc/adjustPests(adjustamt) - pestlevel = CLAMP(pestlevel + adjustamt, 0, 10) + pestlevel = clamp(pestlevel + adjustamt, 0, 10) /obj/machinery/hydroponics/proc/adjustWeeds(adjustamt) - weedlevel = CLAMP(weedlevel + adjustamt, 0, 10) + weedlevel = clamp(weedlevel + adjustamt, 0, 10) /obj/machinery/hydroponics/proc/spawnplant() // why would you put strange reagent in a hydro tray you monster I bet you also feed them blood var/list/livingplants = list(/mob/living/simple_animal/hostile/tree, /mob/living/simple_animal/hostile/killertomato) diff --git a/code/modules/hydroponics/seeds.dm b/code/modules/hydroponics/seeds.dm index 2c1f6a8f..d0bec3ec 100644 --- a/code/modules/hydroponics/seeds.dm +++ b/code/modules/hydroponics/seeds.dm @@ -8,7 +8,8 @@ w_class = WEIGHT_CLASS_TINY resistance_flags = FLAMMABLE var/plantname = "Plants" // Name of plant when planted. - var/product // A type path. The thing that is created when the plant is harvested. + var/obj/item/product // A type path. The thing that is created when the plant is harvested. + var/productdesc var/species = "" // Used to update icons. Should match the name in the sprites unless all icon_* are overridden. var/growing_icon = 'icons/obj/hydroponics/growing.dmi' //the file that stores the sprites of the growing plant from this seed. @@ -26,7 +27,7 @@ var/rarity = 0 // How rare the plant is. Used for giving points to cargo when shipping off to CentCom. var/list/mutatelist = list() // The type of plants that this plant can mutate into. var/list/genes = list() // Plant genes are stored here, see plant_genes.dm for more info. - var/list/forbiddengenes = list() // Plant genes that the seed may be forbidden from having. + var/list/forbiddengenes = list() // Genes the seed cannot have, such as perennial growth var/list/reagents_add = list() // A list of reagents to add to product. // Format: "reagent_id" = potency multiplier @@ -70,6 +71,14 @@ genes += new /datum/plant_gene/reagent(reag_id, reagents_add[reag_id]) reagents_from_genes() //quality coding +/obj/item/seeds/examine(mob/user) + . = ..() + . += "Use a pen on it to rename it or change its description." + if(reagents_add && user.can_see_reagents()) + . += "- Plant Reagents -" + for(var/datum/plant_gene/reagent/G in genes) + . += "- [G.get_name()] -" + /obj/item/seeds/proc/Copy() var/obj/item/seeds/S = new type(null, 1) // Copy all the stats @@ -81,6 +90,10 @@ S.potency = potency S.weed_rate = weed_rate S.weed_chance = weed_chance + S.name = name + S.plantname = plantname + S.desc = desc + S.productdesc = productdesc S.genes = list() for(var/g in genes) var/datum/plant_gene/G = g @@ -91,8 +104,9 @@ /obj/item/seeds/proc/get_gene(typepath) return (locate(typepath) in genes) -obj/item/seeds/proc/is_gene_forbidden(typepath) - return (locate(typepath) in forbiddengenes) + +/obj/item/seeds/proc/is_gene_forbidden(typepath) + return (typepath in forbiddengenes) /obj/item/seeds/proc/reagents_from_genes() @@ -121,9 +135,10 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) adjust_weed_rate(rand(-wrmut, wrmut)) adjust_weed_chance(rand(-wcmut, wcmut)) if(prob(traitmut)) - add_random_traits(1, 1) - - + if(prob(50)) + add_random_traits(1, 1) + else + add_random_reagents(1, 1) /obj/item/seeds/bullet_act(obj/item/projectile/Proj) //Works with the Somatoray to modify plant variables. if(istype(Proj, /obj/item/projectile/energy/florayield)) @@ -136,6 +151,7 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) adjust_yield(1 * rating) else if(prob(1/(yield * yield) * 100))//This formula gives you diminishing returns based on yield. 100% with 1 yield, decreasing to 25%, 11%, 6, 4, 2... adjust_yield(1 * rating) + return BULLET_ACT_HIT else return ..() @@ -156,24 +172,33 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) /obj/item/seeds/proc/harvest(mob/user) var/obj/machinery/hydroponics/parent = loc //for ease of access - var/t_amount = 0 - var/list/result = list() - var/output_loc = parent.Adjacent(user) ? user.loc : parent.loc //needed for TK + var/t_amount = 0 ///Count used for creating the correct amount of results to the harvest. + var/list/result = list() ///List of plants all harvested from the same batch. + var/output_loc = parent.Adjacent(user) ? user.loc : parent.loc //Tile of the harvester to deposit the growables, needed for TK var/product_name - while(t_amount < getYield()) - var/obj/item/reagent_containers/food/snacks/grown/t_prod = new product(output_loc, src) + var/product_count = getYield() + + while(t_amount < product_count) + var/obj/item/reagent_containers/food/snacks/grown/t_prod + t_prod = new product(output_loc, src) + if(parent.myseed.plantname != initial(parent.myseed.plantname)) + t_prod.name = lowertext(parent.myseed.plantname) + if(productdesc) + t_prod.desc = productdesc + t_prod.seed.name = parent.myseed.name + t_prod.seed.desc = parent.myseed.desc + t_prod.seed.plantname = parent.myseed.plantname result.Add(t_prod) // User gets a consumable if(!t_prod) return t_amount++ - product_name = t_prod.name + product_name = parent.myseed.plantname if(getYield() >= 1) - SSblackbox.record_feedback("tally", "food_harvested", getYield(), product_name) + SSblackbox.record_feedback("tally", "food_harvested", product_count, product_name) parent.update_tray(user) return result - /obj/item/seeds/proc/prepare_result(var/obj/item/reagent_containers/food/snacks/grown/T) if(!T.reagents) CRASH("[T] has no reagents.") @@ -194,7 +219,7 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) /// Setters procs /// /obj/item/seeds/proc/adjust_yield(adjustamt) if(yield != -1) // Unharvestable shouldn't suddenly turn harvestable - yield = CLAMP(yield + adjustamt, 0, 10) + yield = clamp(yield + adjustamt, 0, 10) if(yield <= 0 && get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism)) yield = 1 // Mushrooms always have a minimum yield of 1. @@ -203,39 +228,39 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) C.value = yield /obj/item/seeds/proc/adjust_lifespan(adjustamt) - lifespan = CLAMP(lifespan + adjustamt, 10, 100) + lifespan = clamp(lifespan + adjustamt, 10, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/lifespan) if(C) C.value = lifespan /obj/item/seeds/proc/adjust_endurance(adjustamt) - endurance = CLAMP(endurance + adjustamt, 10, 100) + endurance = clamp(endurance + adjustamt, 10, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/endurance) if(C) C.value = endurance /obj/item/seeds/proc/adjust_production(adjustamt) if(yield != -1) - production = CLAMP(production + adjustamt, 1, 10) + production = clamp(production + adjustamt, 1, 10) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/production) if(C) C.value = production /obj/item/seeds/proc/adjust_potency(adjustamt) if(potency != -1) - potency = CLAMP(potency + adjustamt, 0, 100) + potency = clamp(potency + adjustamt, 0, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/potency) if(C) C.value = potency /obj/item/seeds/proc/adjust_weed_rate(adjustamt) - weed_rate = CLAMP(weed_rate + adjustamt, 0, 10) + weed_rate = clamp(weed_rate + adjustamt, 0, 10) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/weed_rate) if(C) C.value = weed_rate /obj/item/seeds/proc/adjust_weed_chance(adjustamt) - weed_chance = CLAMP(weed_chance + adjustamt, 0, 67) + weed_chance = clamp(weed_chance + adjustamt, 0, 67) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/weed_chance) if(C) C.value = weed_chance @@ -244,7 +269,7 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) /obj/item/seeds/proc/set_yield(adjustamt) if(yield != -1) // Unharvestable shouldn't suddenly turn harvestable - yield = CLAMP(adjustamt, 0, 10) + yield = clamp(adjustamt, 0, 10) if(yield <= 0 && get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism)) yield = 1 // Mushrooms always have a minimum yield of 1. @@ -253,39 +278,39 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) C.value = yield /obj/item/seeds/proc/set_lifespan(adjustamt) - lifespan = CLAMP(adjustamt, 10, 100) + lifespan = clamp(adjustamt, 10, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/lifespan) if(C) C.value = lifespan /obj/item/seeds/proc/set_endurance(adjustamt) - endurance = CLAMP(adjustamt, 10, 100) + endurance = clamp(adjustamt, 10, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/endurance) if(C) C.value = endurance /obj/item/seeds/proc/set_production(adjustamt) if(yield != -1) - production = CLAMP(adjustamt, 1, 10) + production = clamp(adjustamt, 1, 10) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/production) if(C) C.value = production /obj/item/seeds/proc/set_potency(adjustamt) if(potency != -1) - potency = CLAMP(adjustamt, 0, 100) + potency = clamp(adjustamt, 0, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/potency) if(C) C.value = potency /obj/item/seeds/proc/set_weed_rate(adjustamt) - weed_rate = CLAMP(adjustamt, 0, 10) + weed_rate = clamp(adjustamt, 0, 10) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/weed_rate) if(C) C.value = weed_rate /obj/item/seeds/proc/set_weed_chance(adjustamt) - weed_chance = CLAMP(adjustamt, 0, 67) + weed_chance = clamp(adjustamt, 0, 67) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/weed_chance) if(C) C.value = weed_chance @@ -320,9 +345,7 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) continue all_traits += " [traits.get_name()]" text += "- Plant Traits:[all_traits]\n" - text += "*---------*" - return text /obj/item/seeds/proc/on_chem_reaction(datum/reagents/S) //in case seeds have some special interaction with special chems @@ -331,19 +354,73 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) /obj/item/seeds/attackby(obj/item/O, mob/user, params) if (istype(O, /obj/item/plant_analyzer)) to_chat(user, "*---------*\n This is \a [src].") - var/text = get_analyzer_text() - if(text) - to_chat(user, "[text]") - + var/text + var/obj/item/plant_analyzer/P_analyzer = O + if(!P_analyzer.scan_mode) + text = get_analyzer_text() + if(text) + to_chat(user, "[text]") + else + to_chat(user, "- Plant Reagents -") + to_chat(user, "*---------*") + if(!LAZYLEN(reagents_add)) + to_chat(user, "- No reagents -") + to_chat(user, "*---------*") + return + for(var/datum/plant_gene/reagent/G in genes) + to_chat(user, "- [G.get_name()] -") + to_chat(user, "*---------*") return + + if(istype(O, /obj/item/pen)) + var/choice = input("What would you like to change?") in list("Plant Name", "Seed Description", "Product Description", "Cancel") + if(!user.canUseTopic(src, BE_CLOSE)) + return + switch(choice) + if("Plant Name") + var/newplantname = reject_bad_text(stripped_input(user, "Write a new plant name:", name, plantname)) + if(!user.canUseTopic(src, BE_CLOSE)) + return + if (length(newplantname) > 20) + to_chat(user, "That name is too long!") + return + if(!newplantname) + to_chat(user, "That name is invalid.") + return + else + name = "[lowertext(newplantname)]" + plantname = newplantname + if("Seed Description") + var/newdesc = stripped_input(user, "Write a new description:", name, desc) + if(!user.canUseTopic(src, BE_CLOSE)) + return + if (length(newdesc) > 180) + to_chat(user, "That description is too long!") + return + if(!newdesc) + to_chat(user, "That description is invalid.") + return + else + desc = newdesc + if("Product Description") + if(product && !productdesc) + productdesc = initial(product.desc) + var/newproductdesc = stripped_input(user, "Write a new description:", name, productdesc) + if(!user.canUseTopic(src, BE_CLOSE)) + return + if (length(newproductdesc) > 180) + to_chat(user, "That description is too long!") + return + if(!newproductdesc) + to_chat(user, "That description is invalid.") + return + else + productdesc = newproductdesc + else + return + ..() // Fallthrough to item/attackby() so that bags can pick seeds up - - - - - - // Checks plants for broken tray icons. Use Advanced Proc Call to activate. // Maybe some day it would be used as unit test. /proc/check_plants_growth_stages_icons() @@ -395,7 +472,7 @@ obj/item/seeds/proc/is_gene_forbidden(typepath) for(var/i in 1 to amount_random_traits) var/random_trait = pick((subtypesof(/datum/plant_gene/trait)-typesof(/datum/plant_gene/trait/plant_type))) var/datum/plant_gene/trait/T = new random_trait - if(T.can_add(src) && !is_gene_forbidden(T)) + if(T.can_add(src) && !is_gene_forbidden(random_trait)) genes += T else qdel(T) diff --git a/tgstation.dme b/tgstation.dme index 9ea813c0..61e22acc 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1822,6 +1822,7 @@ #include "code\modules\hydroponics\gene_modder.dm" #include "code\modules\hydroponics\grown.dm" #include "code\modules\hydroponics\growninedible.dm" +#include "code\modules\hydroponics\hydro_chemreact.dm" #include "code\modules\hydroponics\hydroitemdefines.dm" #include "code\modules\hydroponics\hydroponics.dm" #include "code\modules\hydroponics\plant_genes.dm"