Ports table item autoalign from Bay (#6946)

Made it so items get their pixel x/y reset on pickup.
    Thrown items now also get their pixel placement slightly randomized.
    Tweaked the center of mass on a boatload of items to be more accurate to their sprite art.
    Replaced a bunch of randomized pixel placement code into a unifying proc; randpixel_xy() that uses an item's randpixel var.
This commit is contained in:
fernerr
2019-09-08 22:51:49 +03:00
committed by Erki
parent de748e0607
commit 2a2cc7d52e
57 changed files with 286 additions and 159 deletions
+14 -2
View File
@@ -4,6 +4,7 @@
w_class = 3.0
var/image/blood_overlay //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
@@ -171,7 +172,7 @@
return
if(!src.Adjacent(user) && !(TK in user.mutations))
to_chat(user, span("notice", "\The [src] slips out of your grasp before you can grab it!")) // because things called before this can move it
return // please don't pick things up
return // please don't pick things up
src.pickup(user)
if (istype(src.loc, /obj/item/weapon/storage))
var/obj/item/weapon/storage/S = src.loc
@@ -266,6 +267,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.
@@ -780,4 +783,13 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out.
return TRUE // Already adjacent.
if(AStar(get_turf(us), get_turf(them), /turf/proc/AdjacentTurfsRanged, /turf/proc/Distance, max_nodes=25, max_node_depth=range))
return TRUE
return FALSE
return FALSE
//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
@@ -3,6 +3,7 @@
desc = "A desk lamp with an adjustable mount."
icon_state = "lamp"
item_state = "lamp"
center_of_mass = list("x" = 13,"y" = 11)
brightness_on = 5
w_class = 5
flags = CONDUCT
@@ -17,6 +18,7 @@
desc = "A classic green-shaded desk lamp."
icon_state = "lampgreen"
item_state = "lampgreen"
center_of_mass = list("x" = 15,"y" = 11)
brightness_on = 5
light_color = "#FFC58F"
+3 -3
View File
@@ -62,14 +62,14 @@
destroyed_event.unregister(buffer_object, src)
buffer_object = null
/obj/item/device/multitool/resolve_attackby(atom/A, mob/user)
/obj/item/device/multitool/resolve_attackby(atom/A, mob/user, var/click_parameters)
if(!isobj(A))
return ..(A, user)
return ..(A, user, click_parameters)
var/obj/O = A
var/datum/expansion/multitool/MT = LAZYACCESS(O.expansions, /datum/expansion/multitool)
if(!MT)
return ..(A, user)
return ..(A, user, click_parameters)
user.AddTopicPrint(src)
MT.interact(src, user)
@@ -13,12 +13,12 @@
w_class = 3
max_amount = 60
icon = 'icons/obj/stacks/tiles.dmi'
randpixel = 7
drop_sound = 'sound/items/drop/axe.ogg'
/obj/item/stack/tile/New()
..()
pixel_x = rand(-7, 7)
pixel_y = rand(-7, 7)
randpixel_xy()
/*
* Grass
+2 -2
View File
@@ -72,10 +72,10 @@
var/uses = 10
var/const/NO_EMAG_ACT = -50
/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 == NO_EMAG_ACT)
return ..(A, user)
return ..(A, user, click_parameters)
uses -= used_uses
A.add_fingerprint(user)
@@ -379,14 +379,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 = 1
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
@@ -2,6 +2,7 @@
name = "ashtray"
icon = 'icons/obj/ashtray.dmi'
icon_state = "blank"
randpixel = 5
force_divisor = 0.1
thrown_force_divisor = 0.1
var/image/base_image
@@ -13,8 +14,7 @@
qdel(src)
return
max_butts = round(material.hardness/10) //This is arbitrary but whatever.
src.pixel_y = rand(-5, 5)
src.pixel_x = rand(-6, 6)
randpixel_xy()
update_icon()
return
@@ -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 = 2
@@ -22,8 +23,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)
@@ -85,6 +85,7 @@
item_state = icon_state
/obj/item/weapon/material/twohanded/pickup(mob/user)
..()
unwield()
/obj/item/weapon/material/twohanded/attack_self(mob/user as mob)
@@ -26,6 +26,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
var/maxHealth = 20 //health is already defined
use_sound = 'sound/items/storage/box.ogg'
@@ -44,6 +44,7 @@
/obj/item/weapon/storage/fancy/egg_box
icon = 'icons/obj/food.dmi'
icon_state = "eggbox"
center_of_mass = list("x" = 16,"y" = 7)
icon_type = "egg"
name = "egg box"
storage_slots = 12
@@ -11,6 +11,7 @@
name = "first-aid kit"
desc = "It's an emergency medical kit for those serious boo-boos."
icon_state = "firstaid"
center_of_mass = list("x" = 13,"y" = 10)
throw_speed = 2
throw_range = 8
var/empty = 0
@@ -141,6 +142,7 @@
icon_state = "pill_canister"
icon = 'icons/obj/chemical.dmi'
item_state = "contsolid"
center_of_mass = list("x" = 16,"y" = 12)
w_class = 2.0
can_hold = list(/obj/item/weapon/reagent_containers/pill,/obj/item/weapon/dice,/obj/item/weapon/paper)
allow_quick_gather = 1
@@ -29,6 +29,7 @@
/obj/item/weapon/storage/box/donut
icon = 'icons/obj/food.dmi'
icon_state = "donutbox"
center_of_mass = list("x" = 16,"y" = 9)
name = "donut box"
can_hold = list(/obj/item/weapon/reagent_containers/food/snacks/donut)
foldable = /obj/item/stack/material/cardboard
@@ -4,6 +4,7 @@
icon = 'icons/obj/storage.dmi'
icon_state = "red"
item_state = "toolbox_red"
center_of_mass = list("x" = 16,"y" = 11)
flags = CONDUCT
force = 5
throwforce = 10
+2
View File
@@ -41,6 +41,7 @@
desc = "A tool with a flattened or cross-shaped tip that fits into the head of a screw to turn it."
icon = 'icons/obj/tools.dmi'
icon_state = "screwdriver"
center_of_mass = list("x" = 13,"y" = 7)
flags = CONDUCT
slot_flags = SLOT_BELT | SLOT_EARS
force = 5.0
@@ -106,6 +107,7 @@
desc = "A tool used to cut wires in electrical work."
icon = 'icons/obj/tools.dmi'
icon_state = "cutters"
center_of_mass = list("x" = 18,"y" = 10)
flags = CONDUCT
slot_flags = SLOT_BELT
force = 6.0
+4 -2
View File
@@ -6,6 +6,8 @@
icon = 'icons/obj/items.dmi'
var/icon_base = "beartrap"
icon_state = "beartrap0"
randpixel = 0
center_of_mass = null
desc = "A mechanically activated leg trap. Low-tech, but reliable. Looks like it could really hurt if you set it off."
throwforce = 0
w_class = 3
@@ -267,7 +269,7 @@
if(!ishuman(usr))
to_chat(usr, "<span class='warning'>This mob type can't use this verb.</span>")
return
var/datum/M = captured ? captured.resolve() : null
if(deployed)
@@ -349,7 +351,7 @@
else if (istype(L, /obj/effect/spider/spiderling))
var/obj/effect/spider/spiderling/S = L
msg = "<span class='warning'>[S] jumps out of \the [src].</span>"
unbuckle_mob()
captured = null
visible_message(msg)
@@ -213,6 +213,7 @@
desc = "A collapsed roller bed that can be carried around."
icon = 'icons/obj/rollerbed.dmi'
icon_state = "folded"
center_of_mass = list("x" = 17,"y" = 7)
w_class = 4.0 // Can't be put in backpacks. Oh well.
/obj/item/roller/attack_self(mob/user)
@@ -5,6 +5,8 @@
desc = "Apply butt."
icon = 'icons/obj/furniture.dmi'
icon_state = "stool_preview" //set for the map
randpixel = 0
center_of_mass = null
force = 10
throwforce = 10
w_class = 5