Skip to content

Commit

Permalink
Merge pull request #3652 from MistakeNot4892/loot_piles
Browse files Browse the repository at this point in the history
Backporting Virgo-style loot piles from Lighthouse.
  • Loading branch information
out-of-phaze authored Feb 9, 2024
2 parents 2074272 + cd7c087 commit dfbfcbd
Show file tree
Hide file tree
Showing 10 changed files with 780 additions and 6 deletions.
2 changes: 2 additions & 0 deletions maps/modpack_testing/modpack_testing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include "../../mods/content/mundane.dm"
#include "../../mods/content/scaling_descriptors.dm"

#include "../../mods/content/dungeon_loot/_dungeon_loot.dme"
#include "../../mods/content/bigpharma/_bigpharma.dme"
#include "../../mods/content/byond_membership/_byond_membership.dm"
#include "../../mods/content/corporate/_corporate.dme"
Expand Down
55 changes: 49 additions & 6 deletions maps/tradeship/tradeship-0.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@
/obj/structure/cable{
icon_state = "2-4"
},
/obj/structure/loot_pile/maint/technical,
/turf/simulated/floor,
/area/ship/trade/fore_port_underside_maint)
"fV" = (
Expand Down Expand Up @@ -1439,6 +1440,12 @@
/obj/machinery/atmospherics/pipe/simple/hidden/scrubbers,
/turf/simulated/floor/tiled,
/area/ship/trade/loading_bay)
"wI" = (
/obj/structure/loot_pile/surface/medicine_cabinet{
pixel_y = 18
},
/turf/simulated/floor/carpet/green,
/area/ship/trade/disused)
"wP" = (
/obj/structure/disposalpipe/trunk,
/obj/structure/cable{
Expand Down Expand Up @@ -1661,6 +1668,11 @@
},
/turf/simulated/floor,
/area/ship/trade/undercomms)
"Fy" = (
/obj/effect/decal/cleanable/dirt,
/obj/structure/loot_pile/maint/trash,
/turf/simulated/floor/tiled,
/area/ship/trade/disused)
"FD" = (
/obj/item/mollusc/barnacle{
pixel_x = -5;
Expand Down Expand Up @@ -1746,6 +1758,10 @@
/obj/effect/paint/brown,
/turf/simulated/wall/r_wall/hull,
/area/ship/trade/livestock)
"IA" = (
/obj/structure/loot_pile/maint/junk,
/turf/simulated/floor/carpet/green,
/area/ship/trade/disused)
"IG" = (
/obj/structure/bed/chair/comfy/green{
dir = 1
Expand All @@ -1763,6 +1779,15 @@
/obj/structure/stairs/long/west,
/turf/simulated/floor/tiled/steel_grid,
/area/ship/trade/loading_bay)
"IO" = (
/obj/machinery/atmospherics/pipe/simple/hidden/scrubbers,
/obj/machinery/atmospherics/pipe/simple/hidden/supply,
/obj/structure/cable{
icon_state = "1-2"
},
/obj/structure/loot_pile/maint/boxfort,
/turf/simulated/floor,
/area/ship/trade/fore_port_underside_maint)
"IQ" = (
/obj/structure/disposalpipe/trunk{
dir = 4
Expand Down Expand Up @@ -1958,6 +1983,19 @@
},
/turf/simulated/floor,
/area/ship/trade/disused)
"PE" = (
/obj/machinery/atmospherics/pipe/simple/hidden/supply{
dir = 4
},
/obj/machinery/atmospherics/pipe/simple/hidden/scrubbers{
dir = 4
},
/obj/structure/cable{
icon_state = "4-8"
},
/obj/structure/loot_pile/maint/junk,
/turf/simulated/floor,
/area/ship/trade/fore_port_underside_maint)
"PF" = (
/obj/effect/floor_decal/industrial/warning{
dir = 8;
Expand Down Expand Up @@ -2020,6 +2058,10 @@
/obj/item/stool/padded,
/turf/simulated/floor,
/area/ship/trade/disused)
"RR" = (
/obj/structure/loot_pile/maint/boxfort,
/turf/simulated/floor/carpet/red,
/area/ship/trade/disused)
"Ss" = (
/obj/machinery/atmospherics/pipe/simple/hidden/supply,
/obj/machinery/alarm{
Expand Down Expand Up @@ -2053,6 +2095,7 @@
pixel_y = 20
},
/obj/effect/decal/cleanable/dirt,
/obj/structure/loot_pile/maint/junk,
/turf/simulated/floor,
/area/ship/trade/disused)
"TA" = (
Expand Down Expand Up @@ -4771,7 +4814,7 @@ Gb
fp
ne
ne
ne
IO
ne
aS
Ss
Expand Down Expand Up @@ -4850,7 +4893,7 @@ SC
Ff
Ym
Xe
Nq
PE
ak
ak
ak
Expand Down Expand Up @@ -5588,7 +5631,7 @@ SC
rp
Iu
oG
qt
Fy
aT
yO
LO
Expand Down Expand Up @@ -5831,7 +5874,7 @@ aa
aa
aa
SC
AT
wI
Ym
JQ
Yh
Expand Down Expand Up @@ -5913,8 +5956,8 @@ aa
aa
aa
SC
AT
Ym
IA
RR
JQ
lv
DT
Expand Down
1 change: 1 addition & 0 deletions maps/tradeship/tradeship.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "../random_ruins/exoplanet_ruins/playablecolony/playablecolony.dm"

#include "../../mods/content/dungeon_loot/_dungeon_loot.dme"
#include "../../mods/content/mundane.dm"
#include "../../mods/content/bigpharma/_bigpharma.dme"
#include "../../mods/content/corporate/_corporate.dme"
Expand Down
20 changes: 20 additions & 0 deletions mods/content/dungeon_loot/_dungeon_loot.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
This is pulled directly from Virgo. Credits to them. Modifications made for Lighthouse by Carl.
The below text is holdover from Virgo.
- - - - - - - - - - -
Basically, each player key gets one chance per loot pile to get them phat lewt.
When they click the pile, after a delay, they 'roll' if they get anything, using chance_nothing. If they're unlucky, they get nothing.
Otherwise, they roll up to two times, first a roll for rare things, using chance_rare. If they succeed, they get something quite good.
If that roll fails, they do one final roll, using chance_uncommon. If they succeed, they get something fairly useful.
If that fails again, they walk away with some common junk.
The same player cannot roll again, however other players can. This has two benefits. The first benefit is that someone raiding all of
maintenance will not deprive other people from a shot at loot, and that for the surface variants, it quietly encourages bringing along
buddies, to get more chances at getting cool things instead of someone going solo to hoard all the stuff.
Loot piles can be depleted, if loot_depleted is turned on. Note that players who searched the pile already won't deplete the loot furthers when searching again.
*/

/decl/modpack/dungeon_loot
name = "Dungeon Loot"
dreams = list("Packrats")
9 changes: 9 additions & 0 deletions mods/content/dungeon_loot/_dungeon_loot.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef MODPACK_DUNGEON_LOOT
#define MODPACK_DUNGEON_LOOT
// BEGIN INCLUDE
#include "_dungeon_loot.dm"
#include "loot_pile.dm"
#include "subtypes/exosuit.dm"
#include "subtypes/maint.dm"
#include "subtypes/surface.dm"
#endif
Binary file added mods/content/dungeon_loot/icons/loot_piles.dmi
Binary file not shown.
131 changes: 131 additions & 0 deletions mods/content/dungeon_loot/loot_pile.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/obj/structure/loot_pile
abstract_type = /obj/structure/loot_pile
name = "base loot pile"
desc = "If you can read me, this is bugged."
icon = 'mods/content/dungeon_loot/icons/loot_piles.dmi'
icon_state = "randompile"
density = FALSE
anchored = TRUE

/// Keys that have searched this loot pile, with values of searched time.
var/list/searched_by
/// If true, the same person can loot multiple times. Mostly for debugging.
var/allow_multiple_looting = FALSE
/// Used so you can't spamclick to loot.
var/busy = FALSE
/// Unlucky people might need to loot multiple spots to find things.
var/chance_nothing = 0
/// Probability of pulling from the uncommon_loot list.
var/chance_uncommon = 10
/// Ditto, but for rare_loot list.
var/chance_rare = 1
/// If true, loot piles can be 'depleted' after a certain number of searches by different players, where no more loot can be obtained.
var/loot_depletion = FALSE
/// When this reaches zero, and loot_depleted is true, you can't obtain anymore loot.
var/loot_left = 0
/// If true, and if the loot gets depleted as above, the pile is deleted.
var/delete_on_depletion = FALSE

/obj/structure/loot_pile/Initialize()
var/list/icon_states_to_use = get_icon_states_to_use()
if(icon_states_to_use && icon_states_to_use.len)
icon_state = pick(icon_states_to_use)
. = ..()

/obj/structure/loot_pile/attack_ai(var/mob/user)
if(isrobot(user) && Adjacent(user))
return attack_hand(user)
return ..()

/obj/structure/loot_pile/attack_hand(mob/user)

if(!isliving(user))
return ..()

var/mob/living/L = user
if(busy)
to_chat(L, SPAN_WARNING("\The [src] is already being searched."))
return TRUE

L.visible_message("\The [user] searches through \the [src].", SPAN_NOTICE("You search through \the [src]."), SPAN_NOTICE("You hear some rustling."))

//Do the searching
busy = TRUE
if(!do_after(user,rand(4 SECONDS,6 SECONDS),src))
busy = FALSE
return TRUE
busy = FALSE

// The loot's all gone.
if(loot_depletion && loot_left <= 0)
to_chat(L, SPAN_WARNING("\The [src] has been picked clean."))
return TRUE

//You already searched this one
if(!allow_multiple_looting && (user.ckey in searched_by))
to_chat(L, SPAN_WARNING("You can't find anything else vaguely useful in \the [src]. Another set of eyes might, however."))
return TRUE

// You got unlucky.
if(chance_nothing && prob(chance_nothing))
to_chat(L, SPAN_WARNING("Nothing in this pile really catches your eye this time."))
return TRUE

// You found something!
searched_by |= user.ckey
var/obj/item/loot = null
var/span = "notice" // Blue

if(prob(chance_rare) && length(get_rare_loot())) // You won THE GRAND PRIZE!
loot = produce_rare_item()
span = "cult" // Purple and bold.
else if(prob(chance_uncommon) && length(get_uncommon_loot())) // Otherwise you might still get something good.
loot = produce_uncommon_item()
span = "alium" // Green
else if(length(get_common_loot())) // Welp.
loot = produce_common_item()

if(loot)
loot.forceMove(get_turf(src))
to_chat(L, SPAN_CLASS(span, "You found \a [loot]!"))
if(loot_depletion)
loot_left--
if(loot_left <= 0)
to_chat(L, SPAN_WARNING("You seem to have gotten the last of the spoils inside \the [src]."))
if(delete_on_depletion)
qdel(src)
return TRUE

/obj/structure/loot_pile/proc/produce_common_item()
var/list/common_loot = get_common_loot()
if(length(common_loot))
var/path = pick(common_loot)
return new path(src)

/obj/structure/loot_pile/proc/produce_uncommon_item()
var/list/uncommon_loot = get_uncommon_loot()
if(length(uncommon_loot))
var/path = pick(uncommon_loot)
return new path(src)

/obj/structure/loot_pile/proc/produce_rare_item()
var/list/rare_loot = get_rare_loot()
if(length(rare_loot))
var/path = pick(rare_loot)
return new path(src)

/// Returns a list of generally less-than-useful junk and filler, at least for maint loot piles.
/obj/structure/loot_pile/proc/get_common_loot()
return

/// Returns a list of some maybe actually useful items, usually the reason someone bothers looking inside.
/obj/structure/loot_pile/proc/get_uncommon_loot()
return

/// Returns a list of really powerful, or at least unique items.
/obj/structure/loot_pile/proc/get_rare_loot()
return

/// Returns a list of icon states the pile can choose from on initialization. If empty or null, it will stay the initial icon_state.
/obj/structure/loot_pile/proc/get_icon_states_to_use()
return
Loading

0 comments on commit dfbfcbd

Please sign in to comment.