From 22f1b561e56cf4b087ddb3002faccba399d321f5 Mon Sep 17 00:00:00 2001 From: "C.L" Date: Sun, 25 Sep 2022 03:01:23 -0400 Subject: [PATCH] A few more changes. Makes bluespace ore satchel better. - Makes the mining satchel pick stuff up a bit differently. - Adds a failsafe for mining satchels so you can't pick up too many items at once. (set to 100) - Makes the bluespace ore satchel ACTUALLY bluespace. - Adds 'current capacity' so ore satchels and mining drills can only hold a certain amount. --- .../objects/items/weapons/storage/bags.dm | 47 ++++++++++++++----- code/modules/mining/drilling/drill.dm | 11 +++-- code/modules/mining/ore_box.dm | 3 +- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/code/game/objects/items/weapons/storage/bags.dm b/code/game/objects/items/weapons/storage/bags.dm index 13c53b7c18..add1253d4f 100644 --- a/code/game/objects/items/weapons/storage/bags.dm +++ b/code/game/objects/items/weapons/storage/bags.dm @@ -98,6 +98,8 @@ max_storage_space = ITEMSIZE_COST_NORMAL * 25 max_w_class = ITEMSIZE_NORMAL can_hold = list(/obj/item/weapon/ore) + var/current_capacity = 0 + var/max_pickup = 100 //How much ore can be picked up in one go. There to prevent someone from walking on a turf with 10000 ore and making the server cry. var/list/stored_ore = list( "sand" = 0, "hematite" = 0, @@ -125,12 +127,17 @@ name = "mining satchel of holding" desc = "Like a mining satchel, but when you put your hand in, you're pretty sure you can feel time itself." icon_state = "satchel_bspace" - max_storage_space = ITEMSIZE_COST_NORMAL * 75 // 3x + max_storage_space = ITEMSIZE_COST_NORMAL * 15000 // This should never, ever, ever be reached. /obj/item/weapon/storage/bag/ore/attackby(obj/item/weapon/W as obj, mob/user as mob) + if(current_capacity >= max_storage_space) + to_chat(user, "\the [src] is too full to possibly fit anything else inside of it.") + return + if (istype(W, /obj/item/weapon/ore)) var/obj/item/weapon/ore/ore = W stored_ore[ore.material]++ + current_capacity++ user.remove_from_mob(W) qdel(ore) @@ -155,23 +162,39 @@ /obj/item/weapon/storage/bag/ore/gather_all(turf/T as turf, mob/user as mob, var/silent = 0) var/success = 0 var/failure = 0 + var/current_pickup = 0 + var/max_pickup_reached = 0 for(var/obj/item/weapon/ore/O in T) //Only ever grabs ores. Doesn't do any extraneous checks, as all ore is the same size. Tons of checks means it causes hanging for up to three seconds. - //if(contents.len >= max_storage_space) //TODO: Find a good way of having it hold a maximum amount of ore. - // failure = 1 - // break + if(current_capacity >= max_storage_space) + failure = 1 + break + if(current_pickup >= max_pickup) + max_pickup_reached = 1 + break var/obj/item/weapon/ore/ore = O stored_ore[ore.material]++ + current_capacity++ + current_pickup++ qdel(ore) success = 1 - if(success && !failure && !silent) - to_chat(user, "You put everything in [src].") - //else if(success && (!silent || (silent && contents.len >= max_storage_space))) //TODO: Find a good way of having it hold a maximum amount of ore. - // to_chat(user, "You fill the [src].") - else if(!silent) - to_chat(user, "You fail to pick anything up with \the [src].") - if(istype(user.pulling, /obj/structure/ore_box)) //Bit of a crappy way to do this, as it doubles spam for the user, but it works. + if(!silent) //Let's do a single check and then do more instead of a bunch at once. + if(success && !failure && !max_pickup_reached) //Picked stuff up, did not reach capacity, did not reach max_pickup. + to_chat(user, "You put everything in [src].") + else if(success && failure)) //Picked stuff up to capacity. + to_chat(user, "You fill the [src].") + else if(success && max_pickup_reached) //Picked stuff up to the max_pickup + to_chat(user, "You fill the [src] with as much as you can grab in one go.") + else //Failed. The bag is full. + to_chat(user, "You fail to pick anything up with \the [src].") + if(istype(user.pulling, /obj/structure/ore_box)) //Bit of a crappy way to do this, as it doubles spam for the user, but it works. //Then let me fix it. ~CL. var/obj/structure/ore_box/OB = user.pulling - OB.attackby(src, user) + for(var/ore in stored_ore) + if(stored_ore[ore] > 0) + var/ore_amount = stored_ore[ore] // How many ores does the satchel have? + OB.stored_ore[ore] += ore_amount // Add the ore to the box + stored_ore[ore] = 0 // Set the value of the ore in the satchel to 0. + current_capacity = 0 // Set the amount of ore in the satchel to 0. + one_go_pickup = 0 /obj/item/weapon/storage/bag/ore/equipped(mob/user) ..() diff --git a/code/modules/mining/drilling/drill.dm b/code/modules/mining/drilling/drill.dm index 01d1a4772e..ef21299dcd 100644 --- a/code/modules/mining/drilling/drill.dm +++ b/code/modules/mining/drilling/drill.dm @@ -19,6 +19,7 @@ var/obj/item/device/radio/intercom/faultreporter var/drill_range = 5 var/offset = 2 + var/current_capacity = 0 var/list/stored_ore = list( "sand" = 0, @@ -100,8 +101,8 @@ . += "The drill can mine [harvest_speed] [(harvest_speed == 1)? "ore" : "ores"] a second!" if(exotic_drilling) . += "The drill is upgraded and is capable of mining [(exotic_drilling == 1)? "moderately further" : "as deep as possible"]!" - if(capacity && contents.len) //TODO: Replace contents with a list that calculates current value. - . += "The drill currently has [contents.len] capacity taken up and can fit [capacity - contents.len] more ore." + if(capacity && current_capacity) //TODO: Replace contents with a list that calculates current value. + . += "The drill currently has [current_capacity] capacity taken up and can fit [capacity - current_capacity] more ore." /obj/machinery/mining/drill/Initialize() . = ..() @@ -172,7 +173,7 @@ for(var/metal in ore_types) - if(contents.len >= capacity) + if(current_capacity >= capacity) system_error("Insufficient storage space.") active = 0 need_player_check = 1 @@ -198,7 +199,8 @@ harvesting.resources[metal] = 0 for(var/i=1, i <= create_ore, i++) - stored_ore[metal]++ + stored_ore[metal]++ // Adds the ore to the drill. + current_capacity++ // Adds the ore to the drill's capacity. if(!found_resource) // If a drill can't see an advanced material, it will destroy it while going through. harvesting.has_resources = 0 @@ -396,6 +398,7 @@ var/ore_amount = stored_ore[ore] // How many ores does the satchel have? B.stored_ore[ore] += ore_amount // Add the ore to the machine. stored_ore[ore] = 0 // Set the value of the ore in the satchel to 0. + current_capacity = 0 // Set the amount of ore in the drill to 0. to_chat(usr, "You unload the drill's storage cache into the ore box.") else to_chat(usr, "You must move an ore box up to the drill before you can unload it.") diff --git a/code/modules/mining/ore_box.dm b/code/modules/mining/ore_box.dm index 1e9b75088f..98e8aa5dea 100644 --- a/code/modules/mining/ore_box.dm +++ b/code/modules/mining/ore_box.dm @@ -29,8 +29,6 @@ "verdantium" = 0, "rutile" = 0) - var/list/contained_resources = list() //A list of the ore inside. This is done to reduce lag. - /obj/structure/ore_box/attackby(obj/item/weapon/W as obj, mob/user as mob) if (istype(W, /obj/item/weapon/ore)) @@ -47,6 +45,7 @@ var/ore_amount = S.stored_ore[ore] // How many ores does the satchel have? stored_ore[ore] += ore_amount // Add the ore to the machine. S.stored_ore[ore] = 0 // Set the value of the ore in the satchel to 0. + S.current_capacity = 0 // Set the amount of ore in the satchel to 0. to_chat(user, "You empty the satchel into the box.") return