Skip to content

Commit

Permalink
Bioreactor eris update. (#5065)
Browse files Browse the repository at this point in the history
* first (mostly) working commit

* weh

* more missing things

* hopefully final working commit
  • Loading branch information
benj8560 authored Feb 26, 2024
1 parent 26e2576 commit 140002e
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 119 deletions.
9 changes: 9 additions & 0 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,14 @@
registered_z = new_z
// if this returns true, interaction to turf will be redirected to src instead

///Sets the anchored var and returns if it was sucessfully changed or not. Port from eris since I was getting problems currently only used for the bioreactor
/atom/movable/proc/bio_anchored(anchorvalue)
SHOULD_CALL_PARENT(TRUE)
if(anchored == anchorvalue || !can_anchor)
return FALSE
anchored = anchorvalue
LEGACY_SEND_SIGNAL(src, COMSIG_ATOM_UNFASTEN, anchored)
. = TRUE

/atom/movable/proc/preventsTurfInteractions()
return FALSE
50 changes: 27 additions & 23 deletions code/modules/biomatter_manipulation/biogenerator.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


//Power biomatter generator
//This machine use biomatter reagent and some of O2 to produce power (it also produce CO2)
//It has a few components that can be weared out, so operator should check this machine from time o time and tinker it
Expand Down Expand Up @@ -207,16 +205,16 @@


/obj/machinery/multistructure/biogenerator_part/port/update_icon()
cut_overlays()
overlays.Cut()
if(panel_open)
add_overlay("port-opened")
overlays += "port-opened"
if(pipes_dirtiness)
if(pipes_dirtiness == 1)
add_overlay("port_dirty_low")
overlays += "port_dirty_low"
else if(pipes_dirtiness <= 3)
add_overlay("port_dirty_medium")
overlays += "port_dirty_medium"
else
add_overlay("port_dirty_full")
overlays += "port_dirty_full"


/obj/machinery/multistructure/biogenerator_part/port/examine(mob/user)
Expand All @@ -236,20 +234,27 @@
to_chat(user, SPAN_WARNING("You should close cover first."))
return
if(I.use_tool(user, src, WORKTIME_FAST, tool_type, FAILCHANCE_VERY_EASY, required_stat = STAT_MEC))
var/set_canister = FALSE
if(tank)
tank.anchored = FALSE
tank.pixel_x = initial(tank.pixel_x)
tank = null
playsound(src, 'sound/machines/airlock_ext_open.ogg', 60, 1)
to_chat(user, SPAN_NOTICE("You detached [tank] from [src]."))
tank.can_anchor = TRUE
set_canister = tank.bio_anchored(FALSE)
if(set_canister)
tank.pixel_x = initial(tank.pixel_x)
tank = null
playsound(src, 'sound/machines/airlock_ext_open.ogg', 60, 1)
to_chat(user, SPAN_NOTICE("You detached [tank] from [src]."))
else
tank = locate(/obj/structure/reagent_dispensers) in get_turf(src)
if(tank)
tank.anchored = TRUE
tank.pixel_x = 8
playsound(src, 'sound/machines/airlock_ext_close.ogg', 60, 1)
to_chat(user, SPAN_NOTICE("You attached [tank] to [src]."))

set_canister = tank.bio_anchored(TRUE)
if(set_canister)
tank.can_anchor = FALSE
tank.pixel_x = 8
playsound(src, 'sound/machines/airlock_ext_close.ogg', 60, 1)
to_chat(user, SPAN_NOTICE("You attached [tank] to [src]."))
if(!set_canister)
to_chat(user, SPAN_WARNING("Ugh. You done something wrong!"))
tank = null
if(QUALITY_SCREW_DRIVING)
if(tank)
to_chat(user, SPAN_WARNING("You need to detach [tank] first."))
Expand Down Expand Up @@ -284,7 +289,6 @@
var/obj/machinery/atmospherics/binary/biogen_chamber/chamber
var/obj/machinery/power/biogenerator_core/core


/obj/machinery/multistructure/biogenerator_part/generator/New()
. = ..()
chamber = new(loc)
Expand Down Expand Up @@ -391,7 +395,7 @@
working_cycles = 0
wires = TRUE
else
to_chat(user, SPAN_WARNING("You need atleast 10 cables to replace wiring."))
to_chat(user, SPAN_WARNING("You need at least 10 cables to replace wiring."))
update_icon()


Expand Down Expand Up @@ -437,10 +441,10 @@


/obj/machinery/power/biogenerator_core/update_icon()
cut_overlays()
add_overlay("core-pipe")
overlays.Cut()
overlays += "core-pipe"
if(!coil_frame)
add_overlay("core-coil")
overlays += "core-coil"


/obj/machinery/power/biogenerator_core/examine(mob/user)
Expand Down Expand Up @@ -502,4 +506,4 @@
shock(user, 100)


#undef WEAROUT_CHANCE
#undef WEAROUT_CHANCE
46 changes: 27 additions & 19 deletions code/modules/biomatter_manipulation/bioreactor/biotank.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
var/obj/canister
var/pipes_opened = FALSE
var/pipes_cleanness = 200
var/transfer_rate = 50 //The units per processing tick that are moved into the attached canister


/obj/machinery/multistructure/bioreactor_part/biotank_platform/Initialize()
Expand Down Expand Up @@ -58,16 +57,16 @@


/obj/machinery/multistructure/bioreactor_part/biotank_platform/update_icon()
cut_overlays()
overlays.Cut()
if(pipes_cleanness <= 90)
add_overlay("[icon_state]-dirty_[get_dirtiness_level()]")
overlays += "[icon_state]-dirty_[get_dirtiness_level()]"


/obj/machinery/multistructure/bioreactor_part/biotank_platform/Process()
if(!MS)
return
if(biotank.canister)
biotank.reagents.trans_to_holder(biotank.canister.reagents, transfer_rate)
biotank.reagents.trans_to_holder(biotank.canister.reagents, 100)


/obj/machinery/multistructure/bioreactor_part/biotank_platform/attackby(var/obj/item/I, var/mob/user)
Expand All @@ -89,9 +88,9 @@
..()


/obj/machinery/multistructure/bioreactor_part/biotank_platform/proc/take_amount(var/amount)
biotank.reagents.add_reagent("biomatter", amount)
GLOB.biomatter_neothecnology_amt += amount
/obj/machinery/multistructure/bioreactor_part/biotank_platform/proc/take_amount(new_amount)
biotank.reagents.add_reagent("biomatter", new_amount)
GLOB.biomatter_neothecnology_amt += new_amount


//Pipe wearout. Wearout var - is amount of 'dirt' that will be applied to our pipes
Expand Down Expand Up @@ -145,10 +144,10 @@


/obj/structure/biomatter_tank/update_icon()
cut_overlays()
overlays.Cut()
if(canister && platform.pipes_opened)
var/image/pipe_overlay = image(icon = 'icons/obj/machines/bioreactor.dmi', icon_state = "port-pipe", pixel_y = -9)
add_overlay(pipe_overlay)
overlays += pipe_overlay


/obj/structure/biomatter_tank/attack_hand(mob/user)
Expand All @@ -173,7 +172,7 @@
playsound(loc, 'sound/machines/Custom_blastdoorclose.ogg', 100, 1)


/obj/structure/biomatter_tank/attackby(var/obj/item/I, var/mob/user)
/obj/structure/biomatter_tank/attackby(obj/item/I, mob/user)
var/tool_type = I.get_tool_type(user, list(QUALITY_BOLT_TURNING), src)
switch(tool_type)
if(QUALITY_BOLT_TURNING)
Expand All @@ -184,35 +183,44 @@
to_chat(user, SPAN_WARNING("Nothing to connect to!"))
return
var/turf/user_interaction_loc = user.loc
var/set_canister = FALSE
if(I.use_tool(user, src, WORKTIME_FAST, tool_type, FAILCHANCE_VERY_EASY, required_stat = STAT_MEC))
if(canister)
unset_canister(canister)
set_canister = unset_canister(canister)
else
set_canister(possible_canister)
to_chat(user, SPAN_NOTICE("You [canister ? "connect [canister] to" : "disconnect [canister] from"] [src]."))
toxin_attack(user, rand(5, 15))
else
set_canister = set_canister(possible_canister)
if(set_canister)
to_chat(user, SPAN_NOTICE("You [canister ? "connect [canister] to" : "disconnect [canister] from"] [src]."))
toxin_attack(user, rand(5, 15))
if(!set_canister)
to_chat(user, SPAN_WARNING("Ugh. You done something wrong!"))
shake_animation()
if(reagents.total_volume)
toxin_attack(user, rand(15, 25))
spill_biomass(user_interaction_loc)
update_icon()


/obj/structure/biomatter_tank/proc/set_canister(obj/target_tank)
target_tank.anchored = TRUE
. = target_tank.bio_anchored(TRUE)
if(!.)
return FALSE
target_tank.can_anchor = FALSE
canister = target_tank
platform.MS_bioreactor.metrics_screen.icon_state = "screen_process"
flick("screen_activation", platform.MS_bioreactor.metrics_screen)
playsound(platform.MS_bioreactor.output_port.loc, 'sound/machines/Custom_extin.ogg', 100, 1)

. = TRUE

/obj/structure/biomatter_tank/proc/unset_canister(obj/target_tank)
target_tank.anchored = FALSE
target_tank.can_anchor = TRUE
. = target_tank.bio_anchored(FALSE)
if(!.)
target_tank.can_anchor = FALSE
return FALSE
canister = null
platform.MS_bioreactor.metrics_screen.icon_state = initial(platform.MS_bioreactor.metrics_screen.icon_state)
playsound(platform.MS_bioreactor.output_port.loc, 'sound/machines/Custom_extout.ogg', 100, 1)
. = TRUE


#undef DIRT_LVL_LOW
Expand Down
23 changes: 14 additions & 9 deletions code/modules/biomatter_manipulation/bioreactor/loader.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
var/dir_input = WEST
var/dir_output = NORTH


/obj/machinery/multistructure/bioreactor_part/loader/Initialize()
. = ..()
set_light(1, 1, COLOR_LIGHTING_BLUE_MACHINERY)
Expand All @@ -32,18 +31,24 @@
return
use_power(2)
if(contents.len)
for(var/obj/object in contents)
for(var/atom/movable/A in contents)
var/obj/machinery/multistructure/bioreactor_part/platform/empty_platform = MS_bioreactor.get_unoccupied_platform()
if(empty_platform)
object.forceMove(get_step(src, dir_output))
A.forceMove(get_step(src, dir_output))
else
grab()


/obj/machinery/multistructure/bioreactor_part/loader/proc/grab()
var/obj/item/target = locate() in get_step(src, dir_input)
if(target && !target.anchored && contents.len <= 10)
target.forceMove(loc)
spawn(1)
target.forceMove(src)
flick("loader_take", src)
var/turf/T = get_step(src, dir_input)
for(var/atom/movable/A in T)
if(!A.anchored && contents.len <= 10)
if(isliving(A))
var/mob/living/L = A
if(L.stat != DEAD || ishuman(L))
continue
A.forceMove(loc)
spawn(1)
A.forceMove(src)
flick("loader_take", src)
break
20 changes: 11 additions & 9 deletions code/modules/biomatter_manipulation/bioreactor/platform.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
active_power_usage = 400
var/make_glasswalls_after_creation = FALSE

/obj/machinery/multistructure/bioreactor_part/platform/Initialize(mapload)
/obj/machinery/multistructure/bioreactor_part/platform/Initialize()
. = ..()
update_icon()


/obj/machinery/multistructure/bioreactor_part/platform/Process()
if(!MS)
use_power(1)
Expand All @@ -33,9 +34,9 @@
victim.forceMove(MS_bioreactor.misc_output)
continue
//if our target has hazard protection, apply damage based on the protection percentage.
var/hazard_protection = victim.getarmor(null, "bio")
var/hazard_protection = victim.getarmor(null, ARMOR_BIO)
var/damage = BIOREACTOR_DAMAGE_PER_TICK - (BIOREACTOR_DAMAGE_PER_TICK * (hazard_protection/100))
victim.apply_damage(damage, BRUTE, used_weapon = "Biological")
victim.apply_damage(damage, BURN, used_weapon = "Biological")
victim.adjustOxyLoss(BIOREACTOR_DAMAGE_PER_TICK / 2) // Snowflake shit, but we need the mob to die within a reasonable time frame

if(prob(10))
Expand All @@ -53,7 +54,7 @@
var/obj/item/target = M
//if we found biomatter, let's start processing
//it will slowly disappear. Time based at size of object and we manipulate with its alpha (we also check for it)
if(MATERIAL_BIOMATTER in target.matter)
if((MATERIAL_BIOMATTER in target.matter) && !target.unacidable)
target.alpha -= round(100 / target.w_class)
var/icon/I = new(target.icon, icon_state = target.icon_state)
//we turn this things to degenerate sprite a bit
Expand Down Expand Up @@ -102,12 +103,13 @@
//non robotic limbs will be consumed
if(istype(item, /obj/item/organ))
var/obj/item/organ/organ = item
if(istype(organ, /obj/item/organ/external) && (organ.nature == MODIFICATION_ORGANIC || organ.nature == MODIFICATION_SUPERIOR))
if(istype(organ, /obj/item/organ/external) && organ.nature == MODIFICATION_ORGANIC)
continue
var/obj/machinery/multistructure/bioreactor_part/platform/neighbor_platform = pick(MS_bioreactor.platforms)
organ.forceMove(get_turf(neighbor_platform))
organ.removed()
continue*/

qdel(object)
//now let's add some dirt to the glass
for(var/obj/structure/window/reinforced/bioreactor/glass in loc)
Expand Down Expand Up @@ -201,7 +203,7 @@


/obj/structure/window/reinforced/bioreactor/update_icon()
cut_overlays()
overlays.Cut()
..()
if(contamination_level)
var/biomass_alpha = min((50*contamination_level), 255)
Expand All @@ -210,7 +212,7 @@
biomass.Turn(-40, 40)
biomass.Blend(rgb(0, 0, 0, biomass_alpha))
default.Blend(biomass, ICON_MULTIPLY)
add_overlay(default)
overlays += default


/obj/structure/window/reinforced/bioreactor/proc/apply_dirt(var/amount)
Expand All @@ -220,7 +222,7 @@
opacity = FALSE
if(contamination_level <= 0)
contamination_level = 0
opacity = FALSE
opacity = TRUE
update_icon()


Expand All @@ -233,7 +235,7 @@
if(user.loc != loc)
to_chat(user, SPAN_WARNING("You need to be inside to clean it up."))
return
to_chat(user, SPAN_NOTICE("You begin cleaning [src] with your [I]..."))
to_chat(user, SPAN_NOTICE("You begin cleaning [src] with [I]..."))
if(do_after(user, CLEANING_TIME * contamination_level, src))
to_chat(user, SPAN_NOTICE("You clean \the [src]."))
toxin_attack(user, 5*contamination_level)
Expand Down
1 change: 0 additions & 1 deletion code/modules/biomatter_manipulation/bioreactor/unloader.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
active_power_usage = 180
var/dir_output = NORTH


/obj/machinery/multistructure/bioreactor_part/unloader/Process()
if(!MS)
use_power(1)
Expand Down
Loading

0 comments on commit 140002e

Please sign in to comment.