Skip to content

Commit

Permalink
Crate Shelf Tweaks (#3560)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Mapped crate shelves now start at a height of 2. You can build them to a
max height of 4
Constructed crate shelves start at 1 crate and need to be built up
You can now add shelves to crate shelves (with metal)

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
it's not, honestly. i think this change is going to be the death of the
game. for pr after pr i've made nothing but hastily produced shitcode
changes to a game that used to be soulful and thriving, stripping out
the identity of what's made it so interesting to people. this is where
it comes full circle. im sorry for doing this. but it had to be done.
<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl:
add: You can now add shelves to crate racks
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Co-authored-by: Erika Fox <[email protected]>
Co-authored-by: Sun-Soaked <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2024
1 parent 9fb5e3c commit d5694e9
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions code/game/objects/structures/crateshelf.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#define DEFAULT_SHELF_CAPACITY 3 // Default capacity of the shelf
#define DEFAULT_SHELF_MAX_CAPACITY 4
#define DEFAULT_SHELF_USE_DELAY 1 SECONDS // Default interaction delay of the shelf
#define DEFAULT_SHELF_VERTICAL_OFFSET 10 // Vertical pixel offset of shelving-related things. Set to 10 by default due to this leaving more of the crate on-screen to be clicked.

Expand All @@ -12,9 +13,13 @@
max_integrity = 50 // Not hard to break

var/capacity = DEFAULT_SHELF_CAPACITY
var/max_capacity = DEFAULT_SHELF_MAX_CAPACITY
var/use_delay = DEFAULT_SHELF_USE_DELAY
var/list/shelf_contents

/obj/structure/crate_shelf/built
capacity = 1

/obj/structure/crate_shelf/debug
capacity = 12

Expand Down Expand Up @@ -47,12 +52,40 @@
for(var/obj/structure/closet/crate/crate in shelf_contents)
. += " [icon2html(crate, user)] [crate]"

/obj/structure/crate_shelf/proc/add_shelf(num)
if(capacity + num > max_capacity)
return FALSE
var/stack_layer // This is used to generate the sprite layering of the shelf pieces.
var/stack_offset // This is used to generate the vertical offset of the shelf pieces.
var/prev_capacity = capacity
capacity += num
shelf_contents.len = capacity
for(var/i in prev_capacity to (capacity - 1))
if(i >= 3) // If we're at or above three, we'll be on the way to going off the tile we're on. This allows mobs to be below the shelf when this happens.
stack_layer = ABOVE_MOB_LAYER + (0.02 * i) - 0.01
else
stack_layer = BELOW_OBJ_LAYER + (0.02 * i) - 0.01 // Make each shelf piece render above the last, but below the crate that should be on it.
stack_offset = DEFAULT_SHELF_VERTICAL_OFFSET * i // Make each shelf piece physically above the last.
overlays += image(icon = 'icons/obj/objects.dmi', icon_state = "shelf_stack", layer = stack_layer, pixel_y = stack_offset)

/obj/structure/crate_shelf/attackby(obj/item/item, mob/living/user, params)
if (item.tool_behaviour == TOOL_WRENCH && !(flags_1&NODECONSTRUCT_1))
item.play_tool_sound(src)
if(do_after(user, 3 SECONDS, target = src))
if(do_after(user, 3 SECONDS, src))
deconstruct(TRUE)
return TRUE
if(istype(item, /obj/item/stack/sheet/metal))
if(capacity < max_capacity)
var/obj/item/stack/sheet/metal/our_sheet = item
if(our_sheet.get_amount() >= 2)
balloon_alert(user, "adding additional shelf to rack")
if(do_after(user, 3 SECONDS, src))
add_shelf(1)
our_sheet.add(-2)
return TRUE
to_chat(user, span_notice("Adding a shelf to [src] requires more metal."))
return FALSE
to_chat(user, span_notice("[src] cannot be built any higher!"))
return ..()

/obj/structure/crate_shelf/relay_container_resist_act(mob/living/user, obj/structure/closet/crate)
Expand Down Expand Up @@ -143,4 +176,4 @@
/obj/item/rack_parts/shelf
name = "crate shelf parts"
desc = "Parts of a shelf."
construction_type = /obj/structure/crate_shelf
construction_type = /obj/structure/crate_shelf/built

0 comments on commit d5694e9

Please sign in to comment.