mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-02-05 22:09:05 +00:00
Merge pull request #41276 from kriskog/monkeyrecycler
Monkey recycler connected to xenobio consoles, recycler returns reduced
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
GLOBAL_LIST_EMPTY(monkey_recyclers)
|
||||
|
||||
/obj/machinery/monkey_recycler
|
||||
name = "monkey recycler"
|
||||
desc = "A machine used for recycling dead monkeys into monkey cubes."
|
||||
@@ -9,24 +11,33 @@
|
||||
idle_power_usage = 5
|
||||
active_power_usage = 50
|
||||
circuit = /obj/item/circuitboard/machine/monkey_recycler
|
||||
var/grinded = 0
|
||||
var/required_grind = 5
|
||||
var/cube_production = 1
|
||||
var/stored_matter = 0
|
||||
var/cube_production = 0.2
|
||||
var/list/connected = list() //Keeps track of connected xenobio consoles, for deletion in /Destroy()
|
||||
|
||||
/obj/machinery/monkey_recycler/Initialize(mapload)
|
||||
. = ..()
|
||||
if (mapload)
|
||||
GLOB.monkey_recyclers += src
|
||||
|
||||
/obj/machinery/monkey_recycler/RefreshParts()
|
||||
var/req_grind = 5
|
||||
var/cubes_made = 1
|
||||
/obj/machinery/monkey_recycler/Destroy()
|
||||
if(src in GLOB.monkey_recyclers)
|
||||
GLOB.monkey_recyclers -= src
|
||||
for(var/obj/machinery/computer/camera_advanced/xenobio/console in connected)
|
||||
console.connected_recycler = null
|
||||
return ..()
|
||||
|
||||
/obj/machinery/monkey_recycler/RefreshParts() //Ranges from 0.2 to 0.8 per monkey recycled
|
||||
cube_production = 0
|
||||
for(var/obj/item/stock_parts/manipulator/B in component_parts)
|
||||
req_grind -= B.rating
|
||||
cube_production += B.rating * 0.1
|
||||
for(var/obj/item/stock_parts/matter_bin/M in component_parts)
|
||||
cubes_made = M.rating
|
||||
cube_production = cubes_made
|
||||
required_grind = req_grind
|
||||
|
||||
cube_production += M.rating * 0.1
|
||||
|
||||
/obj/machinery/monkey_recycler/examine(mob/user)
|
||||
..()
|
||||
if(in_range(user, src) || isobserver(user))
|
||||
to_chat(user, "<span class='notice'>The status display reads: Producing <b>[cube_production]</b> cube(s) for every <b>[required_grind]</b> monkey(s) inserted.<span>")
|
||||
to_chat(user, "<span class='notice'>The status display reads: Producing <b>[cube_production]</b> cubes for every monkey inserted.<span>")
|
||||
|
||||
/obj/machinery/monkey_recycler/attackby(obj/item/O, mob/user, params)
|
||||
if(default_deconstruction_screwdriver(user, "grinder_open", "grinder", O))
|
||||
@@ -68,17 +79,23 @@
|
||||
var/offset = prob(50) ? -2 : 2
|
||||
animate(src, pixel_x = pixel_x + offset, time = 0.2, loop = 200) //start shaking
|
||||
use_power(500)
|
||||
grinded++
|
||||
stored_matter += cube_production
|
||||
addtimer(VARSET_CALLBACK(src, pixel_x, initial(pixel_x)))
|
||||
addtimer(CALLBACK(GLOBAL_PROC, /proc/to_chat, user, "<span class='notice'>The machine now has [grinded] monkey\s worth of material stored.</span>"))
|
||||
addtimer(CALLBACK(GLOBAL_PROC, /proc/to_chat, user, "<span class='notice'>The machine now has [stored_matter] monkey\s worth of material stored.</span>"))
|
||||
|
||||
/obj/machinery/monkey_recycler/interact(mob/user)
|
||||
if(grinded >= required_grind)
|
||||
to_chat(user, "<span class='notice'>The machine hisses loudly as it condenses the grinded monkey meat. After a moment, it dispenses a brand new monkey cube.</span>")
|
||||
if(stored_matter >= 1)
|
||||
to_chat(user, "<span class='notice'>The machine hisses loudly as it condenses the ground monkey meat. After a moment, it dispenses a brand new monkey cube.</span>")
|
||||
playsound(src.loc, 'sound/machines/hiss.ogg', 50, 1)
|
||||
grinded -= required_grind
|
||||
for(var/i = 0, i < cube_production, i++)
|
||||
for(var/i in 1 to FLOOR(stored_matter, 1))
|
||||
new /obj/item/reagent_containers/food/snacks/monkeycube(src.loc)
|
||||
to_chat(user, "<span class='notice'>The machine's display flashes that it has [grinded] monkeys worth of material left.</span>")
|
||||
stored_matter--
|
||||
to_chat(user, "<span class='notice'>The machine's display flashes that it has [stored_matter] monkeys worth of material left.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='danger'>The machine needs at least [required_grind] monkey(s) worth of material to produce a monkey cube. It only has [grinded].</span>")
|
||||
to_chat(user, "<span class='danger'>The machine needs at least 1 monkey worth of material to produce a monkey cube. It currently has [stored_matter].</span>")
|
||||
|
||||
/obj/machinery/monkey_recycler/multitool_act(mob/living/user, obj/item/multitool/I)
|
||||
if(istype(I))
|
||||
to_chat(user, "<span class='notice'>You log [src] in the multitool's buffer.</span>")
|
||||
I.buffer = src
|
||||
return TRUE
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
var/datum/component/redirect/listener
|
||||
|
||||
var/obj/machinery/monkey_recycler/connected_recycler
|
||||
var/list/stored_slimes
|
||||
var/obj/item/slimepotion/slime/current_potion
|
||||
var/max_slimes = 5
|
||||
@@ -53,6 +54,10 @@
|
||||
hotkey_help = new
|
||||
stored_slimes = list()
|
||||
listener = AddComponent(/datum/component/redirect, list(COMSIG_ATOM_CONTENTS_DEL = CALLBACK(src, .proc/on_contents_del)))
|
||||
for(var/obj/machinery/monkey_recycler/recycler in GLOB.monkey_recyclers)
|
||||
if(get_area(recycler.loc) == get_area(loc))
|
||||
connected_recycler = recycler
|
||||
connected_recycler.connected += src
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/Destroy()
|
||||
stored_slimes = null
|
||||
@@ -160,6 +165,13 @@
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/machinery/computer/camera_advanced/xenobio/multitool_act(mob/living/user, obj/item/multitool/I)
|
||||
if (istype(I) && istype(I.buffer,/obj/machinery/monkey_recycler))
|
||||
to_chat(user, "<span class='notice'>You link [src] with [I.buffer] in [I] buffer.</span>")
|
||||
connected_recycler = I.buffer
|
||||
connected_recycler.connected += src
|
||||
return TRUE
|
||||
|
||||
/datum/action/innate/slime_place
|
||||
name = "Place Slimes"
|
||||
icon_icon = 'icons/mob/actions/actions_silicon.dmi'
|
||||
@@ -223,10 +235,13 @@
|
||||
var/mob/living/carbon/monkey/food = new /mob/living/carbon/monkey(remote_eye.loc, TRUE, owner)
|
||||
if (!QDELETED(food))
|
||||
food.LAssailant = C
|
||||
X.monkeys --
|
||||
to_chat(owner, "[X] now has [X.monkeys] monkeys left.")
|
||||
else
|
||||
to_chat(owner, "<span class='warning'>Target is not near a camera. Cannot proceed.</span>")
|
||||
X.monkeys--
|
||||
X.monkeys = round(X.monkeys, 0.1) //Prevents rounding errors
|
||||
to_chat(owner, "[X] now has [X.monkeys] monkeys stored.")
|
||||
else
|
||||
to_chat(owner, "[X] needs to have at least 1 monkey stored. Currently has [X.monkeys] monkeys stored.")
|
||||
else
|
||||
to_chat(owner, "<span class='notice'>Target is not near a camera. Cannot proceed.</span>")
|
||||
|
||||
|
||||
/datum/action/innate/monkey_recycle
|
||||
@@ -240,14 +255,20 @@
|
||||
var/mob/living/C = owner
|
||||
var/mob/camera/aiEye/remote/xenobio/remote_eye = C.remote_control
|
||||
var/obj/machinery/computer/camera_advanced/xenobio/X = target
|
||||
var/obj/machinery/monkey_recycler/recycler = X.connected_recycler
|
||||
|
||||
if(!recycler)
|
||||
to_chat(owner, "<span class='notice'>There is no connected monkey recycler. Use a multitool to link one.</span>")
|
||||
return
|
||||
if(GLOB.cameranet.checkTurfVis(remote_eye.loc))
|
||||
for(var/mob/living/carbon/monkey/M in remote_eye.loc)
|
||||
if(M.stat)
|
||||
M.visible_message("[M] vanishes as [M.p_theyre()] reclaimed for recycling!")
|
||||
X.monkeys = round(X.monkeys + 0.2,0.1)
|
||||
to_chat(owner, "[X] now has [X.monkeys] monkeys available.")
|
||||
recycler.use_power(500)
|
||||
X.monkeys += recycler.cube_production
|
||||
X.monkeys = round(X.monkeys, 0.1) //Prevents rounding errors
|
||||
qdel(M)
|
||||
to_chat(owner, "[X] now has [X.monkeys] monkeys available.")
|
||||
else
|
||||
to_chat(owner, "<span class='warning'>Target is not near a camera. Cannot proceed.</span>")
|
||||
|
||||
@@ -416,8 +437,11 @@
|
||||
var/mob/living/carbon/monkey/food = new /mob/living/carbon/monkey(T, TRUE, C)
|
||||
if (!QDELETED(food))
|
||||
food.LAssailant = C
|
||||
X.monkeys --
|
||||
to_chat(C, "[X] now has [X.monkeys] monkeys left.")
|
||||
X.monkeys--
|
||||
X.monkeys = round(X.monkeys, 0.1) //Prevents rounding errors
|
||||
to_chat(C, "[X] now has [X.monkeys] monkeys stored.")
|
||||
else
|
||||
to_chat(C, "[X] needs to have at least 1 monkey stored. Currently has [X.monkeys] monkeys stored.")
|
||||
|
||||
//Pick up monkey
|
||||
/obj/machinery/computer/camera_advanced/xenobio/proc/XenoMonkeyClickCtrl(mob/living/user, mob/living/carbon/monkey/M)
|
||||
@@ -428,10 +452,15 @@
|
||||
var/mob/camera/aiEye/remote/xenobio/E = C.remote_control
|
||||
var/obj/machinery/computer/camera_advanced/xenobio/X = E.origin
|
||||
var/area/mobarea = get_area(M.loc)
|
||||
if(!X.connected_recycler)
|
||||
to_chat(C, "<span class='notice'>There is no connected monkey recycler. Use a multitool to link one.</span>")
|
||||
return
|
||||
if(mobarea.name == E.allowed_area || mobarea.xenobiology_compatible)
|
||||
if(!M.stat)
|
||||
return
|
||||
M.visible_message("[M] vanishes as [p_theyre()] reclaimed for recycling!")
|
||||
X.monkeys = round(X.monkeys + 0.2, 0.1)
|
||||
X.connected_recycler.use_power(500)
|
||||
X.monkeys += connected_recycler.cube_production
|
||||
X.monkeys = round(X.monkeys, 0.1) //Prevents rounding errors
|
||||
qdel(M)
|
||||
to_chat(C, "[X] now has [X.monkeys] monkeys available.")
|
||||
qdel(M)
|
||||
Reference in New Issue
Block a user