Files
+37 21b4095dfd [MDB IGNORE] [IDB IGNORE] Upstream Sync - 04/17/2026 (#5453)
Upstream 04/17/2026

fixes https://github.com/Bubberstation/Bubberstation/issues/5549

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>
Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com>
Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com>
Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com>
Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com>
Co-authored-by: loganuk <fakeemail123@aol.com>
Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com>
Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com>
Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com>
Co-authored-by: Lucy <lucy@absolucy.moe>
Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com>
Co-authored-by: Isratosh <Isratosh@hotmail.com>
Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com>
Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com>
Co-authored-by: Alexander V. <volas@ya.ru>
Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com>
Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Tim <timothymtorres@gmail.com>
Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com>
Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com>
Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com>
Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com>
Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com>
Co-authored-by: Josh <josh.adam.powell@gmail.com>
Co-authored-by: Josh Powell <josh.powell@softwire.com>
Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com>
Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com>
Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com>
Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
2026-05-16 00:56:00 +02:00

113 lines
4.4 KiB
Plaintext

/// Element that makes items turn into other items when you use them on a loom (or any other thing really if you change the var)
/datum/element/loomable
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// What will spawn when the item is loomed
var/resulting_atom
/// How much of item do we need to loom, will be ignored if item isnt a stack
var/required_amount
/// What thing we look for triggering the loom process (usually a loom)
var/atom/loom_type
/// What verb best fits the action of processing whatever the item is, for example "spun [thing]"
var/process_completion_verb
/// If the target needs to be anchored
var/target_needs_anchoring
/// How long it takes to loom the item
var/loom_time
/datum/element/loomable/Attach(
obj/item/target,
resulting_atom = /obj/item/stack/sheet/cloth,
required_amount = 4,
loom_type = /obj/structure/loom,
process_completion_verb = "spun",
target_needs_anchoring = TRUE,
loom_time = 1 SECONDS,
)
. = ..()
//currently this element only works for items as we need to call /obj/item/attack_atom()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
src.resulting_atom = resulting_atom
src.required_amount = required_amount
src.loom_type = loom_type
src.process_completion_verb = process_completion_verb
src.target_needs_anchoring = target_needs_anchoring
src.loom_time = loom_time
RegisterSignal(target, COMSIG_ITEM_ATTACK_ATOM, PROC_REF(try_and_loom_me))
RegisterSignal(target, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
/datum/element/loomable/Detach(obj/item/source)
. = ..()
UnregisterSignal(source, list(COMSIG_ITEM_ATTACK_ATOM, COMSIG_ATOM_EXAMINE))
/// Adds an examine blurb to the description of any item that can be loomed
/datum/element/loomable/proc/on_examine(obj/item/source, mob/examiner, list/examine_list)
SIGNAL_HANDLER
examine_list += span_notice("You could probably process [source] at \a <b>[initial(loom_type.name)]</b>.")
/// Checks if the thing we clicked on can be used as a loom, and if we can actually loom the source at present (an example being does the stack have enough in it (if its a stack))
/datum/element/loomable/proc/try_and_loom_me(obj/item/source, atom/target, mob/living/user)
SIGNAL_HANDLER
if(!istype(target, loom_type))
return
if(ismovable(target))
var/atom/movable/movable_target = target
if(target_needs_anchoring && !movable_target.anchored)
user.balloon_alert(user, "[movable_target] must be secured!")
return
if((required_amount > 1) && istype(source, /obj/item/stack))
var/obj/item/stack/source_stack = source
if(source_stack.amount < required_amount)
user.balloon_alert(user, "need [required_amount] of [source]!")
return
INVOKE_ASYNC(src, PROC_REF(loom_me), source, user, target)
return COMPONENT_CANCEL_ATTACK_CHAIN
/// If a do_after of the specified loom_time passes, will create a new one of resulting_atom and either delete the item, or .use the required amount if its a stack
/datum/element/loomable/proc/loom_me(obj/item/source, mob/living/user, atom/target)
//this allows us to count the amount of times it has successfully used the stack's required amount
var/spawning_amount = 0
var/skill_modifier = user.mind.get_skill_modifier(/datum/skill/production, SKILL_SPEED_MODIFIER) //SKYRAT EDIT
if(isstack(source))
var/obj/item/stack/stack_we_use = source
while(stack_we_use.amount >= required_amount)
if(!do_after(user, loom_time * skill_modifier, target)) //SKYRAT EDIT
break
if(!stack_we_use.use(required_amount))
if (!spawning_amount)
user.balloon_alert(user, "need [required_amount] of [source]!")
break
spawning_amount++
user.mind.adjust_experience(/datum/skill/production, 5) //SKYRAT EDIT
else
if(!do_after(user, loom_time * skill_modifier, target)) //SKYRAT EDIT
user.balloon_alert(user, "interrupted!")
return
qdel(source)
spawning_amount++
user.mind.adjust_experience(/datum/skill/production, 5) //SKYRAT EDIT
if(spawning_amount == 0)
return
var/atom/new_thing = null
if (ispath(resulting_atom, /obj/item/stack))
var/obj/item/stack/stack_type = resulting_atom
while (spawning_amount > 0)
new_thing = new resulting_atom(target.drop_location(), new_amount = min(spawning_amount, stack_type::max_amount))
spawning_amount -= stack_type::max_amount
else
for(var/repeated in 1 to spawning_amount)
new_thing = new resulting_atom(target.drop_location())
user.balloon_alert_to_viewers("[process_completion_verb] [new_thing]")