Skip to content

Commit

Permalink
Fix to stock part hell
Browse files Browse the repository at this point in the history
  • Loading branch information
BogCreature committed Nov 15, 2023
1 parent 63406bb commit 1a490b4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions code/__DEFINES/stock_parts.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//Stock part types (like tool behaviour but for stock parts)
#define PART_CAPACITOR "capacitor"
#define PART_SCANNER "scanning module"
#define PART_MANIPULATOR "manipulator"
#define PART_LASER "micro-laser"
#define PART_BIN "matter bin"
17 changes: 12 additions & 5 deletions code/modules/mining/drill.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
var/preload_cell_type = /obj/item/stock_parts/cell
var/power_cost = 100
var/metal_attached
var/missing_part //I hate this but it's better than most the ideas I've had

/obj/machinery/drill/examine(mob/user)
. = ..()
Expand All @@ -39,11 +40,11 @@
. += "<spawn class='notice'>The low power light is blinking.</span>"
switch(malfunction)
if(1)
. += "<span class='notice'>The [src]'s <b>laser array<b> appears to be broken and needs to be replaced.</span>"
. += "<span class='notice'>The [src]'s <b>laser array</b> appears to be broken and needs to be replaced.</span>"
if(2)
. += "<span class='notice'>The [src]'s <b>sensors<b> appear to be broken and need to be replaced.</span>"
. += "<span class='notice'>The [src]'s <b>sensors</b> appear to be broken and need to be replaced.</span>"
if(3)
. += "<span class='notice'>The [src]'s <b>capacitor<b> appears to be broken and needs to be replaced.</span>"
. += "<span class='notice'>The [src]'s <b>capacitor</b> appears to be broken and needs to be replaced.</span>"
if(4)
. += "<span class='notice'>The [src]'s structure looks like it needs to be <b>welded</b> back together.</span>"
if(5)
Expand Down Expand Up @@ -152,17 +153,20 @@
if(is_type_in_list(tool,needed_parts))
for(var/obj/item/stock_parts/part in component_parts)
var/obj/item/stock_parts/new_part = tool
if(new_part.parent_type == part.parent_type || istype(new_part,part))
if(new_part.part_behaviour == part.part_behaviour)
user.transferItemToLoc(tool,src)
part.forceMove(user.loc)
component_parts += new_part
component_parts -= part
to_chat(user, "<span class='notice'>You replace [part] with [new_part].</span>")
break
else if(component_parts.len < needed_parts.len)
else if(istype(new_part,missing_part))
user.transferItemToLoc(tool,src)
component_parts += new_part
malfunction = null
missing_part = null
obj_integrity = max_integrity
to_chat(user, "<span class='notice'>You replace the broken part with [new_part].</span>")
break
return
if(tool.tool_behaviour == TOOL_MULTITOOL && malfunction == MALF_CALIBRATE)
Expand Down Expand Up @@ -322,16 +326,19 @@
say("Malfunction: Laser array damaged, please replace before continuing mining operations.")
for (var/obj/item/stock_parts/micro_laser/laser in component_parts)
component_parts.Remove(laser)
missing_part = /obj/item/stock_parts/micro_laser
return
if(MALF_SENSOR)
say("Malfunction: Ground penetrating scanner damaged, please replace before continuing mining operations.")
for (var/obj/item/stock_parts/scanning_module/sensor in component_parts)
component_parts.Remove(sensor)
missing_part = /obj/item/stock_parts/scanning_module
return
if(MALF_CAPACITOR)
say("Malfunction: Energy cell capacitor damaged, please replace before continuing mining operations.")
for (var/obj/item/stock_parts/capacitor/capacitor in component_parts)
component_parts.Remove(capacitor)
missing_part = /obj/item/stock_parts/capacitor
return
if(MALF_STRUCTURAL)
say("Malfunction: Drill plating damaged, provide structural repairs before continuing mining operations.")
Expand Down
6 changes: 6 additions & 0 deletions code/modules/research/stock_parts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ If you create T5+ please take a pass at gene_modder.dm [L40]. Max_values MUST fi
icon = 'icons/obj/stock_parts.dmi'
w_class = WEIGHT_CLASS_SMALL
var/rating = 1
var/part_behaviour

/obj/item/stock_parts/Initialize()
. = ..()
Expand All @@ -126,30 +127,35 @@ If you create T5+ please take a pass at gene_modder.dm [L40]. Max_values MUST fi
name = "capacitor"
desc = "A basic capacitor used in the construction of a variety of devices."
icon_state = "capacitor"
part_behaviour = PART_CAPACITOR
custom_materials = list(/datum/material/iron=50, /datum/material/glass=50)

/obj/item/stock_parts/scanning_module
name = "scanning module"
desc = "A compact, high resolution scanning module used in the construction of certain devices."
icon_state = "scan_module"
part_behaviour = PART_SCANNER
custom_materials = list(/datum/material/iron=50, /datum/material/glass=20)

/obj/item/stock_parts/manipulator
name = "micro-manipulator"
desc = "A tiny little manipulator used in the construction of certain devices."
icon_state = "micro_mani"
part_behaviour = PART_MANIPULATOR
custom_materials = list(/datum/material/iron=30)

/obj/item/stock_parts/micro_laser
name = "micro-laser"
desc = "A tiny laser used in certain devices."
icon_state = "micro_laser"
part_behaviour = PART_LASER
custom_materials = list(/datum/material/iron=10, /datum/material/glass=20)

/obj/item/stock_parts/matter_bin
name = "matter bin"
desc = "A container designed to hold compressed matter awaiting reconstruction."
icon_state = "matter_bin"
part_behaviour = PART_BIN
custom_materials = list(/datum/material/iron=80)

//Rating 2
Expand Down
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
#include "code\__DEFINES\stat_tracking.dm"
#include "code\__DEFINES\statpanel.dm"
#include "code\__DEFINES\status_effects.dm"
#include "code\__DEFINES\stock_parts.dm"
#include "code\__DEFINES\subsystems.dm"
#include "code\__DEFINES\tgs.config.dm"
#include "code\__DEFINES\tgs.dm"
Expand Down

0 comments on commit 1a490b4

Please sign in to comment.