TGUI Research

This commit is contained in:
ShadowLarkens
2020-08-25 13:25:57 -07:00
parent 3de27a9e8f
commit 097d4fa283
144 changed files with 9345 additions and 4773 deletions
-114
View File
@@ -1,114 +0,0 @@
//Misc
#define DEAD_PLANT_COLOUR "#C2A180"
#define FROZEN_PLANT_COLOUR "#CCFFFF"
// Definitions for genes (trait groupings)
#define GENE_BIOCHEMISTRY "biochemistry"
#define GENE_HARDINESS "hardiness"
#define GENE_ENVIRONMENT "environment"
#define GENE_METABOLISM "metabolism"
#define GENE_STRUCTURE "appearance"
#define GENE_DIET "diet"
#define GENE_PIGMENT "pigment"
#define GENE_OUTPUT "output"
#define GENE_ATMOSPHERE "atmosphere"
#define GENE_VIGOUR "vigour"
#define GENE_FRUIT "fruit"
#define GENE_SPECIAL "special"
#define ALL_GENES list(GENE_BIOCHEMISTRY,GENE_HARDINESS,GENE_ENVIRONMENT,GENE_METABOLISM,GENE_STRUCTURE,GENE_DIET,GENE_PIGMENT,GENE_OUTPUT,GENE_ATMOSPHERE,GENE_VIGOUR,GENE_FRUIT,GENE_SPECIAL)
//Definitions for traits (individual descriptors)
#define TRAIT_CHEMS 1
#define TRAIT_EXUDE_GASSES 2
#define TRAIT_ALTER_TEMP 3
#define TRAIT_POTENCY 4
#define TRAIT_HARVEST_REPEAT 5
#define TRAIT_PRODUCES_POWER 6
#define TRAIT_JUICY 7
#define TRAIT_PRODUCT_ICON 8
#define TRAIT_PLANT_ICON 0
#define TRAIT_CONSUME_GASSES 10
#define TRAIT_REQUIRES_NUTRIENTS 11
#define TRAIT_NUTRIENT_CONSUMPTION 12
#define TRAIT_REQUIRES_WATER 13
#define TRAIT_WATER_CONSUMPTION 14
#define TRAIT_CARNIVOROUS 15
#define TRAIT_PARASITE 16
#define TRAIT_STINGS 17
#define TRAIT_IDEAL_HEAT 18
#define TRAIT_HEAT_TOLERANCE 19
#define TRAIT_IDEAL_LIGHT 20
#define TRAIT_LIGHT_TOLERANCE 21
#define TRAIT_LOWKPA_TOLERANCE 22
#define TRAIT_HIGHKPA_TOLERANCE 23
#define TRAIT_EXPLOSIVE 24
#define TRAIT_TOXINS_TOLERANCE 25
#define TRAIT_PEST_TOLERANCE 26
#define TRAIT_WEED_TOLERANCE 27
#define TRAIT_ENDURANCE 28
#define TRAIT_YIELD 29
#define TRAIT_SPREAD 30
#define TRAIT_MATURATION 31
#define TRAIT_PRODUCTION 32
#define TRAIT_TELEPORTING 33
#define TRAIT_PLANT_COLOUR 34
#define TRAIT_PRODUCT_COLOUR 35
#define TRAIT_BIOLUM 36
#define TRAIT_BIOLUM_COLOUR 37
#define TRAIT_IMMUTABLE 38
#define TRAIT_FLESH_COLOUR 39
#define TRAIT_SPORING 40
#define TRAIT_BENEFICIAL_REAG 41
#define TRAIT_MUTAGENIC_REAG 42
#define TRAIT_TOXIC_REAG 43
// Global list initialization for plants.
GLOBAL_LIST_INIT(plant_mob_products, list(
/mob/living/simple_mob/creature = 10,
/mob/living/simple_mob/blob/spore = 20,
/mob/living/simple_mob/tomato = 30,
/mob/living/simple_mob/animal/passive/dog = 5,
/mob/living/simple_mob/animal/passive/chicken = 5,
/mob/living/simple_mob/animal/passive/crab = 5,
/mob/living/simple_mob/animal/passive/lizard = 4,
/mob/living/simple_mob/animal/passive/lizard/large = 1,
/mob/living/simple_mob/animal/giant_spider/pepper = 1,
/mob/living/simple_mob/animal/giant_spider/frost = 1,
/mob/living/simple_mob/animal/giant_spider/webslinger = 1,
/mob/living/simple_mob/animal/passive/mouse = 1,
/mob/living/simple_mob/animal/space/carp = 1,
/mob/living/carbon/human/monkey = 1,
/mob/living/carbon/alien/diona = 1
))
GLOBAL_LIST_INIT(plant_item_products, list(
/obj/item/stack/material/cloth = 30,
/obj/item/stack/material/wax = 20,
/obj/item/stack/material/log = 30,
/obj/item/stack/material/resin = 10,
/obj/item/weapon/material/shard/shrapnel = 2,
/obj/item/weapon/ore = 5,
/obj/item/weapon/ore/iron = 2,
/obj/item/weapon/ore/coal = 2,
/obj/item/weapon/reagent_containers/food/snacks/meat = 3,
/obj/random/meat = 1,
/obj/item/weapon/reagent_containers/food/drinks/smallchocmilk = 2,
/obj/item/weapon/reagent_containers/food/drinks/smallmilk = 2,
/obj/item/ammo_casing/a145 = 1,
/obj/item/ammo_casing/chemdart/small = 1,
/obj/item/ammo_casing/chemdart = 1,
/obj/item/organ/internal/brain/grey = 1,
/obj/item/organ/internal/heart/grey = 1,
/obj/item/weapon/spacecash/c1 = 3,
/obj/item/weapon/spacecash/c10 = 1
))
GLOBAL_LIST_INIT(forbidden_plant_growth_sprites, list(
"gnomes"
))
GLOBAL_LIST_INIT(forbidden_plant_product_sprites, list(
"gnomes"
))
+8 -15
View File
@@ -30,7 +30,7 @@
log_debug("Plantname not provided and and [src] requires it at [x],[y],[z]")
return INITIALIZE_HINT_QDEL
seed = plant_controller.seeds[plantname]
seed = SSplants.seeds[plantname]
if(!seed)
log_debug("Plant name '[plantname]' does not exist and [src] requires it at [x],[y],[z]")
@@ -62,18 +62,11 @@
force = 1
/obj/item/weapon/reagent_containers/food/snacks/grown/proc/update_desc()
if(!seed)
return
if(!plant_controller)
sleep(250) // ugly hack, should mean roundstart plants are fine.
if(!plant_controller)
to_world("<span class='danger'>Plant controller does not exist and [src] requires it. Aborting.</span>")
qdel(src)
return
if(plant_controller.product_descs["[seed.uid]"])
desc = plant_controller.product_descs["[seed.uid]"]
if(SSplants.product_descs["[seed.uid]"])
desc = SSplants.product_descs["[seed.uid]"]
else
var/list/descriptors = list()
if(reagents.has_reagent("sugar") || reagents.has_reagent("cherryjelly") || reagents.has_reagent("honey") || reagents.has_reagent("berryjuice"))
@@ -125,17 +118,17 @@
desc += " mushroom"
else
desc += " fruit"
plant_controller.product_descs["[seed.uid]"] = desc
SSplants.product_descs["[seed.uid]"] = desc
desc += ". Delicious! Probably."
/obj/item/weapon/reagent_containers/food/snacks/grown/update_icon()
if(!seed || !plant_controller || !plant_controller.plant_icon_cache)
if(!seed || !SSplants || !SSplants.plant_icon_cache)
return
overlays.Cut()
var/image/plant_icon
var/icon_key = "fruit-[seed.get_trait(TRAIT_PRODUCT_ICON)]-[seed.get_trait(TRAIT_PRODUCT_COLOUR)]-[seed.get_trait(TRAIT_PLANT_COLOUR)]"
if(plant_controller.plant_icon_cache[icon_key])
plant_icon = plant_controller.plant_icon_cache[icon_key]
if(SSplants.plant_icon_cache[icon_key])
plant_icon = SSplants.plant_icon_cache[icon_key]
else
plant_icon = image('icons/obj/hydroponics_products.dmi',"blank")
var/image/fruit_base = image('icons/obj/hydroponics_products.dmi',"[seed.get_trait(TRAIT_PRODUCT_ICON)]-product")
@@ -145,7 +138,7 @@
var/image/fruit_leaves = image('icons/obj/hydroponics_products.dmi',"[seed.get_trait(TRAIT_PRODUCT_ICON)]-leaf")
fruit_leaves.color = "[seed.get_trait(TRAIT_PLANT_COLOUR)]"
plant_icon.overlays |= fruit_leaves
plant_controller.plant_icon_cache[icon_key] = plant_icon
SSplants.plant_icon_cache[icon_key] = plant_icon
overlays |= plant_icon
/obj/item/weapon/reagent_containers/food/snacks/grown/Crossed(var/mob/living/M)
+1 -1
View File
@@ -19,7 +19,7 @@
//Handle some post-spawn var stuff.
if(planttype)
plantname = planttype
var/datum/seed/S = plant_controller.seeds[plantname]
var/datum/seed/S = SSplants.seeds[plantname]
if(!S || !S.chems)
return
+6 -6
View File
@@ -410,8 +410,8 @@
seed_noun = pick("spores","nodes","cuttings","seeds")
set_trait(TRAIT_POTENCY,rand(5,30),200,0)
set_trait(TRAIT_PRODUCT_ICON,pick(plant_controller.accessible_product_sprites))
set_trait(TRAIT_PLANT_ICON,pick(plant_controller.accessible_plant_sprites))
set_trait(TRAIT_PRODUCT_ICON,pick(SSplants.accessible_product_sprites))
set_trait(TRAIT_PLANT_ICON,pick(SSplants.accessible_plant_sprites))
set_trait(TRAIT_PLANT_COLOUR,"#[get_random_colour(0,75,190)]")
set_trait(TRAIT_PRODUCT_COLOUR,"#[get_random_colour(0,75,190)]")
update_growth_stages()
@@ -788,10 +788,10 @@
to_chat(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 plant_controller.seeds))
uid = plant_controller.seeds.len + 1
if(name == "new line" || !(name in SSplants.seeds))
uid = SSplants.seeds.len + 1
name = "[uid]"
plant_controller.seeds[name] = src
SSplants.seeds[name] = src
if(harvest_sample)
var/obj/item/seeds/seeds = new(get_turf(user))
@@ -877,6 +877,6 @@
/datum/seed/proc/update_growth_stages()
if(get_trait(TRAIT_PLANT_ICON))
growth_stages = plant_controller.plant_sprites[get_trait(TRAIT_PLANT_ICON)]
growth_stages = SSplants.plant_sprites[get_trait(TRAIT_PLANT_ICON)]
else
growth_stages = 0
-169
View File
@@ -1,169 +0,0 @@
// Attempts to offload processing for the spreading plants from the MC.
// Processes vines/spreading plants.
#define PLANTS_PER_TICK 500 // Cap on number of plant segments processed.
#define PLANT_TICK_TIME 75 // Number of ticks between the plant processor cycling.
// Debug for testing seed genes.
/client/proc/show_plant_genes()
set category = "Debug"
set name = "Show Plant Genes"
set desc = "Prints the round's plant gene masks."
if(!holder) return
if(!plant_controller || !plant_controller.gene_tag_masks)
to_chat(usr, "Gene masks not set.")
return
for(var/mask in plant_controller.gene_tag_masks)
to_chat(usr, "[mask]: [plant_controller.gene_tag_masks[mask]]")
var/global/datum/controller/plants/plant_controller // Set in New().
/datum/controller/plants
var/plants_per_tick = PLANTS_PER_TICK
var/plant_tick_time = PLANT_TICK_TIME
var/list/product_descs = list() // Stores generated fruit descs.
var/list/plant_queue = list() // All queued plants.
var/list/seeds = list() // All seed data stored here.
var/list/gene_tag_masks = list() // Gene obfuscation for delicious trial and error goodness.
var/list/plant_icon_cache = list() // Stores images of growth, fruits and seeds.
var/list/plant_sprites = list() // List of all growth sprites plus number of growth stages.
var/list/accessible_plant_sprites = list() // List of all plant sprites allowed to appear in random generation.
var/list/plant_product_sprites = list() // List of all harvested product sprites.
var/list/accessible_product_sprites = list() // List of all product sprites allowed to appear in random generation.
var/processing = 0 // Off/on.
var/list/gene_masked_list = list() // Stored gene masked list, rather than recreating it when needed.
var/list/plant_gene_datums = list() // Stored datum versions of the gene masked list.
/datum/controller/plants/New()
if(plant_controller && plant_controller != src)
log_debug("Rebuilding plant controller.")
qdel(plant_controller)
plant_controller = src
setup()
process()
// 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.
/datum/controller/plants/proc/setup()
// Build the icon lists.
for(var/icostate in cached_icon_states('icons/obj/hydroponics_growing.dmi'))
var/split = findtext(icostate,"-")
if(!split)
// invalid icon_state
continue
var/ikey = copytext(icostate,(split+1))
if(ikey == "dead")
// don't count dead icons
continue
ikey = text2num(ikey)
var/base = copytext(icostate,1,split)
if(!(plant_sprites[base]) || (plant_sprites[base]<ikey))
plant_sprites[base] = ikey
if(!(base in GLOB.forbidden_plant_growth_sprites))
accessible_plant_sprites[base] = ikey
for(var/icostate in cached_icon_states('icons/obj/hydroponics_products.dmi'))
var/split = findtext(icostate,"-")
var/base = copytext(icostate,1,split)
if(split)
plant_product_sprites |= base
if(!(base in GLOB.forbidden_plant_product_sprites))
accessible_product_sprites |= base
// Populate the global seed datum list.
for(var/type in typesof(/datum/seed)-/datum/seed)
var/datum/seed/S = new type
seeds[S.name] = S
S.uid = "[seeds.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 all_seed_packs)
S.update_seed()
//Might as well mask the gene types while we're at it.
var/list/gene_datums = decls_repository.decls_of_subtype(/decl/plantgene)
var/list/used_masks = list()
var/list/plant_traits = ALL_GENES
while(plant_traits && plant_traits.len)
var/gene_tag = pick(plant_traits)
var/gene_mask = "[uppertext(num2hex(rand(0,255), 2))]"
while(gene_mask in used_masks)
gene_mask = "[uppertext(num2hex(rand(0,255), 2))]"
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
plant_gene_datums[gene_mask] = G
gene_masked_list.Add(list(list("tag" = gene_tag, "mask" = gene_mask)))
// Proc for creating a random seed type.
/datum/controller/plants/proc/create_random_seed(var/survive_on_station)
var/datum/seed/seed = new()
seed.randomize()
seed.uid = plant_controller.seeds.len + 1
seed.name = "[seed.uid]"
seeds[seed.name] = seed
if(survive_on_station)
if(seed.consume_gasses)
seed.consume_gasses["phoron"] = null
seed.consume_gasses["carbon_dioxide"] = null
if(seed.chems && !isnull(seed.chems["pacid"]))
seed.chems["pacid"] = null // Eating through the hull will make these plants completely inviable, albeit very dangerous.
seed.chems -= null // Setting to null does not actually remove the entry, which is weird.
seed.set_trait(TRAIT_IDEAL_HEAT,293)
seed.set_trait(TRAIT_HEAT_TOLERANCE,20)
seed.set_trait(TRAIT_IDEAL_LIGHT,8)
seed.set_trait(TRAIT_LIGHT_TOLERANCE,5)
seed.set_trait(TRAIT_LOWKPA_TOLERANCE,25)
seed.set_trait(TRAIT_HIGHKPA_TOLERANCE,200)
return seed
/datum/controller/plants/process()
processing = 1
spawn(0)
set background = 1
var/processed = 0
while(1)
if(!processing)
sleep(plant_tick_time)
else
processed = 0
if(plant_queue.len)
var/target_to_process = min(plant_queue.len,plants_per_tick)
for(var/x=0;x<target_to_process;x++)
if(!plant_queue.len)
break
var/obj/effect/plant/plant = pick(plant_queue)
plant_queue -= plant
if(!istype(plant))
continue
plant.process()
processed++
sleep(1) // Stagger processing out so previous tick can resolve (overlapping plant segments etc)
sleep(max(1,(plant_tick_time-processed)))
/datum/controller/plants/proc/add_plant(var/obj/effect/plant/plant)
plant_queue |= plant
/datum/controller/plants/proc/remove_plant(var/obj/effect/plant/plant)
plant_queue -= plant
+105 -109
View File
@@ -62,7 +62,7 @@
return attack_hand(user)
/obj/machinery/botany/attack_hand(mob/user as mob)
ui_interact(user)
tgui_interact(user)
/obj/machinery/botany/proc/finished_task()
active = 0
@@ -136,14 +136,16 @@
var/datum/seed/genetics // Currently scanned seed genetic structure.
var/degradation = 0 // Increments with each scan, stops allowing gene mods after a certain point.
/obj/machinery/botany/extractor/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
/obj/machinery/botany/extractor/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "BotanyIsolator", name)
ui.open()
if(!user)
return
/obj/machinery/botany/extractor/tgui_data(mob/user)
var/list/data = ..()
var/list/data = list()
var/list/geneMasks = plant_controller.gene_masked_list
var/list/geneMasks = SSplants.gene_masked_list
data["geneMasks"] = geneMasks
data["activity"] = active
@@ -168,95 +170,93 @@
data["hasGenetics"] = 0
data["sourceName"] = 0
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "botany_isolator.tmpl", "Lysis-isolation Centrifuge UI", 470, 450)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
/obj/machinery/botany/Topic(href, href_list)
return data
/obj/machinery/botany/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return 1
if(href_list["eject_packet"])
if(!seed) return
seed.loc = get_turf(src)
if(seed.seed.name == "new line" || isnull(plant_controller.seeds[seed.seed.name]))
seed.seed.uid = plant_controller.seeds.len + 1
seed.seed.name = "[seed.seed.uid]"
plant_controller.seeds[seed.seed.name] = seed.seed
seed.update_seed()
visible_message("[bicon(src)] [src] beeps and spits out [seed].")
seed = null
if(href_list["eject_disk"])
if(!loaded_disk) return
loaded_disk.loc = get_turf(src)
visible_message("[bicon(src)] [src] beeps and spits out [loaded_disk].")
loaded_disk = null
return TRUE
usr.set_machine(src)
src.add_fingerprint(usr)
add_fingerprint(usr)
/obj/machinery/botany/extractor/Topic(href, href_list)
switch(action)
if("eject_packet")
if(!seed)
return
seed.forceMove(get_turf(src))
if(seed.seed.name == "new line" || isnull(SSplants.seeds[seed.seed.name]))
seed.seed.uid = SSplants.seeds.len + 1
seed.seed.name = "[seed.seed.uid]"
SSplants.seeds[seed.seed.name] = seed.seed
seed.update_seed()
visible_message("[bicon(src)] [src] beeps and spits out [seed].")
seed = null
return TRUE
if("eject_disk")
if(!loaded_disk)
return
loaded_disk.forceMove(get_turf(src))
visible_message("[bicon(src)] [src] beeps and spits out [loaded_disk].")
loaded_disk = null
return TRUE
/obj/machinery/botany/extractor/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return 1
return TRUE
usr.set_machine(src)
src.add_fingerprint(usr)
switch(action)
if("scan_genome")
if(!seed)
return
if(href_list["scan_genome"])
last_action = world.time
active = 1
if(!seed) return
if(seed && seed.seed)
genetics = seed.seed
degradation = 0
last_action = world.time
active = 1
qdel(seed)
seed = null
return TRUE
if(seed && seed.seed)
genetics = seed.seed
degradation = 0
if("get_gene")
if(!genetics || !loaded_disk)
return
qdel(seed)
seed = null
last_action = world.time
active = 1
if(href_list["get_gene"])
var/datum/plantgene/P = genetics.get_gene(params["get_gene"])
if(!P)
return
loaded_disk.genes += P
if(!genetics || !loaded_disk) return
loaded_disk.genesource = "[genetics.display_name]"
if(!genetics.roundstart)
loaded_disk.genesource += " (variety #[genetics.uid])"
last_action = world.time
active = 1
loaded_disk.name += " ([SSplants.gene_tag_masks[params["get_gene"]]], #[genetics.uid])"
loaded_disk.desc += " The label reads \'gene [SSplants.gene_tag_masks[params["get_gene"]]], sampled from [genetics.display_name]\'."
eject_disk = 1
var/datum/plantgene/P = genetics.get_gene(href_list["get_gene"])
if(!P) return
loaded_disk.genes += P
degradation += rand(20,60)
if(degradation >= 100)
failed_task = 1
genetics = null
degradation = 0
return TRUE
loaded_disk.genesource = "[genetics.display_name]"
if(!genetics.roundstart)
loaded_disk.genesource += " (variety #[genetics.uid])"
loaded_disk.name += " ([plant_controller.gene_tag_masks[href_list["get_gene"]]], #[genetics.uid])"
loaded_disk.desc += " The label reads \'gene [plant_controller.gene_tag_masks[href_list["get_gene"]]], sampled from [genetics.display_name]\'."
eject_disk = 1
degradation += rand(20,60)
if(degradation >= 100)
failed_task = 1
if("clear_buffer")
if(!genetics)
return
genetics = null
degradation = 0
if(href_list["clear_buffer"])
if(!genetics) return
genetics = null
degradation = 0
src.updateUsrDialog()
return
return TRUE
// Fires an extracted trait into another packet of seeds with a chance
// of destroying it based on the size/complexity of the plasmid.
@@ -265,13 +265,15 @@
icon_state = "traitgun"
disk_needs_genes = 1
/obj/machinery/botany/editor/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
if(!user)
return
var/list/data = list()
/obj/machinery/botany/editor/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "BotanyEditor", name)
ui.open()
/obj/machinery/botany/editor/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
var/list/data = ..()
data["activity"] = active
if(seed)
@@ -286,7 +288,7 @@
for(var/datum/plantgene/P in loaded_disk.genes)
if(data["locus"] != "") data["locus"] += ", "
data["locus"] += "[plant_controller.gene_tag_masks[P.genetype]]"
data["locus"] += "[SSplants.gene_tag_masks[P.genetype]]"
else
data["disk"] = 0
@@ -298,36 +300,30 @@
else
data["loaded"] = 0
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "botany_editor.tmpl", "Bioballistic Delivery UI", 470, 450)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
/obj/machinery/botany/editor/Topic(href, href_list)
return data
/obj/machinery/botany/editor/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return 1
return TRUE
if(href_list["apply_gene"])
if(!loaded_disk || !seed) return
switch(action)
if("apply_gene")
if(!loaded_disk || !seed)
return
last_action = world.time
active = 1
last_action = world.time
active = 1
if(!isnull(plant_controller.seeds[seed.seed.name]))
seed.seed = seed.seed.diverge(1)
seed.seed_type = seed.seed.name
seed.update_seed()
if(!isnull(SSplants.seeds[seed.seed.name]))
seed.seed = seed.seed.diverge(1)
seed.seed_type = seed.seed.name
seed.update_seed()
if(prob(seed.modified))
failed_task = 1
seed.modified = 101
if(prob(seed.modified))
failed_task = 1
seed.modified = 101
for(var/datum/plantgene/gene in loaded_disk.genes)
seed.seed.apply_gene(gene)
seed.modified += rand(5,10)
usr.set_machine(src)
src.add_fingerprint(usr)
for(var/datum/plantgene/gene in loaded_disk.genes)
seed.seed.apply_gene(gene)
seed.modified += rand(5,10)
return TRUE
+3 -3
View File
@@ -19,8 +19,8 @@ GLOBAL_LIST_BOILERPLATE(all_seed_packs, /obj/item/seeds)
//Grabs the appropriate seed datum from the global list.
/obj/item/seeds/proc/update_seed()
if(!seed && seed_type && !isnull(plant_controller.seeds) && plant_controller.seeds[seed_type])
seed = plant_controller.seeds[seed_type]
if(!seed && seed_type && !isnull(SSplants.seeds) && SSplants.seeds[seed_type])
seed = SSplants.seeds[seed_type]
update_appearance()
//Updates strings and icon appropriately based on seed datum.
@@ -76,7 +76,7 @@ GLOBAL_LIST_BOILERPLATE(all_seed_packs, /obj/item/seeds)
seed_type = null
/obj/item/seeds/random/Initialize()
seed = plant_controller.create_random_seed()
seed = SSplants.create_random_seed()
seed_type = seed.name
. = ..()
+130 -236
View File
@@ -211,23 +211,15 @@
if(lockdown)
return
user.set_machine(src)
interact(user)
tgui_interact(user)
/obj/machinery/seed_storage/interact(mob/user as mob)
if (..())
return
if(smart)
scanner = list("stats", "produce", "soil", "temperature", "light", "pressure")
else
scanner = initial(scanner)
if (!seeds_initialized)
/obj/machinery/seed_storage/tgui_interact(mob/user, datum/tgui/ui)
if(!seeds_initialized)
for(var/typepath in starting_seeds)
var/amount = starting_seeds[typepath]
if(isnull(amount)) amount = 1
for (var/i = 1 to amount)
for(var/i = 1 to amount)
var/O = new typepath
add(O)
for(var/typepath in contraband_seeds)
@@ -239,251 +231,153 @@
add(O, 1)
seeds_initialized = 1
var/dat = "<center><h1>Seed storage contents</h1></center>"
if (piles.len == 0)
dat += "<font color='red'>No seeds</font>"
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "SeedStorage", name)
ui.open()
/obj/machinery/seed_storage/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
var/list/data = ..()
if(smart)
scanner = list("stats", "produce", "soil", "temperature", "light", "pressure")
else
dat += "<table style='text-align:center;border-style:solid;border-width:1px;padding:4px'><tr><td>Name</td>"
dat += "<td>Variety</td>"
if ("stats" in scanner)
dat += "<td>E</td><td>Y</td><td>M</td><td>Pr</td><td>Pt</td><td>Harvest</td>"
scanner = initial(scanner)
data["scanner"] = scanner
var/list/piles_to_check = piles
if(hacked || emagged)
piles_to_check = piles + piles_contra
var/list/seeds = list()
for(var/datum/seed_pile/S in piles_to_check)
var/datum/seed/seed = S.seed_type
if(!seed)
continue
var/list/seedinfo = list(
"name" = seed.seed_name,
"uid" = seed.uid,
"amount" = S.amount,
"id" = S.ID,
)
seedinfo["traits"] = list()
if("stats" in scanner)
seedinfo["traits"]["Endurance"] = seed.get_trait(TRAIT_ENDURANCE)
seedinfo["traits"]["Yield"] = seed.get_trait(TRAIT_YIELD)
seedinfo["traits"]["Production"] = seed.get_trait(TRAIT_PRODUCTION)
seedinfo["traits"]["Potency"] = seed.get_trait(TRAIT_POTENCY)
seedinfo["traits"]["Repeat Harvest"] = seed.get_trait(TRAIT_HARVEST_REPEAT)
if("temperature" in scanner)
seedinfo["traits"]["Ideal Heat"] = seed.get_trait(TRAIT_IDEAL_HEAT)
if("light" in scanner)
seedinfo["traits"]["Ideal Light"] = seed.get_trait(TRAIT_IDEAL_LIGHT)
if("soil" in scanner)
if(seed.get_trait(TRAIT_REQUIRES_NUTRIENTS))
if(seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) < 0.05)
seedinfo["traits"]["Nutrient Consumption"] = "Low"
else if(seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) > 0.2)
seedinfo["traits"]["Nutrient Consumption"] = "High"
else
seedinfo["traits"]["Nutrient Consumption"] = "Norm"
else
seedinfo["traits"]["Nutrient Consumption"] = "No"
if(seed.get_trait(TRAIT_REQUIRES_WATER))
if(seed.get_trait(TRAIT_WATER_CONSUMPTION) < 1)
seedinfo["traits"]["Water Consumption"] = "Low"
else if(seed.get_trait(TRAIT_WATER_CONSUMPTION) > 5)
seedinfo["traits"]["Water Consumption"] = "High"
else
seedinfo["traits"]["Water Consumption"] = "Norm"
else
seedinfo["traits"]["Water Consumption"] = "No"
seedinfo["traits"]["notes"] = ""
switch(seed.get_trait(TRAIT_CARNIVOROUS))
if(1)
seedinfo["traits"]["notes"] += "CARN "
if(2)
seedinfo["traits"]["notes"] += "FASTCARN"
switch(seed.get_trait(TRAIT_SPREAD))
if(1)
seedinfo["traits"]["notes"] += "VINE "
if(2)
seedinfo["traits"]["notes"] += "FASTVINE"
if ("pressure" in scanner)
if(seed.get_trait(TRAIT_LOWKPA_TOLERANCE) < 20)
seedinfo["traits"]["notes"] += "LP "
if(seed.get_trait(TRAIT_HIGHKPA_TOLERANCE) > 220)
seedinfo["traits"]["notes"] += "HP "
if ("temperature" in scanner)
dat += "<td>Temp</td>"
if(seed.get_trait(TRAIT_HEAT_TOLERANCE) > 30)
seedinfo["traits"]["notes"] += "TEMRES "
else if(seed.get_trait(TRAIT_HEAT_TOLERANCE) < 10)
seedinfo["traits"]["notes"] += "TEMSEN "
if ("light" in scanner)
dat += "<td>Light</td>"
if ("soil" in scanner)
dat += "<td>Nutri</td><td>Water</td>"
dat += "<td>Notes</td><td>Amount</td><td></td></tr>"
for (var/datum/seed_pile/S in piles)
var/datum/seed/seed = S.seed_type
if(!seed)
continue
dat += "<tr>"
dat += "<td>[seed.seed_name]</td>"
dat += "<td>#[seed.uid]</td>"
if ("stats" in scanner)
dat += "<td>[seed.get_trait(TRAIT_ENDURANCE)]</td><td>[seed.get_trait(TRAIT_YIELD)]</td><td>[seed.get_trait(TRAIT_MATURATION)]</td><td>[seed.get_trait(TRAIT_PRODUCTION)]</td><td>[seed.get_trait(TRAIT_POTENCY)]</td>"
if(seed.get_trait(TRAIT_HARVEST_REPEAT))
dat += "<td>Multiple</td>"
else
dat += "<td>Single</td>"
if ("temperature" in scanner)
dat += "<td>[seed.get_trait(TRAIT_IDEAL_HEAT)] K</td>"
if ("light" in scanner)
dat += "<td>[seed.get_trait(TRAIT_IDEAL_LIGHT)] L</td>"
if ("soil" in scanner)
if(seed.get_trait(TRAIT_REQUIRES_NUTRIENTS))
if(seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) < 0.05)
dat += "<td>Low</td>"
else if(seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) > 0.2)
dat += "<td>High</td>"
else
dat += "<td>Norm</td>"
else
dat += "<td>No</td>"
if(seed.get_trait(TRAIT_REQUIRES_WATER))
if(seed.get_trait(TRAIT_WATER_CONSUMPTION) < 1)
dat += "<td>Low</td>"
else if(seed.get_trait(TRAIT_WATER_CONSUMPTION) > 5)
dat += "<td>High</td>"
else
dat += "<td>Norm</td>"
else
dat += "<td>No</td>"
if(seed.get_trait(TRAIT_LIGHT_TOLERANCE) > 10)
seedinfo["traits"]["notes"] += "LIGRES "
else if(seed.get_trait(TRAIT_LIGHT_TOLERANCE) < 3)
seedinfo["traits"]["notes"] += "LIGSEN "
if(seed.get_trait(TRAIT_TOXINS_TOLERANCE) < 3)
seedinfo["traits"]["notes"] += "TOXSEN "
else if(seed.get_trait(TRAIT_TOXINS_TOLERANCE) > 6)
seedinfo["traits"]["notes"] += "TOXRES "
if(seed.get_trait(TRAIT_PEST_TOLERANCE) < 3)
seedinfo["traits"]["notes"] += "PESTSEN "
else if(seed.get_trait(TRAIT_PEST_TOLERANCE) > 6)
seedinfo["traits"]["notes"] += "PESTRES "
if(seed.get_trait(TRAIT_WEED_TOLERANCE) < 3)
seedinfo["traits"]["notes"] += "WEEDSEN "
else if(seed.get_trait(TRAIT_WEED_TOLERANCE) > 6)
seedinfo["traits"]["notes"] += "WEEDRES "
if(seed.get_trait(TRAIT_PARASITE))
seedinfo["traits"]["notes"] += "PAR "
if ("temperature" in scanner)
if(seed.get_trait(TRAIT_ALTER_TEMP) > 0)
seedinfo["traits"]["notes"] += "TEMP+ "
if(seed.get_trait(TRAIT_ALTER_TEMP) < 0)
seedinfo["traits"]["notes"] += "TEMP- "
if(seed.get_trait(TRAIT_BIOLUM))
seedinfo["traits"]["notes"] += "LUM "
dat += "<td>"
switch(seed.get_trait(TRAIT_CARNIVOROUS))
if(1)
dat += "CARN "
if(2)
dat += "<font color='red'>CARN </font>"
switch(seed.get_trait(TRAIT_SPREAD))
if(1)
dat += "VINE "
if(2)
dat += "<font color='red'>VINE </font>"
if ("pressure" in scanner)
if(seed.get_trait(TRAIT_LOWKPA_TOLERANCE) < 20)
dat += "LP "
if(seed.get_trait(TRAIT_HIGHKPA_TOLERANCE) > 220)
dat += "HP "
if ("temperature" in scanner)
if(seed.get_trait(TRAIT_HEAT_TOLERANCE) > 30)
dat += "TEMRES "
else if(seed.get_trait(TRAIT_HEAT_TOLERANCE) < 10)
dat += "TEMSEN "
if ("light" in scanner)
if(seed.get_trait(TRAIT_LIGHT_TOLERANCE) > 10)
dat += "LIGRES "
else if(seed.get_trait(TRAIT_LIGHT_TOLERANCE) < 3)
dat += "LIGSEN "
if(seed.get_trait(TRAIT_TOXINS_TOLERANCE) < 3)
dat += "TOXSEN "
else if(seed.get_trait(TRAIT_TOXINS_TOLERANCE) > 6)
dat += "TOXRES "
if(seed.get_trait(TRAIT_PEST_TOLERANCE) < 3)
dat += "PESTSEN "
else if(seed.get_trait(TRAIT_PEST_TOLERANCE) > 6)
dat += "PESTRES "
if(seed.get_trait(TRAIT_WEED_TOLERANCE) < 3)
dat += "WEEDSEN "
else if(seed.get_trait(TRAIT_WEED_TOLERANCE) > 6)
dat += "WEEDRES "
if(seed.get_trait(TRAIT_PARASITE))
dat += "PAR "
if ("temperature" in scanner)
if(seed.get_trait(TRAIT_ALTER_TEMP) > 0)
dat += "TEMP+ "
if(seed.get_trait(TRAIT_ALTER_TEMP) < 0)
dat += "TEMP- "
if(seed.get_trait(TRAIT_BIOLUM))
dat += "LUM "
dat += "</td>"
dat += "<td>[S.amount]</td>"
dat += "<td><a href='byond://?src=\ref[src];task=vend;id=[S.ID]'>Vend</a> <a href='byond://?src=\ref[src];task=purge;id=[S.ID]'>Purge</a></td>"
dat += "</tr>"
if(hacked || emagged)
for (var/datum/seed_pile/S in piles_contra)
var/datum/seed/seed = S.seed_type
if(!seed)
continue
dat += "<tr>"
dat += "<td>[seed.seed_name]</td>"
dat += "<td>#[seed.uid]</td>"
if ("stats" in scanner)
dat += "<td>[seed.get_trait(TRAIT_ENDURANCE)]</td><td>[seed.get_trait(TRAIT_YIELD)]</td><td>[seed.get_trait(TRAIT_MATURATION)]</td><td>[seed.get_trait(TRAIT_PRODUCTION)]</td><td>[seed.get_trait(TRAIT_POTENCY)]</td>"
if(seed.get_trait(TRAIT_HARVEST_REPEAT))
dat += "<td>Multiple</td>"
else
dat += "<td>Single</td>"
if ("temperature" in scanner)
dat += "<td>[seed.get_trait(TRAIT_IDEAL_HEAT)] K</td>"
if ("light" in scanner)
dat += "<td>[seed.get_trait(TRAIT_IDEAL_LIGHT)] L</td>"
if ("soil" in scanner)
if(seed.get_trait(TRAIT_REQUIRES_NUTRIENTS))
if(seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) < 0.05)
dat += "<td>Low</td>"
else if(seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) > 0.2)
dat += "<td>High</td>"
else
dat += "<td>Norm</td>"
else
dat += "<td>No</td>"
if(seed.get_trait(TRAIT_REQUIRES_WATER))
if(seed.get_trait(TRAIT_WATER_CONSUMPTION) < 1)
dat += "<td>Low</td>"
else if(seed.get_trait(TRAIT_WATER_CONSUMPTION) > 5)
dat += "<td>High</td>"
else
dat += "<td>Norm</td>"
else
dat += "<td>No</td>"
seeds.Add(list(seedinfo))
dat += "<td>"
switch(seed.get_trait(TRAIT_CARNIVOROUS))
if(1)
dat += "CARN "
if(2)
dat += "<font color='red'>CARN </font>"
switch(seed.get_trait(TRAIT_SPREAD))
if(1)
dat += "VINE "
if(2)
dat += "<font color='red'>VINE </font>"
if ("pressure" in scanner)
if(seed.get_trait(TRAIT_LOWKPA_TOLERANCE) < 20)
dat += "LP "
if(seed.get_trait(TRAIT_HIGHKPA_TOLERANCE) > 220)
dat += "HP "
if ("temperature" in scanner)
if(seed.get_trait(TRAIT_HEAT_TOLERANCE) > 30)
dat += "TEMRES "
else if(seed.get_trait(TRAIT_HEAT_TOLERANCE) < 10)
dat += "TEMSEN "
if ("light" in scanner)
if(seed.get_trait(TRAIT_LIGHT_TOLERANCE) > 10)
dat += "LIGRES "
else if(seed.get_trait(TRAIT_LIGHT_TOLERANCE) < 3)
dat += "LIGSEN "
if(seed.get_trait(TRAIT_TOXINS_TOLERANCE) < 3)
dat += "TOXSEN "
else if(seed.get_trait(TRAIT_TOXINS_TOLERANCE) > 6)
dat += "TOXRES "
if(seed.get_trait(TRAIT_PEST_TOLERANCE) < 3)
dat += "PESTSEN "
else if(seed.get_trait(TRAIT_PEST_TOLERANCE) > 6)
dat += "PESTRES "
if(seed.get_trait(TRAIT_WEED_TOLERANCE) < 3)
dat += "WEEDSEN "
else if(seed.get_trait(TRAIT_WEED_TOLERANCE) > 6)
dat += "WEEDRES "
if(seed.get_trait(TRAIT_PARASITE))
dat += "PAR "
if ("temperature" in scanner)
if(seed.get_trait(TRAIT_ALTER_TEMP) > 0)
dat += "TEMP+ "
if(seed.get_trait(TRAIT_ALTER_TEMP) < 0)
dat += "TEMP- "
if(seed.get_trait(TRAIT_BIOLUM))
dat += "LUM "
dat += "</td>"
dat += "<td>[S.amount]</td>"
dat += "<td><a href='byond://?src=\ref[src];task=vend;id=[S.ID]'>Vend</a> <a href='byond://?src=\ref[src];task=purge;id=[S.ID]'>Purge</a></td>"
dat += "</tr>"
dat += "</table>"
data["seeds"] = seeds
user << browse(dat, "window=seedstorage")
onclose(user, "seedstorage")
return data
/obj/machinery/seed_storage/Topic(var/href, var/list/href_list)
if (..())
return
var/task = href_list["task"]
var/ID = text2num(href_list["id"])
/obj/machinery/seed_storage/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return TRUE
var/ID = text2num(params["id"])
for (var/datum/seed_pile/N in piles)
if (N.ID == ID)
if (task == "vend")
var/list/piles_to_check = piles
if(hacked || emagged)
piles_to_check = piles + piles_contra
for(var/datum/seed_pile/N in piles_to_check)
if(N.ID == ID)
if(action == "vend")
var/obj/O = pick(N.seeds)
if (O)
if(O)
--N.amount
N.seeds -= O
if (N.amount <= 0 || N.seeds.len <= 0)
if(N.amount <= 0 || N.seeds.len <= 0)
piles -= N
qdel(N)
O.loc = src.loc
else
piles -= N
qdel(N)
else if (task == "purge")
for (var/obj/O in N.seeds)
return TRUE
else if(action == "purge")
for(var/obj/O in N.seeds)
qdel(O)
piles -= N
qdel(N)
return TRUE
break
if(hacked || emagged)
for (var/datum/seed_pile/N in piles_contra)
if (N.ID == ID)
if (task == "vend")
var/obj/O = pick(N.seeds)
if (O)
--N.amount
N.seeds -= O
if (N.amount <= 0 || N.seeds.len <= 0)
piles_contra -= N
qdel(N)
O.loc = src.loc
else
piles_contra -= N
qdel(N)
else if (task == "purge")
for (var/obj/O in N.seeds)
qdel(O)
piles_contra -= N
qdel(N)
break
updateUsrDialog()
/obj/machinery/seed_storage/attackby(var/obj/item/O as obj, var/mob/user as mob)
if (istype(O, /obj/item/seeds) && !lockdown)
@@ -12,7 +12,7 @@
if(turfs.len) //Pick a turf to spawn at if we can
var/turf/simulated/floor/T = pick(turfs)
var/datum/seed/seed = plant_controller.create_random_seed(1)
var/datum/seed/seed = SSplants.create_random_seed(1)
seed.set_trait(TRAIT_SPREAD,2) // So it will function properly as vines.
seed.set_trait(TRAIT_POTENCY,rand(potency_min, potency_max)) // 70-100 potency will help guarantee a wide spread and powerful effects.
seed.set_trait(TRAIT_MATURATION,rand(maturation_min, maturation_max))
@@ -74,9 +74,9 @@
/obj/effect/plant/Destroy()
if(seed.get_trait(TRAIT_SPREAD)==2)
unsense_proximity(callback = .HasProximity, center = get_turf(src))
plant_controller.remove_plant(src)
SSplants.remove_plant(src)
for(var/obj/effect/plant/neighbor in range(1,src))
plant_controller.add_plant(neighbor)
SSplants.add_plant(neighbor)
return ..()
/obj/effect/plant/single
@@ -90,15 +90,15 @@
else
parent = newparent
if(!plant_controller)
if(!SSplants)
sleep(250) // ugly hack, should mean roundstart plants are fine. TODO initialize perhaps?
if(!plant_controller)
if(!SSplants)
to_world("<span class='danger'>Plant controller does not exist and [src] requires it. Aborting.</span>")
qdel(src)
return
if(!istype(newseed))
newseed = plant_controller.seeds[DEFAULT_SEED]
newseed = SSplants.seeds[DEFAULT_SEED]
seed = newseed
if(!seed)
qdel(src)
@@ -135,7 +135,7 @@
/obj/effect/plant/proc/finish_spreading()
set_dir(calc_dir())
update_icon()
plant_controller.add_plant(src)
SSplants.add_plant(src)
//Some plants eat through plating.
if(islist(seed.chems) && !isnull(seed.chems["pacid"]))
var/turf/T = get_turf(src)
@@ -240,7 +240,7 @@
/obj/effect/plant/attackby(var/obj/item/weapon/W, var/mob/user)
user.setClickCooldown(user.get_attack_speed(W))
plant_controller.add_plant(src)
SSplants.add_plant(src)
if(W.is_wirecutter() || istype(W, /obj/item/weapon/surgical/scalpel))
if(sampled)
@@ -33,7 +33,7 @@
neighbors |= floor
if(neighbors.len)
plant_controller.add_plant(src) //if we have neighbours again, start processing
SSplants.add_plant(src) //if we have neighbours again, start processing
// Update all of our friends.
var/turf/T = get_turf(src)
@@ -110,7 +110,7 @@
// We shouldn't have spawned if the controller doesn't exist.
check_health()
if(has_buckled_mobs() || neighbors.len)
plant_controller.add_plant(src)
SSplants.add_plant(src)
//spreading vines aren't created on their final turf.
//Instead, they are created at their parent and then move to their destination.
@@ -160,7 +160,7 @@
continue
for(var/obj/effect/plant/neighbor in check_turf.contents)
neighbor.neighbors |= check_turf
plant_controller.add_plant(neighbor)
SSplants.add_plant(neighbor)
spawn(1) if(src) qdel(src)
#undef NEIGHBOR_REFRESH_TIME
+4 -4
View File
@@ -366,7 +366,7 @@
//Remove the seed if something is already planted.
if(seed) seed = null
seed = plant_controller.seeds[pick(list("reishi","nettle","amanita","mushrooms","plumphelmet","towercap","harebells","weeds"))]
seed = SSplants.seeds[pick(list("reishi","nettle","amanita","mushrooms","plumphelmet","towercap","harebells","weeds"))]
if(!seed) return //Weed does not exist, someone fucked up.
dead = 0
@@ -396,7 +396,7 @@
// We need to make sure we're not modifying one of the global seed datums.
// If it's not in the global list, then no products of the line have been
// harvested yet and it's safe to assume it's restricted to this tray.
if(!isnull(plant_controller.seeds[seed.name]))
if(!isnull(SSplants.seeds[seed.name]))
seed = seed.diverge()
seed.mutate(severity,get_turf(src))
@@ -452,8 +452,8 @@
var/previous_plant = seed.display_name
var/newseed = seed.get_mutant_variant()
if(newseed in plant_controller.seeds)
seed = plant_controller.seeds[newseed]
if(newseed in SSplants.seeds)
seed = SSplants.seeds[newseed]
else
return
+177 -125
View File
@@ -16,42 +16,50 @@
icon = 'icons/obj/device.dmi'
icon_state = "hydro"
item_state = "analyzer"
var/form_title
var/last_data
var/datum/seed/last_seed
var/list/last_reagents
/obj/item/device/analyzer/plant_analyzer/proc/print_report_verb()
set name = "Print Plant Report"
set category = "Object"
set src = usr
/obj/item/device/analyzer/plant_analyzer/attack_self(mob/user)
tgui_interact(user)
if(usr.stat || usr.restrained() || usr.lying)
return
print_report(usr)
/obj/item/device/analyzer/plant_analyzer/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "PlantAnalyzer", name)
ui.open()
/obj/item/device/analyzer/plant_analyzer/tgui_state(mob/user)
return GLOB.tgui_inventory_state
/obj/item/device/analyzer/plant_analyzer/Topic(href, href_list)
/obj/item/device/analyzer/plant_analyzer/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
var/list/data = ..()
var/datum/seed/grown_seed = locate(last_seed)
if(!istype(grown_seed))
return list("no_seed" = TRUE)
data["no_seed"] = FALSE
data["seed"] = grown_seed.get_tgui_analyzer_data(user)
data["reagents"] = last_reagents
return data
/obj/item/device/analyzer/plant_analyzer/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return
if(href_list["print"])
print_report(usr)
/obj/item/device/analyzer/plant_analyzer/proc/print_report(var/mob/living/user)
if(!last_data)
to_chat(user, "There is no scan data to print.")
return
var/obj/item/weapon/paper/P = new /obj/item/weapon/paper(get_turf(src))
P.name = "paper - [form_title]"
P.info = "[last_data]"
if(istype(user,/mob/living/carbon/human))
user.put_in_hands(P)
user.visible_message("\The [src] spits out a piece of paper.")
return
/obj/item/device/analyzer/plant_analyzer/attack_self(mob/user as mob)
print_report(user)
return 0
return TRUE
switch(action)
if("print")
print_report(usr)
return TRUE
if("close")
last_seed = null
last_reagents = null
return TRUE
/obj/item/device/analyzer/plant_analyzer/afterattack(obj/target, mob/user, flag)
if(!flag) return
if(!flag)
return
var/datum/seed/grown_seed
var/datum/reagents/grown_reagents
@@ -60,13 +68,13 @@
else if(istype(target,/obj/item/weapon/reagent_containers/food/snacks/grown))
var/obj/item/weapon/reagent_containers/food/snacks/grown/G = target
grown_seed = plant_controller.seeds[G.plantname]
grown_seed = SSplants.seeds[G.plantname]
grown_reagents = G.reagents
else if(istype(target,/obj/item/weapon/grown))
var/obj/item/weapon/grown/G = target
grown_seed = plant_controller.seeds[G.plantname]
grown_seed = SSplants.seeds[G.plantname]
grown_reagents = G.reagents
else if(istype(target,/obj/item/seeds))
@@ -87,12 +95,38 @@
to_chat(user, "<span class='danger'>[src] can tell you nothing about \the [target].</span>")
return
form_title = "[grown_seed.seed_name] (#[grown_seed.uid])"
var/dat = "<h3>Plant data for [form_title]</h3>"
last_seed = REF(grown_seed)
user.visible_message("<span class='notice'>[user] runs the scanner over \the [target].</span>")
dat += "<h2>General Data</h2>"
last_reagents = list()
if(grown_reagents && grown_reagents.reagent_list && grown_reagents.reagent_list.len)
for(var/datum/reagent/R in grown_reagents.reagent_list)
last_reagents.Add(list(list(
"name" = R.name,
"volume" = grown_reagents.get_reagent_amount(R.id),
)))
tgui_interact(user)
/obj/item/device/analyzer/plant_analyzer/proc/print_report_verb()
set name = "Print Plant Report"
set category = "Object"
set src = usr
if(usr.stat || usr.restrained() || usr.lying)
return
print_report(usr)
/obj/item/device/analyzer/plant_analyzer/proc/print_report(var/mob/living/user)
var/datum/seed/grown_seed = locate(last_seed)
if(!istype(grown_seed))
to_chat(user, "<span class='warning'>There is no scan data to print.</span>")
return
var/form_title = "[grown_seed.seed_name] (#[grown_seed.uid])"
var/dat = "<h3>Plant data for [form_title]</h3>"
dat += "<h2>General Data</h2>"
dat += "<table>"
dat += "<tr><td><b>Endurance</b></td><td>[grown_seed.get_trait(TRAIT_ENDURANCE)]</td></tr>"
dat += "<tr><td><b>Yield</b></td><td>[grown_seed.get_trait(TRAIT_YIELD)]</td></tr>"
@@ -101,138 +135,156 @@
dat += "<tr><td><b>Potency</b></td><td>[grown_seed.get_trait(TRAIT_POTENCY)]</td></tr>"
dat += "</table>"
if(grown_reagents && grown_reagents.reagent_list && grown_reagents.reagent_list.len)
if(LAZYLEN(last_reagents))
dat += "<h2>Reagent Data</h2>"
dat += "<br>This sample contains: "
for(var/datum/reagent/R in grown_reagents.reagent_list)
dat += "<br>- [R.name], [grown_reagents.get_reagent_amount(R.id)] unit(s)"
for(var/i in 1 to LAZYLEN(last_reagents))
dat += "<br>- [last_reagents[i]["name"]], [last_reagents[i]["volume"]] unit(s)"
dat += "<h2>Other Data</h2>"
if(grown_seed.get_trait(TRAIT_HARVEST_REPEAT))
dat += "This plant can be harvested repeatedly.<br>"
var/list/tgui_data = grown_seed.get_tgui_analyzer_data()
if(grown_seed.get_trait(TRAIT_IMMUTABLE) == -1)
dat += "This plant is highly mutable.<br>"
else if(grown_seed.get_trait(TRAIT_IMMUTABLE) > 0)
dat += "This plant does not possess genetics that are alterable.<br>"
dat += jointext(tgui_data["trait_info"], "<br>\n")
if(grown_seed.get_trait(TRAIT_REQUIRES_NUTRIENTS))
if(grown_seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) < 0.05)
dat += "It consumes a small amount of nutrient fluid.<br>"
else if(grown_seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) > 0.2)
dat += "It requires a heavy supply of nutrient fluid.<br>"
var/obj/item/weapon/paper/P = new /obj/item/weapon/paper(get_turf(src))
P.name = "paper - [form_title]"
P.info = "[dat]"
if(istype(user,/mob/living/carbon/human))
user.put_in_hands(P)
user.visible_message("\The [src] spits out a piece of paper.")
return
/datum/seed/proc/get_tgui_analyzer_data(mob/user)
var/list/data = list()
data["name"] = seed_name
data["uid"] = uid
data["endurance"] = get_trait(TRAIT_ENDURANCE)
data["yield"] = get_trait(TRAIT_YIELD)
data["maturation_time"] = get_trait(TRAIT_MATURATION)
data["production_time"] = get_trait(TRAIT_PRODUCTION)
data["potency"] = get_trait(TRAIT_POTENCY)
data["trait_info"] = list()
if(get_trait(TRAIT_HARVEST_REPEAT))
data["trait_info"] += "This plant can be harvested repeatedly."
if(get_trait(TRAIT_IMMUTABLE) == -1)
data["trait_info"] += "This plant is highly mutable."
else if(get_trait(TRAIT_IMMUTABLE) > 0)
data["trait_info"] += "This plant does not possess genetics that are alterable."
if(get_trait(TRAIT_REQUIRES_NUTRIENTS))
if(get_trait(TRAIT_NUTRIENT_CONSUMPTION) < 0.05)
data["trait_info"] += "It consumes a small amount of nutrient fluid."
else if(get_trait(TRAIT_NUTRIENT_CONSUMPTION) > 0.2)
data["trait_info"] += "It requires a heavy supply of nutrient fluid."
else
dat += "It requires a supply of nutrient fluid.<br>"
data["trait_info"] += "It requires a supply of nutrient fluid."
if(grown_seed.get_trait(TRAIT_REQUIRES_WATER))
if(grown_seed.get_trait(TRAIT_WATER_CONSUMPTION) < 1)
dat += "It requires very little water.<br>"
else if(grown_seed.get_trait(TRAIT_WATER_CONSUMPTION) > 5)
dat += "It requires a large amount of water.<br>"
if(get_trait(TRAIT_REQUIRES_WATER))
if(get_trait(TRAIT_WATER_CONSUMPTION) < 1)
data["trait_info"] += "It requires very little water."
else if(get_trait(TRAIT_WATER_CONSUMPTION) > 5)
data["trait_info"] += "It requires a large amount of water."
else
dat += "It requires a stable supply of water.<br>"
data["trait_info"] += "It requires a stable supply of water."
if(grown_seed.mutants && grown_seed.mutants.len)
dat += "It exhibits a high degree of potential subspecies shift.<br>"
if(mutants && mutants.len)
data["trait_info"] += "It exhibits a high degree of potential subspecies shift."
dat += "It thrives in a temperature of [grown_seed.get_trait(TRAIT_IDEAL_HEAT)] Kelvin."
data["trait_info"] += "It thrives in a temperature of [get_trait(TRAIT_IDEAL_HEAT)] Kelvin."
if(grown_seed.get_trait(TRAIT_LOWKPA_TOLERANCE) < 20)
dat += "<br>It is well adapted to low pressure levels."
if(grown_seed.get_trait(TRAIT_HIGHKPA_TOLERANCE) > 220)
dat += "<br>It is well adapted to high pressure levels."
if(get_trait(TRAIT_LOWKPA_TOLERANCE) < 20)
data["trait_info"] += "It is well adapted to low pressure levels."
if(get_trait(TRAIT_HIGHKPA_TOLERANCE) > 220)
data["trait_info"] += "It is well adapted to high pressure levels."
if(grown_seed.get_trait(TRAIT_HEAT_TOLERANCE) > 30)
dat += "<br>It is well adapted to a range of temperatures."
else if(grown_seed.get_trait(TRAIT_HEAT_TOLERANCE) < 10)
dat += "<br>It is very sensitive to temperature shifts."
if(get_trait(TRAIT_HEAT_TOLERANCE) > 30)
data["trait_info"] += "It is well adapted to a range of temperatures."
else if(get_trait(TRAIT_HEAT_TOLERANCE) < 10)
data["trait_info"] += "It is very sensitive to temperature shifts."
dat += "<br>It thrives in a light level of [grown_seed.get_trait(TRAIT_IDEAL_LIGHT)] lumen[grown_seed.get_trait(TRAIT_IDEAL_LIGHT) == 1 ? "" : "s"]."
data["trait_info"] += "It thrives in a light level of [get_trait(TRAIT_IDEAL_LIGHT)] lumen[get_trait(TRAIT_IDEAL_LIGHT) == 1 ? "" : "s"]."
if(grown_seed.get_trait(TRAIT_LIGHT_TOLERANCE) > 10)
dat += "<br>It is well adapted to a range of light levels."
else if(grown_seed.get_trait(TRAIT_LIGHT_TOLERANCE) < 3)
dat += "<br>It is very sensitive to light level shifts."
if(get_trait(TRAIT_LIGHT_TOLERANCE) > 10)
data["trait_info"] += "It is well adapted to a range of light levels."
else if(get_trait(TRAIT_LIGHT_TOLERANCE) < 3)
data["trait_info"] += "It is very sensitive to light level shifts."
if(grown_seed.get_trait(TRAIT_TOXINS_TOLERANCE) < 3)
dat += "<br>It is highly sensitive to toxins."
else if(grown_seed.get_trait(TRAIT_TOXINS_TOLERANCE) > 6)
dat += "<br>It is remarkably resistant to toxins."
if(get_trait(TRAIT_TOXINS_TOLERANCE) < 3)
data["trait_info"] += "It is highly sensitive to toxins."
else if(get_trait(TRAIT_TOXINS_TOLERANCE) > 6)
data["trait_info"] += "It is remarkably resistant to toxins."
if(grown_seed.get_trait(TRAIT_PEST_TOLERANCE) < 3)
dat += "<br>It is highly sensitive to pests."
else if(grown_seed.get_trait(TRAIT_PEST_TOLERANCE) > 6)
dat += "<br>It is remarkably resistant to pests."
if(get_trait(TRAIT_PEST_TOLERANCE) < 3)
data["trait_info"] += "It is highly sensitive to pests."
else if(get_trait(TRAIT_PEST_TOLERANCE) > 6)
data["trait_info"] += "It is remarkably resistant to pests."
if(grown_seed.get_trait(TRAIT_WEED_TOLERANCE) < 3)
dat += "<br>It is highly sensitive to weeds."
else if(grown_seed.get_trait(TRAIT_WEED_TOLERANCE) > 6)
dat += "<br>It is remarkably resistant to weeds."
if(get_trait(TRAIT_WEED_TOLERANCE) < 3)
data["trait_info"] += "It is highly sensitive to weeds."
else if(get_trait(TRAIT_WEED_TOLERANCE) > 6)
data["trait_info"] += "It is remarkably resistant to weeds."
switch(grown_seed.get_trait(TRAIT_SPREAD))
switch(get_trait(TRAIT_SPREAD))
if(1)
dat += "<br>It is able to be planted outside of a tray."
data["trait_info"] += "It is able to be planted outside of a tray."
if(2)
dat += "<br>It is a robust and vigorous vine that will spread rapidly."
data["trait_info"] += "It is a robust and vigorous vine that will spread rapidly."
switch(grown_seed.get_trait(TRAIT_CARNIVOROUS))
switch(get_trait(TRAIT_CARNIVOROUS))
if(1)
dat += "<br>It is carnivorous and will eat tray pests for sustenance."
data["trait_info"] += "It is carnivorous and will eat tray pests for sustenance."
if(2)
dat += "<br>It is carnivorous and poses a significant threat to living things around it."
data["trait_info"] += "It is carnivorous and poses a significant threat to living things around it."
if(grown_seed.get_trait(TRAIT_PARASITE))
dat += "<br>It is capable of parisitizing and gaining sustenance from tray weeds."
if(get_trait(TRAIT_PARASITE))
data["trait_info"] += "It is capable of parisitizing and gaining sustenance from tray weeds."
/*
There's currently no code that actually changes the temperature of the local environment, so let's not show it until there is.
if(grown_seed.get_trait(TRAIT_ALTER_TEMP))
dat += "<br>It will periodically alter the local temperature by [grown_seed.get_trait(TRAIT_ALTER_TEMP)] degrees Kelvin."
if(get_trait(TRAIT_ALTER_TEMP))
data["trait_info"] += "It will periodically alter the local temperature by [get_trait(TRAIT_ALTER_TEMP)] degrees Kelvin."
*/
if(grown_seed.get_trait(TRAIT_BIOLUM))
dat += "<br>It is [grown_seed.get_trait(TRAIT_BIOLUM_COLOUR) ? "<font color='[grown_seed.get_trait(TRAIT_BIOLUM_COLOUR)]'>bio-luminescent</font>" : "bio-luminescent"]."
if(get_trait(TRAIT_BIOLUM))
data["trait_info"] += "It is [get_trait(TRAIT_BIOLUM_COLOUR) ? "<font color='[get_trait(TRAIT_BIOLUM_COLOUR)]'>bio-luminescent</font>" : "bio-luminescent"]."
if(grown_seed.get_trait(TRAIT_PRODUCES_POWER))
dat += "<br>The fruit will function as a battery if prepared appropriately."
if(get_trait(TRAIT_PRODUCES_POWER))
data["trait_info"] += "The fruit will function as a battery if prepared appropriately."
if(grown_seed.get_trait(TRAIT_STINGS))
dat += "<br>The fruit is covered in stinging spines."
if(get_trait(TRAIT_STINGS))
data["trait_info"] += "The fruit is covered in stinging spines."
if(grown_seed.get_trait(TRAIT_JUICY) == 1)
dat += "<br>The fruit is soft-skinned and juicy."
else if(grown_seed.get_trait(TRAIT_JUICY) == 2)
dat += "<br>The fruit is excessively juicy."
if(get_trait(TRAIT_JUICY) == 1)
data["trait_info"] += "The fruit is soft-skinned and juicy."
else if(get_trait(TRAIT_JUICY) == 2)
data["trait_info"] += "The fruit is excessively juicy."
if(grown_seed.get_trait(TRAIT_EXPLOSIVE))
dat += "<br>The fruit is internally unstable."
if(get_trait(TRAIT_EXPLOSIVE))
data["trait_info"] += "The fruit is internally unstable."
if(grown_seed.get_trait(TRAIT_TELEPORTING))
dat += "<br>The fruit is temporal/spatially unstable."
if(get_trait(TRAIT_TELEPORTING))
data["trait_info"] += "The fruit is temporal/spatially unstable."
if(grown_seed.exude_gasses && grown_seed.exude_gasses.len)
for(var/gas in grown_seed.exude_gasses)
if(exude_gasses && exude_gasses.len)
for(var/gas in exude_gasses)
var/amount = ""
if (grown_seed.exude_gasses[gas] > 7)
if (exude_gasses[gas] > 7)
amount = "large amounts of "
else if (grown_seed.exude_gasses[gas] < 5)
else if (exude_gasses[gas] < 5)
amount = "small amounts of "
dat += "<br>It will release [amount][gas_data.name[gas]] into the environment."
data["trait_info"] += "It will release [amount][gas_data.name[gas]] into the environment."
if(grown_seed.consume_gasses && grown_seed.consume_gasses.len)
for(var/gas in grown_seed.consume_gasses)
if(consume_gasses && consume_gasses.len)
for(var/gas in consume_gasses)
var/amount = ""
if (grown_seed.consume_gasses[gas] > 7)
if (consume_gasses[gas] > 7)
amount = "large amounts of "
else if (grown_seed.consume_gasses[gas] < 5)
else if (consume_gasses[gas] < 5)
amount = "small amounts of "
dat += "<br>It will consume [amount][gas_data.name[gas]] from the environment."
data["trait_info"] += "It will consume [amount][gas_data.name[gas]] from the environment."
if(dat)
last_data = dat
dat += "<br><br>\[<a href='?src=\ref[src];print=1'>print report</a>\]"
user << browse(dat,"window=plant_analyzer")
return
return data
@@ -35,7 +35,7 @@
if(dead)
var/ikey = "[seed.get_trait(TRAIT_PLANT_ICON)]-dead"
var/image/dead_overlay = plant_controller.plant_icon_cache["[ikey]"]
var/image/dead_overlay = SSplants.plant_icon_cache["[ikey]"]
if(!dead_overlay)
dead_overlay = image('icons/obj/hydroponics_growing.dmi', "[ikey]")
dead_overlay.color = DEAD_PLANT_COLOUR
@@ -55,23 +55,23 @@
maturation = 1
overlay_stage = maturation ? max(1,round(age/maturation)) : 1
var/ikey = "[seed.get_trait(TRAIT_PLANT_ICON)]-[overlay_stage]"
var/image/plant_overlay = plant_controller.plant_icon_cache["[ikey]-[seed.get_trait(TRAIT_PLANT_COLOUR)]"]
var/image/plant_overlay = SSplants.plant_icon_cache["[ikey]-[seed.get_trait(TRAIT_PLANT_COLOUR)]"]
if(frozen == 1)
plant_overlay = image('icons/obj/hydroponics_growing.dmi', "[ikey]")
plant_overlay.color = FROZEN_PLANT_COLOUR
if(!plant_overlay)
plant_overlay = image('icons/obj/hydroponics_growing.dmi', "[ikey]")
plant_overlay.color = seed.get_trait(TRAIT_PLANT_COLOUR)
plant_controller.plant_icon_cache["[ikey]-[seed.get_trait(TRAIT_PLANT_COLOUR)]"] = plant_overlay
SSplants.plant_icon_cache["[ikey]-[seed.get_trait(TRAIT_PLANT_COLOUR)]"] = plant_overlay
add_overlay(plant_overlay)
if(harvest && overlay_stage == seed.growth_stages)
ikey = "[seed.get_trait(TRAIT_PRODUCT_ICON)]"
var/image/harvest_overlay = plant_controller.plant_icon_cache["product-[ikey]-[seed.get_trait(TRAIT_PLANT_COLOUR)]"]
var/image/harvest_overlay = SSplants.plant_icon_cache["product-[ikey]-[seed.get_trait(TRAIT_PLANT_COLOUR)]"]
if(!harvest_overlay)
harvest_overlay = image('icons/obj/hydroponics_products.dmi', "[ikey]")
harvest_overlay.color = seed.get_trait(TRAIT_PRODUCT_COLOUR)
plant_controller.plant_icon_cache["product-[ikey]-[seed.get_trait(TRAIT_PRODUCT_COLOUR)]"] = harvest_overlay
SSplants.plant_icon_cache["product-[ikey]-[seed.get_trait(TRAIT_PRODUCT_COLOUR)]"] = harvest_overlay
add_overlay(harvest_overlay)