Makes Mining Satchels brute-force their way out of lagging, minerborg prodding.

This commit is contained in:
Mechoid
2018-02-20 12:58:13 -08:00
parent c0ca35bb2e
commit 8a3dcc5cc1
3 changed files with 94 additions and 4 deletions
@@ -68,6 +68,9 @@
// -----------------------------
// Mining Satchel
// -----------------------------
/*
* Mechoid - Orebags are the most common quick-gathering thing, and also have tons of lag associated with it. Their checks are going to be hyper-simplified due to this, and their INCREDIBLY singular target contents.
*/
/obj/item/weapon/storage/bag/ore
name = "mining satchel"
@@ -79,7 +82,80 @@
max_storage_space = ITEMSIZE_COST_NORMAL * 25
max_w_class = ITEMSIZE_NORMAL
can_hold = list(/obj/item/weapon/ore)
var/stored_ore = list()
var/last_update = 0
/obj/item/weapon/storage/bag/ore/remove_from_storage(obj/item/W as obj, atom/new_location)
if(!istype(W)) return 0
if(new_location)
if(ismob(loc))
W.dropped(usr)
if(ismob(new_location))
W.hud_layerise()
else
W.reset_plane_and_layer()
W.forceMove(new_location)
else
W.forceMove(get_turf(src))
W.on_exit_storage(src)
update_icon()
return 1
/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
for(var/obj/item/weapon/ore/I 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)
failure = 1
break
I.forceMove(src)
success = 1
if(success && !failure && !silent)
to_chat(user, "<span class='notice'>You put everything in [src].</span>")
else if(success && (!silent || (silent && contents.len >= max_storage_space)))
to_chat(user, "<span class='notice'>You fill the [src].</span>")
else if(!silent)
to_chat(user, "<span class='notice'>You fail to pick anything up with \the [src].</span>")
/obj/item/weapon/storage/bag/ore/examine(mob/user)
..()
if(!Adjacent(user)) //Can only check the contents of ore boxes if you can physically reach them.
return
if(istype(user, /mob/living))
add_fingerprint(user)
if(!contents.len)
to_chat(user, "It is empty.")
return
if(world.time > last_update + 10)
update_ore_count()
last_update = world.time
to_chat(user, "<span class='notice'>It holds:</span>")
for(var/ore in stored_ore)
to_chat(user, "<span class='notice'>- [stored_ore[ore]] [ore]</span>")
return
/obj/item/weapon/storage/bag/ore/open(mob/user as mob) //No opening it for the weird UI of having shit-tons of ore inside it.
if(world.time > last_update + 10)
update_ore_count()
last_update = world.time
examine(user)
/obj/item/weapon/storage/bag/ore/proc/update_ore_count() //Stolen from ore boxes.
stored_ore = list()
for(var/obj/item/weapon/ore/O in contents)
if(stored_ore[O.name])
stored_ore[O.name]++
else
stored_ore[O.name] = 1
// -----------------------------
// Plant bag
+6 -4
View File
@@ -14,12 +14,15 @@
if (istype(W, /obj/item/weapon/ore))
user.remove_from_mob(W)
src.contents += W
if (istype(W, /obj/item/weapon/storage))
else if (istype(W, /obj/item/weapon/storage))
var/obj/item/weapon/storage/S = W
if(!S.contents.len)
return
S.hide_from(usr)
for(var/obj/item/weapon/ore/O in S.contents)
S.remove_from_storage(O, src) //This will move the item to this item's contents
user << "<font color='blue'>You empty the satchel into the box.</font>"
to_chat(user,"<span class='notice'>You empty the satchel into the box.</span>")
update_ore_count()
@@ -62,13 +65,12 @@
user << "- [stored_ore[ore]] [ore]"
return
/obj/structure/ore_box/verb/empty_box()
set name = "Empty Ore Box"
set category = "Object"
set src in view(1)
if(!istype(usr, /mob/living/carbon/human)) //Only living, intelligent creatures with hands can empty ore boxes.
if(!istype(usr, /mob/living/carbon/human) && !istype(usr, /mob/living/silicon/robot)) //Only living, intelligent creatures with gripping aparatti can empty ore boxes.
usr << "<font color='red'>You are physically incapable of emptying the ore box.</font>"
return
@@ -885,6 +885,18 @@
cleaned_human.update_inv_shoes(0)
cleaned_human.clean_blood(1)
cleaned_human << "<font color='red'>[src] cleans your face!</font>"
if((module_state_1 && istype(module_state_1, /obj/item/weapon/storage/bag/ore)) || (module_state_2 && istype(module_state_2, /obj/item/weapon/storage/bag/ore)) || (module_state_3 && istype(module_state_3, /obj/item/weapon/storage/bag/ore))) //Borgs and drones can use their mining bags ~automagically~ if they're deployed in a slot. Only mining bags, as they're optimized for mass use.
var/obj/item/weapon/storage/bag/ore/B = null
if(istype(module_state_1, /obj/item/weapon/storage/bag/ore)) //First orebag has priority, if they for some reason have multiple.
B = module_state_1
else if(istype(module_state_2, /obj/item/weapon/storage/bag/ore))
B = module_state_2
else if(istype(module_state_3, /obj/item/weapon/storage/bag/ore))
B = module_state_3
var/turf/tile = loc
if(isturf(tile))
B.gather_all(tile, src, 1) //Shhh, unless the bag fills, don't spam the borg's chat with stuff that's going on every time they move!
return
/mob/living/silicon/robot/proc/self_destruct()