Files
CHOMPStation2/code/modules/mob/living/simple_mob/harvesting.dm
CHOMPStation2 ab154b48b2 [MIRROR] refactors most spans (#9139)
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com>
Co-authored-by: Kashargul <KashL@t-online.de>
2024-10-04 15:00:17 +02:00

43 lines
1.7 KiB
Plaintext

/mob/living/simple_mob
// What do you hit the mob with (on help) to get something from it?
var/obj/harvest_tool
// How long do we have to wait until it's harvestable again?
var/harvest_cooldown = 10 MINUTES
// How long does it take to harvest?
var/harvest_delay = 30 SECONDS
// What world.time was the last harvest?
var/harvest_recent = 0
// How many times can we roll at max on the chance table?
var/harvest_per_hit = 1
// Verb for harvesting. "sheared" "clipped" etc.
var/harvest_verb = "harvested"
// Associative list of paths and their chances. path = straws in the lot
var/list/harvest_results
/mob/living/simple_mob/examine(mob/user)
. = ..()
if(stat != DEAD && user && harvest_tool && (get_dist(user, src) <= 3))
. += span_notice("\The [src] can be [harvest_verb] with a [initial(harvest_tool.name)] every [harvest_cooldown / 600] minutes.") //CHOMPEdit Please do math better
var/time_to_harvest = (harvest_recent + harvest_cooldown) - world.time
if(time_to_harvest > 0)
. += span_notice("It can be [harvest_verb] in [(time_to_harvest)] second(s).") //CHOMPEdit This is as good as I can get for now, I intend to make it better later
else
. += span_notice("It can be [harvest_verb] now.")
/mob/living/simple_mob/proc/livestock_harvest(var/obj/item/tool, var/mob/living/user)
if(!LAZYLEN(harvest_results)) // Might be a unique interaction of an object using the proc to do something weird, or just someone's a donk.
harvest_recent = world.time
return
if(istype(tool, harvest_tool)) // Sanity incase something incorrect is passed in.
harvest_recent = world.time
var/max_harvests = rand(1,harvest_per_hit)
for(var/I = 1 to max_harvests)
var/new_path = pickweight(harvest_results)
new new_path(get_turf(user))
return