Shovel digging refactor (#19345)

* fixes per pile lootable counts

* shovel digging element

* retooled to flag

* take two

* proc that

* sand digging

* collapse that system in too

* allow base loot

* desc

* potat

* fix that

* no making that on rocks

* oops

* var version

* prevent that dupe

* fixes

---------

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
Will
2026-03-26 22:10:06 -04:00
committed by GitHub
co-authored by Cameron Lennox
parent 3fc4d84466
commit bf29ca396f
14 changed files with 143 additions and 97 deletions
+17 -7
View File
@@ -4,9 +4,9 @@
var/chance_rare = 1 // Ditto, but for rare_loot list.
var/chance_gamma = 0 // Singledrop global loot table shared with all piles.
var/allow_multiple_looting = FALSE // If true, the same person can loot multiple times. Mostly for debugging.
var/allow_multiple_looting = TRUE // If true, the same person can loot multiple times. Mostly for debugging.
var/loot_depletion = FALSE // 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_left = 0 // When this reaches zero, and loot_depleted is true, you can't obtain anymore loot.
var/loot_left = 0 // Maximum number of times a pile can be looted before no loot will remain for anyone
var/delete_on_depletion = FALSE // If true, and if the loot gets depleted as above, the pile is deleted.
var/list/unlucky_loot = list() // Unlucky is the worst tier. Only people with the unlucky trait can get this stuff. Primed grenades, dangerous syringes, etc.
@@ -14,6 +14,8 @@
var/list/uncommon_loot = list() // Uncommon is actually maybe some useful items, usually the reason someone bothers looking inside.
var/list/rare_loot = list() // Rare is really powerful, or at least unique items.
var/static/list/piles_looted = list() // Keeps track of the number of times a specific pile has been looted if the specific lootable type has loot_depletion on
/datum/element/lootable/Attach(atom/target)
. = ..()
if(!isatom(target))
@@ -22,15 +24,19 @@
/datum/element/lootable/Detach(atom/target)
. = ..()
if(loot_depletion)
piles_looted -= REF(target)
UnregisterSignal(target, COMSIG_LOOT_REWARD)
/// Calculates and drops loot, the source's turf is where it will be dropped, L is the searching mob, and searched_by is a passed list for storing who has searched a loot pile.
/datum/element/lootable/proc/loot(atom/source,mob/living/L,var/list/searched_by, wake_chance = 0)
SIGNAL_HANDLER
// The loot's all gone.
if(loot_depletion && loot_left <= 0)
to_chat(L, span_warning("\The [source] has been picked clean."))
return
if(loot_depletion)
var/looted_count = piles_looted[REF(source)]
if(looted_count >= loot_left)
to_chat(L, span_warning("\The [source] has been picked clean."))
return
// You got unlucky.
if(chance_nothing && prob(chance_nothing))
@@ -100,8 +106,12 @@
// Check if we should delete on depletion
if(!loot_depletion)
return
loot_left--
if(loot_left > 0)
// Add to looted piles if not already one
if(!(REF(source) in piles_looted))
piles_looted[REF(source)] = 0
// Increase the looted count till we've hit our limit
piles_looted[REF(source)] += 1
if(piles_looted[REF(source)] < loot_left)
return
to_chat(L, span_warning("You seem to have gotten the last of the spoils in \the [source]."))
if(delete_on_depletion)