From 4c3d99e94c1136d4251b3c11236d90bc0dae046f Mon Sep 17 00:00:00 2001 From: Matt Atlas Date: Fri, 8 Jan 2021 18:21:15 +0100 Subject: [PATCH] Fixes table alignment once and for all plus borg item teleportation fix. (#10939) --- code/game/atoms_movable.dm | 78 +++++++++---------- code/modules/mob/inventory.dm | 19 ++--- .../mob/living/silicon/robot/inventory.dm | 25 +++--- .../mob/living/silicon/robot/items/gripper.dm | 7 +- code/modules/tables/interactions.dm | 10 ++- code/modules/tables/tables.dm | 1 - html/changelogs/mattatlas-necessaryevil.yml | 41 ++++++++++ 7 files changed, 107 insertions(+), 74 deletions(-) create mode 100644 html/changelogs/mattatlas-necessaryevil.yml diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 598ebf67d3e..8df12dab60b 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -367,49 +367,47 @@ sleep(1) animate(I, alpha = 0, transform = matrix(), time = 1) -/atom/movable/proc/do_putdown_animation(atom/target, mob/user, var/click_params) - if(QDELETED(src)) - return - if(QDELETED(target)) - return - if(QDELETED(user)) - return - var/old_invisibility = invisibility // I don't know, it may be used. Basically turns the actual object invisible while the animation plays. - invisibility = 100 - var/turf/old_turf = get_turf(user) - if(QDELETED(old_turf)) - return - var/image/I = image(icon = src, loc = old_turf, layer = layer + 0.1) - I.transform = matrix() * 0 - I.appearance_flags = (RESET_COLOR|RESET_TRANSFORM|NO_CLIENT_COLOR|RESET_ALPHA|PIXEL_SCALE) - I.pixel_x = 0 - I.pixel_y = 0 - if (istype(target,/mob)) - I.dir = target.dir +/atom/movable/proc/do_putdown_animation(atom/target, mob/user) + spawn() + if(QDELETED(src)) + return + if(QDELETED(target)) + return + if(QDELETED(user)) + return + var/old_invisibility = invisibility // I don't know, it may be used. Basically turns the actual object invisible while the animation plays. + invisibility = 100 + var/turf/old_turf = get_turf(user) + if(QDELETED(old_turf)) + return + var/image/I = image(icon = src, loc = old_turf, layer = layer + 0.1) + I.transform = matrix() * 0 + I.appearance_flags = (RESET_COLOR|RESET_TRANSFORM|NO_CLIENT_COLOR|RESET_ALPHA|PIXEL_SCALE) + I.pixel_x = 0 + I.pixel_y = 0 + if (istype(target,/mob)) + I.dir = target.dir - var/list/viewing = list() - for (var/mob/M in viewers(target)) - if (M.client) - viewing |= M.client - flick_overlay(I, viewing, 4) + var/list/viewing = list() + for (var/mob/M in viewers(target)) + if (M.client) + viewing |= M.client + flick_overlay(I, viewing, 4) - if(istype(target, /obj/structure/table)) - var/obj/structure/table/T = target - T.auto_align(src, click_params) - var/to_x = (target.x - old_turf.x) * 32 + pixel_x - var/to_y = (target.y - old_turf.y) * 32 + pixel_y - var/old_x = pixel_x - var/old_y = pixel_y - pixel_x = 0 - pixel_y = 0 + var/to_x = (target.x - old_turf.x) * 32 + pixel_x + var/to_y = (target.y - old_turf.y) * 32 + pixel_y + var/old_x = pixel_x + var/old_y = pixel_y + pixel_x = 0 + pixel_y = 0 - animate(I, pixel_x = to_x, pixel_y = to_y, time = 3, transform = matrix(), easing = CUBIC_EASING) - sleep(3) - if(QDELETED(src)) - return - invisibility = old_invisibility - pixel_x = old_x - pixel_y = old_y + animate(I, pixel_x = to_x, pixel_y = to_y, time = 3, transform = matrix(), easing = CUBIC_EASING) + sleep(3) + if(QDELETED(src)) + return + invisibility = old_invisibility + pixel_x = old_x + pixel_y = old_y /atom/movable/proc/simple_move_animation(atom/target) set waitfor = FALSE diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 020651ad395..9ae894fe523 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -187,21 +187,18 @@ var/list/slot_equipment_priority = list( \ // Removes an item from inventory and places it in the target atom. // If canremove or other conditions need to be checked then use unEquip instead. -/mob/proc/drop_from_inventory(var/obj/item/W, var/atom/target, var/click_params) +/mob/proc/drop_from_inventory(var/obj/item/W, var/atom/target) if(W) if(!target) target = loc remove_from_mob(W) if(!(W && W.loc)) - return 1 - INVOKE_ASYNC(W, /atom/movable/proc/do_putdown_animation, target, src, click_params) - if(istype(target, /obj/structure/table)) - W.forceMove(target.loc) - else - W.forceMove(target) + return TRUE + W.do_putdown_animation(target, src) + W.forceMove(target) update_icon() - return 1 - return 0 + return TRUE + return FALSE //Drops the item in our left hand /mob/proc/drop_l_hand(var/atom/target) @@ -283,10 +280,10 @@ var/list/slot_equipment_priority = list( \ return slot //This differs from remove_from_mob() in that it checks if the item can be unequipped first. -/mob/proc/unEquip(obj/item/I, force = 0, var/atom/target, var/click_params) //Force overrides NODROP for things like wizarditis and admin undress. +/mob/proc/unEquip(obj/item/I, force = 0, var/atom/target) //Force overrides NODROP for things like wizarditis and admin undress. if(!(force || canUnEquip(I))) return - drop_from_inventory(I, target, click_params) + drop_from_inventory(I, target) return 1 diff --git a/code/modules/mob/living/silicon/robot/inventory.dm b/code/modules/mob/living/silicon/robot/inventory.dm index ba65665237c..dcd5b1f666a 100644 --- a/code/modules/mob/living/silicon/robot/inventory.dm +++ b/code/modules/mob/living/silicon/robot/inventory.dm @@ -231,24 +231,24 @@ to_chat(src, "You need to disable a module first!") /mob/living/silicon/robot/put_in_hands(var/obj/item/W) // Maybe hands. - var/obj/item/gripper/G = null + var/obj/item/gripper/G if (istype(module_state_1, /obj/item/gripper)) G = module_state_1 if (!G.wrapped && G.grip_item(W, src, 1)) - return 1 + return TRUE else if (istype(module_state_2, /obj/item/gripper)) G = module_state_2 if (!G.wrapped && G.grip_item(W, src, 0)) - return 1 + return TRUE else if (istype(module_state_3, /obj/item/gripper)) G = module_state_3 if (!G.wrapped && G.grip_item(W, src, 0)) - return 1 + return TRUE W.forceMove(get_turf(src)) - return 0 + return FALSE /mob/living/silicon/robot/drop_item() @@ -257,11 +257,8 @@ if (G.wrapped) G.drop_item() return - uneq_active() - - /mob/living/silicon/robot/drop_from_inventory(var/obj/item/W, var/atom/target = null) if(W) if(!target) @@ -269,17 +266,15 @@ if (istype(W.loc, /obj/item/gripper)) var/obj/item/gripper/G = W.loc G.drop(target) - return 1 - return 0 - + return TRUE + return FALSE /mob/living/silicon/robot/canUnEquip(obj/item/I) if(!I) //If there's nothing to drop, the drop is automatically successful. - return 1 + return TRUE if (I.loc != src) - return 1//Allows objects inside grippers - return 0//don't allow dropping our modules - + return TRUE //Allows objects inside grippers + return FALSE //don't allow dropping our modules /mob/living/silicon/robot/proc/describe_module(var/slot) var/list/index_module = list(module_state_1,module_state_2,module_state_3) diff --git a/code/modules/mob/living/silicon/robot/items/gripper.dm b/code/modules/mob/living/silicon/robot/items/gripper.dm index 61d2437eda8..2d69ac0c71b 100644 --- a/code/modules/mob/living/silicon/robot/items/gripper.dm +++ b/code/modules/mob/living/silicon/robot/items/gripper.dm @@ -112,6 +112,7 @@ if(wrapped.loc == src) if(force_holder) wrapped.force = force_holder + wrapped.do_putdown_animation(target, loc) wrapped.forceMove(target) force_holder = null to_chat(loc, SPAN_NOTICE("You release \the [wrapped].")) // loc will always be the cyborg @@ -122,16 +123,16 @@ /obj/item/gripper/attack(mob/living/carbon/M, mob/living/carbon/user) if(wrapped) //The force of the wrapped obj gets set to zero during the attack() and afterattack(). force_holder = wrapped.force - wrapped.force = 0.0 + wrapped.force = 0 wrapped.attack(M,user) if(QDELETED(wrapped)) wrapped = null return TRUE else // mob interactions switch(user.a_intent) - if("help") + if(I_HELP) user.visible_message("\The [user] [pick("boops", "squeezes", "pokes", "prods", "strokes", "bonks")] \the [M] with \the [src]") - if("harm") + if(I_HURT) M.attack_generic(user, user.mob_size, "crushed")//about 16 dmg for a cyborg //Attack generic does a visible message so we dont need one here user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN * 3) diff --git a/code/modules/tables/interactions.dm b/code/modules/tables/interactions.dm index 1067af69332..9e792817c17 100644 --- a/code/modules/tables/interactions.dm +++ b/code/modules/tables/interactions.dm @@ -138,8 +138,9 @@ step(O, get_dir(O, src)) return -/obj/structure/table/attackby(obj/item/W as obj, mob/user as mob, var/click_parameters) - if (!W) return +/obj/structure/table/attackby(obj/item/W, mob/user, var/click_parameters) + if (!W) + return // Handle harm intent grabbing/tabling. if(istype(W, /obj/item/grab) && get_dist(src,user)<2) @@ -201,9 +202,10 @@ return // Placing stuff on tables - if(user.unEquip(W, 0, src, click_parameters)) + if(user.unEquip(W, 0, loc)) //Loc is intentional here so we don't forceMove() items into oblivion user.make_item_drop_sound(W) - return 1 + auto_align(W, click_parameters) + return #define CELLS 8 //Amount of cells per row/column in grid #define CELLSIZE (world.icon_size/CELLS) //Size of a cell in pixels diff --git a/code/modules/tables/tables.dm b/code/modules/tables/tables.dm index bd81b757b57..574090ace9f 100644 --- a/code/modules/tables/tables.dm +++ b/code/modules/tables/tables.dm @@ -101,7 +101,6 @@ to_chat(user, "It has a few scrapes and dents.") /obj/structure/table/attackby(obj/item/W, mob/user) - if(reinforced && W.isscrewdriver()) remove_reinforced(W, user) if(!reinforced) diff --git a/html/changelogs/mattatlas-necessaryevil.yml b/html/changelogs/mattatlas-necessaryevil.yml new file mode 100644 index 00000000000..bbc21fea018 --- /dev/null +++ b/html/changelogs/mattatlas-necessaryevil.yml @@ -0,0 +1,41 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: MattAtlas + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Fixed borgs teleporting items into oblivion and funky table alignment antics."