diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 6fc470cc81..0cc03b6df7 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -103,7 +103,7 @@ var/sdepth = A.storage_depth(src) if((!isturf(A) && A == loc) || (sdepth != -1 && sdepth <= 1)) if(W) - var/resolved = W.resolve_attackby(A, src) + var/resolved = W.resolve_attackby(A, src, params) if(!resolved && A && W) W.afterattack(A, src, 1, params) // 1 indicates adjacency else @@ -143,7 +143,7 @@ if(A.Adjacent(src) || (W && W.attack_can_reach(src, A, W.reach)) ) // see adjacent.dm if(W) // Return 1 in attackby() to prevent afterattack() effects (when safely moving items for example) - var/resolved = W.resolve_attackby(A,src) + var/resolved = W.resolve_attackby(A,src, params) if(!resolved && A && W) W.afterattack(A, src, 1, params) // 1: clicking something Adjacent else diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 15129285c3..047d4d6a48 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -28,13 +28,13 @@ avoid code duplication. This includes items that may sometimes act as a standard return //I would prefer to rename this to attack(), but that would involve touching hundreds of files. -/obj/item/proc/resolve_attackby(atom/A, mob/user, var/attack_modifier = 1) +/obj/item/proc/resolve_attackby(atom/A, mob/user, var/attack_modifier = 1, var/click_parameters) pre_attack(A, user) add_fingerprint(user) - return A.attackby(src, user, attack_modifier) + return A.attackby(src, user, attack_modifier, click_parameters) // No comment -/atom/proc/attackby(obj/item/W, mob/user, var/attack_modifier) +/atom/proc/attackby(obj/item/W, mob/user, var/attack_modifier, var/click_parameters) return /atom/movable/attackby(obj/item/W, mob/user, var/attack_modifier) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 3bacfb8d2d..78f8ab4ffe 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -4,6 +4,7 @@ w_class = ITEMSIZE_NORMAL var/image/blood_overlay = null //this saves our blood splatter overlay, which will be processed not to go over the edges of the sprite + var/randpixel = 6 var/abstract = 0 var/r_speed = 1.0 var/health = null @@ -282,6 +283,8 @@ // called just as an item is picked up (loc is not yet changed) /obj/item/proc/pickup(mob/user) + pixel_x = 0 + pixel_y = 0 return // called when this item is removed from a storage item, which is passed on as S. The loc variable is already set to the new destination before this is called. @@ -711,6 +714,16 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out. /obj/item/proc/in_inactive_hand(mob/user) return +//Used for selecting a random pixel placement, usually on initialize. Checks for pixel_x/y to not interfere with mapped in items. +/obj/item/proc/randpixel_xy() + if(!pixel_x && !pixel_y) + pixel_x = rand(-randpixel, randpixel) + pixel_y = rand(-randpixel, randpixel) + return TRUE + else + return FALSE + + // My best guess as to why this is here would be that it does so little. Still, keep it under all the procs, for sanity's sake. /obj/item/device icon = 'icons/obj/device.dmi' diff --git a/code/game/objects/items/devices/flashlight.dm b/code/game/objects/items/devices/flashlight.dm index 176d2d6bab..6930e5f26d 100644 --- a/code/game/objects/items/devices/flashlight.dm +++ b/code/game/objects/items/devices/flashlight.dm @@ -295,6 +295,7 @@ desc = "A desk lamp with an adjustable mount." icon_state = "lamp" force = 10 + center_of_mass = list("x" = 13,"y" = 11) brightness_on = 10 //TFF 27/11/19 - post refactor fix for intensity levels. w_class = ITEMSIZE_LARGE power_use = 0 @@ -305,6 +306,7 @@ /obj/item/device/flashlight/lamp/green desc = "A classic green-shaded desk lamp." icon_state = "lampgreen" + center_of_mass = list("x" = 15,"y" = 11) brightness_on = 5 flashlight_colour = "#FFC58F" diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 1a50df2e3e..324ade23ce 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -13,6 +13,8 @@ gender = PLURAL origin_tech = list(TECH_MATERIAL = 1) icon = 'icons/obj/stacks.dmi' + randpixel = 7 + center_of_mass = null var/list/datum/stack_recipe/recipes var/singular_name var/amount = 1 diff --git a/code/game/objects/items/stacks/tiles/tile_types.dm b/code/game/objects/items/stacks/tiles/tile_types.dm index 7c441e8169..357ff7e125 100644 --- a/code/game/objects/items/stacks/tiles/tile_types.dm +++ b/code/game/objects/items/stacks/tiles/tile_types.dm @@ -14,13 +14,13 @@ name = "tile" singular_name = "tile" desc = "A non-descript floor tile" + randpixel = 7 w_class = ITEMSIZE_NORMAL max_amount = 60 /obj/item/stack/tile/New() ..() - pixel_x = rand(-7, 7) - pixel_y = rand(-7, 7) + randpixel_xy() /* * Grass diff --git a/code/game/objects/items/weapons/cigs_lighters.dm b/code/game/objects/items/weapons/cigs_lighters.dm index 9d05d1541c..d8fe6304c5 100644 --- a/code/game/objects/items/weapons/cigs_lighters.dm +++ b/code/game/objects/items/weapons/cigs_lighters.dm @@ -359,14 +359,14 @@ CIGARETTE PACKETS ARE IN FANCY.DM desc = "A manky old cigarette butt." icon = 'icons/obj/clothing/masks.dmi' icon_state = "cigbutt" + randpixel = 10 w_class = ITEMSIZE_TINY slot_flags = SLOT_EARS throwforce = 1 /obj/item/weapon/cigbutt/Initialize() . = ..() - pixel_x = rand(-10,10) - pixel_y = rand(-10,10) + randpixel_xy() transform = turn(transform,rand(0,360)) /obj/item/weapon/cigbutt/cigarbutt diff --git a/code/game/objects/items/weapons/id cards/cards.dm b/code/game/objects/items/weapons/id cards/cards.dm index c84c4f781e..2b153bab21 100644 --- a/code/game/objects/items/weapons/id cards/cards.dm +++ b/code/game/objects/items/weapons/id cards/cards.dm @@ -70,10 +70,10 @@ origin_tech = list(TECH_MAGNET = 2, TECH_ILLEGAL = 2) var/uses = 10 -/obj/item/weapon/card/emag/resolve_attackby(atom/A, mob/user) +/obj/item/weapon/card/emag/resolve_attackby(atom/A, mob/user, var/click_parameters) var/used_uses = A.emag_act(uses, user, src) if(used_uses < 0) - return ..(A, user) + return ..(A, user, click_parameters) uses -= used_uses A.add_fingerprint(user) diff --git a/code/game/objects/items/weapons/material/ashtray.dm b/code/game/objects/items/weapons/material/ashtray.dm index 5cf907fbf5..5cd017f005 100644 --- a/code/game/objects/items/weapons/material/ashtray.dm +++ b/code/game/objects/items/weapons/material/ashtray.dm @@ -4,6 +4,7 @@ var/global/list/ashtray_cache = list() name = "ashtray" icon = 'icons/obj/objects.dmi' icon_state = "blank" + randpixel = 5 force_divisor = 0.1 thrown_force_divisor = 0.1 var/image/base_image @@ -15,8 +16,7 @@ var/global/list/ashtray_cache = list() qdel(src) return max_butts = round(material.hardness/5) //This is arbitrary but whatever. - src.pixel_y = rand(-5, 5) - src.pixel_x = rand(-6, 6) + randpixel_xy() update_icon() return diff --git a/code/game/objects/items/weapons/material/shards.dm b/code/game/objects/items/weapons/material/shards.dm index 39ece8873b..f98959ff2e 100644 --- a/code/game/objects/items/weapons/material/shards.dm +++ b/code/game/objects/items/weapons/material/shards.dm @@ -5,6 +5,7 @@ icon = 'icons/obj/shards.dmi' desc = "Made of nothing. How does this even exist?" // set based on material, if this desc is visible it's a bug (shards default to being made of glass) icon_state = "large" + randpixel = 8 sharp = 1 edge = 1 w_class = ITEMSIZE_SMALL @@ -28,8 +29,7 @@ return icon_state = "[material.shard_icon][pick("large", "medium", "small")]" - pixel_x = rand(-8, 8) - pixel_y = rand(-8, 8) + randpixel_xy() update_icon() if(material.shard_type) diff --git a/code/game/objects/items/weapons/storage/boxes.dm b/code/game/objects/items/weapons/storage/boxes.dm index 3fa442ab6d..669ca244f8 100644 --- a/code/game/objects/items/weapons/storage/boxes.dm +++ b/code/game/objects/items/weapons/storage/boxes.dm @@ -24,6 +24,7 @@ desc = "It's just an ordinary box." icon_state = "box" item_state = "syringe_kit" + center_of_mass = list("x" = 13,"y" = 10) var/foldable = /obj/item/stack/material/cardboard // BubbleWrap - if set, can be folded (when empty) into a sheet of cardboard max_w_class = ITEMSIZE_SMALL max_storage_space = INVENTORY_BOX_SPACE diff --git a/code/game/objects/items/weapons/storage/fancy.dm b/code/game/objects/items/weapons/storage/fancy.dm index a5efceb72b..830f5a2631 100644 --- a/code/game/objects/items/weapons/storage/fancy.dm +++ b/code/game/objects/items/weapons/storage/fancy.dm @@ -47,6 +47,7 @@ icon_state = "eggbox" icon_type = "egg" name = "egg box" + center_of_mass = list("x" = 16,"y" = 7) storage_slots = 12 can_hold = list( /obj/item/weapon/reagent_containers/food/snacks/egg, diff --git a/code/game/objects/items/weapons/storage/misc.dm b/code/game/objects/items/weapons/storage/misc.dm index 3d3c3aad83..9f6d4929b8 100644 --- a/code/game/objects/items/weapons/storage/misc.dm +++ b/code/game/objects/items/weapons/storage/misc.dm @@ -7,6 +7,7 @@ icon_state = "donutbox" name = "donut box" desc = "A box that holds tasty donuts, if you're lucky." + center_of_mass = list("x" = 16,"y" = 9) max_storage_space = ITEMSIZE_COST_SMALL * 6 can_hold = list(/obj/item/weapon/reagent_containers/food/snacks/donut) foldable = /obj/item/stack/material/cardboard diff --git a/code/game/objects/items/weapons/storage/toolbox.dm b/code/game/objects/items/weapons/storage/toolbox.dm index 8edc046972..9ce324c44e 100644 --- a/code/game/objects/items/weapons/storage/toolbox.dm +++ b/code/game/objects/items/weapons/storage/toolbox.dm @@ -4,6 +4,7 @@ icon = 'icons/obj/storage.dmi' icon_state = "red" item_state_slots = list(slot_r_hand_str = "toolbox_red", slot_l_hand_str = "toolbox_red") + center_of_mass = list("x" = 16,"y" = 11) force = 10 throwforce = 10 throw_speed = 1 diff --git a/code/game/objects/items/weapons/tools/screwdriver.dm b/code/game/objects/items/weapons/tools/screwdriver.dm index e07bb1155d..d63692635d 100644 --- a/code/game/objects/items/weapons/tools/screwdriver.dm +++ b/code/game/objects/items/weapons/tools/screwdriver.dm @@ -6,6 +6,7 @@ desc = "You can be totally screwwy with this." icon = 'icons/obj/tools.dmi' icon_state = "screwdriver" + center_of_mass = list("x" = 13,"y" = 7) slot_flags = SLOT_BELT | SLOT_EARS force = 6 w_class = ITEMSIZE_TINY diff --git a/code/game/objects/items/weapons/tools/wirecutters.dm b/code/game/objects/items/weapons/tools/wirecutters.dm index 4d61609db4..4cfc99487c 100644 --- a/code/game/objects/items/weapons/tools/wirecutters.dm +++ b/code/game/objects/items/weapons/tools/wirecutters.dm @@ -6,6 +6,7 @@ desc = "This cuts wires." icon = 'icons/obj/tools.dmi' icon_state = "cutters" + center_of_mass = list("x" = 18,"y" = 10) slot_flags = SLOT_BELT force = 6 throw_speed = 2 diff --git a/code/game/objects/items/weapons/traps.dm b/code/game/objects/items/weapons/traps.dm index 0e452bd535..ab71c0cec5 100644 --- a/code/game/objects/items/weapons/traps.dm +++ b/code/game/objects/items/weapons/traps.dm @@ -6,6 +6,8 @@ icon = 'icons/obj/items.dmi' icon_state = "beartrap0" desc = "A mechanically activated leg trap. Low-tech, but reliable. Looks like it could really hurt if you set it off." + randpixel = 0 + center_of_mass = null throwforce = 0 w_class = ITEMSIZE_NORMAL origin_tech = list(TECH_MATERIAL = 1) diff --git a/code/game/objects/structures/stool_bed_chair_nest/bed.dm b/code/game/objects/structures/stool_bed_chair_nest/bed.dm index d0de7a71ea..92148d56c4 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/bed.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/bed.dm @@ -231,6 +231,7 @@ desc = "A collapsed roller bed that can be carried around." icon = 'icons/obj/rollerbed.dmi' icon_state = "folded_rollerbed" + center_of_mass = list("x" = 17,"y" = 7) slot_flags = SLOT_BACK w_class = ITEMSIZE_LARGE var/rollertype = /obj/item/roller diff --git a/code/game/objects/structures/stool_bed_chair_nest/stools.dm b/code/game/objects/structures/stool_bed_chair_nest/stools.dm index b3b8f0f457..24a069afcf 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/stools.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/stools.dm @@ -6,6 +6,8 @@ var/global/list/stool_cache = list() //haha stool desc = "Apply butt." icon = 'icons/obj/furniture_vr.dmi' //VOREStation Edit - new Icons icon_state = "stool_preview" //set for the map + randpixel = 0 + center_of_mass = null force = 10 throwforce = 10 w_class = ITEMSIZE_HUGE diff --git a/code/game/turfs/simulated/floor_attackby.dm b/code/game/turfs/simulated/floor_attackby.dm index 83d2444f96..f3368b5115 100644 --- a/code/game/turfs/simulated/floor_attackby.dm +++ b/code/game/turfs/simulated/floor_attackby.dm @@ -156,4 +156,6 @@ return if(flooring) return + if(!istype(W)) + return attackby(T, user) \ No newline at end of file diff --git a/code/modules/clothing/shoes/magboots.dm b/code/modules/clothing/shoes/magboots.dm index 21e83f4185..bb4dd13fdb 100644 --- a/code/modules/clothing/shoes/magboots.dm +++ b/code/modules/clothing/shoes/magboots.dm @@ -5,6 +5,7 @@ item_flags = PHORONGUARD item_state_slots = list(slot_r_hand_str = "magboots", slot_l_hand_str = "magboots") species_restricted = null + center_of_mass = list("x" = 17,"y" = 12) force = 3 overshoes = 1 shoes_under_pants = -1 //These things are huge diff --git a/code/modules/clothing/spacesuits/spacesuits.dm b/code/modules/clothing/spacesuits/spacesuits.dm index 300368260a..84ba6d8835 100644 --- a/code/modules/clothing/spacesuits/spacesuits.dm +++ b/code/modules/clothing/spacesuits/spacesuits.dm @@ -6,6 +6,8 @@ name = "Space helmet" icon_state = "space" desc = "A special helmet designed for work in a hazardous, low-pressure environment." + randpixel = 0 + center_of_mass = null flags = PHORONGUARD item_flags = THICKMATERIAL | AIRTIGHT | ALLOW_SURVIVALFOOD permeability_coefficient = 0.01 diff --git a/code/modules/clothing/suits/bio.dm b/code/modules/clothing/suits/bio.dm index 0b447470e8..5fb635bca2 100644 --- a/code/modules/clothing/suits/bio.dm +++ b/code/modules/clothing/suits/bio.dm @@ -3,6 +3,8 @@ name = "bio hood" icon_state = "bio" desc = "A hood that protects the head and face from biological comtaminants." + randpixel = 0 + center_of_mass = null permeability_coefficient = 0.01 armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 100, rad = 20) flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|BLOCKHAIR diff --git a/code/modules/food/food.dm b/code/modules/food/food.dm index 1e91e48ae0..6a0fa1f0ab 100644 --- a/code/modules/food/food.dm +++ b/code/modules/food/food.dm @@ -9,8 +9,6 @@ volume = 50 //Sets the default container amount for all food items. var/filling_color = "#FFFFFF" //Used by sandwiches. - var/list/center_of_mass = list() // Used for table placement - /obj/item/weapon/reagent_containers/food/Initialize() . = ..() if (center_of_mass.len && !pixel_x && !pixel_y) diff --git a/code/modules/food/food/cans.dm b/code/modules/food/food/cans.dm index 1c0071e47e..22b2b31125 100644 --- a/code/modules/food/food/cans.dm +++ b/code/modules/food/food/cans.dm @@ -19,7 +19,7 @@ name = "bottled water" desc = "Introduced to the vending machines by Skrellian request, this water comes straight from the Martian poles." icon_state = "waterbottle" - center_of_mass = list("x"=15, "y"=8) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/waterbottle/Initialize() . = ..() @@ -29,7 +29,7 @@ name = "\improper Space Mountain Wind" desc = "Blows right through you like a space wind." icon_state = "space_mountain_wind" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/space_mountain_wind/Initialize() ..() @@ -39,7 +39,7 @@ name = "\improper Thirteen Loko" desc = "The CMO has advised crew members that consumption of Thirteen Loko may result in seizures, blindness, drunkeness, or even death. Please Drink Responsibly." icon_state = "thirteen_loko" - center_of_mass = list("x"=16, "y"=8) + center_of_mass = list("x"=16, "y"=10) /obj/item/weapon/reagent_containers/food/drinks/cans/thirteenloko/Initialize() . = ..() @@ -49,7 +49,7 @@ name = "\improper Dr. Gibb" desc = "A delicious mixture of 42 different flavors." icon_state = "dr_gibb" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/dr_gibb/Initialize() ..() @@ -59,7 +59,7 @@ name = "\improper Star-kist" desc = "The taste of a star in liquid form. And, a bit of tuna...?" icon_state = "starkist" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/starkist/Initialize() . = ..() @@ -69,7 +69,7 @@ name = "\improper Space-Up" desc = "Tastes like a hull breach in your mouth." icon_state = "space-up" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/space_up/Initialize() ..() @@ -79,7 +79,7 @@ name = "\improper Lemon-Lime" desc = "You wanted ORANGE. It gave you Lemon Lime." icon_state = "lemon-lime" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/lemon_lime/Initialize() ..() @@ -89,7 +89,7 @@ name = "\improper Vrisk Serket Iced Tea" desc = "That sweet, refreshing southern earthy flavor. That's where it's from, right? South Earth?" icon_state = "ice_tea_can" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/iced_tea/Initialize() ..() @@ -99,7 +99,7 @@ name = "\improper Grapel Juice" desc = "500 pages of rules of how to appropriately enter into a combat with this juice!" icon_state = "purple_can" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/grape_juice/Initialize() ..() @@ -109,7 +109,7 @@ name = "\improper T-Borg's Tonic Water" desc = "Quinine tastes funny, but at least it'll keep that Space Malaria away." icon_state = "tonic" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/tonic/Initialize() . = ..() @@ -119,7 +119,7 @@ name = "soda water" desc = "A can of soda water. Still water's more refreshing cousin." icon_state = "sodawater" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/sodawater/Initialize() . = ..() @@ -129,7 +129,7 @@ name = "\improper Classic Ginger Ale" desc = "For when you need to be more retro than NanoTrasen already pays you for." icon_state = "gingerale" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/drinks/cans/gingerale/Initialize() . = ..() diff --git a/code/modules/food/food/condiment.dm b/code/modules/food/food/condiment.dm index 918f741efc..44558b1855 100644 --- a/code/modules/food/food/condiment.dm +++ b/code/modules/food/food/condiment.dm @@ -83,12 +83,12 @@ name = "Salt Shaker" desc = "Salt. From space oceans, presumably." icon_state = "saltshaker" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=17, "y"=11) if("blackpepper") name = "Pepper Mill" desc = "Often used to flavor food or make people sneeze." icon_state = "peppermillsmall" - center_of_mass = list("x"=16, "y"=10) + center_of_mass = list("x"=17, "y"=11) if("cornoil") name = "Corn Oil" desc = "A delicious oil used in cooking. Made from corn." @@ -159,6 +159,7 @@ name = "salt shaker" // a large one. desc = "Salt. From space oceans, presumably." icon_state = "saltshakersmall" + center_of_mass = list("x"=17, "y"=11) /obj/item/weapon/reagent_containers/food/condiment/small/saltshaker/Initialize() . = ..() @@ -168,6 +169,7 @@ name = "pepper mill" desc = "Often used to flavor food or make people sneeze." icon_state = "peppermillsmall" + center_of_mass = list("x"=17, "y"=11) /obj/item/weapon/reagent_containers/food/condiment/small/peppermill/Initialize() . = ..() @@ -379,6 +381,7 @@ desc = "A big bag of flour. Good for baking!" icon = 'icons/obj/food.dmi' icon_state = "flour" + center_of_mass = list("x"=16, "y"=8) /obj/item/weapon/reagent_containers/food/condiment/flour/on_reagent_change() return @@ -386,5 +389,4 @@ /obj/item/weapon/reagent_containers/food/condiment/flour/Initialize() . = ..() reagents.add_reagent("flour", 30) - src.pixel_x = rand(-10.0, 10) - src.pixel_y = rand(-10.0, 10) + randpixel_xy() diff --git a/code/modules/food/food/snacks.dm b/code/modules/food/food/snacks.dm index 03481d474c..7e21459df4 100644 --- a/code/modules/food/food/snacks.dm +++ b/code/modules/food/food/snacks.dm @@ -3265,6 +3265,7 @@ desc = "A box suited for pizzas." icon = 'icons/obj/food.dmi' icon_state = "pizzabox1" + center_of_mass = list("x" = 16,"y" = 6) var/open = 0 // Is the box open? var/ismessy = 0 // Fancy mess on the lid diff --git a/code/modules/games/cards.dm b/code/modules/games/cards.dm index 08d762e093..fbe703868f 100644 --- a/code/modules/games/cards.dm +++ b/code/modules/games/cards.dm @@ -453,4 +453,5 @@ update_icon() /obj/item/weapon/hand/pickup(mob/user as mob) + ..() src.update_icon() diff --git a/code/modules/materials/material_sheets.dm b/code/modules/materials/material_sheets.dm index f6708481b5..287e35be27 100644 --- a/code/modules/materials/material_sheets.dm +++ b/code/modules/materials/material_sheets.dm @@ -6,6 +6,7 @@ w_class = ITEMSIZE_NORMAL throw_speed = 3 throw_range = 3 + center_of_mass = null max_amount = 50 item_icons = list( slot_l_hand_str = 'icons/mob/items/lefthand_material.dmi', @@ -19,8 +20,7 @@ /obj/item/stack/material/New() ..() - pixel_x = rand(0,4)-4 - pixel_y = rand(0,4)-4 + randpixel_xy() if(!default_type) default_type = DEFAULT_WALL_MATERIAL diff --git a/code/modules/mining/coins.dm b/code/modules/mining/coins.dm index 85a1df37d0..b5f0a92103 100644 --- a/code/modules/mining/coins.dm +++ b/code/modules/mining/coins.dm @@ -5,6 +5,7 @@ name = "Coin" desc = "A simple coin you can flip." icon_state = "coin" + randpixel = 8 force = 0.0 throwforce = 0.0 w_class = ITEMSIZE_TINY @@ -13,8 +14,7 @@ var/sides = 2 /obj/item/weapon/coin/New() - pixel_x = rand(0,16)-8 - pixel_y = rand(0,8)-8 + randpixel_xy() /obj/item/weapon/coin/gold name = "gold coin" diff --git a/code/modules/mining/ore.dm b/code/modules/mining/ore.dm index 9040f27e10..81076ca8e3 100644 --- a/code/modules/mining/ore.dm +++ b/code/modules/mining/ore.dm @@ -2,6 +2,7 @@ name = "small rock" icon = 'icons/obj/mining.dmi' icon_state = "ore2" + randpixel = 8 w_class = ITEMSIZE_SMALL var/datum/geosample/geologic_data var/material @@ -113,8 +114,7 @@ material = null /obj/item/weapon/ore/New() - pixel_x = rand(0,16)-8 - pixel_y = rand(0,8)-8 + randpixel_xy() /obj/item/weapon/ore/attackby(obj/item/weapon/W as obj, mob/user as mob) if(istype(W,/obj/item/device/core_sampler)) diff --git a/code/modules/mob/holder.dm b/code/modules/mob/holder.dm index 1755ec85ce..0febfdc5c4 100644 --- a/code/modules/mob/holder.dm +++ b/code/modules/mob/holder.dm @@ -5,6 +5,8 @@ var/list/holder_mob_icon_cache = list() name = "holder" desc = "You shouldn't ever see this." icon = 'icons/obj/objects.dmi' + randpixel = 0 + center_of_mass = null slot_flags = SLOT_HEAD | SLOT_HOLSTER show_messages = 1 diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 0f0f95d336..be4c06f55b 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -133,7 +133,7 @@ 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 = null) +/mob/proc/drop_from_inventory(var/obj/item/W, var/atom/target) if(W) remove_from_mob(W, target) if(!(W && W.loc)) @@ -187,10 +187,10 @@ var/list/slot_equipment_priority = list( \ //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) //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) + drop_from_inventory(I, target) return 1 diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 78981e6c45..7b09f39ca0 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -774,7 +774,11 @@ default behaviour is: to_chat(usr, "[src] does not have any stored infomation!") else to_chat(usr, "OOC Metadata is not supported by this server!") +<<<<<<< HEAD //VOREStation Edit End - Making it so SSD people have prefs with fallback to original style. +======= + +>>>>>>> 48eba82... Merge pull request #6710 from Cerebulon/precisionplacement return /mob/living/Move(a, b, flag) @@ -1305,6 +1309,9 @@ default behaviour is: src.inertia_dir = get_dir(target, src) step(src, inertia_dir) + if(istype(item,/obj/item)) + var/obj/item/W = item + W.randpixel_xy() /* if(istype(src.loc, /turf/space) || (src.flags & NOGRAV)) //they're in space, move em one space in the opposite direction diff --git a/code/modules/modular_computers/computers/modular_computer/variables.dm b/code/modules/modular_computers/computers/modular_computer/variables.dm index c746493ff8..8a1641a125 100644 --- a/code/modules/modular_computers/computers/modular_computer/variables.dm +++ b/code/modules/modular_computers/computers/modular_computer/variables.dm @@ -24,8 +24,8 @@ icon = null // This thing isn't meant to be used on it's own. Subtypes should supply their own icon. icon_state = null - //center_of_mass = null // No pixelshifting by placing on tables, etc. - //randpixel = 0 // And no random pixelshifting on-creation either. + center_of_mass = null // No pixelshifting by placing on tables, etc. + randpixel = 0 // And no random pixelshifting on-creation either. var/icon_state_unpowered = null // Icon state when the computer is turned off var/icon_state_menu = "menu" // Icon state overlay when the computer is turned on, but no program is loaded that would override the screen. var/icon_state_screensaver = null diff --git a/code/modules/projectiles/ammunition.dm b/code/modules/projectiles/ammunition.dm index 0f9608f49c..07b307090e 100644 --- a/code/modules/projectiles/ammunition.dm +++ b/code/modules/projectiles/ammunition.dm @@ -3,6 +3,7 @@ desc = "A bullet casing." icon = 'icons/obj/ammo.dmi' icon_state = "s-casing" + randpixel = 10 slot_flags = SLOT_BELT | SLOT_EARS throwforce = 1 w_class = ITEMSIZE_TINY @@ -18,8 +19,7 @@ ..() if(ispath(projectile_type)) BB = new projectile_type(src) - pixel_x = rand(-10, 10) - pixel_y = rand(-10, 10) + randpixel_xy() //removes the projectile from the ammo casing /obj/item/ammo_casing/proc/expend() diff --git a/code/modules/reagents/reagent_containers/glass.dm b/code/modules/reagents/reagent_containers/glass.dm index 13b0ef3539..4eda5c89ca 100644 --- a/code/modules/reagents/reagent_containers/glass.dm +++ b/code/modules/reagents/reagent_containers/glass.dm @@ -152,6 +152,7 @@ icon = 'icons/obj/chemical.dmi' icon_state = "beaker" item_state = "beaker" + center_of_mass = list("x" = 15,"y" = 11) matter = list("glass" = 500) /obj/item/weapon/reagent_containers/glass/beaker/Initialize() @@ -200,6 +201,7 @@ name = "large beaker" desc = "A large beaker." icon_state = "beakerlarge" + center_of_mass = list("x" = 16,"y" = 11) matter = list("glass" = 5000) volume = 120 amount_per_transfer_from_this = 10 @@ -210,6 +212,7 @@ name = "cryostasis beaker" desc = "A cryostasis beaker that allows for chemical storage without reactions." icon_state = "beakernoreact" + center_of_mass = list("x" = 16,"y" = 13) matter = list("glass" = 500) volume = 60 amount_per_transfer_from_this = 10 @@ -219,6 +222,7 @@ name = "bluespace beaker" desc = "A bluespace beaker, powered by experimental bluespace technology." icon_state = "beakerbluespace" + center_of_mass = list("x" = 16,"y" = 11) matter = list("glass" = 5000) volume = 300 amount_per_transfer_from_this = 10 @@ -229,6 +233,7 @@ name = "vial" desc = "A small glass vial." icon_state = "vial" + center_of_mass = list("x" = 15,"y" = 9) matter = list("glass" = 250) volume = 30 w_class = ITEMSIZE_TINY @@ -248,6 +253,7 @@ icon = 'icons/obj/janitor.dmi' icon_state = "bucket" item_state = "bucket" + center_of_mass = list("x" = 16,"y" = 10) matter = list(DEFAULT_WALL_MATERIAL = 200) w_class = ITEMSIZE_NORMAL amount_per_transfer_from_this = 20 @@ -304,6 +310,7 @@ obj/item/weapon/reagent_containers/glass/bucket/wood icon = 'icons/obj/janitor.dmi' icon_state = "woodbucket" item_state = "woodbucket" + center_of_mass = list("x" = 16,"y" = 8) matter = list("wood" = 50) w_class = ITEMSIZE_LARGE amount_per_transfer_from_this = 20 diff --git a/code/modules/reagents/reagent_containers/spray.dm b/code/modules/reagents/reagent_containers/spray.dm index 22398a170e..3e94bedd59 100644 --- a/code/modules/reagents/reagent_containers/spray.dm +++ b/code/modules/reagents/reagent_containers/spray.dm @@ -4,6 +4,7 @@ icon = 'icons/obj/janitor.dmi' icon_state = "cleaner" item_state = "cleaner" + center_of_mass = list("x" = 16,"y" = 10) flags = OPENCONTAINER|NOBLUDGEON //TFF 24/12/19 - Let people print more spray bottles if needed. matter = list("glass" = 300, DEFAULT_WALL_MATERIAL = 300) @@ -122,6 +123,7 @@ icon = 'icons/obj/weapons.dmi' icon_state = "pepperspray" item_state = "pepperspray" + center_of_mass = list("x" = 16,"y" = 16) possible_transfer_amounts = null volume = 40 var/safety = TRUE @@ -164,6 +166,7 @@ icon = 'icons/obj/gun.dmi' icon_state = "chemsprayer" item_state = "chemsprayer" + center_of_mass = list("x" = 16,"y" = 16) throwforce = 3 w_class = ITEMSIZE_NORMAL possible_transfer_amounts = null diff --git a/code/modules/reagents/reagent_containers/syringes.dm b/code/modules/reagents/reagent_containers/syringes.dm index 66c5f652f9..c5764ee8fe 100644 --- a/code/modules/reagents/reagent_containers/syringes.dm +++ b/code/modules/reagents/reagent_containers/syringes.dm @@ -11,6 +11,7 @@ icon = 'icons/obj/syringe.dmi' item_state = "syringe_0" icon_state = "0" + center_of_mass = list("x" = 16,"y" = 14) matter = list("glass" = 150) amount_per_transfer_from_this = 5 possible_transfer_amounts = null diff --git a/code/modules/research/research.dm b/code/modules/research/research.dm index 5304f8c738..e8aa507f86 100644 --- a/code/modules/research/research.dm +++ b/code/modules/research/research.dm @@ -225,13 +225,13 @@ research holder datum. icon = 'icons/obj/cloning.dmi' icon_state = "datadisk2" item_state = "card-id" + randpixel = 5 w_class = ITEMSIZE_SMALL matter = list(DEFAULT_WALL_MATERIAL = 30, "glass" = 10) var/datum/tech/stored /obj/item/weapon/disk/tech_disk/New() - pixel_x = rand(-5.0, 5) - pixel_y = rand(-5.0, 5) + randpixel_xy() /obj/item/weapon/disk/design_disk name = "component design disk" @@ -239,10 +239,10 @@ research holder datum. icon = 'icons/obj/cloning.dmi' icon_state = "datadisk2" item_state = "card-id" + randpixel = 5 w_class = ITEMSIZE_SMALL matter = list(DEFAULT_WALL_MATERIAL = 30, "glass" = 10) var/datum/design/blueprint /obj/item/weapon/disk/design_disk/New() - pixel_x = rand(-5.0, 5) - pixel_y = rand(-5.0, 5) + randpixel_xy() diff --git a/code/modules/tables/interactions.dm b/code/modules/tables/interactions.dm index ffda1690c0..a58958511a 100644 --- a/code/modules/tables/interactions.dm +++ b/code/modules/tables/interactions.dm @@ -71,7 +71,7 @@ return -/obj/structure/table/attackby(obj/item/W as obj, mob/user as mob) +/obj/structure/table/attackby(obj/item/W as obj, mob/user as mob, var/click_parameters) if (!W) return // Handle harm intent grabbing/tabling. @@ -139,9 +139,49 @@ to_chat(user, "There's nothing to put \the [W] on! Try adding plating to \the [src] first.") return - if(item_place) - user.drop_item(src.loc) - return +// Placing stuff on tables + if(user.unEquip(W, 0, src.loc)) + auto_align(W, click_parameters) + return 1 + +#define CELLS 8 //Amount of cells per row/column in grid +#define CELLSIZE (world.icon_size/CELLS) //Size of a cell in pixels +/* +Automatic alignment of items to an invisible grid, defined by CELLS and CELLSIZE. +Since the grid will be shifted to own a cell that is perfectly centered on the turf, we end up with two 'cell halves' +on edges of each row/column. +Each item defines a center_of_mass, which is the pixel of a sprite where its projected center of mass toward a turf +surface can be assumed. For a piece of paper, this will be in its center. For a bottle, it will be (near) the bottom +of the sprite. +auto_align() will then place the sprite so the defined center_of_mass is at the bottom left corner of the grid cell +closest to where the cursor has clicked on. +Note: This proc can be overwritten to allow for different types of auto-alignment. +*/ + +/obj/item/var/list/center_of_mass = list("x" = 16,"y" = 16) + +/obj/structure/table/proc/auto_align(obj/item/W, click_parameters) + if(!W.center_of_mass) + W.randpixel_xy() + return + + if(!click_parameters) + return + + var/list/mouse_control = params2list(click_parameters) + + var/mouse_x = text2num(mouse_control["icon-x"]) + var/mouse_y = text2num(mouse_control["icon-y"]) + + if(isnum(mouse_x) && isnum(mouse_y)) + var/cell_x = max(0, min(CELLS-1, round(mouse_x/CELLSIZE))) + var/cell_y = max(0, min(CELLS-1, round(mouse_y/CELLSIZE))) + + W.pixel_x = (CELLSIZE * (0.5 + cell_x)) - W.center_of_mass["x"] + W.pixel_y = (CELLSIZE * (0.5 + cell_y)) - W.center_of_mass["y"] + +#undef CELLS +#undef CELLSIZE /obj/structure/table/attack_tk() // no telehulk sorry return diff --git a/code/modules/xenoarcheaology/sampling.dm b/code/modules/xenoarcheaology/sampling.dm index ead1ffa8bb..01c00ed000 100644 --- a/code/modules/xenoarcheaology/sampling.dm +++ b/code/modules/xenoarcheaology/sampling.dm @@ -3,14 +3,14 @@ desc = "It looks extremely delicate." icon = 'icons/obj/xenoarchaeology.dmi' icon_state = "sliver1" + randpixel = 8 w_class = ITEMSIZE_TINY sharp = 1 var/datum/geosample/geological_data /obj/item/weapon/rocksliver/New() icon_state = "sliver[rand(1, 3)]" - pixel_x = rand(-8, 8) - pixel_y = rand(-8 ,0) + randpixel_xy() /datum/geosample var/age = 0 diff --git a/html/changelogs/Cerebulon - precisionplacement.yml b/html/changelogs/Cerebulon - precisionplacement.yml new file mode 100644 index 0000000000..4adee6fb34 --- /dev/null +++ b/html/changelogs/Cerebulon - precisionplacement.yml @@ -0,0 +1,37 @@ +################################ +# 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 +################################# + +# Your name. +author: Cerebulon + +# 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: + - rscadd: "Most items can now be placed precisely on tables and racks." + - rscadd: "Thrown items now land on a random spot on the target tile."