Skip to content

Commit

Permalink
Merge pull request #4675 from MistakeNot4892/feature/cream
Browse files Browse the repository at this point in the history
Adds cream to goats/cows, adds cream skimming.
  • Loading branch information
out-of-phaze authored Jan 3, 2025
2 parents a670b1e + 85b234d commit 6d3a929
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 18 deletions.
19 changes: 15 additions & 4 deletions code/datums/extensions/milkable/milkable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
var/milk_min = 5
var/milk_max = 10

var/cream_type = /decl/material/liquid/drink/milk/cream
var/cream_min = 2
var/cream_max = 5

var/impatience = 0
var/decl/skill/milking_skill = SKILL_BOTANY
var/milking_skill_req = SKILL_BASIC
Expand Down Expand Up @@ -42,9 +46,16 @@
create_milk()

/datum/extension/milkable/proc/create_milk()
var/create_milk = min(rand(milk_min, milk_max), REAGENTS_FREE_SPACE(udder))
if(create_milk > 0)
udder.add_reagent(milk_type, create_milk, get_milk_data())

var/create_milk = min(rand(milk_min, milk_max), REAGENTS_FREE_SPACE(udder))
var/create_cream = min(rand(cream_min, cream_max), REAGENTS_FREE_SPACE(udder) - create_milk)

if(create_milk <= 0 && create_cream <= 0)
return

var/list/milk_data = get_milk_data()
udder.add_reagent(milk_type, create_milk, milk_data)
udder.add_reagent(cream_type, create_cream, milk_data)

/datum/extension/milkable/proc/get_milk_data()
var/static/list/milk_data = list(
Expand Down Expand Up @@ -113,7 +124,7 @@
SPAN_NOTICE("\The [user] milks \the [critter] into \the [container]."),
SPAN_NOTICE("You milk \the [critter] into \the [container].")
)
udder.trans_type_to(container, milk_type, min(REAGENTS_FREE_SPACE(container.reagents), rand(15, 20)))
udder.trans_to(container, min(REAGENTS_FREE_SPACE(container.reagents), rand(15, 20)))
return TRUE

/datum/extension/milkable/proc/handle_milking_failure(mob/user, mob/living/critter)
Expand Down
26 changes: 13 additions & 13 deletions code/modules/crafting/metalwork/metalwork_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@
obj_flags = OBJ_FLAG_NO_STORAGE
var/max_held = 10

/obj/item/chems/crucible/attackby(obj/item/W, mob/user)
/obj/item/chems/crucible/attackby(obj/item/used_item, mob/user)

// Fill a mould.
if(istype(W, /obj/item/chems/mould))
if(W.material?.hardness <= MAT_VALUE_MALLEABLE)
to_chat(user, SPAN_WARNING("\The [W] is currently too soft to be used as a mould."))
if(istype(used_item, /obj/item/chems/mould))
if(used_item.material?.hardness <= MAT_VALUE_MALLEABLE)
to_chat(user, SPAN_WARNING("\The [used_item] is currently too soft to be used as a mould."))
return TRUE
if(standard_pour_into(user, W))
if(standard_pour_into(user, used_item))
return TRUE

// Skim off any slag.
if(istype(W, /obj/item/chems) && ATOM_IS_OPEN_CONTAINER(W) && W.reagents)
if(istype(used_item, /obj/item/chems) && ATOM_IS_OPEN_CONTAINER(used_item) && used_item.reagents)

// Pour contents into the crucible.
if(W.reagents.total_volume)
var/obj/item/chems/pouring = W
if(used_item.reagents.total_volume)
var/obj/item/chems/pouring = used_item
if(pouring.standard_pour_into(user, src))
return TRUE

// Attempting to skim off slag.
// TODO: check for appropriate vessel material? Check melting point against temperature of crucible?
if(reagents?.total_volume && length(reagents.reagent_volumes) > 1)
var/removing = min(amount_per_transfer_from_this, REAGENTS_FREE_SPACE(W.reagents))
var/removing = min(amount_per_transfer_from_this, REAGENTS_FREE_SPACE(used_item.reagents))
if(removing < length(reagents.reagent_volumes)-1)
to_chat(user, SPAN_WARNING("\The [W] is full."))
to_chat(user, SPAN_WARNING("\The [used_item] is full."))
return TRUE
// Remove a portion, excepting the primary reagent.
var/old_amt = W.reagents.total_volume
var/old_amt = used_item.reagents.total_volume
var/decl/material/primary_mat = reagents.get_primary_reagent_decl()
reagents.trans_to_holder(W.reagents, removing, skip_reagents = list(primary_mat.type))
to_chat(user, SPAN_NOTICE("You skim [W.reagents.total_volume-old_amt] unit\s of slag from the top of \the [primary_mat]."))
reagents.trans_to_holder(used_item.reagents, removing, skip_reagents = list(primary_mat.type))
to_chat(user, SPAN_NOTICE("You skim [used_item.reagents.total_volume-old_amt] unit\s of slag from the top of \the [primary_mat]."))
return TRUE

return ..()
Expand Down
2 changes: 2 additions & 0 deletions code/modules/materials/_materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ INITIALIZE_IMMEDIATE(/obj/effect/gas_overlay)
var/list/stack_origin_tech = @'{"materials":1}' // Research level for stacks.

// Attributes
/// Does this material float to the top of liquids, allowing it to be skimmed off? Specific to cream at time of writing.
var/skimmable = FALSE
/// How rare is this material in exoplanet xenoflora?
var/exoplanet_rarity_plant = MAT_RARITY_MUNDANE
/// How rare is this material in exoplanet atmospheres?
Expand Down
8 changes: 7 additions & 1 deletion code/modules/reagents/Chemistry-Holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,12 @@ var/global/datum/reagents/sink/infinite_reagent_sink = new

/* Atom reagent creation - use it all the time */

/datum/reagents/proc/get_skimmable_reagents()
for(var/mat in reagent_volumes)
var/decl/material/reagent = GET_DECL(mat)
if(reagent.skimmable)
LAZYADD(., mat)

/atom/proc/create_reagents(var/max_vol)
if(reagents)
log_debug("Attempted to create a new reagents holder when already referencing one: [log_info_line(src)]")
Expand All @@ -928,4 +934,4 @@ var/global/datum/reagents/sink/infinite_reagent_sink = new
var/decl/material/newreagent = GET_DECL(reagent_type)
if(!istype(newreagent))
return FALSE
return TRUE
return TRUE
1 change: 1 addition & 0 deletions code/modules/reagents/chems/chems_drinks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@
taste_description = "creamy milk"
color = "#dfd7af"
uid = "chem_drink_cream"
skimmable = TRUE

glass_name = "cream"
glass_desc = "Ewwww..."
Expand Down
15 changes: 15 additions & 0 deletions code/modules/reagents/reagent_containers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@
return

/obj/item/chems/attackby(obj/item/used_item, mob/user)

// Skimming off cream, repurposed from crucibles.
// TODO: potentially make this an alt interaction and unify with slag skimming.
if(istype(used_item, /obj/item/chems) && ATOM_IS_OPEN_CONTAINER(used_item) && used_item.reagents?.maximum_volume && reagents?.total_volume && length(reagents.reagent_volumes) > 1)
var/list/skimmable_reagents = reagents.get_skimmable_reagents()
if(length(skimmable_reagents))
var/removing = min(amount_per_transfer_from_this, REAGENTS_FREE_SPACE(used_item.reagents))
if(removing <= 0)
to_chat(user, SPAN_WARNING("\The [used_item] is full."))
else
var/old_amt = used_item.reagents.total_volume
reagents.trans_to_holder(used_item.reagents, removing, skip_reagents = (reagents.reagent_volumes - skimmable_reagents))
to_chat(user, SPAN_NOTICE("You skim [used_item.reagents.total_volume-old_amt] unit\s of [used_item.reagents.get_primary_reagent_name()] from the top of \the [reagents.get_primary_reagent_name()]."))
return TRUE

if(used_item.user_can_attack_with(user, silent = TRUE))
if(IS_PEN(used_item))
var/tmp_label = sanitize_safe(input(user, "Enter a label for [name]", "Label", label_text), MAX_NAME_LEN)
Expand Down

0 comments on commit 6d3a929

Please sign in to comment.