Skip to content

Commit

Permalink
RPED 2: You mean I can fast replace cells and beakers with this? (#6012)
Browse files Browse the repository at this point in the history
Co-authored-by: TheObserver-sys <[email protected]>
Co-authored-by: silicons <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2023
1 parent d84bacb commit 2e223ea
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
17 changes: 12 additions & 5 deletions code/game/machinery/_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
CB.apply_default_parts(src)
RefreshParts()

// todo: this is fucked, refactor
/obj/machinery/proc/default_part_replacement(var/mob/user, var/obj/item/storage/part_replacer/R)
if(!istype(R))
return 0
Expand All @@ -418,23 +419,29 @@
if(panel_open || !R.panel_req)
var/obj/item/circuitboard/CB = circuit
var/P
for(var/obj/item/stock_parts/A in component_parts)
for(var/obj/item/A in component_parts)
var/our_rating = A.rped_rating()
if(isnull(our_rating))
continue
for(var/T in CB.req_components)
if(ispath(A.type, T))
P = T
break
for(var/obj/item/stock_parts/B in R.contents)
for(var/obj/item/B in R.contents)
var/their_rating = B.rped_rating()
if(isnull(their_rating))
continue
if(istype(B, P) && istype(A, P))
if(B.rating > A.rating)
if(their_rating > our_rating)
R.remove_from_storage(B, src)
R.handle_item_insertion(A, null, TRUE)
component_parts -= A
component_parts += B
B.loc = null
to_chat(user, "<span class='notice'>[A.name] replaced with [B.name].</span>")
break
update_appearance()
RefreshParts()
update_appearance()
RefreshParts()
return 1

// todo: refactor
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,9 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.

/// These procs are for RPEDs and part ratings. The concept for this was borrowed from /vg/station.
/// Gets the rating of the item, used in stuff like machine construction.
/// return null for don't use as part
/obj/item/proc/get_rating()
return FALSE
return null

/// These procs are for RPEDs and part ratings, but used for RPED sorting of parts.
/obj/item/proc/rped_rating()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/stock_parts/part_replacer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
desc = "A special mechanical module made to store, sort, and apply standard machine parts."
icon_state = "RPED"
w_class = ITEMSIZE_HUGE
can_hold = list(/obj/item/stock_parts)
can_hold = list(/obj/item/stock_parts, /obj/item/cell/, /obj/item/reagent_containers/glass/beaker/)
storage_slots = 100
use_to_pickup = 1
allow_quick_gather = 1
Expand Down
4 changes: 4 additions & 0 deletions code/modules/power/cell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
var/charge_amount = 25 // How much power to give, if self_recharge is true. The number is in absolute cell charge, as it gets divided by CELLRATE later.
var/last_use = 0 // A tracker for use in self-charging
var/charge_delay = 0 // How long it takes for the cell to start recharging after last use
var/rating = 1
materials = list(MAT_STEEL = 700, MAT_GLASS = 50)

// Overlay stuff.
Expand All @@ -44,6 +45,9 @@
STOP_PROCESSING(SSobj, src)
return ..()

/obj/item/cell/get_rating()
return rating

/obj/item/cell/get_cell()
return src

Expand Down
5 changes: 5 additions & 0 deletions code/modules/power/cells/power_cells.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
origin_tech = list(TECH_POWER = 2)
icon_state = "hcell"
maxcharge = 10000
rating = 2
materials = list(MAT_STEEL = 700, MAT_GLASS = 60)

/obj/item/cell/high/empty
Expand All @@ -38,6 +39,7 @@
origin_tech = list(TECH_POWER = 5)
icon_state = "scell"
maxcharge = 20000
rating = 3
materials = list(MAT_STEEL = 700, MAT_GLASS = 70)

/obj/item/cell/super/empty
Expand All @@ -48,6 +50,7 @@
origin_tech = list(TECH_POWER = 6)
icon_state = "hpcell"
maxcharge = 30000
rating = 4
materials = list(MAT_STEEL = 700, MAT_GLASS = 80)

/obj/item/cell/hyper/empty
Expand All @@ -58,6 +61,7 @@
icon_state = "icell"
origin_tech = null
maxcharge = 30000 //determines how badly mobs get shocked
rating = 6
materials = list(MAT_STEEL = 700, MAT_GLASS = 80)

/obj/item/cell/infinite/check_charge()
Expand All @@ -84,6 +88,7 @@
icon_state = "yellow slime extract" //"potato_battery"
description_info = "This 'cell' holds a max charge of 10k and self recharges over time."
maxcharge = 10000
rating = 5
materials = null
self_recharge = TRUE
charge_amount = 750
Expand Down
7 changes: 7 additions & 0 deletions code/modules/reagents/reagent_containers/glass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
w_class = WEIGHT_CLASS_TINY
drop_sound = 'sound/items/drop/glass.ogg'
pickup_sound = 'sound/items/pickup/glass.ogg'
/// rped rating
var/rped_rating = 0

/obj/item/reagent_containers/glass/beaker/Initialize(mapload)
. = ..()
Expand All @@ -172,6 +174,9 @@
..()
update_icon()

/obj/item/reagent_containers/glass/beaker/rped_rating()
return rped_rating

/obj/item/reagent_containers/glass/beaker/update_icon()
cut_overlays()
var/list/overlays_to_add = list()
Expand Down Expand Up @@ -209,6 +214,7 @@
amount_per_transfer_from_this = 10
possible_transfer_amounts = list(5,10,15,25,30,60,120)
atom_flags = OPENCONTAINER
rped_rating = 1

/obj/item/reagent_containers/glass/beaker/noreact
name = "cryostasis beaker"
Expand All @@ -232,6 +238,7 @@
amount_per_transfer_from_this = 10
possible_transfer_amounts = list(5,10,15,25,30,60,120,300)
atom_flags = OPENCONTAINER
rped_rating = 3

/obj/item/reagent_containers/glass/beaker/vial
name = "vial"
Expand Down

0 comments on commit 2e223ea

Please sign in to comment.