From 8790bfd014a585e15ec1f538f17dcd50c4ed9c96 Mon Sep 17 00:00:00 2001 From: Zuhayr Date: Sat, 31 Jan 2015 12:11:33 +1030 Subject: [PATCH] Mature mob-plants have a chance of self-harvesting if the tray lid is not closed. --- code/modules/hydroponics/hydro_tray.dm | 15 +++++++++++---- code/modules/hydroponics/seed_datums.dm | 9 +++++++-- code/modules/hydroponics/spread_plant.dm | 8 ++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/code/modules/hydroponics/hydro_tray.dm b/code/modules/hydroponics/hydro_tray.dm index b2870a4edf0..efd363ed9ab 100644 --- a/code/modules/hydroponics/hydro_tray.dm +++ b/code/modules/hydroponics/hydro_tray.dm @@ -7,7 +7,7 @@ flags = OPENCONTAINER volume = 100 - var/mechanical = 1 //Set to 0 to stop it from drawing the alert lights. + var/mechanical = 1 // Set to 0 to stop it from drawing the alert lights. // Plant maintenance vars. var/waterlevel = 100 // Water (max 100) @@ -300,6 +300,10 @@ if(prob(3)) // On each tick, there's a chance the pest population will increase pestlevel += 0.1 * HYDRO_SPEED_MULTIPLIER + // Some seeds will self-harvest if you don't keep a lid on them. + if(seed && seed.can_self_harvest && harvest && !closed_system && prob(5)) + harvest() + check_level_sanity() update_icon() return @@ -360,14 +364,17 @@ /obj/machinery/portable_atmospherics/hydroponics/proc/harvest(var/mob/user) //Harvest the product of the plant, - if(!seed || !harvest || !user) + if(!seed || !harvest) return if(closed_system) - user << "You can't harvest from the plant while the lid is shut." + if(user) user << "You can't harvest from the plant while the lid is shut." return - seed.harvest(user,yield_mod) + if(user) + seed.harvest(user,yield_mod) + else + seed.harvest(get_turf(src),yield_mod) // Reset values. harvest = 0 diff --git a/code/modules/hydroponics/seed_datums.dm b/code/modules/hydroponics/seed_datums.dm index 002682a60b1..74c9063f6d8 100644 --- a/code/modules/hydroponics/seed_datums.dm +++ b/code/modules/hydroponics/seed_datums.dm @@ -84,6 +84,7 @@ proc/populate_seed_list() var/display_name // Prettier name. var/roundstart // If set, seed will not display variety number. var/mysterious // Only used for the random seed packets. + var/can_self_harvest = 0 // Mostly used for living mobs. var/growth_stages = 0 // Number of stages the plant passes through before it is mature. var/list/traits = list() // Initialized in New() var/list/products // Possible fruit/other product paths. @@ -660,9 +661,9 @@ proc/populate_seed_list() got_product = 1 if(!force_amount && !got_product && !harvest_sample) - user << "You fail to harvest anything useful." + if(istype(user)) user << "You fail to harvest anything useful." else - user << "You [harvest_sample ? "take a sample" : "harvest"] from the [display_name]." + if(istype(user)) user << "You [harvest_sample ? "take a sample" : "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)) @@ -728,6 +729,7 @@ proc/populate_seed_list() new_seed.name = "new line" new_seed.uid = 0 new_seed.roundstart = 0 + new_seed.can_self_harvest = can_self_harvest //Copy over everything else. if(products) new_seed.products = products.Copy() @@ -979,6 +981,7 @@ proc/populate_seed_list() display_name = "killer tomato plant" products = list(/mob/living/simple_animal/tomato) mutants = null + can_self_harvest = 1 /datum/seed/tomato/killer/New() ..() @@ -1190,6 +1193,7 @@ proc/populate_seed_list() display_name = "walking mushrooms" products = list(/mob/living/simple_animal/mushroom) mutants = null + can_self_harvest = 1 /datum/seed/mushroom/plump/walking/New() ..() @@ -1810,6 +1814,7 @@ proc/populate_seed_list() seed_noun = "nodes" display_name = "replicant pods" products = list(/mob/living/carbon/alien/diona) + can_self_harvest = 1 /datum/seed/diona/New() ..() diff --git a/code/modules/hydroponics/spread_plant.dm b/code/modules/hydroponics/spread_plant.dm index 34e77328ea5..302dde78132 100644 --- a/code/modules/hydroponics/spread_plant.dm +++ b/code/modules/hydroponics/spread_plant.dm @@ -15,8 +15,8 @@ var/obj/effect/plant/parent var/datum/seed/seed var/floor = 0 - var/spread_chance = 40 - var/spread_into_adjacent = 60 + var/spread_chance = 100 //40 + var/spread_into_adjacent = 100 //60 var/evolve_chance = 2 var/last_tick = 0 var/hibernating = 0 @@ -27,8 +27,8 @@ /obj/effect/plant/New(var/newloc, var/datum/seed/newseed) ..() - if(!newseed) - newseed = DEFAULT_SEED + if(!istype(newseed)) + newseed = seed_types[DEFAULT_SEED] seed = newseed if(!seed) del(src)