Files
Bubberstation/code/modules/hydroponics/grown.dm
4dplanner b872c9798e Fix squashing (#42135)
Squashed plants now react on the turf they are squashed.

Currently they react on the turf before if they hit a person because they don't
move through the dense object.
2018-12-31 16:04:52 -08:00

171 lines
6.0 KiB
Plaintext

// ***********************************************************
// Foods that are produced from hydroponics ~~~~~~~~~~
// Data from the seeds carry over to these grown foods
// ***********************************************************
// Base type. Subtypes are found in /grown dir.
/obj/item/reagent_containers/food/snacks/grown
icon = 'icons/obj/hydroponics/harvest.dmi'
var/obj/item/seeds/seed = null // type path, gets converted to item on New(). It's safe to assume it's always a seed item.
var/plantname = ""
var/bitesize_mod = 0
var/splat_type = /obj/effect/decal/cleanable/food/plant_smudge
// If set, bitesize = 1 + round(reagents.total_volume / bitesize_mod)
dried_type = -1
// Saves us from having to define each stupid grown's dried_type as itself.
// If you don't want a plant to be driable (watermelons) set this to null in the time definition.
resistance_flags = FLAMMABLE
var/dry_grind = FALSE //If TRUE, this object needs to be dry to be ground up
var/can_distill = TRUE //If FALSE, this object cannot be distilled into an alcohol.
var/distill_reagent //If NULL and this object can be distilled, it uses a generic fruit_wine reagent and adjusts its variables.
var/wine_flavor //If NULL, this is automatically set to the fruit's flavor. Determines the flavor of the wine if distill_reagent is NULL.
var/wine_power = 10 //Determines the boozepwr of the wine if distill_reagent is NULL.
/obj/item/reagent_containers/food/snacks/grown/Initialize(mapload, obj/item/seeds/new_seed)
. = ..()
if(!tastes)
tastes = list("[name]" = 1)
if(new_seed)
seed = new_seed.Copy()
else if(ispath(seed))
// This is for adminspawn or map-placed growns. They get the default stats of their seed type.
seed = new seed()
seed.adjust_potency(50-seed.potency)
pixel_x = rand(-5, 5)
pixel_y = rand(-5, 5)
if(dried_type == -1)
dried_type = src.type
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_new(src, loc)
seed.prepare_result(src)
transform *= TRANSFORM_USING_VARIABLE(seed.potency, 100) + 0.5 //Makes the resulting produce's sprite larger or smaller based on potency!
add_juice()
/obj/item/reagent_containers/food/snacks/grown/proc/add_juice()
if(reagents)
if(bitesize_mod)
bitesize = 1 + round(reagents.total_volume / bitesize_mod)
return 1
return 0
/obj/item/reagent_containers/food/snacks/grown/examine(user)
..()
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
if(T.examine_line)
to_chat(user, T.examine_line)
/obj/item/reagent_containers/food/snacks/grown/attackby(obj/item/O, mob/user, params)
..()
if (istype(O, /obj/item/plant_analyzer))
var/msg = "<span class='info'>*---------*\n This is \a <span class='name'>[src]</span>.\n"
if(seed)
msg += seed.get_analyzer_text()
var/reag_txt = ""
if(seed)
for(var/reagent_id in seed.reagents_add)
var/datum/reagent/R = GLOB.chemical_reagents_list[reagent_id]
var/amt = reagents.get_reagent_amount(reagent_id)
reag_txt += "\n<span class='info'>- [R.name]: [amt]</span>"
if(reag_txt)
msg += reag_txt
msg += "<br><span class='info'>*---------*</span>"
to_chat(user, msg)
else
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_attackby(src, O, user)
// Various gene procs
/obj/item/reagent_containers/food/snacks/grown/attack_self(mob/user)
if(seed && seed.get_gene(/datum/plant_gene/trait/squash))
squash(user)
..()
/obj/item/reagent_containers/food/snacks/grown/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
if(!..()) //was it caught by a mob?
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_throw_impact(src, hit_atom)
if(seed.get_gene(/datum/plant_gene/trait/squash))
squash(hit_atom)
/obj/item/reagent_containers/food/snacks/grown/proc/squash(atom/target)
var/turf/T = get_turf(target)
forceMove(T)
if(ispath(splat_type, /obj/effect/decal/cleanable/food/plant_smudge))
if(filling_color)
var/obj/O = new splat_type(T)
O.color = filling_color
O.name = "[name] smudge"
else if(splat_type)
new splat_type(T)
if(trash)
generate_trash(T)
visible_message("<span class='warning'>[src] has been squashed.</span>","<span class='italics'>You hear a smack.</span>")
if(seed)
for(var/datum/plant_gene/trait/trait in seed.genes)
trait.on_squash(src, target)
reagents.reaction(T)
for(var/A in T)
reagents.reaction(A)
qdel(src)
/obj/item/reagent_containers/food/snacks/grown/On_Consume()
if(iscarbon(usr))
if(seed)
for(var/datum/plant_gene/trait/T in seed.genes)
T.on_consume(src, usr)
..()
/obj/item/reagent_containers/food/snacks/grown/generate_trash(atom/location)
if(trash && ispath(trash, /obj/item/grown))
. = new trash(location, seed)
trash = null
return
return ..()
/obj/item/reagent_containers/food/snacks/grown/grind_requirements()
if(dry_grind && !dry)
to_chat(usr, "<span class='warning'>[src] needs to be dry before it can be ground up!</span>")
return
return TRUE
/obj/item/reagent_containers/food/snacks/grown/on_grind()
var/nutriment = reagents.get_reagent_amount("nutriment")
if(grind_results&&grind_results.len)
for(var/i in 1 to grind_results.len)
grind_results[grind_results[i]] = nutriment
reagents.del_reagent("nutriment")
reagents.del_reagent("vitamin")
/obj/item/reagent_containers/food/snacks/grown/on_juice()
var/nutriment = reagents.get_reagent_amount("nutriment")
if(juice_results&&juice_results.len)
for(var/i in 1 to juice_results.len)
juice_results[juice_results[i]] = nutriment
reagents.del_reagent("nutriment")
reagents.del_reagent("vitamin")
// For item-containing growns such as eggy or gatfruit
/obj/item/reagent_containers/food/snacks/grown/shell/attack_self(mob/user)
var/obj/item/T
if(trash)
T = generate_trash()
qdel(src)
user.putItemFromInventoryInHandIfPossible(T, user.active_hand_index, TRUE)
to_chat(user, "<span class='notice'>You open [src]\'s shell, revealing \a [T].</span>")