Skip to content

Commit

Permalink
Bee and insect swarm rework (beewrite).
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Aug 6, 2024
1 parent 153c312 commit cebc8fe
Show file tree
Hide file tree
Showing 43 changed files with 1,164 additions and 331 deletions.
1 change: 1 addition & 0 deletions code/__defines/hydroponics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Defining these to point to the relevant decl types just to avoid a massive changeset.
// TODO: rename to PLANT_TRAIT or bare decls to avoid mixing up with GetTrait etc.
#define TRAIT_CHEMS /decl/plant_trait/chems
#define TRAIT_POLLEN /decl/plant_trait/pollen
#define TRAIT_EXUDE_GASSES /decl/plant_trait/exude_gasses
#define TRAIT_ALTER_TEMP /decl/plant_trait/alter_temp
#define TRAIT_POTENCY /decl/plant_trait/potency
Expand Down
169 changes: 169 additions & 0 deletions code/game/machinery/centrifuge.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/datum/storage/hopper/industrial/centrifuge
can_hold = list(/obj/item/food) // also handles hive frames; see insects modpack.
expected_type = /obj/machinery/centrifuge

/datum/storage/hopper/industrial/centrifuge/can_be_inserted(obj/item/W, mob/user, stop_messages)
. = ..()
if(. && !W.reagents?.total_volume)
if(user)
to_chat(user, SPAN_WARNING("\The [W] is empty."))
return FALSE

/obj/machinery/centrifuge
name = "industrial centrifuge"
desc = "A machine used to extract reagents and materials from objects via spinning them at extreme speed."
icon = 'icons/obj/machines/centrifuge.dmi'
icon_state = ICON_STATE_WORLD
anchored = TRUE
density = TRUE
construct_state = /decl/machine_construction/default/panel_closed
uncreated_component_parts = null
storage = /datum/storage/hopper/industrial/centrifuge
base_type = /obj/machinery/centrifuge
stat_immune = 0

// Reference to our reagent container. Set to a path to create on init.
var/obj/item/loaded_beaker

// Stolen from fabricators.
var/sound_id
var/datum/sound_token/sound_token
var/work_sound = 'sound/machines/fabricator_loop.ogg'

/obj/machinery/centrifuge/mapped
loaded_beaker = /obj/item/chems/glass/beaker/large

/obj/machinery/centrifuge/Initialize()
. = ..()
if(ispath(loaded_beaker))
loaded_beaker = new loaded_beaker

/obj/machinery/centrifuge/Destroy()
QDEL_NULL(loaded_beaker)
return ..()

/obj/machinery/centrifuge/dismantle()
if(loaded_beaker)
loaded_beaker.dropInto(loc)
loaded_beaker = null
return ..()

/obj/machinery/centrifuge/components_are_accessible(path)
return use_power != POWER_USE_ACTIVE && ..()

/obj/machinery/centrifuge/cannot_transition_to(state_path, mob/user)
if(use_power == POWER_USE_ACTIVE)
return SPAN_NOTICE("You must wait for \the [src] to finish first!")
return ..()

/obj/machinery/centrifuge/attackby(obj/item/used_item, mob/user)

if(use_power == POWER_USE_ACTIVE)
to_chat(user, SPAN_NOTICE("\The [src] is currently spinning, wait until it's finished."))
return TRUE

if((. = component_attackby(used_item, user)))
return

// Load in a new container for products.
if(istype(used_item, /obj/item/chems/glass/beaker))
if(loaded_beaker)
to_chat(user, SPAN_WARNING("\The [src] already has a beaker loaded."))
return TRUE
if(user.try_unequip(used_item, src))
loaded_beaker = used_item
to_chat(user, SPAN_NOTICE("You load \the [loaded_beaker] into \the [src]."))
return TRUE

// Parent call handles inserting the frame into our contents,
return ..()

/obj/machinery/centrifuge/attack_hand(mob/user)

if(use_power == POWER_USE_ACTIVE)
user.visible_message("\The [user] disengages \the [src].")
update_use_power(POWER_USE_IDLE)
return TRUE

if(use_power == POWER_USE_IDLE)
if(!loaded_beaker || QDELETED(loaded_beaker))
to_chat(user, SPAN_WARNING("\The [src] has no beaker loaded to receive any products."))
loaded_beaker = null // just in case
return TRUE

if(length(get_stored_inventory()))
user.visible_message("\The [user] engages \the [src].")
update_use_power(POWER_USE_ACTIVE)
else
to_chat(user, SPAN_WARNING("\The [src]'s hopper is empty."))
return TRUE

if(use_power == POWER_USE_OFF || !operable())
to_chat(user, SPAN_WARNING("\The [src]'s interface is unresponsive."))
return TRUE

return ..()

/obj/machinery/centrifuge/Process(wait, tick)
..()

if(use_power != POWER_USE_ACTIVE)
return

if(!loaded_beaker)
visible_message("\The [src] stops spinning and flashes a red light.")
update_use_power(POWER_USE_IDLE)
return

var/list/processing_items = get_stored_inventory()
if(!length(processing_items))
visible_message("\The [src] stops spinning and flashes a green light.")
update_use_power(POWER_USE_IDLE)
return

var/obj/item/thing = processing_items[1]
thing.handle_centrifuge_process(src)
if(!QDELETED(thing) && loc)
thing.dropInto(loc)

/obj/machinery/recycler/Initialize()
sound_id = "[work_sound]"
return ..()

/obj/machinery/recycler/Destroy()
QDEL_NULL(sound_token)
return ..()

/obj/machinery/recycler/update_use_power()
. = ..()
if(use_power == POWER_USE_ACTIVE)
if(!sound_token)
sound_token = play_looping_sound(src, sound_id, work_sound, volume = 30)
else
dump_trace_material()
QDEL_NULL(sound_token)

/obj/machinery/centrifuge/on_update_icon()
icon_state = initial(icon_state)
if(stat & BROKEN)
icon_state = "[icon_state]-broken"
else if(use_power == POWER_USE_OFF || !operable())
icon_state = "[icon_state]-off"
else if(use_power == POWER_USE_ACTIVE)
icon_state = "[icon_state]-working"

/obj/machinery/centrifuge/get_alt_interactions(var/mob/user)
. = ..()
if(loaded_beaker)
LAZYADD(., list(/decl/interaction_handler/remove_centrifuge_beaker))

/decl/interaction_handler/remove_centrifuge_beaker
name = "Remove Beaker"
expected_target_type = /obj/machinery/centrifuge

/decl/interaction_handler/remove_centrifuge_beaker/invoked(atom/target, mob/user, obj/item/prop)
var/obj/machinery/centrifuge/centrifuge = target
if(centrifuge.loaded_beaker)
centrifuge.loaded_beaker.dropInto(centrifuge.loc)
user.put_in_hands(centrifuge.loaded_beaker)
centrifuge.loaded_beaker = null
31 changes: 31 additions & 0 deletions code/game/objects/items/__item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1150,3 +1150,34 @@ modules/mob/living/human/life.dm if you die, you will be zoomed out.

/obj/item/proc/get_equipment_tint()
return TINT_NONE

// Bespoke proc for handling when a centrifuge smooshes us, only currently used by growns and hive frames.
/obj/item/proc/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
SHOULD_CALL_PARENT(TRUE)
return istype(centrifuge) && !QDELETED(centrifuge.loaded_beaker) && istype(centrifuge.loaded_beaker)

/obj/item/proc/convert_matter_to_lumps(skip_qdel = FALSE)

var/list/scrap_matter = list()
for(var/mat in matter)
var/mat_amount = matter[mat]
var/obj/item/stack/material/mat_stack = /obj/item/stack/material/lump
var/mat_per_stack = SHEET_MATERIAL_AMOUNT * initial(mat_stack.matter_multiplier)
var/sheet_amount = round(mat_amount / mat_per_stack)
if(sheet_amount)
var/obj/item/stack/material/lump/lump = new(loc, sheet_amount, mat)
LAZYADD(., lump)
mat_amount -= sheet_amount * mat_per_stack
if(mat_amount)
scrap_matter[mat] += mat_amount

if(length(scrap_matter))
var/obj/item/debris/scraps/scraps = new(loc)
scraps.matter = scrap_matter.Copy()
scraps.update_primary_material()
LAZYADD(., scraps)

matter = null
material = null
if(!skip_qdel)
qdel(src)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/obj/item/stock_parts/console_screen = 1,
/obj/item/stock_parts/keyboard = 1,
/obj/item/stock_parts/power/apc/buildable = 1
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@
/obj/item/stock_parts/circuitboard/cooker/get_buildable_types()
return subtypesof(/obj/machinery/cooker)

/obj/item/stock_parts/circuitboard/centrifuge
name = "circuitboard (industrial centrifuge)"
build_path = /obj/machinery/centrifuge
board_type = "machine"
origin_tech = @'{"biotech":2,"engineering":1}'
req_components = list(
/obj/item/stock_parts/manipulator = 2,
/obj/item/stock_parts/matter_bin = 2)

/obj/item/stock_parts/circuitboard/seed_extractor
name = "circuitboard (seed extractor)"
build_path = /obj/machinery/seed_extractor
board_type = "machine"
origin_tech = @'{"biotech":2,"engineering":1}'
req_components = list(
/obj/item/stock_parts/manipulator = 2,
/obj/item/stock_parts/matter_bin = 2
)

/obj/item/stock_parts/circuitboard/seed_storage
name = "circuitboard (seed storage)"
build_path = /obj/machinery/seed_storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
path = /obj/item/stock_parts/circuitboard/cooker

/datum/fabricator_recipe/imprinter/circuit/seed_extractor
path = /obj/item/stock_parts/circuitboard/seed
path = /obj/item/stock_parts/circuitboard/seed_extractor

/datum/fabricator_recipe/imprinter/circuit/vending
path = /obj/item/stock_parts/circuitboard/vending
Expand Down Expand Up @@ -496,3 +496,6 @@

/datum/fabricator_recipe/imprinter/circuit/central_atmos
path = /obj/item/stock_parts/circuitboard/central_atmos

/datum/fabricator_recipe/imprinter/circuit/centrifuge
path = /obj/item/stock_parts/circuitboard/centrifuge
4 changes: 4 additions & 0 deletions code/modules/genetics/plants/gene_biochemistry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
if(seed.get_trait(trait) > 0)
seed.set_trait(trait, seed.get_trait(trait), null, 1, 0.85)

seed.produces_pollen = LAZYACCESS(gene.values, TRAIT_POLLEN)

LAZYINITLIST(seed.chems)
var/list/gene_value = LAZYACCESS(gene.values, TRAIT_CHEMS)
for(var/rid in gene_value)
Expand All @@ -42,10 +44,12 @@

LAZYREMOVE(gene.values, TRAIT_EXUDE_GASSES)
LAZYREMOVE(gene.values, TRAIT_CHEMS)
LAZYREMOVE(gene.values, TRAIT_POLLEN)

return ..()

/decl/plant_gene/biochemistry/copy_initial_seed_values(datum/plantgene/gene, datum/seed/seed)
LAZYSET(gene.values, TRAIT_CHEMS, seed.chems?.Copy())
LAZYSET(gene.values, TRAIT_EXUDE_GASSES, seed.exude_gasses?.Copy())
LAZYSET(gene.values, TRAIT_POLLEN, seed.produces_pollen)
return ..()
3 changes: 3 additions & 0 deletions code/modules/genetics/plants/trait_pollen.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/decl/plant_trait/pollen
name = "pollen"
requires_master_gene = FALSE
12 changes: 12 additions & 0 deletions code/modules/hydroponics/grown.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
var/seeds_extracted = FALSE
var/datum/seed/seed

// This is sort of pointless while food is a valid input on the ChemMaster but maybe
// in the future there will be some more interesting ways to process growns/food.
/obj/item/food/grown/handle_centrifuge_process(obj/machinery/centrifuge/centrifuge)
if(!(. = ..()))
return
if(reagents.total_volume)
reagents.trans_to_holder(centrifuge.loaded_beaker.reagents, reagents.total_volume)
for(var/obj/item/thing in contents)
thing.dropInto(centrifuge.loc)
for(var/atom/movable/thing in convert_matter_to_lumps())
thing.dropInto(centrifuge.loc)

/obj/item/food/grown/examine(mob/user, distance)
. = ..()
if(user && distance <= 1 && seed && user.skill_check(work_skill, SKILL_BASIC))
Expand Down
1 change: 1 addition & 0 deletions code/modules/hydroponics/seed.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
var/base_seed_value = 5 // Used when generating price.
var/scannable_result
var/grown_is_seed = FALSE
var/produces_pollen = 0

// Dissection values.
var/min_seed_extracted = 1
Expand Down
3 changes: 3 additions & 0 deletions code/modules/hydroponics/trays/tray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
var/force_update // Set this to bypass the cycle time check.
var/obj/temp_chem_holder // Something to hold reagents during process_reagents()

// Counter used by bees.
var/pollen = 0

// Seed details/line data.
var/datum/seed/seed = null // The currently planted seed

Expand Down
3 changes: 3 additions & 0 deletions code/modules/hydroponics/trays/tray_process.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
mutate((rand(100) < 15) ? 2 : 1)
mutation_level = 0

if(pollen < 10)
pollen += seed?.produces_pollen

// Maintain tray nutrient and water levels.
if(seed.get_trait(TRAIT_REQUIRES_NUTRIENTS) && seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) > 0 && nutrilevel > 0 && prob(25))
nutrilevel -= max(0,seed.get_trait(TRAIT_NUTRIENT_CONSUMPTION) * growth_rate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
name = "spider venom"
uid = "liquid_spider_venom"
lore_text = "A deadly necrotic toxin produced by giant spiders to disable their prey."
taste_description = "absolutely vile"
taste_description = "vile poison"
color = "#91d895"
toxicity_targets_organ = BP_LIVER
toxicity = 5
Expand Down
Binary file removed icons/obj/apiary_bees_etc.dmi
Binary file not shown.
Binary file removed icons/obj/beekeeping.dmi
Binary file not shown.
Binary file added icons/obj/machines/centrifuge.dmi
Binary file not shown.
Binary file modified icons/obj/virology.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions maps/away/unishi/unishi.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "unishi_areas.dm"
#include "unishi_jobs.dm"
#include "../../../mods/content/xenobiology/_xenobiology.dme"
#include "../../../mods/content/insects/_insects.dme"

/obj/abstract/submap_landmark/joinable_submap/unishi
name = "SRV Verne"
Expand Down
2 changes: 1 addition & 1 deletion maps/exodus/exodus-2.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -26493,7 +26493,7 @@
pixel_x = -21;
pixel_y = -10
},
/obj/machinery/honey_extractor,
/obj/machinery/centrifuge/mapped,
/turf/floor/tiled/steel_grid,
/area/exodus/hydroponics/garden)
"bev" = (
Expand Down
10 changes: 5 additions & 5 deletions maps/ministation/ministation-1.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -5727,9 +5727,9 @@
/obj/item/tool/hoe/mini,
/obj/item/tool/spade,
/obj/item/tool/spade,
/obj/item/honey_frame,
/obj/item/honey_frame,
/obj/item/honey_frame,
/obj/item/hive_frame/crafted,
/obj/item/hive_frame/crafted,
/obj/item/hive_frame/crafted,
/turf/floor/tiled,
/area/ministation/hydro)
"yg" = (
Expand Down Expand Up @@ -6051,7 +6051,7 @@
"zj" = (
/obj/effect/floor_decal/corner/beige/half,
/obj/structure/table/glass,
/obj/machinery/honey_extractor,
/obj/machinery/centrifuge/mapped,
/turf/floor/tiled,
/area/ministation/hydro)
"zl" = (
Expand Down Expand Up @@ -8759,7 +8759,7 @@
/turf/floor/tiled,
/area/ministation/hall/e2)
"Oo" = (
/obj/machinery/beehive,
/obj/structure/apiary/mapped,
/turf/floor/fake_grass,
/area/ministation/hydro)
"Op" = (
Expand Down
Loading

0 comments on commit cebc8fe

Please sign in to comment.