Moves the plant analyzer chem mode to right click + lets you read out a tray's chemical contents (#56836)

This commit is contained in:
MrMelbert
2021-02-13 00:35:29 -08:00
committed by GitHub
parent 53d6bf8179
commit 4f7a73c3e0
9 changed files with 168 additions and 85 deletions
-6
View File
@@ -33,12 +33,6 @@
/// Minumum plant health required for gene shears.
#define GENE_SHEAR_MIN_HEALTH 15
/// -- Plant analyzer scanning modes. --
/// Stats mode - displays a plant's growth statistics (potency, yield, traits, etc.).
#define PLANT_SCANMODE_STATS 0
/// Chemical mode - displays a plant's reagents (either reagent genes or chemical contents).
#define PLANT_SCANMODE_CHEMICALS 1
/// -- Flags for seeds. --
/// Allows a plant to wild mutate (mutate on haravest) at a certain instability.
#define MUTATE_EARLY (1<<0)
+1 -1
View File
@@ -39,7 +39,7 @@
attackby_result = target.attackby(src, user, params)
if (SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return TRUE
if (SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
if (SECONDARY_ATTACK_CONTINUE_CHAIN)
// Normal behavior
else
CRASH("attackby_secondary must return an SECONDARY_ATTACK_* define, please consult code/__DEFINES/combat.dm")
-8
View File
@@ -250,11 +250,3 @@
I.desc = "Looks like this was \an [src] some time ago."
qdel(src)
return TRUE
/obj/structure/glowshroom/attackby(obj/item/I, mob/living/user, params)
if (istype(I, /obj/item/plant_analyzer))
var/obj/item/plant_analyzer/plant_analyzer = I
to_chat(user, plant_analyzer.scan_plant(myseed))
return
return ..() // Attack normally
-6
View File
@@ -48,9 +48,3 @@
/obj/item/graft/Destroy()
QDEL_NULL(stored_trait)
return ..()
/obj/item/graft/attackby(obj/item/I, mob/living/user, params)
if(istype(I, /obj/item/plant_analyzer) && !user.combat_mode)
var/obj/item/plant_analyzer/plant_analyzer = I
to_chat(user, plant_analyzer.get_graft_text(src))
return ..()
-6
View File
@@ -70,12 +70,6 @@
/obj/item/food/grown/proc/make_dryable()
AddElement(/datum/element/dryable, type)
/obj/item/food/grown/attackby(obj/item/O, mob/user, params)
..()
if (istype(O, /obj/item/plant_analyzer))
var/obj/item/plant_analyzer/plant_analyzer = O
to_chat(user, plant_analyzer.scan_plant(src))
/obj/item/food/grown/MakeLeaveTrash()
if(trash_type)
AddElement(/datum/element/food_trash, trash_type, FOOD_TRASH_OPENABLE, /obj/item/food/grown/.proc/generate_trash)
@@ -32,13 +32,6 @@
transform *= TRANSFORM_USING_VARIABLE(seed.potency, 100) + 0.5
add_juice()
/obj/item/grown/attackby(obj/item/O, mob/user, params)
..()
if (istype(O, /obj/item/plant_analyzer))
var/obj/item/plant_analyzer/plant_analyzer = O
to_chat(user, plant_analyzer.scan_plant(src))
return
/obj/item/grown/proc/add_juice()
if(reagents)
return TRUE
+167 -41
View File
@@ -1,4 +1,3 @@
// Plant analyzer
/obj/item/plant_analyzer
name = "plant analyzer"
@@ -12,86 +11,213 @@
w_class = WEIGHT_CLASS_TINY
slot_flags = ITEM_SLOT_BELT
custom_materials = list(/datum/material/iron=30, /datum/material/glass=20)
var/scan_mode = PLANT_SCANMODE_STATS
/obj/item/plant_analyzer/examine()
. = ..()
. += "<span class='notice'>Activate it in your hand to change \the [src] between a growth statistics mode and a chemical reagents mode.</span>"
. += "<span class='notice'>Left click a plant to scan its growth stats, and right click to scan its chemical reagent stats.</span>"
/obj/item/plant_analyzer/attack_self(mob/user)
/// When we attack something, first - try to scan something we hit with left click. Left-clicking uses scans for stats
/obj/item/plant_analyzer/pre_attack(atom/target, mob/living/user)
. = ..()
scan_mode = !scan_mode
to_chat(user, "<span class='notice'>You switch [src] to [scan_mode == PLANT_SCANMODE_CHEMICALS ? "scan for chemical reagents and traits" : "scan for plant growth statistics"].</span>")
/obj/item/plant_analyzer/attack(mob/living/M, mob/living/carbon/human/user)
//Checks if target is a podman
if(ispodperson(M))
user.visible_message("<span class='notice'>[user] analyzes [M]'s vitals.</span>", \
"<span class='notice'>You analyze [M]'s vitals.</span>")
if(scan_mode == PLANT_SCANMODE_STATS)
healthscan(user, M, advanced = TRUE)
else
chemscan(user, M)
add_fingerprint(user)
if(user.combat_mode)
return
return ..()
return do_plant_stats_scan(target, user)
/// Same as above, but with right click. Right-clicking scans for chemicals.
/obj/item/plant_analyzer/pre_attack_secondary(atom/target, mob/living/user)
if(user.combat_mode)
return SECONDARY_ATTACK_CONTINUE_CHAIN
return do_plant_chem_scan(target, user) ? SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN : SECONDARY_ATTACK_CONTINUE_CHAIN
/*
* Scan the target on plant scan mode. This prints traits and stats to the user.
*
* scan_target - the atom we're scanning
* user - the user doing the scanning.
*
* returns FALSE if it's not an object or item that does something when we scan it.
* returns TRUE if we can scan the object, and outputs the message to the USER.
*/
/obj/item/plant_analyzer/proc/do_plant_stats_scan(atom/scan_target, mob/user)
if(istype(scan_target, /obj/machinery/hydroponics))
to_chat(user, scan_tray_stats(scan_target))
return TRUE
if(istype(scan_target, /obj/structure/glowshroom))
var/obj/structure/glowshroom/shroom_plant = scan_target
to_chat(user, scan_plant_stats(shroom_plant.myseed))
return TRUE
if(istype(scan_target, /obj/item/graft))
to_chat(user, get_graft_text(scan_target))
return TRUE
if(isitem(scan_target))
var/obj/item/scanned_object = scan_target
if(scanned_object.get_plant_seed() || istype(scanned_object, /obj/item/seeds))
to_chat(user, scan_plant_stats(scanned_object))
return TRUE
if(ispodperson(scan_target))
pod_person_health_scan(scan_target, user)
return TRUE
return FALSE
/*
* Scan the target on chemical scan mode. This prints chemical genes and reagents to the user.
*
* scan_target - the atom we're scanning
* user - the user doing the scanning.
*
* returns FALSE if it's not an object or item that does something when we scan it.
* returns TRUE if we can scan the object, and outputs the message to the USER.
*/
/obj/item/plant_analyzer/proc/do_plant_chem_scan(atom/scan_target, mob/user)
if(istype(scan_target, /obj/machinery/hydroponics))
to_chat(user, scan_tray_chems(scan_target))
return TRUE
if(istype(scan_target, /obj/structure/glowshroom))
var/obj/structure/glowshroom/shroom_plant = scan_target
to_chat(user, scan_plant_chems(shroom_plant.myseed))
return TRUE
if(istype(scan_target, /obj/item/graft))
to_chat(user, get_graft_text(scan_target))
return TRUE
if(isitem(scan_target))
var/obj/item/scanned_object = scan_target
if(scanned_object.get_plant_seed() || istype(scanned_object, /obj/item/seeds))
to_chat(user, scan_plant_chems(scanned_object))
return TRUE
if(ispodperson(scan_target))
pod_person_chem_scan(scan_target, user)
return TRUE
return FALSE
/*
* Scan a podperson's health with the plant analyzer. No wound scanning, though.
*
* scanned_mob - the podperson being scanned
* user - the person doing the scanning
*/
/obj/item/plant_analyzer/proc/pod_person_health_scan(mob/living/carbon/human/scanned_mob, mob/living/carbon/human/user)
user.visible_message("<span class='notice'>[user] analyzes [scanned_mob]'s vitals.</span>", \
"<span class='notice'>You analyze [scanned_mob]'s vitals.</span>")
healthscan(user, scanned_mob, advanced = TRUE)
add_fingerprint(user)
/*
* Scan a podperson's chemical contents with the plant analyzer.
*
* scanned_mob - the podperson being scanned
* user - the person doing the scanning
*/
/obj/item/plant_analyzer/proc/pod_person_chem_scan(mob/living/carbon/human/scanned_mob, mob/living/carbon/human/user)
user.visible_message("<span class='notice'>[user] analyzes [scanned_mob]'s bloodstream.</span>", \
"<span class='notice'>You analyze [scanned_mob]'s bloodstream.</span>")
chemscan(user, scanned_mob)
add_fingerprint(user)
/**
* This proc is called when we scan a hydroponics tray or soil.
* This proc is called when we scan a hydroponics tray or soil on left click (stats mode)
* It formats the plant name, it's age, the plant's stats, and the tray's stats.
*
* - scanned_tray - the tray or soil we are scanning.
*
* Returns the formatted message as text.
*/
/obj/item/plant_analyzer/proc/scan_tray(obj/machinery/hydroponics/scanned_tray)
/obj/item/plant_analyzer/proc/scan_tray_stats(obj/machinery/hydroponics/scanned_tray)
var/returned_message = "<span class='info'>*---------*\n"
if(scanned_tray.myseed)
returned_message += "*** <B>[scanned_tray.myseed.plantname]</B> ***\n"
returned_message += "- Plant Age: <span class='notice'>[scanned_tray.age]</span></span>\n"
returned_message += scan_plant(scanned_tray.myseed)
returned_message += scan_plant_stats(scanned_tray.myseed)
else
returned_message += "<span class='info'><B>No plant found.</B></span>\n"
returned_message += "<span class='info'>- Weed level: <span class='notice'>[scanned_tray.weedlevel] / [MAX_TRAY_WEEDS]</span>\n"
returned_message += "<span class='info'>"
returned_message += "- Weed level: <span class='notice'>[scanned_tray.weedlevel] / [MAX_TRAY_WEEDS]</span>\n"
returned_message += "- Pest level: <span class='notice'>[scanned_tray.pestlevel] / [MAX_TRAY_PESTS]</span>\n"
returned_message += "- Toxicity level: <span class='notice'>[scanned_tray.toxic] / [MAX_TRAY_TOXINS]</span>\n"
returned_message += "- Water level: <span class='notice'>[scanned_tray.waterlevel] / [scanned_tray.maxwater]</span>\n"
returned_message += "- Nutrition level: <span class='notice'>[scanned_tray.reagents.total_volume] / [scanned_tray.maxnutri]</span>\n"
if(scanned_tray.yieldmod != 1)
returned_message += "- Yield modifier on harvest: <span class='notice'>[scanned_tray.yieldmod]x</span>\n"
returned_message += "*---------*</span>"
returned_message += "*---------*</span>"
return returned_message
/**
* This proc is called when a seed or any grown plant is scanned.
* It formats the plant name as well as either its traits or its chemical contents.
* This proc is called when we scan a hydroponics tray or soil on right click (chemicals mode)
* It formats the plant name and age, as well as the plant's chemical genes and the tray's contents.
*
* - scanned_tray - the tray or soil we are scanning.
*
* Returns the formatted message as text.
*/
/obj/item/plant_analyzer/proc/scan_tray_chems(obj/machinery/hydroponics/scanned_tray)
var/returned_message = "<span class='info'>*---------*\n"
if(scanned_tray.myseed)
returned_message += "*** <B>[scanned_tray.myseed.plantname]</B> ***\n"
returned_message += "- Plant Age: <span class='notice'>[scanned_tray.age]</span></span>\n"
returned_message += scan_plant_chems(scanned_tray.myseed)
else
returned_message += "<span class='info'><B>No plant found.</B></span>\n"
returned_message += "<span class='info'>"
returned_message += "- Tray contains:\n"
if(scanned_tray.reagents.reagent_list.len)
for(var/datum/reagent/reagent_id in scanned_tray.reagents.reagent_list)
returned_message += "- <span class='notice'>[reagent_id.volume] / [scanned_tray.maxnutri] units of [reagent_id]</span>\n"
else
returned_message += "<span class='notice'>No reagents found.</span>\n"
returned_message += "*---------*</span>"
return returned_message
/**
* This proc is called when a seed or any grown plant is scanned on left click (stats mode).
* It formats the plant name as well as either its traits and stats.
*
* - scanned_object - the source objecte for what we are scanning. This can be a grown food, a grown inedible, or a seed.
*
* Returns the formatted output as text.
*/
/obj/item/plant_analyzer/proc/scan_plant(obj/item/scanned_object)
/obj/item/plant_analyzer/proc/scan_plant_stats(obj/item/scanned_object)
var/returned_message = "<span class='info'>*---------*\nThis is \a <span class='name'>[scanned_object]</span>.\n"
var/obj/item/seeds/our_seed = scanned_object
if(!istype(our_seed)) //if we weren't passed a seed, we were passed a plant with a seed
var/obj/item/grown/scanned_plant = scanned_object
our_seed = scanned_plant.seed
our_seed = scanned_object.get_plant_seed()
switch(scan_mode)
if(PLANT_SCANMODE_STATS)
if(our_seed && istype(our_seed))
returned_message += get_analyzer_text_traits(our_seed)
else
returned_message += "*---------*\nNo genes found.\n*---------*"
if(PLANT_SCANMODE_CHEMICALS)
if(scanned_object.reagents) //we have reagents contents
returned_message += get_analyzer_text_chem_contents(scanned_object)
else if (our_seed.reagents_add?.len) //we have a seed with reagent genes
returned_message += get_analyzer_text_chem_genes(our_seed)
else
returned_message += "*---------*\nNo reagents found.\n*---------*"
if(our_seed && istype(our_seed))
returned_message += get_analyzer_text_traits(our_seed)
else
returned_message += "*---------*\nNo genes found.\n*---------*"
returned_message += "</span>\n"
return returned_message
/**
* This proc is called when a seed or any grown plant is scanned on right click (chemical mode).
* It formats the plant name as well as its chemical contents.
*
* - scanned_object - the source objecte for what we are scanning. This can be a grown food, a grown inedible, or a seed.
*
* Returns the formatted output as text.
*/
/obj/item/plant_analyzer/proc/scan_plant_chems(obj/item/scanned_object)
var/returned_message = "<span class='info'>*---------*\nThis is \a <span class='name'>[scanned_object]</span>.\n"
var/obj/item/seeds/our_seed = scanned_object
if(!istype(our_seed)) //if we weren't passed a seed, we were passed a plant with a seed
our_seed = scanned_object.get_plant_seed()
if(scanned_object.reagents) //we have reagents contents
returned_message += get_analyzer_text_chem_contents(scanned_object)
else if (our_seed.reagents_add?.len) //we have a seed with reagent genes
returned_message += get_analyzer_text_chem_genes(our_seed)
else
returned_message += "*---------*\nNo reagents found.\n*---------*"
returned_message += "</span>\n"
return returned_message
-5
View File
@@ -586,11 +586,6 @@
to_chat(user, "<span class='warning'>[src] already has seeds in it!</span>")
return
else if(istype(O, /obj/item/plant_analyzer))
var/obj/item/plant_analyzer/plant_analyzer = O
to_chat(user, plant_analyzer.scan_tray(src))
return
else if(istype(O, /obj/item/cultivator))
if(weedlevel > 0)
user.visible_message("<span class='notice'>[user] uproots the weeds.</span>", "<span class='notice'>You remove the weeds from [src].</span>")
-5
View File
@@ -503,11 +503,6 @@
return
/obj/item/seeds/attackby(obj/item/O, mob/user, params)
if (istype(O, /obj/item/plant_analyzer))
var/obj/item/plant_analyzer/plant_analyzer = O
to_chat(user, plant_analyzer.scan_plant(src))
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))