mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 17:52:36 +00:00
* Fixes diggable turfs being diggable with any item (#66099) Fixes a check for if an item behaved as a shovel in the diggable component where it was returning true regardless of the item used. * Fixes diggable turfs being diggable with any item Co-authored-by: GoblinBackwards <22856555+GoblinBackwards@users.noreply.github.com>
29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
/// Lets you make hitting a turf with a shovel pop something out, and scrape the turf
|
|
/datum/component/diggable
|
|
/// Typepath to spawn on hit
|
|
var/to_spawn
|
|
/// Amount to spawn on hit
|
|
var/amount
|
|
/// What should we tell the user they did?
|
|
var/action_text
|
|
|
|
/datum/component/diggable/Initialize(to_spawn, amount = 1, action_text)
|
|
. = ..()
|
|
if(!isturf(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
src.to_spawn = to_spawn
|
|
src.amount = amount
|
|
src.action_text = action_text
|
|
RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, .proc/handle_attack)
|
|
|
|
/datum/component/diggable/proc/handle_attack(datum/source, obj/item/hit_by, mob/living/bastard, params)
|
|
if(hit_by.tool_behaviour != TOOL_SHOVEL || !params)
|
|
return
|
|
var/turf/parent_turf = parent
|
|
for(var/i in 1 to amount)
|
|
new to_spawn(parent_turf)
|
|
bastard.visible_message(span_notice("[bastard] digs up [parent_turf]."), span_notice("You [action_text] [parent_turf]."))
|
|
playsound(parent_turf, 'sound/effects/shovel_dig.ogg', 50, TRUE)
|
|
parent_turf.ScrapeAway(flags = CHANGETURF_INHERIT_AIR)
|