mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-01-09 08:51:57 +00:00
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:
@@ -11,6 +11,7 @@
|
||||
var/datum/battle_monsters/trap/trap_datum
|
||||
|
||||
w_class = ITEMSIZE_TINY
|
||||
drop_sound = null
|
||||
|
||||
//Card information here
|
||||
|
||||
@@ -23,6 +24,14 @@
|
||||
var/obj/item/battle_monsters/card/adding_card = attacking
|
||||
make_deck(user,adding_card)
|
||||
|
||||
/obj/item/battle_monsters/card/resolve_attackby(atom/A, mob/user, var/click_parameters)
|
||||
if(istype(A,/obj/structure/table) || istype(A,/obj/structure/dueling_table))
|
||||
user.visible_message(\
|
||||
span("notice","\The [user] plays \the [src]!"),\
|
||||
span("notice","You play \the [src]!")\
|
||||
)
|
||||
..(A, user, click_parameters)
|
||||
|
||||
/obj/item/battle_monsters/card/attack_self(mob/user as mob)
|
||||
flip_card(user)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/obj/item/battle_monsters/
|
||||
icon = 'icons/obj/battle_monsters/card.dmi'
|
||||
icon_state = ""
|
||||
var/list/center_of_mass = list("x"=16, "y"=16)
|
||||
var/facedown = TRUE
|
||||
var/rotated = FALSE
|
||||
|
||||
@@ -66,43 +65,3 @@
|
||||
)
|
||||
|
||||
update_icon()
|
||||
|
||||
|
||||
#define CELLS_X 6
|
||||
#define CELLSIZE_X (32/CELLS_X)
|
||||
|
||||
#define CELLS_Y 6
|
||||
#define CELLSIZE_Y (32/CELLS_Y)
|
||||
|
||||
/obj/item/battle_monsters/afterattack(atom/A, mob/user, proximity, params) //Copy and pasted from foodcode.
|
||||
if(proximity && params && (istype(A, /obj/structure/table) || (istype(A,/obj/structure/dueling_table) && A.density)) && center_of_mass.len)
|
||||
|
||||
user.visible_message(\
|
||||
span("notice","\The [user] plays \the [src]."),\
|
||||
span("notice","You play \the [src].")\
|
||||
)
|
||||
|
||||
//Places the item on a grid
|
||||
var/list/mouse_control = mouse_safe_xy(params)
|
||||
|
||||
var/mouse_x = mouse_control["icon-x"]
|
||||
var/mouse_y = mouse_control["icon-y"]
|
||||
|
||||
if(!isnum(mouse_x) || !isnum(mouse_y))
|
||||
return
|
||||
|
||||
var/cell_x = max(0, min(CELLS_X-1, round(mouse_x/CELLSIZE_X)))
|
||||
var/cell_y = max(0, min(CELLS_Y-1, round(mouse_y/CELLSIZE_Y)))
|
||||
|
||||
pixel_x = (CELLSIZE_X * (0.5 + cell_x)) - center_of_mass["x"]
|
||||
pixel_y = (CELLSIZE_Y * (0.5 + cell_y)) - center_of_mass["y"]
|
||||
|
||||
layer = A.layer + 0.1
|
||||
|
||||
. = ..()
|
||||
|
||||
#undef CELLS_X
|
||||
#undef CELLSIZE_X
|
||||
|
||||
#undef CELLS_Y
|
||||
#undef CELLSIZE_Y
|
||||
|
||||
@@ -20,6 +20,30 @@
|
||||
density = 0
|
||||
mouse_opacity = 0
|
||||
|
||||
/obj/structure/dueling_table/attackby(obj/item/W as obj, mob/user as mob)
|
||||
user.drop_item(src.loc)
|
||||
return
|
||||
#define CELLS 8
|
||||
#define CELLSIZE (world.icon_size/CELLS)
|
||||
|
||||
/obj/structure/dueling_table/attackby(obj/item/W as obj, mob/user as mob, var/click_parameters)
|
||||
if(user.unEquip(W, 0, src.loc))
|
||||
if(!W.center_of_mass)
|
||||
W.randpixel_xy()
|
||||
return
|
||||
|
||||
if(!click_parameters)
|
||||
return
|
||||
|
||||
var/list/mouse_control = mouse_safe_xy(click_parameters)
|
||||
var/mouse_x = mouse_control["icon-x"]
|
||||
var/mouse_y = 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"]
|
||||
|
||||
W.layer = src.layer + 0.1
|
||||
|
||||
#undef CELLS
|
||||
#undef CELLSIZE
|
||||
|
||||
Reference in New Issue
Block a user