Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaking biogenerator/seed extractor attackby(). #4643

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
/decl/machine_construction/proc/attackby(obj/item/I, mob/user, obj/machinery/machine)
if(!validate_state(machine))
PRINT_STACK_TRACE("Machine [log_info_line(machine)] violated the state assumptions of the construction state [type]!")
machine.attackby(I, user)
return TRUE
return machine.attackby(I, user)
return FALSE

/decl/machine_construction/proc/mechanics_info()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
playsound(get_turf(machine), 'sound/items/Screwdriver.ogg', 50, 1)
to_chat(user, SPAN_NOTICE("You release some of the logic wiring on \the [machine]. The cover panel remains closed."))
machine.update_icon()
return
return TRUE
if(IS_WRENCH(I))
TRANSFER_STATE(down_state)
playsound(get_turf(machine), 'sound/items/Crowbar.ogg', 50, 1)
Expand All @@ -23,6 +23,7 @@
machine.part_replacement(user, replacer)
machine.display_parts(user)
return TRUE
return FALSE

/decl/machine_construction/default/panel_closed/door/mechanics_info()
. = list()
Expand All @@ -40,6 +41,7 @@
to_chat(user, SPAN_NOTICE("You tuck the exposed wiring back into \the [machine] and screw the hatch back into place."))
machine.queue_icon_update()
return TRUE
return FALSE

/decl/machine_construction/default/panel_closed/door/hacking/mechanics_info()
. = list()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
machine.panel_open = TRUE
to_chat(user, SPAN_NOTICE("You open the maintenance hatch of \the [machine]."))
machine.update_icon()
return
return TRUE
if(istype(I, /obj/item/part_replacer))
var/obj/item/part_replacer/replacer = I
if(replacer.remote_interaction)
machine.part_replacement(user, replacer)
machine.display_parts(user)
return TRUE
return FALSE

/decl/machine_construction/default/panel_closed/post_construct(obj/machinery/machine)
try_change_state(machine, down_state)
Expand Down Expand Up @@ -75,16 +76,14 @@
machine.panel_open = FALSE
to_chat(user, SPAN_NOTICE("You close the maintenance hatch of \the [machine]."))
machine.update_icon()
return

return TRUE
if(istype(I, /obj/item/part_replacer))
return machine.part_replacement(user, I)

if(IS_WRENCH(I))
return machine.part_removal(user)

if(istype(I))
return machine.part_insertion(user, I)
return FALSE

/decl/machine_construction/default/panel_open/mechanics_info()
. = list()
Expand Down
29 changes: 14 additions & 15 deletions code/game/machinery/_machines_base/machine_construction/frame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
TRANSFER_STATE(/decl/machine_construction/default/deconstructed)
to_chat(user, "<span class='notice'>You deconstruct \the [machine].</span>")
machine.dismantle()

return FALSE

/decl/machine_construction/frame/unwrenched/mechanics_info()
. = list()
Expand All @@ -49,15 +49,13 @@
try_change_state(machine, /decl/machine_construction/frame/unwrenched)

/decl/machine_construction/frame/wrenched/attackby(obj/item/I, mob/user, obj/machinery/machine)

if(IS_WRENCH(I))
playsound(machine.loc, 'sound/items/Ratchet.ogg', 50, 1)
if(do_after(user, 20, machine))
TRANSFER_STATE(/decl/machine_construction/frame/unwrenched)
to_chat(user, "<span class='notice'>You unfasten \the [machine].</span>")
machine.anchored = FALSE
return

return TRUE
if(IS_COIL(I))
var/obj/item/stack/cable_coil/C = I
if(C.get_amount() < 5)
Expand All @@ -69,7 +67,7 @@
TRANSFER_STATE(/decl/machine_construction/frame/awaiting_circuit)
to_chat(user, "<span class='notice'>You add cables to the frame.</span>")
return TRUE

return FALSE

/decl/machine_construction/frame/wrenched/mechanics_info()
. = list()
Expand All @@ -91,22 +89,22 @@
if(istype(I, /obj/item/stock_parts/circuitboard))
var/obj/item/stock_parts/circuitboard/circuit = I
if(circuit.board_type == machine.expected_machine_type)
if(!user.canUnEquip(I))
return FALSE
TRANSFER_STATE(/decl/machine_construction/frame/awaiting_parts)
user.try_unequip(I, machine)
playsound(machine.loc, 'sound/items/Deconstruct.ogg', 50, 1)
to_chat(user, "<span class='notice'>You add the circuit board to \the [machine].</span>")
machine.circuit = I
return
if(user.canUnEquip(I))
TRANSFER_STATE(/decl/machine_construction/frame/awaiting_parts)
user.try_unequip(I, machine)
playsound(machine.loc, 'sound/items/Deconstruct.ogg', 50, 1)
to_chat(user, "<span class='notice'>You add the circuit board to \the [machine].</span>")
machine.circuit = I
else
to_chat(user, "<span class='warning'>This frame does not accept circuit boards of this type!</span>")
return TRUE
return TRUE
if(IS_WIRECUTTER(I))
TRANSFER_STATE(/decl/machine_construction/frame/wrenched)
playsound(machine.loc, 'sound/items/Wirecutter.ogg', 50, 1)
to_chat(user, "<span class='notice'>You remove the cables.</span>")
new /obj/item/stack/cable_coil(machine.loc, 5)
return TRUE
return FALSE

/decl/machine_construction/frame/awaiting_circuit/mechanics_info()
. = list()
Expand All @@ -131,7 +129,7 @@
machine.circuit.dropInto(machine.loc)
machine.circuit = null
to_chat(user, "<span class='notice'>You remove the circuit board.</span>")
return
return TRUE
if(IS_SCREWDRIVER(I))
playsound(machine.loc, 'sound/items/Screwdriver.ogg', 50, 1)
var/obj/machinery/new_machine = new machine.circuit.build_path(machine.loc, machine.dir, FALSE)
Expand All @@ -145,6 +143,7 @@
PRINT_STACK_TRACE("Machine of type [new_machine.type] was built from a circuit and frame, but had no construct state set.")
qdel(machine)
return TRUE
return FALSE

/decl/machine_construction/frame/awaiting_parts/mechanics_info()
. = list()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
playsound(get_turf(machine), 'sound/items/Ratchet.ogg', 50, 1)
machine.visible_message(SPAN_NOTICE("\The [user] deconstructs \the [machine]."))
machine.dismantle()
return
return TRUE
return ..()

/decl/machine_construction/default/panel_closed/item_chassis/mechanics_info()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
new /obj/item/stack/cable_coil(get_turf(machine), 5)
machine.set_broken(TRUE, MACHINE_BROKEN_CONSTRUCT)
machine.queue_icon_update()
return
return TRUE

if((. = up_interaction(I, user, machine)))
return
Expand Down Expand Up @@ -135,10 +135,9 @@
to_chat(user, SPAN_NOTICE("You wire the [machine]."))
machine.set_broken(FALSE, MACHINE_BROKEN_CONSTRUCT)
machine.queue_icon_update()
return
else
to_chat(user, SPAN_WARNING("You need five pieces of cable to wire \the [machine]."))
return TRUE
return TRUE

if((. = down_interaction(I, user, machine)))
return
Expand Down Expand Up @@ -200,14 +199,16 @@
machine.install_component(board)
user.visible_message(SPAN_NOTICE("\The [user] inserts \the [board] into \the [machine]!"), SPAN_NOTICE("You insert \the [board] into \the [machine]!"))
machine.queue_icon_update()
return
return TRUE

if(IS_WRENCH(I))
TRANSFER_STATE(/decl/machine_construction/default/deconstructed)
playsound(get_turf(machine), 'sound/items/Ratchet.ogg', 50, 1)
machine.visible_message(SPAN_NOTICE("\The [user] deconstructs \the [machine]."))
machine.dismantle()
return
return TRUE

return FALSE

/decl/machine_construction/wall_frame/no_circuit/mechanics_info()
. = list()
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/_machines_base/machinery_components.dm
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ var/global/list/machine_path_to_circuit_type
/obj/machinery/proc/component_stat_change(var/obj/item/stock_parts/part, old_stat, flag)

/obj/machinery/attackby(obj/item/I, mob/user)
if(component_attackby(I, user))
return TRUE
if((. = component_attackby(I, user)))
return
return ..()

/obj/machinery/proc/component_attackby(obj/item/I, mob/user)
Expand All @@ -265,7 +265,7 @@ var/global/list/machine_path_to_circuit_type
continue
if((. = part.attackby(I, user)))
return
return construct_state && construct_state.attackby(I, user, src)
return construct_state?.attackby(I, user, src)

/obj/machinery/proc/component_attack_hand(mob/user)
for(var/obj/item/stock_parts/part in component_parts)
Expand Down
72 changes: 40 additions & 32 deletions code/game/machinery/biogenerator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,45 +79,53 @@
return SPAN_NOTICE("You must turn \the [src] off first.")
return ..()

/obj/machinery/biogenerator/attackby(var/obj/item/O, var/mob/user)
if((. = component_attackby(O, user)))
return
/obj/machinery/biogenerator/attackby(var/obj/item/used_item, var/mob/user)

if(processing)
to_chat(user, "<span class='notice'>\The [src] is currently processing.</span>")
if(istype(O, /obj/item/chems/glass))
if((. = component_attackby(used_item, user)))
return
to_chat(user, SPAN_WARNING("\The [src] is currently processing."))
return TRUE

if(istype(used_item, /obj/item/chems/glass))
if(beaker)
to_chat(user, "<span class='notice'>]\The [src] is already loaded.</span>")
return TRUE
else if(user.try_unequip(O, src))
beaker = O
to_chat(user, SPAN_NOTICE("\The [src] is already loaded."))
else if(user.try_unequip(used_item, src))
beaker = used_item
state = BG_READY
updateUsrDialog()
return TRUE
return TRUE

if(ingredients >= capacity)
to_chat(user, "<span class='notice'>\The [src] is already full! Activate it.</span>")
else if(isobj(O))
if(O.storage)
var/hadPlants = 0
for(var/obj/item/food/grown/G in O.storage.get_contents())
hadPlants = 1
O.storage.remove_from_storage(user, G, src, TRUE)
ingredients++
if(ingredients >= capacity)
to_chat(user, "<span class='notice'>You fill \the [src] to its capacity.</span>")
break
O.storage.finish_bulk_removal() //Now do the UI stuff once.
if(!hadPlants)
to_chat(user, "<span class='notice'>\The [O] has no produce inside.</span>")
else if(ingredients < capacity)
to_chat(user, "<span class='notice'>You empty \the [O] into \the [src].</span>")

else if(!istype(O, /obj/item/food/grown))
to_chat(user, "<span class='notice'>You cannot put this in \the [src].</span>")
else if(user.try_unequip(O, src))
to_chat(user, SPAN_NOTICE("\The [src] is already full! Activate it."))
return TRUE

if(used_item.storage)
var/added_plants = FALSE
for(var/obj/item/food/grown/G in used_item.storage.get_contents())
added_plants = TRUE
used_item.storage.remove_from_storage(user, G, src, TRUE)
ingredients++
if(ingredients >= capacity)
to_chat(user, SPAN_NOTICE("You fill \the [src] to its capacity."))
break
used_item.storage.finish_bulk_removal() //Now do the UI stuff once.
if(!added_plants)
to_chat(user, SPAN_WARNING("\The [used_item] has no produce inside."))
else if(ingredients < capacity)
to_chat(user, SPAN_NOTICE("You empty \the [used_item] into \the [src]."))
return TRUE

if(!istype(used_item, /obj/item/food/grown))
to_chat(user, SPAN_WARNING("You cannot put this in \the [src]."))
return TRUE

if(user.try_unequip(used_item, src))
ingredients++
to_chat(user, "<span class='notice'>You put \the [O] in \the [src]</span>")
update_icon()
to_chat(user, SPAN_NOTICE("You put \the [used_item] in \the [src]"))
return TRUE

return ..()

/**
* Display the NanoUI window for the vending machine.
Expand Down
3 changes: 0 additions & 3 deletions code/game/machinery/seed_extractor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

/obj/machinery/seed_extractor/attackby(var/obj/item/O, var/mob/user)

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

// Fruits and vegetables.
if(istype(O, /obj/item/food/grown))
if(!user.try_unequip(O))
Expand Down
10 changes: 5 additions & 5 deletions code/game/machinery/turrets/turret_ammo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
var/obj/item/ammo_casing/casing = W
if(stored_caliber && casing.caliber != stored_caliber)
to_chat(user, SPAN_WARNING("The caliber of \the [casing] does not match the caliber stored in \the [src]!"))
return FALSE
return TRUE
if(length(stored_ammo) >= max_ammo)
to_chat(user, SPAN_WARNING("\The [src] is full!"))
return FALSE
return TRUE

casing.forceMove(src)
stored_ammo += casing
Expand All @@ -49,13 +49,13 @@
var/obj/item/ammo_magazine/magazine = W
if(stored_caliber && magazine.caliber != stored_caliber)
to_chat(user, SPAN_WARNING("The caliber of \the [magazine] does not match the caliber stored in \the [src]!"))
return FALSE
return TRUE
if(!length(magazine.stored_ammo))
to_chat(user, SPAN_WARNING("\The [magazine] is empty!"))
return FALSE
return TRUE
if(length(stored_ammo) >= max_ammo)
to_chat(user, SPAN_WARNING("\The [src] is full!"))
return FALSE
return TRUE

stored_caliber = magazine.caliber
for(var/obj/item/ammo_casing/casing in magazine.stored_ammo)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/detectivework/microscope/_forensic_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
return res + ..()

/obj/machinery/forensic/attackby(obj/item/W, mob/user)
if(component_attackby(W, user))
return TRUE
if((. = component_attackby(W, user)))
return

if(user?.a_intent == I_HURT)
return ..() // bash, bash!
Expand Down
4 changes: 2 additions & 2 deletions code/modules/fabrication/fabricator_intake.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
to_chat(user, SPAN_WARNING("\The [src] cannot process \the [thing]."))

/obj/machinery/fabricator/attackby(var/obj/item/O, var/mob/user)
if(component_attackby(O, user))
return TRUE
if((. = component_attackby(O, user)))
return
if(panel_open && (IS_MULTITOOL(O) || IS_WIRECUTTER(O)))
attack_hand_with_interaction_checks(user)
return TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/modular_computers/hardware/_hardware.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
to_chat(user, "***** DIAGNOSTICS REPORT *****")
to_chat(user, jointext(diagnostics(), "\n"))
to_chat(user, "******************************")
return 1
return TRUE
return ..()

/obj/item/stock_parts/computer/on_install(obj/machinery/machine)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/modular_computers/hardware/lan_port.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
var/turf/T = get_turf(parent)
if(check_terminal_block(T))
to_chat(user, SPAN_WARNING("There's already a network cable there!"))
return FALSE
return TRUE
if(istype(T) && !T.is_plating())
to_chat(user, SPAN_WARNING("You must remove the floor plating beneath \the [parent] first."))
return TRUE
Expand Down
Loading
Loading