Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MODULAR] Trash piles: trash sweet trash #88

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions modular_doppler/objects_and_structures/code/structure.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/obj/effect/spawner/random/structure/crate
name = "crate spawner"
icon_state = "crate_secure"
loot = list(
/obj/effect/spawner/random/structure/crate_loot = 495,
/obj/structure/trash_pile = 250,
/obj/structure/closet/crate/trashcart/filled = 75,
/obj/effect/spawner/random/trash/moisture_trap = 50,
/obj/effect/spawner/random/trash/hobo_squat = 30,
/obj/structure/closet/mini_fridge = 35,
/obj/effect/spawner/random/trash/mess = 30,
/obj/item/kirbyplants/fern = 20,
/obj/structure/closet/crate/decorations = 15,
/obj/effect/decal/remains/human/smokey/maintenance = 7,
/obj/structure/destructible/cult/pants_altar = 1,
)
138 changes: 138 additions & 0 deletions modular_doppler/objects_and_structures/code/trash_pile.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/obj/structure/trash_pile
name = "trash pile"
desc = "A heap of garbage, but maybe there's something interesting inside?"
icon = 'modular_doppler/objects_and_structures/icons/trash_piles.dmi'
icon_state = "randompile"
density = TRUE
anchored = TRUE
layer = TABLE_LAYER
obj_flags = CAN_BE_HIT
pass_flags = LETPASSTHROW

max_integrity = 50

var/hide_person_time = 30
var/hide_item_time = 15

var/list/searchedby = list()// Characters that have searched this trashpile, with values of searched time.

/obj/structure/trash_pile/Initialize(mapload)
. = ..()
icon_state = pick(
"pile1",
"pile2",
"pilechair",
"piletable",
"pilevending",
"brtrashpile",
"microwavepile",
"rackpile",
"boxfort",
"trashbag",
"brokecomp",
)

/obj/structure/trash_pile/proc/do_search(mob/user)
if(contents.len) // There's something hidden
var/atom/hidden_atom = contents[contents.len] // Get the most recent hidden thing
if(istype(hidden_atom, /mob/living))
var/mob/living/hidden_mob = hidden_atom
balloon_alert(user, "someone is inside!")
eject_mob(hidden_mob)
else if (istype(hidden_atom, /obj/item))
var/obj/item/hidden_item = hidden_atom
balloon_alert(user, "found something!")
hidden_item.forceMove(src.loc)
else
// You already searched this one bruh
if(user.ckey in searchedby)
balloon_alert(user, "already searched!")
// You found an item!
else
produce_alpha_item()
balloon_alert(user, "found something!")
searchedby += user.ckey

/obj/structure/trash_pile/attack_hand(mob/user)
// Human mob
if(ishuman(user))
var/mob/living/carbon/human/human_user = user
human_user.visible_message("[user] searches through \the [src].", span_notice("You search through \the [src]."))
// Do the searching
if(do_after(user, rand(4 SECONDS, 6 SECONDS), target = src))
if(src.loc) // Let's check if the pile still exists
do_search(user)
else
return ..()

// Random lists
/obj/structure/trash_pile/proc/produce_alpha_item()
var/lootspawn = pick_weight(GLOB.maintenance_loot)
while(islist(lootspawn))
lootspawn = pick_weight(lootspawn)
var/obj/item/hidden_item = new lootspawn(get_turf(src))
return hidden_item

/obj/structure/trash_pile/mouse_drop_receive(atom/dropping, mob/user, params)
if(user == dropping && iscarbon(dropping))
var/mob/living/dropped_mob = dropping
if(dropped_mob.mobility_flags & MOBILITY_MOVE)
dive_in_pile(user)
return

/obj/structure/trash_pile/proc/eject_mob(mob/living/hidden_mob)
hidden_mob.forceMove(src.loc)
playsound(hidden_mob.loc, 'sound/machines/chime.ogg', 50, FALSE, -5)
hidden_mob.do_alert_animation(hidden_mob)

/obj/structure/trash_pile/proc/do_dive(mob/user)
if(contents.len)
for(var/mob/hidden_mob in contents)
balloon_alert(user, "already someone inside!")
eject_mob(hidden_mob)
return FALSE
return TRUE

/obj/structure/trash_pile/proc/dive_in_pile(mob/user)
user.visible_message(span_warning("[user] starts diving into [src]."), \
span_notice("You start diving into [src]..."))
var/adjusted_dive_time = hide_person_time
if(HAS_TRAIT(user, TRAIT_RESTRAINED)) // hiding takes twice as long when restrained.
adjusted_dive_time *= 2

if(do_after(user, adjusted_dive_time, user))
if(src.loc) // Checking if structure has been destroyed
if(do_dive(user))
user.forceMove(src)

/obj/structure/trash_pile/proc/can_hide_item(obj/item/hidden_item)
if(contents.len > 10)
return FALSE
return TRUE

/obj/structure/trash_pile/attackby(obj/item/hidden_item, mob/living/user, params)
if(!user.combat_mode)
if(can_hide_item(hidden_item))
balloon_alert(user, "hiding item...")
if(do_after(user, hide_item_time, user))
if(src.loc)
if(user.transferItemToLoc(hidden_item, src))
balloon_alert(user, "item hidden")
else
balloon_alert(user, "it's stuck to your hand!")
else
balloon_alert(user, "it's full!")
return

. = ..()

/obj/structure/trash_pile/Destroy()
for(var/atom/movable/pile_contents in src)
pile_contents.forceMove(src.loc)
return ..()

/obj/structure/trash_pile/container_resist_act(mob/user)
user.forceMove(src.loc)

/obj/structure/trash_pile/relaymove(mob/user)
container_resist_act(user)
Binary file not shown.
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6811,7 +6811,9 @@
#include "modular_doppler\obj_flags_doppler\code\objs.dm"
#include "modular_doppler\objects_and_structures\code\icemoon_tiles.dm"
#include "modular_doppler\objects_and_structures\code\sauna_oven.dm"
#include "modular_doppler\objects_and_structures\code\structure.dm"
#include "modular_doppler\objects_and_structures\code\towel_bins.dm"
#include "modular_doppler\objects_and_structures\code\trash_pile.dm"
#include "modular_doppler\objects_and_structures\code\watercloset.dm"
#include "modular_doppler\pixel_shift\living.dm"
#include "modular_doppler\pixel_shift\living_movement.dm"
Expand Down
Loading