From e582e7019e57f4b5c7629d3a5519202984899b36 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 25 May 2018 11:48:50 -0400 Subject: [PATCH 1/2] Merge pull request #38023 from AutomaticFrenzy/patch/toh-kay Fix various bugs with telekinesis --- code/__HELPERS/unsorted.dm | 14 ++++++++------ code/_onclick/click.dm | 2 +- code/_onclick/telekinesis.dm | 8 +++++++- code/datums/components/material_container.dm | 14 ++++++++------ code/game/objects/items/stacks/sheets/mineral.dm | 5 +++-- code/game/objects/items/tools/crowbar.dm | 2 +- code/game/objects/items/tools/screwdriver.dm | 2 +- code/game/objects/items/tools/wirecutters.dm | 2 +- code/game/objects/items/tools/wrench.dm | 2 +- .../kitchen_machinery/deep_fryer.dm | 5 ++++- 10 files changed, 35 insertions(+), 21 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 4230138cf6..e1a41f1d49 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -944,7 +944,7 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list( else return "white" -/proc/params2turf(scr_loc, turf/origin) +/proc/params2turf(scr_loc, turf/origin, client/C) if(!scr_loc) return null var/tX = splittext(scr_loc, ",") @@ -953,11 +953,12 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list( tY = tY[1] tX = splittext(tX[1], ":") tX = tX[1] - tX = CLAMP(origin.x + text2num(tX) - world.view - 1, 1, world.maxx) - tY = CLAMP(origin.y + text2num(tY) - world.view - 1, 1, world.maxy) + var/list/actual_view = getviewsize(C ? C.view : world.view) + tX = CLAMP(origin.x + text2num(tX) - round(actual_view[1] / 2) - 1, 1, world.maxx) + tY = CLAMP(origin.y + text2num(tY) - round(actual_view[2] / 2) - 1, 1, world.maxy) return locate(tX, tY, tZ) -/proc/screen_loc2turf(text, turf/origin) +/proc/screen_loc2turf(text, turf/origin, client/C) if(!text) return null var/tZ = splittext(text, ",") @@ -966,8 +967,9 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list( tX = splittext(tZ[2], "-") tX = text2num(tX[2]) tZ = origin.z - tX = CLAMP(origin.x + 7 - tX, 1, world.maxx) - tY = CLAMP(origin.y + 7 - tY, 1, world.maxy) + var/list/actual_view = getviewsize(C ? C.view : world.view) + tX = CLAMP(origin.x + round(actual_view[1] / 2) - tX, 1, world.maxx) + tY = CLAMP(origin.y + round(actual_view[2] / 2) - tY, 1, world.maxy) return locate(tX, tY, tZ) /proc/IsValidSrc(datum/D) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index dfa2a27ded..6a3778b451 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -473,7 +473,7 @@ var/mob/living/carbon/C = usr C.swap_hand() else - var/turf/T = params2turf(modifiers["screen-loc"], get_turf(usr.client ? usr.client.eye : usr)) + var/turf/T = params2turf(modifiers["screen-loc"], get_turf(usr.client ? usr.client.eye : usr), usr.client) params += "&catcher=1" if(T) T.Click(location, control, params) diff --git a/code/_onclick/telekinesis.dm b/code/_onclick/telekinesis.dm index a060cbb834..18f1c61d94 100644 --- a/code/_onclick/telekinesis.dm +++ b/code/_onclick/telekinesis.dm @@ -15,7 +15,7 @@ /atom/proc/attack_tk(mob/user) if(user.stat || !tkMaxRangeCheck(user, src)) return - new /obj/effect/temp_visual/telekinesis(loc) + new /obj/effect/temp_visual/telekinesis(get_turf(src)) user.UnarmedAttack(src,0) // attack_hand, attack_paw, etc add_hiddenprint(user) return @@ -104,6 +104,12 @@ qdel(src) return +/obj/item/tk_grab/examine(user) + if (focus) + focus.examine(user) + else + ..() + /obj/item/tk_grab/attack_self(mob/user) if(!focus) return diff --git a/code/datums/components/material_container.dm b/code/datums/components/material_container.dm index 94dc92c0b9..e167cbb092 100644 --- a/code/datums/components/material_container.dm +++ b/code/datums/components/material_container.dm @@ -58,6 +58,8 @@ return if(user.a_intent != INTENT_HELP) return + if(I.flags_1 & ABSTRACT_1) + return if((I.flags_1 & HOLOGRAM_1) || (I.item_flags & NO_MAT_REDEMPTION) || (tc && !is_type_in_typecache(I, tc))) to_chat(user, "[parent] won't accept [I]!") return @@ -77,13 +79,14 @@ /datum/component/material_container/proc/user_insert(obj/item/I, mob/living/user) set waitfor = FALSE var/requested_amount + var/active_held = user.get_active_held_item() // differs from I when using TK if(istype(I, /obj/item/stack) && precise_insertion) var/atom/current_parent = parent var/obj/item/stack/S = I requested_amount = input(user, "How much do you want to insert?", "Inserting [S.singular_name]s") as num|null if(isnull(requested_amount) || (requested_amount <= 0)) return - if(QDELETED(I) || QDELETED(user) || QDELETED(src) || parent != current_parent || !user.canUseTopic(current_parent, BE_CLOSE) || !user.is_holding(I)) + if(QDELETED(I) || QDELETED(user) || QDELETED(src) || parent != current_parent || user.physical_can_use_topic(current_parent) < UI_INTERACTIVE || user.get_active_held_item() != active_held) return if(!user.temporarilyRemoveItemFromInventory(I)) to_chat(user, "[I] is stuck to you and cannot be placed into [parent].") @@ -93,16 +96,15 @@ if(istype(I, /obj/item/stack)) var/obj/item/stack/S = I to_chat(user, "You insert [inserted] [S.singular_name][inserted>1 ? "s" : ""] into [parent].") - if(!QDELETED(I)) - if(!user.put_in_hands(I)) - stack_trace("Warning: User could not put object back in hand during material container insertion, line [__LINE__]! This can lead to issues.") - I.forceMove(user.drop_location()) + if(!QDELETED(I) && I == active_held && !user.put_in_hands(I)) + stack_trace("Warning: User could not put object back in hand during material container insertion, line [__LINE__]! This can lead to issues.") + I.forceMove(user.drop_location()) else to_chat(user, "You insert a material total of [inserted] into [parent].") qdel(I) if(after_insert) after_insert.Invoke(I.type, last_inserted_id, inserted) - else + else if(I == active_held) user.put_in_active_hand(I) //For inserting an amount of material diff --git a/code/game/objects/items/stacks/sheets/mineral.dm b/code/game/objects/items/stacks/sheets/mineral.dm index 719835e872..be7507e3d2 100644 --- a/code/game/objects/items/stacks/sheets/mineral.dm +++ b/code/game/objects/items/stacks/sheets/mineral.dm @@ -84,9 +84,10 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \ if(istype(W, /obj/item/stack/ore/glass)) var/obj/item/stack/ore/glass/G = W to_chat(user, "You fill the sandbag.") - var/obj/item/stack/sheet/mineral/sandbags/I = new /obj/item/stack/sheet/mineral/sandbags + var/obj/item/stack/sheet/mineral/sandbags/I = new /obj/item/stack/sheet/mineral/sandbags(drop_location()) qdel(src) - user.put_in_hands(I) + if (Adjacent(user) && !issilicon(user)) + user.put_in_hands(I) G.use(1) else return ..() diff --git a/code/game/objects/items/tools/crowbar.dm b/code/game/objects/items/tools/crowbar.dm index 0684da08b2..6cee5def2a 100644 --- a/code/game/objects/items/tools/crowbar.dm +++ b/code/game/objects/items/tools/crowbar.dm @@ -82,7 +82,7 @@ /obj/item/crowbar/power/attack_self(mob/user) playsound(get_turf(user), 'sound/items/change_jaws.ogg', 50, 1) - var/obj/item/wirecutters/power/cutjaws = new /obj/item/wirecutters/power + var/obj/item/wirecutters/power/cutjaws = new /obj/item/wirecutters/power(drop_location()) to_chat(user, "You attach the cutting jaws to [src].") qdel(src) user.put_in_active_hand(cutjaws) \ No newline at end of file diff --git a/code/game/objects/items/tools/screwdriver.dm b/code/game/objects/items/tools/screwdriver.dm index a29c103fda..123ffaa76c 100644 --- a/code/game/objects/items/tools/screwdriver.dm +++ b/code/game/objects/items/tools/screwdriver.dm @@ -123,7 +123,7 @@ /obj/item/screwdriver/power/attack_self(mob/user) playsound(get_turf(user),'sound/items/change_drill.ogg',50,1) - var/obj/item/wrench/power/b_drill = new /obj/item/wrench/power + var/obj/item/wrench/power/b_drill = new /obj/item/wrench/power(drop_location()) to_chat(user, "You attach the bolt driver bit to [src].") qdel(src) user.put_in_active_hand(b_drill) diff --git a/code/game/objects/items/tools/wirecutters.dm b/code/game/objects/items/tools/wirecutters.dm index 33c7be5dfd..2bf9c93ff9 100644 --- a/code/game/objects/items/tools/wirecutters.dm +++ b/code/game/objects/items/tools/wirecutters.dm @@ -107,7 +107,7 @@ /obj/item/wirecutters/power/attack_self(mob/user) playsound(get_turf(user), 'sound/items/change_jaws.ogg', 50, 1) - var/obj/item/crowbar/power/pryjaws = new /obj/item/crowbar/power + var/obj/item/crowbar/power/pryjaws = new /obj/item/crowbar/power(drop_location()) to_chat(user, "You attach the pry jaws to [src].") qdel(src) user.put_in_active_hand(pryjaws) diff --git a/code/game/objects/items/tools/wrench.dm b/code/game/objects/items/tools/wrench.dm index 9a9a3684c3..dc78e9aace 100644 --- a/code/game/objects/items/tools/wrench.dm +++ b/code/game/objects/items/tools/wrench.dm @@ -62,7 +62,7 @@ /obj/item/wrench/power/attack_self(mob/user) playsound(get_turf(user),'sound/items/change_drill.ogg',50,1) - var/obj/item/wirecutters/power/s_drill = new /obj/item/screwdriver/power + var/obj/item/wirecutters/power/s_drill = new /obj/item/screwdriver/power(drop_location()) to_chat(user, "You attach the screw driver bit to [src].") qdel(src) user.put_in_active_hand(s_drill) diff --git a/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm b/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm index ebea393397..0f3985040f 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/deep_fryer.dm @@ -30,6 +30,7 @@ God bless America. use_power = IDLE_POWER_USE idle_power_usage = 5 container_type = OPENCONTAINER + layer = BELOW_OBJ_LAYER var/obj/item/reagent_containers/food/snacks/deepfryholder/frying //What's being fried RIGHT NOW? var/cook_time = 0 var/oil_use = 0.05 //How much cooking oil is used per tick @@ -127,7 +128,9 @@ God bless America. to_chat(user, "You eject [frying] from [src].") frying.fry(cook_time) icon_state = "fryer_off" - user.put_in_hands(frying) + frying.forceMove(drop_location()) + if(Adjacent(user) && !issilicon(user)) + user.put_in_hands(frying) frying = null cook_time = 0 frying_fried = FALSE