Skip to content

Commit

Permalink
bugfix: HONKputer disassemble (#6210)
Browse files Browse the repository at this point in the history
* Update buildandrepair.dm

* Update buildandrepair.dm

* Part I.

* Part II.

* Update buildandrepair.dm

* Update 2

* доработка

* доработка x2

---------

Co-authored-by: Daeberdir <[email protected]>
Co-authored-by: Antoonij <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent 2f8d685 commit c0a5319
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 77 deletions.
140 changes: 78 additions & 62 deletions code/game/machinery/computer/buildandrepair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,15 @@
build_path = /obj/machinery/computer/turbine_computer
origin_tech = "programming=4;engineering=4;powerstorage=4"


/obj/item/circuitboard/HONKputer
board_name = "HONKputer"
build_path = /obj/machinery/computer/HONKputer
origin_tech = "programming=2"
icon = 'icons/obj/machines/HONKputer.dmi'
icon_state = "bananium_board"
board_type = "HONKputer"


/obj/item/circuitboard/broken
board_name = "Broken curcuit"
Expand Down Expand Up @@ -549,6 +552,14 @@
var/obj/item/circuitboard/circuit = null


/obj/structure/computerframe/Initialize(mapload, obj/item/circuitboard/circuit)
. = ..()

if(circuit)
src.circuit = new circuit(src)
state = STATE_GLASS // Spawned during completed computer Init, so it's completed.


/obj/structure/computerframe/examine(mob/user)
. = ..()
. += span_notice("It is [anchored ? "<b>bolted</b> to the floor" : "<b>unbolted</b>"].")
Expand All @@ -569,10 +580,33 @@

/obj/structure/computerframe/deconstruct(disassembled = TRUE)
if(!(obj_flags & NODECONSTRUCT))
drop_computer_parts()
var/location = drop_location()
drop_computer_materials(location)

if(circuit)
circuit.forceMove(location)

if(state >= STATE_WIRES)
new /obj/item/stack/cable_coil(location, 5)

if(state == STATE_GLASS)
new /obj/item/stack/sheet/glass(location, 2)

state = STATE_EMPTY
circuit = null

return ..() // will qdel the frame


/obj/structure/computerframe/Destroy()
if(istype(circuit))
qdel(circuit)

circuit = null

return ..()


/obj/structure/computerframe/AltClick(mob/user)
if(!Adjacent(user))
return
Expand All @@ -588,16 +622,9 @@
/obj/structure/computerframe/obj_break(damage_flag)
deconstruct()

/obj/structure/computerframe/proc/drop_computer_parts()
var/location = drop_location()

/obj/structure/computerframe/proc/drop_computer_materials(location)
new /obj/item/stack/sheet/metal(location, 5)
if(circuit)
circuit.forceMove(location)
circuit = null
if(state >= STATE_WIRES)
new /obj/item/stack/cable_coil(location, 5)
if(state == STATE_GLASS)
new /obj/item/stack/sheet/glass(location, 2)


/obj/structure/computerframe/update_icon_state()
Expand Down Expand Up @@ -651,27 +678,30 @@
/obj/structure/computerframe/screwdriver_act(mob/living/user, obj/item/I)
if(state != STATE_CIRCUIT && state != STATE_NOWIRES && state != STATE_GLASS)
return FALSE

. = TRUE

if(!I.use_tool(src, user, volume = I.tool_volume))
return .
return

switch(state)
if(STATE_CIRCUIT)
to_chat(user, span_notice("You screw the circuit board into place."))
state = STATE_NOWIRES
update_icon(UPDATE_ICON_STATE)

if(STATE_NOWIRES)
to_chat(user, span_notice("You unfasten the circuit board."))
state = STATE_CIRCUIT
update_icon(UPDATE_ICON_STATE)

if(STATE_GLASS)
if(!anchored)
to_chat(user, span_warning("Monitor can't be properly connected to the unfastened frame!"))
return

to_chat(user, span_notice("You connect the monitor."))
var/B = new circuit.build_path(loc)
if(istype(circuit, /obj/item/circuitboard/supplycomp))
var/obj/machinery/computer/supplycomp/SC = B
var/obj/item/circuitboard/supplycomp/C = circuit
SC.can_order_contraband = C.contraband_enabled
qdel(src)
new circuit.build_path(get_turf(src), src)


/obj/structure/computerframe/wirecutter_act(mob/living/user, obj/item/I)
Expand All @@ -694,16 +724,17 @@
if(STATE_EMPTY)
if(!istype(I, /obj/item/circuitboard))
return ..()

add_fingerprint(user)
if(istype(I, /obj/item/circuitboard/HONKputer) && !istype(src, /obj/structure/computerframe/HONKputer))
to_chat(user, span_warning("[src] does not accept circuit boards of this type!"))
return ATTACK_CHAIN_PROCEED
var/obj/item/circuitboard/new_circuit = I
if(new_circuit.board_type != "computer")

if(!circuit_compatibility_check(I))
to_chat(user, span_warning("[src] does not accept circuit boards of this type!"))
return ATTACK_CHAIN_PROCEED
if(!user.drop_transfer_item_to_loc(new_circuit, src))

if(!user.drop_transfer_item_to_loc(I, src))
return ..()

var/obj/item/circuitboard/new_circuit = I
new_circuit.play_tool_sound(src)
to_chat(user, span_notice("You place [new_circuit] inside [src]."))
name += " ([new_circuit.board_name])"
Expand Down Expand Up @@ -755,11 +786,27 @@
return ..()


/obj/structure/computerframe/proc/on_construction(obj/machinery/computer/computer)
forceMove(computer)


/obj/structure/computerframe/proc/circuit_compatibility_check(obj/item/circuitboard/circuit)
return circuit.board_type == "computer"


/obj/structure/computerframe/HONKputer
name = "Bananium Computer-frame"
icon = 'icons/obj/machines/HONKputer.dmi'


/obj/structure/computerframe/HONKputer/drop_computer_materials(location)
new /obj/item/stack/sheet/mineral/bananium(location, 20)


/obj/structure/computerframe/HONKputer/circuit_compatibility_check(obj/item/circuitboard/circuit)
return circuit.board_type == "HONKputer"


/obj/structure/computerframe/abductor
icon_state = "comp_frame_alien1"

Expand All @@ -768,47 +815,16 @@
icon_state = "comp_frame_alien[state]"


/obj/structure/computerframe/abductor/screwdriver_act(mob/living/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user))
return
/obj/structure/computerframe/abductor/on_construction(obj/machinery/computer/computer)
..()
computer.abductor = TRUE
computer.max_integrity = 400
computer.obj_integrity = 400

switch(state)
if(STATE_CIRCUIT)
to_chat(user, span_notice("You screw the circuit board into place."))
state = STATE_NOWIRES
I.play_tool_sound(src)
update_icon(UPDATE_ICON_STATE)
if(STATE_NOWIRES)
to_chat(user, span_notice("You unfasten the circuit board."))
state = STATE_CIRCUIT
I.play_tool_sound(src)
update_icon(UPDATE_ICON_STATE)
if(STATE_GLASS)
to_chat(user, span_notice("You connect the monitor."))
I.play_tool_sound(src)
var/obj/machinery/computer/computer = new circuit.build_path(loc)
computer.abductor = TRUE
computer.update_icon()
computer.max_integrity = 400
computer.obj_integrity = 400
computer.update_icon()
if(istype(circuit, /obj/item/circuitboard/supplycomp))
var/obj/machinery/computer/supplycomp/supply_comp = computer
var/obj/item/circuitboard/supplycomp/supply_circuit = circuit
supply_comp.can_order_contraband = supply_circuit.contraband_enabled
qdel(src)

/obj/structure/computerframe/abductor/drop_computer_parts()
var/location = drop_location()

/obj/structure/computerframe/abductor/drop_computer_materials(location)
new /obj/item/stack/sheet/mineral/abductor(location, 4)
if(circuit)
circuit.forceMove(location)
circuit = null
if(state >= STATE_WIRES)
new /obj/item/stack/cable_coil(location, 5)
if(state == STATE_GLASS)
new /obj/item/stack/sheet/glass(location, 2)


#undef STATE_EMPTY
#undef STATE_CIRCUIT
Expand Down
48 changes: 33 additions & 15 deletions code/game/machinery/computer/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
integrity_failure = 100
armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 40, "acid" = 20)
var/obj/item/circuitboard/circuit = null //if circuit==null, computer can't disassembly
var/obj/structure/computerframe/frame = /obj/structure/computerframe
var/icon_keyboard = "generic_key"
var/icon_screen = "generic"
var/light_range_on = 1
Expand All @@ -22,11 +23,30 @@
var/force_no_power_icon_state = FALSE


/obj/machinery/computer/Initialize(mapload)
/obj/machinery/computer/Initialize(mapload, obj/structure/computerframe/frame)
. = ..()

if(frame)
src.frame = frame

else
var/frame_type = abductor ? /obj/structure/computerframe/abductor : src.frame
src.frame = new frame_type(src, circuit)

src.frame.on_construction(src)
power_change()
update_icon()


/obj/machinery/computer/Destroy()
if(istype(frame))
qdel(frame)

frame = null

return ..()


/obj/machinery/computer/process()
if(stat & (NOPOWER|BROKEN))
return FALSE
Expand Down Expand Up @@ -140,37 +160,35 @@
if(prob(10))
obj_break("energy")


/obj/machinery/computer/deconstruct(disassembled = TRUE, mob/user)
on_deconstruction()
if(!(obj_flags & NODECONSTRUCT))
if(circuit) //no circuit, no computer frame
var/obj/structure/computerframe/A
if(abductor)
A = new /obj/structure/computerframe/abductor(loc)
else
A = new /obj/structure/computerframe(loc)
var/obj/item/circuitboard/M = new circuit(A)
A.name += " ([M.board_name])"
A.setDir(dir)
A.circuit = M
A.set_anchored(TRUE)
if(stat & BROKEN)
if(user)
to_chat(user, span_notice("The broken glass falls out."))

else
playsound(src, 'sound/effects/hit_on_shattered_glass.ogg', 70, TRUE)

new /obj/item/shard(drop_location())
new /obj/item/shard(drop_location())
A.state = 4
frame.state = 4

else
if(user)
to_chat(user, span_notice("You disconnect the monitor."))
A.state = 5
A.update_icon()

frame.update_icon()

for(var/obj/C in src)
C.forceMove(loc)
C.forceMove(get_turf(src))

frame = null
qdel(src)


/obj/machinery/computer/proc/set_broken()
if(!(resistance_flags & INDESTRUCTIBLE))
stat |= BROKEN
Expand Down
1 change: 1 addition & 0 deletions code/game/machinery/computer/honkputer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
light_color = LIGHT_COLOR_PINK
req_access = list(ACCESS_CLOWN)
circuit = /obj/item/circuitboard/HONKputer
frame = /obj/structure/computerframe/HONKputer
var/authenticated = 0
var/message_cooldown = 0
var/state = STATE_DEFAULT
Expand Down
11 changes: 11 additions & 0 deletions code/modules/shuttle/supply.dm
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,17 @@
req_access = list()
is_public = TRUE


/obj/machinery/computer/supplycomp/Initialize(mapload, obj/structure/computerframe/frame)
. = ..()

var/obj/item/circuitboard/supplycomp/my_circuit = src.frame.circuit
if(!istype(my_circuit))
return

can_order_contraband = my_circuit.contraband_enabled


/obj/machinery/computer/supplycomp/attack_ai(var/mob/user as mob)
return attack_hand(user)

Expand Down

0 comments on commit c0a5319

Please sign in to comment.