[MIRROR] Enables the RPED to construct/replace beakers, igniters and bluespace crystals (#5673)
* Enables the RPED to construct/replace beakers, igniters and bluespace crystals (#35779) * - Makes it possible to load the rped with beakers, assemblies and other such parts * - Fixes cell ratings being not really related to desirability * - sorry uhhh emp cells need to be slightly better than regular cells * Enables the RPED to construct/replace beakers, igniters and bluespace crystals
This commit is contained in:
committed by
Poojawa
parent
3755037c28
commit
4351621e7d
@@ -401,19 +401,28 @@ Class Procs:
|
||||
var/P
|
||||
if(W.works_from_distance)
|
||||
display_parts(user)
|
||||
for(var/obj/item/stock_parts/A in component_parts)
|
||||
for(var/obj/item/A in component_parts)
|
||||
for(var/D in CB.req_components)
|
||||
if(ispath(A.type, D))
|
||||
P = D
|
||||
break
|
||||
for(var/obj/item/stock_parts/B in W.contents)
|
||||
for(var/obj/item/B in W.contents)
|
||||
if(istype(B, P) && istype(A, P))
|
||||
if(B.rating > A.rating)
|
||||
W.remove_from_storage(B, src)
|
||||
if(B.get_part_rating() > A.get_part_rating())
|
||||
if(istype(B,/obj/item/stack)) //conveniently this will mean A is also a stack and I will kill the first person to prove me wrong
|
||||
var/obj/item/stack/SA = A
|
||||
var/obj/item/stack/SB = B
|
||||
var/used_amt = SA.get_amount()
|
||||
if(!SB.use(used_amt))
|
||||
continue //if we don't have the exact amount to replace we don't
|
||||
var/obj/item/stack/SN = new SB.merge_type(null,used_amt)
|
||||
component_parts += SN
|
||||
else
|
||||
W.remove_from_storage(B, src)
|
||||
component_parts += B
|
||||
B.moveToNullspace()
|
||||
W.handle_item_insertion(A, 1)
|
||||
component_parts -= A
|
||||
component_parts += B
|
||||
B.moveToNullspace()
|
||||
to_chat(user, "<span class='notice'>[A.name] replaced with [B.name].</span>")
|
||||
shouldplaysound = 1 //Only play the sound when parts are actually replaced!
|
||||
break
|
||||
|
||||
@@ -192,7 +192,7 @@
|
||||
var/list/part_list = list()
|
||||
|
||||
//Assemble a list of current parts, then sort them by their rating!
|
||||
for(var/obj/item/stock_parts/co in replacer)
|
||||
for(var/obj/item/co in replacer)
|
||||
part_list += co
|
||||
//Sort the parts. This ensures that higher tier items are applied first.
|
||||
part_list = sortTim(part_list, /proc/cmp_rped_sort)
|
||||
@@ -200,13 +200,28 @@
|
||||
for(var/path in req_components)
|
||||
while(req_components[path] > 0 && (locate(path) in part_list))
|
||||
var/obj/item/part = (locate(path) in part_list)
|
||||
added_components[part] = path
|
||||
replacer.remove_from_storage(part, src)
|
||||
req_components[path]--
|
||||
part_list -= part
|
||||
if(istype(part,/obj/item/stack))
|
||||
var/obj/item/stack/S = part
|
||||
var/used_amt = min(round(S.get_amount()), req_components[path])
|
||||
if(!used_amt || !S.use(used_amt))
|
||||
continue
|
||||
var/NS = new S.merge_type(src, used_amt)
|
||||
added_components[NS] = path
|
||||
req_components[path] -= used_amt
|
||||
else
|
||||
added_components[part] = path
|
||||
replacer.remove_from_storage(part, src)
|
||||
req_components[path]--
|
||||
|
||||
for(var/obj/item/stock_parts/part in added_components)
|
||||
components += part
|
||||
for(var/obj/item/part in added_components)
|
||||
if(istype(part,/obj/item/stack))
|
||||
var/obj/item/stack/S = part
|
||||
var/obj/item/stack/NS = locate(S.merge_type) in components //find a stack to merge with
|
||||
if(NS)
|
||||
S.merge(NS)
|
||||
if(!QDELETED(part)) //If we're a stack and we merged we might not exist anymore
|
||||
components += part
|
||||
to_chat(user, "<span class='notice'>[part.name] applied.</span>")
|
||||
if(added_components.len)
|
||||
replacer.play_rped_sound()
|
||||
@@ -242,7 +257,6 @@
|
||||
if(user.a_intent == INTENT_HARM)
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/structure/frame/machine/deconstruct(disassembled = TRUE)
|
||||
if(!(flags_1 & NODECONSTRUCT_1))
|
||||
if(state >= 2)
|
||||
|
||||
@@ -817,3 +817,7 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE)
|
||||
// Used in a callback that is passed by use_tool into do_after call. Do not override, do not call manually.
|
||||
/obj/item/proc/tool_check_callback(mob/living/user, amount, datum/callback/extra_checks)
|
||||
return tool_use_check(user, amount) && (!extra_checks || extra_checks.Invoke())
|
||||
|
||||
// Returns a numeric value for sorting items used as parts in machines, so they can be replaced by the rped
|
||||
/obj/item/proc/get_part_rating()
|
||||
return 0
|
||||
@@ -21,6 +21,9 @@
|
||||
pixel_x = rand(-5, 5)
|
||||
pixel_y = rand(-5, 5)
|
||||
|
||||
/obj/item/stack/ore/bluespace_crystal/get_part_rating()
|
||||
return 1
|
||||
|
||||
/obj/item/stack/ore/bluespace_crystal/attack_self(mob/user)
|
||||
user.visible_message("<span class='warning'>[user] crushes [src]!</span>", "<span class='danger'>You crush [src]!</span>")
|
||||
new /obj/effect/particle_effect/sparks(loc)
|
||||
|
||||
Reference in New Issue
Block a user