From 8709a72fc01c3f9e1965619f76472667572adb1c Mon Sep 17 00:00:00 2001 From: timothyteakettle <59849408+timothyteakettle@users.noreply.github.com> Date: Mon, 20 Jul 2020 00:40:18 +0100 Subject: [PATCH] fry everything --- code/__DEFINES/is_helpers.dm | 2 +- code/__HELPERS/unsorted.dm | 1 - code/datums/components/edible.dm | 3 +- code/datums/components/fried.dm | 89 +++++++++++++++++++ code/modules/food_and_drinks/food/snacks.dm | 7 +- .../food_and_drinks/food/snacks_bread.dm | 87 ------------------ .../kitchen_machinery/deep_fryer.dm | 12 +-- .../chemistry/reagents/food_reagents.dm | 8 +- .../chemistry/recipes/slime_extracts.dm | 5 +- tgstation.dme | 1 + 10 files changed, 107 insertions(+), 108 deletions(-) create mode 100644 code/datums/components/fried.dm diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index 90c7c34f8d..a9d9bda00c 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -216,7 +216,7 @@ GLOBAL_LIST_INIT(pointed_types, typecacheof(list( #define isgun(A) (istype(A, /obj/item/gun)) -#define isfood(A) (istype(A, /obj/item/reagent_containers/food)) +#define isfood(A) (istype(A, /obj/item/reagent_containers/food/snacks)) //Assemblies #define isassembly(O) (istype(O, /obj/item/assembly)) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index cbe004ed90..4addae3ac4 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1437,7 +1437,6 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) /obj/item/reagent_containers/food/snacks/grown, /obj/item/reagent_containers/food/snacks/grown/mushroom, /obj/item/reagent_containers/food/snacks/grown/nettle, // base type - /obj/item/reagent_containers/food/snacks/deepfryholder, /obj/item/reagent_containers/food/snacks/grown/shell, /obj/item/reagent_containers/food/snacks/clothing, /obj/item/reagent_containers/food/snacks/store/bread diff --git a/code/datums/components/edible.dm b/code/datums/components/edible.dm index 47e60a1ee1..dc2e490fe4 100644 --- a/code/datums/components/edible.dm +++ b/code/datums/components/edible.dm @@ -51,7 +51,8 @@ Behavior that's still missing from this component that original food items had t var/atom/owner = parent - owner.create_reagents(volume, INJECTABLE) + if(!owner.reagents) //we don't want to override what's in the item if it possibly contains reagents already + owner.create_reagents(volume, INJECTABLE) if(initial_reagents) for(var/rid in initial_reagents) diff --git a/code/datums/components/fried.dm b/code/datums/components/fried.dm new file mode 100644 index 0000000000..3e4b78a1a6 --- /dev/null +++ b/code/datums/components/fried.dm @@ -0,0 +1,89 @@ +/*! + This component essentially encapsulates frying and utilizes the edible component + This means fried items can work like regular ones, and generally the code is far less messy +*/ +/datum/component/fried + var/fry_power //how powerfully was this item fried + var/atom/owner //the atom it is owned by + var/stored_name //name of the owner when the component was first added + var/frying_examine_text = "the coders messed frying code up, report this!" + +/datum/component/fried/Initialize(frying_power) + if(!isatom(parent)) + return COMPONENT_INCOMPATIBLE + + RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/examine) + + fry_power = frying_power + owner = parent + stored_name = owner.name + + setup_fried_item() + +//some stuff to do with the contents of fried junk +GLOBAL_VAR_INIT(frying_hardmode, TRUE) +GLOBAL_VAR_INIT(frying_bad_chem_add_volume, TRUE) +GLOBAL_LIST_INIT(frying_bad_chems, list( +/datum/reagent/toxin/bad_food = 1, +/datum/reagent/toxin = 1, +/datum/reagent/lithium = 1, +/datum/reagent/mercury = 1, +)) + +/datum/component/fried/proc/examine(datum/source, mob/user, list/examine_list) + examine_list += "The [parent] has been [frying_examine_text]" + +/datum/component/fried/proc/setup_fried_item() //sets the name, colour and examine text and edibility up + switch(fry_power) + if(0 to 15) + owner.name = "lightly fried [owner.name]" + owner.add_atom_colour(rgb(166,103,54), FIXED_COLOUR_PRIORITY) + frying_examine_text = "lightly fried" + if(16 to 49) + owner.name = "fried [owner.name]" + owner.add_atom_colour(rgb(103,63,24), FIXED_COLOUR_PRIORITY) + frying_examine_text = "moderately fried" + if(50 to 59) + owner.name = "deep fried [owner.name]" + owner.add_atom_colour(rgb(63,23,4), FIXED_COLOUR_PRIORITY) + frying_examine_text = "deeply fried" + else + owner.name = "the physical manifestation of fried foods" + owner.add_atom_colour(rgb(33,19,9), FIXED_COLOUR_PRIORITY) + frying_examine_text = "incomprehensibly fried to a crisp" + + var/list/fried_tastes = list("crispy") + var/fried_foodtypes = FRIED + var/fried_junk = FALSE + + if(!isfood(owner) && GLOB.frying_hardmode && GLOB.frying_bad_chems.len && !owner.reagents) //you fried some junk, it's not gonna taste great + fried_junk = TRUE + fried_foodtypes |= TOXIC // junk tastes toxic too + else + if(isfood(owner)) + var/obj/item/reagent_containers/food/snacks/food_item = owner + fried_tastes += food_item.tastes + fried_foodtypes |= food_item.foodtype + + owner.AddComponent(/datum/component/edible, foodtypes = fried_tastes, tastes = fried_tastes) + + //adding the edible component gives it reagents meaning we can now add the bad frying reagents if it's junk + if(fried_junk && owner.reagents) //check again just incase + var/R = rand(1, GLOB.frying_bad_chems.len) + var/bad_chem = GLOB.frying_bad_chems[R] + var/bad_chem_amount = max(4,GLOB.frying_bad_chems[bad_chem] * (fry_power/12.5)) //4u of bad chem reached when deeply fried + owner.reagents.add_reagent(bad_chem, bad_chem_amount) + +/datum/component/fried/proc/restore_name() //restore somethings name + //we do string manipulation and not restoring their name to real_name because some things hide your real_name and we want to maintain that + if(copytext(owner.name,1,14) == "lightly fried ") + owner.name = copytext(owner.name,15) + else + if(copytext(owner.name,1,6) == "fried ") + owner.name = copytext(owner.name,7) + else + if(copytext(owner.name,1,11) == "deep fried ") + owner.name = copytext(owner.name, 12) + else + if(owner.name == "the physical manifestation of fried foods") //if the name is still this, their name hasn't changed, so we can safely restore their stored name + owner.name = stored_name diff --git a/code/modules/food_and_drinks/food/snacks.dm b/code/modules/food_and_drinks/food/snacks.dm index de264ff0e4..7c2cba0c95 100644 --- a/code/modules/food_and_drinks/food/snacks.dm +++ b/code/modules/food_and_drinks/food/snacks.dm @@ -21,7 +21,7 @@ Food formatting and crafting examples. icon_state = "saltychip" //Refers to an icon, usually in food.dmi bitesize = 3 //How many reagents are consumed in each bite. list_reagents = list(/datum/reagent/consumable/nutriment = 6, //What's inside the snack, but only if spawned. For example, from a chemical reaction, vendor, or slime core spawn. - /datum/reagent/consumable/nutriment/vitamin = 2) + /datum/reagent/consumable/nutriment/vitamin = 2) bonus_reagents = list(/datum/reagent/consumable/nutriment = 1, //What's -added- to the food, in addition to the reagents contained inside the foods used to craft it. Basically, a reward for cooking. /datum/reagent/consumable/nutriment/vitamin = 1) ^^For example. Egg+Egg = 2Egg + Bonus Reagents. filling_color = "#F4A460" //What color it will use if put in a custom food. @@ -406,3 +406,8 @@ All foods are distributed among various categories. Use common sense. TB.MouseDrop(over) else return ..() + +// //////////////////////////////////////////////Frying//////////////////////////////////////// +/atom/proc/fry(cook_time = 30) //you can truly fry anything + if(!GetComponent(/datum/component/fried)) + AddComponent(/datum/component/fried, frying_power = cook_time) diff --git a/code/modules/food_and_drinks/food/snacks_bread.dm b/code/modules/food_and_drinks/food/snacks_bread.dm index f3d84f7169..0d7c715654 100644 --- a/code/modules/food_and_drinks/food/snacks_bread.dm +++ b/code/modules/food_and_drinks/food/snacks_bread.dm @@ -191,93 +191,6 @@ tastes = list("bread" = 1, "garlic" = 1, "butter" = 1) foodtype = GRAIN -/obj/item/reagent_containers/food/snacks/deepfryholder - name = "Deep Fried Foods Holder Obj" - desc = "If you can see this description the code for the deep fryer fucked up." - icon = 'icons/obj/food/food.dmi' - icon_state = "" - bitesize = 2 - var/fried_garbage = FALSE //did you really fry a fire extinguisher? - -GLOBAL_VAR_INIT(frying_hardmode, TRUE) -GLOBAL_VAR_INIT(frying_bad_chem_add_volume, TRUE) -GLOBAL_LIST_INIT(frying_bad_chems, list( -/datum/reagent/toxin/bad_food = 3, -/datum/reagent/drug/aranesp = 2, -/datum/reagent/toxin = 2, -/datum/reagent/lithium = 2, -/datum/reagent/mercury = 2, -)) - -/obj/item/reagent_containers/food/snacks/deepfryholder/Initialize(mapload, obj/item/fried) - . = ..() - name = fried.name //We'll determine the other stuff when it's actually removed - appearance = fried.appearance - layer = initial(layer) - plane = initial(plane) - lefthand_file = fried.lefthand_file - righthand_file = fried.righthand_file - item_state = fried.item_state - desc = fried.desc - w_class = fried.w_class - slowdown = fried.slowdown - equip_delay_self = fried.equip_delay_self - equip_delay_other = fried.equip_delay_other - strip_delay = fried.strip_delay - species_exception = fried.species_exception - item_flags = fried.item_flags - obj_flags = fried.obj_flags - - if(isfood(fried)) - fried.reagents.trans_to(src, fried.reagents.total_volume) - qdel(fried) - else - fried.forceMove(src) - trash = fried - fried_garbage = TRUE - -/obj/item/reagent_containers/food/snacks/deepfryholder/Destroy() - if(trash) - QDEL_NULL(trash) - . = ..() - -/obj/item/reagent_containers/food/snacks/deepfryholder/On_Consume(mob/living/eater) - if(fried_garbage && GLOB.frying_hardmode && GLOB.frying_bad_chems.len) - var/R = rand(1, GLOB.frying_bad_chems.len) - var/bad_chem = GLOB.frying_bad_chems[R] - var/bad_chem_amount = GLOB.frying_bad_chems[bad_chem] - eater.reagents.add_reagent(bad_chem, bad_chem_amount) - //All fried inedible items also get condensed cooking oil added, which induces minor vomiting and heart damage - eater.reagents.add_reagent(/datum/reagent/toxin/condensed_cooking_oil, 2) - if(trash) - QDEL_NULL(trash) - ..() - -/obj/item/reagent_containers/food/snacks/deepfryholder/proc/fry(cook_time = 30) - switch(cook_time) - if(0 to 15) - add_atom_colour(rgb(166,103,54), FIXED_COLOUR_PRIORITY) - name = "lightly-fried [name]" - desc = "[desc] It's been lightly fried in a deep fryer." - adjust_food_quality(food_quality - 5) - if(16 to 49) - add_atom_colour(rgb(103,63,24), FIXED_COLOUR_PRIORITY) - name = "fried [name]" - desc = "[desc] It's been fried, increasing its tastiness value by [rand(1, 75)]%." - adjust_food_quality(food_quality - 10) - if(50 to 59) - add_atom_colour(rgb(63,23,4), FIXED_COLOUR_PRIORITY) - name = "deep-fried [name]" - desc = "[desc] Deep-fried to perfection." - adjust_food_quality(food_quality) //we shouldn't punish perfection in the fried arts - if(60 to INFINITY) - add_atom_colour(rgb(33,19,9), FIXED_COLOUR_PRIORITY) - name = "the physical manifestation of the very concept of fried foods" - desc = "A heavily-fried...something. Who can tell anymore?" - adjust_food_quality(0) //good job, you're truly the best cook. - filling_color = color - foodtype |= FRIED - /obj/item/reagent_containers/food/snacks/butteredtoast name = "buttered toast" desc = "Butter lightly spread over a piece of toast." diff --git a/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm b/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm index d05f0b334f..5cb5a59afb 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm @@ -29,7 +29,7 @@ God bless America. use_power = IDLE_POWER_USE idle_power_usage = 5 layer = BELOW_OBJ_LAYER - var/obj/item/reagent_containers/food/snacks/deepfryholder/frying //What's being fried RIGHT NOW? + var/obj/item/frying //What's being fried RIGHT NOW? var/cook_time = 0 var/oil_use = 0.05 //How much cooking oil is used per tick var/fry_speed = 1 //How quickly we fry food @@ -91,7 +91,7 @@ God bless America. if(I.resistance_flags & INDESTRUCTIBLE) to_chat(user, "You don't feel it would be wise to fry [I]...") return - if(istype(I, /obj/item/reagent_containers/food/snacks/deepfryholder)) + if(I.GetComponent(/datum/component/fried)) to_chat(user, "Your cooking skills are not up to the legendary Doublefry technique.") return if(default_unfasten_wrench(user, I)) @@ -102,14 +102,8 @@ God bless America. if(is_type_in_typecache(I, deepfry_blacklisted_items) || HAS_TRAIT(I, TRAIT_NODROP) || (I.item_flags & (ABSTRACT | DROPDEL))) return ..() else if(!frying && user.transferItemToLoc(I, src)) + frying = I to_chat(user, "You put [I] into [src].") - frying = new/obj/item/reagent_containers/food/snacks/deepfryholder(src, I) - //setup food quality for item depending on if it's edible or not - if(isfood(I)) - var/obj/item/reagent_containers/food/original_food = I - frying.adjust_food_quality(original_food.food_quality) //food quality remains unchanged until degree of frying is calculated - else - frying.adjust_food_quality(10) //inedible fried item has low quality icon_state = "fryer_on" fry_loop.start() diff --git a/code/modules/reagents/chemistry/reagents/food_reagents.dm b/code/modules/reagents/chemistry/reagents/food_reagents.dm index f80cd10792..982ef85328 100644 --- a/code/modules/reagents/chemistry/reagents/food_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/food_reagents.dm @@ -115,11 +115,11 @@ /datum/reagent/consumable/cooking_oil/reaction_obj(obj/O, reac_volume) if(holder && holder.chem_temp >= fry_temperature) - if(isitem(O) && !istype(O, /obj/item/reagent_containers/food/snacks/deepfryholder) && !(O.resistance_flags & (FIRE_PROOF|INDESTRUCTIBLE))) + if(isitem(O) && !O.GetComponent(/datum/component/fried) && !(O.resistance_flags & (FIRE_PROOF|INDESTRUCTIBLE)) && !O.reagents) //don't fry stuff we shouldn't O.loc.visible_message("[O] rapidly fries as it's splashed with hot oil! Somehow.") - var/obj/item/reagent_containers/food/snacks/deepfryholder/F = new(O.drop_location(), O) - F.fry(volume) - F.reagents.add_reagent(/datum/reagent/consumable/cooking_oil, reac_volume) + O.fry(volume) + if(O.reagents) + O.reagents.add_reagent(/datum/reagent/consumable/cooking_oil, reac_volume) /datum/reagent/consumable/cooking_oil/reaction_mob(mob/living/M, method = TOUCH, reac_volume, show_message = 1, touch_protection = 0) if(!istype(M)) diff --git a/code/modules/reagents/chemistry/recipes/slime_extracts.dm b/code/modules/reagents/chemistry/recipes/slime_extracts.dm index ead47e2a42..2c3f25e73a 100644 --- a/code/modules/reagents/chemistry/recipes/slime_extracts.dm +++ b/code/modules/reagents/chemistry/recipes/slime_extracts.dm @@ -165,10 +165,7 @@ var/chosen = getbork() var/obj/B = new chosen(T) if(prob(5))//Fry it! - var/obj/item/reagent_containers/food/snacks/deepfryholder/fried - fried = new(T, B) - fried.fry() // actually set the name and colour it - B = fried + B.fry() // actually set the name and colour it if(prob(50)) for(var/j in 1 to rand(1, 3)) step(B, pick(NORTH,SOUTH,EAST,WEST)) diff --git a/tgstation.dme b/tgstation.dme index 9314992c5f..2c5d30e2b7 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -415,6 +415,7 @@ #include "code\datums\components\explodable.dm" #include "code\datums\components\field_of_vision.dm" #include "code\datums\components\footstep.dm" +#include "code\datums\components\fried.dm" #include "code\datums\components\identification.dm" #include "code\datums\components\igniter.dm" #include "code\datums\components\infective.dm"