Merge pull request #6651 from VOREStation/upstream-merge-6710

[MIRROR] Ports precision placement of items
This commit is contained in:
Novacat
2020-02-22 10:33:58 -05:00
committed by GitHub
43 changed files with 186 additions and 57 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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()
. = ..()

View File

@@ -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()

View File

@@ -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

View File

@@ -453,4 +453,5 @@
update_icon()
/obj/item/weapon/hand/pickup(mob/user as mob)
..()
src.update_icon()

View File

@@ -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

View File

@@ -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"

View File

@@ -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))

View File

@@ -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

View File

@@ -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

View File

@@ -775,7 +775,6 @@ default behaviour is:
else
to_chat(usr, "OOC Metadata is not supported by this server!")
//VOREStation Edit End - Making it so SSD people have prefs with fallback to original style.
return
/mob/living/Move(a, b, flag)
if (buckled && buckled.loc != a) //not updating position
@@ -1305,6 +1304,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

View File

@@ -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

View File

@@ -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()

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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()

View File

@@ -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, "<span class='warning'>There's nothing to put \the [W] on! Try adding plating to \the [src] first.</span>")
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

View File

@@ -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