Files
Bubberstation/code/game/objects/items/stacks/stack.dm
SpaceLoveSs13 7aa6664021 Mirror (#27453)
* Fix Conflicts

* Change COGBAR_ANIMATION_TIME to seconds and not deciseconds (#82530)

Most people should not be using this define

* New Battle Arcade (#81810)

Remakes Battle Arcade from just about the ground up, with exceptions
taken for emagged stuff since I didn't really want to touch its
behavior.

The Battle Arcade now has stages that players can go through, unlocking
a stage by beating 2 enemies and the boss of the previous one, but this
must all be done in a row. You can choose to take a break between each
battle and there's a good chance you'll sleep just fine but there's also
a chance it can go wrong either through an ambush or robbery.

The Inn lets you restore everything for 15 gold and you can buy a sword
and armor, each level you unlock is a new sword and armor pair you can
buy that's better than the last, it's 30 gold each but scales up as you
progress through levels. They are really worth getting so it's best to
try to not lose your money early in.

The battle system is nearly the same as how it was before but I removed
the poor combo system that plagued the old arcade as one big knowledge
lock, now it's more just turn based. The game is built on permadeath so
dying means you restart from the beginning, but if you are going to lose
you can try to escape instead which costs you half of your gold.

Getting to higher levels increases the difficulty of enemies but also
increases the gaming exp rewards which could make this a better way to
get exp if you can get good at it.

Gaming EXP is used to increase chances of counterattacking but doesn't
give any extra health to the player.

I also removed the exploit of being able to screwdriver arcade cabinets
because people would do that if they thought they were on the verge of
losing to bypass the effects of loss. I instead replaced it with a new
interaction that the Curator's display case key can be used to reset
arcade cabinets (there's several keys on the chain so it made sense to
me), which I added solely because I thought Curators would be the type
of person to have run an actual arcade.

This is some gameplay

https://github.com/tgstation/tgstation/assets/53777086/499083f5-75cc-43b5-b457-017a012beede

As a misc sidenote, I also split up the arcade file just like how Orion
Trail was before, just for neat code organization.
The Inn keeper is straight up just a photo of my localhost dude, he's
not a player reference or anything it's not my actual character.
I also have no idea how well balanced this is cause I suck at it lol.

Battle Arcade is one of 3 last machines in my hackmd here to turn into
TGUI https://hackmd.io/XLt5MoRvRxuhFbwtk4VAUA?view
I've always thought the current version of battle arcade is quite lame
and lacks any progression, like Orion Trail I thought that since I was
moving this to TGUI, it would also be a perfect opportunity to revamp it
and try to improve on where it failed before, especially since the
alternative (NTOS Arcade) is also lame as hell and is even lamer than
HTML battle arcade (spam mana, then spam health, then just spam attack,
rinse and repeat).
This will hopefully be more entertaining and give players sense that
they are getting through a series of tasks rather than doing one same
one again and again.

🆑 JohnFulpWillard, Zeek the Rat
add: Battle Arcade has been completely overhauled in a new progression
system, this time using TGUI.
add: The Curator's keys can now reset arcade cabinets.
balance: You now need to be literate to play arcade games, except for
Mediborg's Amputation Adventure.
fix: You can no longer screwdriver emagged arcade consoles. Accept your
fate.
fix: Silicons can no longer play Mediborg's Amputation Adventure.
/🆑

---------

Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com>

* Change setting item weight class to a setter to patch some weight class related shenanigans (#82494)

## About The Pull Request

Fixes #81052 
Fixes #58008

Setting weight class of items is now done via `update_weight_class`.

I updated as many occurrences of manually setting `w_class` as I could
find but I may have missed some. Let me know if you know of any I
missed.

This is done to allow datums to react to an item having its weight class
changed.

Humans and atom storage are two such datums which now react to having an
item in its contents change weight class, to allow it to expel items
that grow to a weight class beyond what is normally allowed.

## Changelog

🆑 Melbert
fix: You can't fit items which are normally too large for a storage by
fitting it in the storage when it is small, then growing it to a larger
size.
/🆑

* Material datum color update, plus touching up some material items (knight armor, tiles) (#82500)

## About The Pull Request

Tries to bring the material datum colors in closer approximation to the
stacks they're attached too. I literally used the colors on the stacks.
some might need to be lighter or darker, but for the most part they'll
look...closer to their actual material hues.

![material datum stuff
2](https://github.com/tgstation/tgstation/assets/40847847/a3a5968f-cab3-43dd-8699-3dae879b21fb)

I've also tweaked the sprites of both the tile object and the actual
material tile turf to give it the right shading.


![image](https://github.com/tgstation/tgstation/assets/40847847/56489479-8774-492b-b8cc-aeabc6c0a67f)

In addition to the tiles, I've also updated the knight armor and helmet
to look closer to the much higher quality plate armor already in the
game.

## Why It's Good For The Game

It bothered me that the material datum coloring was inconsistent with
the actual colors used for the material stacks. When they were updated,
and even before they were updated, material datum stuff just never
looked _right_. I wanted to change that so that it looks just right.

I did not like the old material knight armor whatsoever. It was a
dithered mess, and seemed to already use parts of the standard plate
armor but with all the actual shading removed or replaced with the wrong
colors. This fixes that so that the armor is actually readable for what
it is.

## Changelog
🆑
image: Updates the colors of various material datum to bring them closer
in-line with their actual material stacks
image: Improves the sprites for the material knight armor and helmet.
/🆑

* LateInitialize is not allowed to call parent anymore (#82540)

## About The Pull Request

I've seen a few cases in the past where LateInitialize is done cause of
the init return value being set to do so for no real reason, I thought I
should try to avoid that by ensuring LateInitialize isn't ever called
without overriding.

This fixes a ton of machine's LateInitialize not calling parent
(mechpad, door buttons, message monitor, a lot of tram machines,
abductor console, holodeck computer & disposal bin), avoiding having to
set itself up to be connected to power. If they were intended to not
connect to power, they should be using ``NO_POWER_USE`` instead.

Also removes a ton of returns to LateInit when it's already getting it
from parent regardless (many cases of that in machine code).

## Why It's Good For The Game

I think this is better for coding standard reasons as well as just
making sure we're not calling this proc on things that does absolutely
nothing with them. A machine not using power can be seen evidently not
using power with ``NO_POWER_USE``, not so much if it's LateInitialize
not calling parent.

## Changelog

🆑
fix: Mech pads, door buttons, message monitors, tram machines, abductor
consoles & holodeck computers now use power.
/🆑

* Fix table top deconstruction (#82508)

## About The Pull Request

Edited: updated changelog, read comments for changes in implementation
details

So previously, tables would let you use a wrench to fully deconstruct
them, or a screwdriver to take off only their top.
This, however, broke in two different ways in #82280, when their
deconstruction logic got changed.

First off, deconstructed tables would only drop the materials for their
top and not their frame.
For this, the primary culprit seems to be on line 307:

c34d56a45b/code/game/objects/structures/tables_racks.dm (L300-L307)
Where `new framestack(target_turf, framestackamount)` accidentally got
an extra indent, and ended up in the less common half of the if-else
chain.
Just moving this outside of the if-else chain again fixes it.

Secondly, tables had their own special deconstruction logic, which got
'standardized'.
Issue. This was special to accommodate for having two different
deconstruction logics: full or top only.
With `deconstruct(...)` no longer being overridable, I feel it's awkward
to attempt to proxy that information to the new `atom_deconstruct(...)`
So we introduce a new method, `deconstruct_top`, for the screwdriver to
use, which handles deconstructing only the top.
```dm
/obj/structure/table/proc/deconstruct_top()
	var/obj/table_frame = new frame(loc)
	if(obj_flags & NO_DECONSTRUCTION)
		table_frame.obj_flags |= NO_DECONSTRUCTION
	else // Mimic deconstruction logic, only drop our materials without NO_DECONSTRUCTION
		var/turf/target_turf = get_turf(src)
		drop_top_mats(target_turf)
	qdel(src)
```
Mimicking the `NO_DECONSTRUCTION` logic of normal deconstruction, and
copying over the flag onto its frames if need be.
This fixes screwdriver deconstruction.
## Why It's Good For The Game

Fixes #82503.
We can now deconstruct the table top separately again, AND get the right
materials back too.

## Changelog
🆑 00-Steven, SyncIt21
fix: Wrench table deconstruction gives the right materials again.
fix: Screwdriver table deconstruction only deconstructs the top again.
/🆑

* [NO GBP] Reagent grinders display reagents on examination (#82535)

## About The Pull Request
- Fixes #82531

Somehow omitted this during the general maintenance thing

## Changelog
🆑
fix: Reagent grinders display reagents of its beaker on examination
/🆑

* Monkeys now use height offset (and monkey tail works) (#81598)

This PR adds the ability for monkeys to wear any jumpsuit in the game,
and adds support for them to wear things like coats, gloves, and shoes
(though this cannot be obtained in-game and is solely achieved through
admins, which I also improved a bit upon by adding a defined bitfield
for no equip flags).

This reverts a lot of changes from
https://github.com/tgstation/tgstation/pull/73325 - We no longer check
height from limbs and such to bring sprites down, instead monkeys now
work more similarly to humans, so the entire PR was made irrelevant, and
I didn't really want to leave around dead code for the sake of having a
human with longer legs.

I've now also added support for Dwarfism, which makes monkeys look even
smaller. Very minor change but at least now the mutation doesn't feel
like it does literally nothing to monkeys (since they can already walk
over tables).

Here's a few examples of how it can appear in game (purely for
demonstration, as it is currently intentionally made impossible to
obtain in-game, though if someone wants to change that post-this PR now
that support is added, feel free):

Tails have been broken for a while now, the only reason you see them
in-game is because they are baked into the monkey sprites. This fixes
that, which means humans can now get monkey tails implanted into them
(hell yeah) and monkeys can have their tails removed (also hell yeah)

* Gets [weird] with (spies) by adding protect and deuteragonist-flavored objectives. (#82447)

## About The Pull Request

What are their goals? Why are they doing this? gets weird with Spy
objectives - namely by adding a lot more ways spies might be asked to
affect various targets around the station.

the first of these is by several flavors of Protecting targets (these do
NOT print a success at roundend in keeping with Spy design:)
- Protect (get a humanoid target off alive)
- Protect Nonhuman (get an entity off alive)
- Jailbreak (make sure a humanoid target escapes free)
- Detain (make sure a humanoid target gets taken out arrested)

the second of this is by a new escape condition: 
- Exile (get off-station or off the Z-level by the end of the shift -
sometimes it's not just pods, you need to fuck off to space to win.)

the third is through a massive increase in the number of possible:
- objective templates 
- departments to target (Command + Service added)
- specific locations to target
- general classes of objects to target (medicines, floor tiles, critical
infrastructure, etc.)
- efforts to target (such as meals, mechs, public supplies)
- ways to leave (you can be asked to abscond from the scene of your
crimes?)

## Why It's Good For The Game

More goofy and weird prompts to do more interesting things with Spies.
One thing I think we're sorely missing in our lineup is antagonists that
can act a bit more as deuteragonists - very possibly helping the crew
under certain conditions and frustrating the Hell out of them in others.

Since there's no way to check their objectives, and they get their
gear/progression through stealing shit, they're still very much an
antagonist and exist under the suspicion of doing bad... but, just going
by their objectives, introducing more varied (and in some cases even
benign) goals for them creates suggestions pointing to a lot more varied
and interesting stories if people choose to run with it.

* Adds anosmia quirk (#82206)

## About The Pull Request

Adds anosmia quirk. Anosmia, also known as smell blindness, is the loss
of the ability to detect one or more smells.

I tried to find all smells action and (most likely) update all of them,
unfortunately I can't change descriptions for this quirk.

## Why It's Good For The Game

Some characters will be able to not feel smells
That affect:
* Gases feelings and alerts (CO2, Plasma, miasm) - you don't feel them
* Bakery and cooking
* Changeling ability to feel other changelings by smell
* Some unimportant spans

* Explosions Part I - Directional Explosions (#82429)

## About The Pull Request

Adds the ability for explosions to be directional. This is achieved by
adding an angle check to `prepare_explosion_turfs()` to drop any turfs
outside the cone of the explosion. If the arc covers a full 360 degrees,
as is the default, it will accept all the turfs without performing the
angle check.

Uses this functionality to rework both rocket launcher backblast and X4
explosions. Rocket launcher backblast has been changed from a shotgun of
indendiary bullets to a directional explosion of similar length. X4 now
uses a directional explosion to "ensure user safety".

Apparently the old method of moving the explosion one tile away didn't
even work, as it blew up `target` before trying to check its density for
the directional behaviour.

https://youtu.be/Mzdt7d7Le2Y

## Why It's Good For The Game

Directional explosions - Useful functionality for a range of potential
use cases, which can be implemented with minimal extra processing cost
(Worst case scenario being very large directional explosions)

Backblast - Looks way cooler than a bunch of projectiles, and should be
significantly more functional in high-lag situations where projectile
code tends to get fucky

X4 - More predictable for players wanting to use it as a breaching
charge, you can actually stand near the charge and not have to worry
about being hoist upon your own petard.

## Changelog
🆑
add: Added support for directional explosions.
add: Rocket launcher backblast is now 271% more explosive, check your
six for friendlies!
add: X4 charges now explode in a cone away from the user when placed on
a sufficiently solid object.
fix: X4 charges will now behave correctly when placed on dense atoms
(note: don't try to read a variable from an atom you just blew up)
/🆑

* Add balloon alerts to plunging (#82559)

## About The Pull Request

Makes all plunging actions (pretty much anything using `plunger_act`)
have a visible balloon alert.

## Why It's Good For The Game

Makes sense that others would easily notice you plunging the shit out of
something.

Also, more people might finally learn that you can plunge the vent clogs
instead of welding them.

## Changelog
🆑
qol: Added balloon alerts whenever you start plunging something (i.e )
/🆑

* Fixes spurious runtime on Icemoon caused by turf calling unimplemented LateInitialize() (#82572)

## About The Pull Request

As of https://github.com/tgstation/tgstation/pull/82540 this runtime was
happening,


![image](https://github.com/tgstation/tgstation/assets/13398309/4d838fda-c157-4e33-ae64-77eafca1806f)

`/turf/open/openspace/icemoon/` can be changed to
`/turf/open/misc/asteroid/snow/icemoon/do_not_chasm` before
`Initialize()` returns, which resulted in it `INITIALIZE_HINT_LATELOAD`
getting returned on a turf that does not have an implementation of that
proc.

This should fix that.

## Why It's Good For The Game

Fixes CI error

* Blueprints tgui (#82565)

Blueprints now use a TGUI panel instead of the old HTML one.
Also did general code improvement and maintaining to blueprints in
general and also destroyed the ``areaeditor`` level, repathing it to
just 'blueprints'.
Also adds a sound when you look at structural data cause why not

Video demonstration:

https://github.com/tgstation/tgstation/assets/53777086/861773fd-3d57-472d-bc94-d67b0d4f1dbd

The 4 blueprint types:

![image](https://github.com/tgstation/tgstation/assets/53777086/bfd68eb5-c430-4608-a3f7-d6ac86727882)

Another HTML menu dead underground.
This is more responsive and doesn't require constant updating to see
which area you're in, feels less OOC (instead of saying "the blueprints
say", just say it, you ARE the blueprints).

Like, come on

![image](https://github.com/tgstation/tgstation/assets/53777086/fcf1b8b6-37c3-4c94-969f-3b121c983dc0)

Look at all this wasted space

![image](https://github.com/tgstation/tgstation/assets/53777086/1d3e61cd-bc56-4280-a3bb-0c66604e75b3)

🆑
refactor: Blueprints now use TGUI.
qol: Blueprints can now be used while lying down.
/🆑

* General maintenance for chem master (#82002)

**1. Qol**
- Adds screen tips & examines for screwdriver, wrench, crowbar & beaker
insertion, removal & replacing actions
- Analyzing reagents is now a client side feature & not a back end mode,
meaning one person can see details of a reagent while the other can
print stuff and do other operations so it's a non blocking operation.
This also means 2 players can see information of 2 different reagents in
their own screens, With that the overlay for analysis mode has been
removed
- You cannot do any tool acts on machines while printing. Balloon alerts
will be displayed warning you of that.
- The preferred container for the master reagent in the beaker is now
showed in both condiment & chem master. It can be enabled/disabled via a
CheckBox

**2. Code Improvements**
- Removed defines like `TARGET_BEAKER` , `TARGET_BEAKER` etc. ther
functionality is implemented as params in the `transfer_reagent()` proc
directly
- Removed all variables relating to analyzing reagents like
`reagent_analysis_mode`, `has_container_suggestion` etc. all memory
savings
- `printable_containers` now stores static values that can be shared
across many chem masters
- Updates only overlays and not the whole icon during operations for
efficiency

**3. Fixes**
- You can hit the chem master with the screwdriver, wrench, crowbar &
beaker when in combat mode
 - You cannot insert hologram items into the chem master
- Deconstructing a condiment master will give you the circuit board
already pre-programmed with that option selected so you don't need to
use a screwdriver to re program it
- `printing_amount` is now the maximum number of containers that can be
printed at a time. Presently this number with upgraded parts would print
out empty containers especially for patches. This is because
`volume_per_item` does not take into consideration this var. Also this
var would not give control to the player on exactly how many containers
to print as whatever amount the player entered would be multiplied with
this value producing a lot of waste & worse empty containers. Now this
var determines exactly how many containers you can print and is imposed
on the client side UI as well

**4. Refactors (UI performance)**
- Beaker data is compressed into a single entity & sent to the UI. This
is set to null if no beaker is loaded thus saving data sent
- Reuses Beaker props from chem synthesizer to reduce code
- reagent REF replaced with direct type converted to text and later
converted with `text2path()` cause its much faster

🆑
qol: Adds screen tips & examines for screwdriver, wrench, crowbar &
beaker insertion, removal & replacing actions
qol: Analyzing reagents no longer blocks other players from doing other
operations. Multiple players can analyze different reagents on the same
machine
qol: You cannot do any tool acts on the machine while printing to
prevent any side effects.
qol: The preferred container for the master reagent in the beaker is now
showed in both condiment & chem master. The feature can be
enabled/disabled via a check box
code: removed defines for reagent transfer, vars for reagent analyzis to
save memory. Autodoc for other vars & procs
fix: You can hit the chem master with tools like screwdriver, crowbar,
wrench & beaker in combat mode
fix: You cannot insert hologram items into the chem master
fix: Deconstructing a condiment master will give you the circuit board
already pre-programmed with that option
fix: You now print the exact amount of containers requested even with
upgraded parts without creating empty containers. Max printable
containers is 13 with tier 4 parts able to print 50 containers.
refactor: Optimized client side UI code & chem master as a whole.
/🆑

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>

* Wraps `lowertext()` to ensure proper stringification. (#82442)

Fixes #82440

This PR just creates a new macro, `LOWER_TEXT()` (yes the irony is not
lost on me) to wrap around all calls of `lowertext()` and ensure that
whatever we input into that proc will be stringified using the `"[]"`
(or `tostring()` for the nerds) operator. very simple.

I also added a linter to enforce this (and prevent all forms of
regression) because I think that machines should do the menial work and
we shouldn't expect maintainers to remember this, let me know if you
disagree. if there is a time when it should be opted out for some
reason, the linter does respect it if you wrap your input with the
`UNLINT()` function.

* Clowns can now make balloon... toys. And also mallets and hats. (#82288)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

Clowns will now start with a box of 24 random long balloons and a
skillchip in their noggin allowing them to create balloon animals by
combining two of them of different colour together. Owners of the
skillchip also gain access to crafting recepies of balloon mallets,
vests, helmets and tophats, all created from long balloons. A crate of
long balloons, with a box of balloons inside, can be bought at cargo, in
case the clown runs out. I might edit this once I wake up, its 3 in the
morning right now.
Oh also, resprited how balloons look in inventory.

![image](https://github.com/tgstation/tgstation/assets/122572637/2d7ce955-c787-48a5-bfda-4613d2eed837)

Balloon animals funny.
Silly features are my favourite kind of features, and this one's
open-ended too.
Someone on the coder chat recommended someone would do it that one time,
here it goes.

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑
add: Added long balloon box to the clown's starting inventory, and a
skill-chip of long lost honk-motherian knowledge to their brain.
add: Added long balloons. Consequently, added balloon animals to make
from such balloons. Also, balloon top hat, vest, helmet, and a mallet.
Don't ask about the mallet.
add: A long balloons box harvested fresh from the farms on the clown
planet will be able to be shipped in a crate to the cargo department
near you!
add: As per requests; water balloons can now be printed at service
lathe, and entertainment modsuit can now blow long balloons!
image: Balloons will now have an unique sprite when in the inventory,
compared when to on the ground.
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Jacquerel <hnevard@gmail.com>

* Quick spellcheck 'steall' (#82560)

## About The Pull Request

https://github.com/tgstation/tgstation/pull/82447 quick followup to
this, caught it while glancing through the code.

* Fix

* merge conflicts

* Revert "Monkeys now use height offset (and monkey tail works) (#81598)"

This reverts commit 5cfdc5972d16c6b509220e8874a927696249d36a.

* fix

* Fixed lateinitialize

* This should cut it

* Oh right

* There?

* Damn, here?

* There

* [NO GBP] Fixes spurious runtime caused by icemoon (again) (#82582)

## About The Pull Request

https://github.com/tgstation/tgstation/pull/82572 I tried to fix this
but there was an unaccounted race condition which just caused a separate
runtime...


![firefox_GxGibAO281](https://github.com/tgstation/tgstation/assets/13398309/f251aecc-ef17-4bae-a741-5aade40de423)

Since the type is being changed mid-execution `replacement_turf` will
become out of scope. My bad--this should fix it now for good.

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com>
Co-authored-by: necromanceranne <40847847+necromanceranne@users.noreply.github.com>
Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: Higgin <cdonny11@yahoo.com>
Co-authored-by: NeonNik2245 <106491639+NeonNik2245@users.noreply.github.com>
Co-authored-by: Thunder12345 <Thunder12345@users.noreply.github.com>
Co-authored-by: Lucy <lucy@absolucy.moe>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: YesterdaysPromise <122572637+YesterdaysPromise@users.noreply.github.com>
Co-authored-by: Jacquerel <hnevard@gmail.com>
Co-authored-by: Useroth <37159550+Useroth@users.noreply.github.com>
2024-04-26 01:22:24 +02:00

748 lines
26 KiB
Plaintext

//stack recipe placement check types
/// Checks if there is an object of the result type in any of the cardinal directions
#define STACK_CHECK_CARDINALS (1<<0)
/// Checks if there is an object of the result type within one tile
#define STACK_CHECK_ADJACENT (1<<1)
/* Stack type objects!
* Contains:
* Stacks
* Recipe datum
* Recipe list datum
*/
/*
* Stacks
*/
/obj/item/stack
icon = 'icons/obj/stack_objects.dmi'
gender = PLURAL
material_modifier = 0.05 //5%, so that a 50 sheet stack has the effect of 5k materials instead of 100k.
max_integrity = 100
item_flags = SKIP_FANTASY_ON_SPAWN
/// A list to all recipies this stack item can create.
var/list/datum/stack_recipe/recipes
/// What's the name of just 1 of this stack. You have a stack of leather, but one piece of leather
var/singular_name
/// How much is in this stack?
var/amount = 1
/// How much is allowed in this stack?
// Also see stack recipes initialisation. "max_res_amount" must be equal to this max_amount
var/max_amount = 50
/// If TRUE, this stack is a module used by a cyborg (doesn't run out like normal / etc)
var/is_cyborg = FALSE
/// Related to above. If present, the energy we draw from when using stack items, for cyborgs
var/datum/robot_energy_storage/source
/// Related to above. How much energy it costs from storage to use stack items
var/cost = 1
/// This path and its children should merge with this stack, defaults to src.type
var/merge_type = null
/// The weight class the stack has at amount > 2/3rds max_amount
var/full_w_class = WEIGHT_CLASS_NORMAL
/// Determines whether the item should update it's sprites based on amount.
var/novariants = TRUE
/// List that tells you how much is in a single unit.
var/list/mats_per_unit
/// Datum material type that this stack is made of
var/material_type
// NOTE: When adding grind_results, the amounts should be for an INDIVIDUAL ITEM -
// these amounts will be multiplied by the stack size in on_grind()
/// Amount of matter given back to RCDs
var/matter_amount = 0
/// Does this stack require a unique girder in order to make a wall?
var/has_unique_girder = FALSE
/// What typepath table we create from this stack
var/obj/structure/table/tableVariant
/// What typepath stairs do we create from this stack
var/obj/structure/stairs/stairs_type
/// If TRUE, we'll use a radial instead when displaying recipes
var/use_radial = FALSE
/// If use_radial is TRUE, this is the radius of the radial
var/radial_radius = 52
// The following are all for medical treatment
// They're here instead of /stack/medical
// because sticky tape can be used as a makeshift bandage or splint
/// If set and this used as a splint for a broken bone wound,
/// This is used as a multiplier for applicable slowdowns (lower = better) (also for speeding up burn recoveries)
var/splint_factor
/// Like splint_factor but for burns instead of bone wounds. This is a multiplier used to speed up burn recoveries
var/burn_cleanliness_bonus
/// How much blood flow this stack can absorb if used as a bandage on a cut wound.
/// note that absorption is how much we lower the flow rate, not the raw amount of blood we suck up
var/absorption_capacity
/// How quickly we lower the blood flow on a cut wound we're bandaging.
/// Expected lifetime of this bandage in seconds is thus absorption_capacity/absorption_rate,
/// or until the cut heals, whichever comes first
var/absorption_rate
/obj/item/stack/Initialize(mapload, new_amount, merge = TRUE, list/mat_override=null, mat_amt=1)
if(new_amount != null)
amount = new_amount
while(amount > max_amount)
amount -= max_amount
new type(loc, max_amount, FALSE)
if(!merge_type)
merge_type = type
if(LAZYLEN(mat_override))
set_mats_per_unit(mat_override, mat_amt)
else if(LAZYLEN(mats_per_unit))
set_mats_per_unit(mats_per_unit, 1)
else if(LAZYLEN(custom_materials))
set_mats_per_unit(custom_materials, amount ? 1/amount : 1)
. = ..()
if(merge)
for(var/obj/item/stack/item_stack in loc)
if(item_stack == src)
continue
if(can_merge(item_stack))
INVOKE_ASYNC(src, PROC_REF(merge_without_del), item_stack)
if(is_zero_amount(delete_if_zero = FALSE))
return INITIALIZE_HINT_QDEL
recipes = get_main_recipes().Copy()
if(material_type)
var/datum/material/what_are_we_made_of = GET_MATERIAL_REF(material_type) //First/main material
for(var/category in what_are_we_made_of.categories)
switch(category)
if(MAT_CATEGORY_BASE_RECIPES)
recipes |= SSmaterials.base_stack_recipes.Copy()
if(MAT_CATEGORY_RIGID)
recipes |= SSmaterials.rigid_stack_recipes.Copy()
update_weight()
update_appearance()
var/static/list/loc_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(on_movable_entered_occupied_turf),
)
AddElement(/datum/element/connect_loc, loc_connections)
if(is_path_in_list(merge_type, GLOB.golem_stack_food_directory))
AddComponent(/datum/component/golem_food, golem_food_key = merge_type)
/** Sets the amount of materials per unit for this stack.
*
* Arguments:
* - [mats][/list]: The value to set the mats per unit to.
* - multiplier: The amount to multiply the mats per unit by. Defaults to 1.
*/
/obj/item/stack/proc/set_mats_per_unit(list/mats, multiplier=1)
mats_per_unit = SSmaterials.FindOrCreateMaterialCombo(mats, multiplier)
update_custom_materials()
/** Updates the custom materials list of this stack.
*/
/obj/item/stack/proc/update_custom_materials()
set_custom_materials(mats_per_unit, amount, is_update=TRUE)
/**
* Override to make things like metalgen accurately set custom materials
*/
/obj/item/stack/set_custom_materials(list/materials, multiplier=1, is_update=FALSE)
return is_update ? ..() : set_mats_per_unit(materials, multiplier/(amount || 1))
/obj/item/stack/blend_requirements()
if(is_cyborg)
to_chat(usr, span_warning("[src] is too integrated into your chassis and can't be ground up!"))
return
return TRUE
/obj/item/stack/grind(datum/reagents/target_holder, mob/user)
var/current_amount = get_amount()
if(current_amount <= 0 || QDELETED(src)) //just to get rid of this 0 amount/deleted stack we return success
return TRUE
if(on_grind() == -1)
return FALSE
if(isnull(target_holder))
return TRUE
if(reagents)
reagents.trans_to(target_holder, reagents.total_volume, transferred_by = user)
var/available_volume = target_holder.maximum_volume - target_holder.total_volume
//compute total volume of reagents that will be occupied by grind_results
var/total_volume = 0
for(var/reagent in grind_results)
total_volume += grind_results[reagent]
//compute number of pieces(or sheets) from available_volume
var/available_amount = min(current_amount, round(available_volume / total_volume))
if(available_amount <= 0)
return FALSE
//Now transfer the grind results scaled by available_amount
var/list/grind_reagents = grind_results.Copy()
for(var/reagent in grind_reagents)
grind_reagents[reagent] *= available_amount
target_holder.add_reagent_list(grind_reagents)
/**
* use available_amount of sheets/pieces, return TRUE only if all sheets/pieces of this stack were used
* we don't delete this stack when it reaches 0 because we expect the all in one grinder, etc to delete
* this stack if grinding was successfull
*/
use(available_amount, check = FALSE)
return available_amount == current_amount
/obj/item/stack/proc/get_main_recipes()
RETURN_TYPE(/list)
SHOULD_CALL_PARENT(TRUE)
return list() //empty list
/obj/item/stack/proc/update_weight()
if(amount <= (max_amount * (1/3)))
update_weight_class(clamp(full_w_class-2, WEIGHT_CLASS_TINY, full_w_class))
else if (amount <= (max_amount * (2/3)))
update_weight_class(clamp(full_w_class-1, WEIGHT_CLASS_TINY, full_w_class))
else
update_weight_class(full_w_class)
/obj/item/stack/update_icon_state()
if(novariants)
return ..()
if(amount <= (max_amount * (1/3)))
icon_state = initial(icon_state)
return ..()
if (amount <= (max_amount * (2/3)))
icon_state = "[initial(icon_state)]_2"
return ..()
icon_state = "[initial(icon_state)]_3"
return ..()
/obj/item/stack/examine(mob/user)
. = ..()
if(is_cyborg)
return
if(singular_name)
if(get_amount()>1)
. += "There are [get_amount()] [singular_name]\s in the stack."
else
. += "There is [get_amount()] [singular_name] in the stack."
else if(get_amount()>1)
. += "There are [get_amount()] in the stack."
else
. += "There is [get_amount()] in the stack."
. += span_notice("<b>Right-click</b> with an empty hand to take a custom amount.")
/obj/item/stack/proc/get_amount()
if(is_cyborg)
. = round(source?.energy / cost)
else
. = (amount)
/**
* Builds all recipes in a given recipe list and returns an association list containing them
*
* Arguments:
* * recipe_to_iterate - The list of recipes we are using to build recipes
*/
/obj/item/stack/proc/recursively_build_recipes(list/recipe_to_iterate)
var/list/L = list()
for(var/recipe in recipe_to_iterate)
if(istype(recipe, /datum/stack_recipe_list))
var/datum/stack_recipe_list/R = recipe
L["[R.title]"] = recursively_build_recipes(R.recipes)
if(istype(recipe, /datum/stack_recipe))
var/datum/stack_recipe/R = recipe
L["[R.title]"] = build_recipe(R)
return L
/**
* Returns a list of properties of a given recipe
*
* Arguments:
* * R - The stack recipe we are using to get a list of properties
*/
/obj/item/stack/proc/build_recipe(datum/stack_recipe/R)
return list(
"res_amount" = R.res_amount,
"max_res_amount" = R.max_res_amount,
"req_amount" = R.req_amount,
"ref" = text_ref(R),
)
/**
* Checks if the recipe is valid to be used
*
* Arguments:
* * R - The stack recipe we are checking if it is valid
* * recipe_list - The list of recipes we are using to check the given recipe
*/
/obj/item/stack/proc/is_valid_recipe(datum/stack_recipe/R, list/recipe_list)
for(var/S in recipe_list)
if(S == R)
return TRUE
if(istype(S, /datum/stack_recipe_list))
var/datum/stack_recipe_list/L = S
if(is_valid_recipe(R, L.recipes))
return TRUE
return FALSE
/obj/item/stack/interact(mob/user)
if(use_radial)
show_construction_radial(user)
else
ui_interact(user)
/obj/item/stack/ui_state(mob/user)
return GLOB.hands_state
/obj/item/stack/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "StackCrafting", name)
ui.open()
/obj/item/stack/ui_data(mob/user)
var/list/data = list()
data["amount"] = get_amount()
return data
/obj/item/stack/ui_static_data(mob/user)
var/list/data = list()
data["recipes"] = recursively_build_recipes(recipes)
return data
/obj/item/stack/ui_act(action, params)
. = ..()
if(.)
return
switch(action)
if("make")
var/datum/stack_recipe/recipe = locate(params["ref"])
var/multiplier = text2num(params["multiplier"])
return make_item(usr, recipe, multiplier)
/// The key / title for a radial option that shows the entire list of buildables (uses the old menu)
#define FULL_LIST "view full list"
/// Shows a radial consisting of every radial recipe we have in our list.
/obj/item/stack/proc/show_construction_radial(mob/builder)
var/list/options = list()
var/list/titles_to_recipes = list()
for(var/datum/stack_recipe/radial/recipe in recipes)
var/datum/radial_menu_choice/option = new()
option.image = image(
icon = initial(recipe.result_type.icon),
icon_state = initial(recipe.result_type.icon_state),
)
if(recipe.desc)
option.info = recipe.desc
options[recipe.title] = option
titles_to_recipes[recipe.title] = recipe
// After everything's been added to the radial, add an option
// that lets the user see the whole list of buildables
options[FULL_LIST] = image(
icon = 'icons/hud/radial.dmi',
icon_state = "radial_full_list",
)
var/selection = show_radial_menu(
user = builder,
anchor = builder,
choices = options,
custom_check = CALLBACK(src, PROC_REF(radial_check), builder),
radius = radial_radius,
tooltips = TRUE,
)
if(!selection)
return
// Run normal UI interact if we wanna see the full list
if(selection == FULL_LIST)
ui_interact(builder)
return
// Otherwise go straight to building
var/datum/stack_recipe/picked_recipe = titles_to_recipes[selection]
if(!istype(picked_recipe))
return
make_item(builder, picked_recipe, 1)
/// Used as a callback for radial building.
/obj/item/stack/proc/radial_check(mob/builder)
if(QDELETED(builder) || QDELETED(src))
return FALSE
if(builder.incapacitated())
return FALSE
if(!builder.is_holding(src))
return FALSE
return TRUE
#undef FULL_LIST
/// Makes the item with the given recipe.
/obj/item/stack/proc/make_item(mob/builder, datum/stack_recipe/recipe, multiplier)
if(get_amount() < 1 && !is_cyborg) //sanity check as this shouldn't happen
qdel(src)
return
if(!is_valid_recipe(recipe, recipes)) //href exploit protection
return
if(!multiplier || multiplier < 1 || !IS_FINITE(multiplier)) //href exploit protection
stack_trace("Invalid multiplier value in stack creation [multiplier], [usr] is likely attempting an exploit")
return
if(!building_checks(builder, recipe, multiplier))
return
if(recipe.time)
var/adjusted_time = 0
builder.balloon_alert(builder, "building...")
builder.visible_message(
span_notice("[builder] starts building \a [recipe.title]."),
span_notice("You start building \a [recipe.title]..."),
)
if(HAS_TRAIT(builder, recipe.trait_booster))
adjusted_time = (recipe.time * recipe.trait_modifier)
else
adjusted_time = recipe.time
if(!do_after(builder, adjusted_time, target = builder))
builder.balloon_alert(builder, "interrupted!")
return
if(!building_checks(builder, recipe, multiplier))
return
var/atom/created
if(recipe.max_res_amount > 1) // Is it a stack?
created = new recipe.result_type(builder.drop_location(), recipe.res_amount * multiplier)
builder.balloon_alert(builder, "built items")
else if(ispath(recipe.result_type, /turf))
var/turf/covered_turf = builder.drop_location()
if(!isturf(covered_turf))
return
var/turf/created_turf = covered_turf.place_on_top(recipe.result_type, flags = CHANGETURF_INHERIT_AIR)
builder.balloon_alert(builder, "placed [ispath(recipe.result_type, /turf/open) ? "floor" : "wall"]")
if(recipe.applies_mats && LAZYLEN(mats_per_unit))
created_turf.set_custom_materials(mats_per_unit, recipe.req_amount / recipe.res_amount)
else
created = new recipe.result_type(builder.drop_location())
builder.balloon_alert(builder, "built item")
if(created)
created.setDir(builder.dir)
on_item_crafted(builder, created)
// Use up the material
use(recipe.req_amount * multiplier)
builder.investigate_log("crafted [recipe.title]", INVESTIGATE_CRAFTING)
// Apply mat datums
if(recipe.applies_mats && LAZYLEN(mats_per_unit))
if(isstack(created))
var/obj/item/stack/crafted_stack = created
crafted_stack.set_mats_per_unit(mats_per_unit, recipe.req_amount / recipe.res_amount)
else
created.set_custom_materials(mats_per_unit, recipe.req_amount / recipe.res_amount)
// We could be qdeleted - like if it's a stack and has already been merged
if(QDELETED(created))
return TRUE
// Add fingerprints first, otherwise created might already be deleted because of stack merging
created.add_fingerprint(builder)
if(isitem(created))
builder.put_in_hands(created)
//BubbleWrap - so newly formed boxes are empty
if(istype(created, /obj/item/storage))
for (var/obj/item/thing in created)
qdel(thing)
//BubbleWrap END
return TRUE
/// Run special logic on created items after they've been successfully crafted.
/obj/item/stack/proc/on_item_crafted(mob/builder, atom/created)
return
/obj/item/stack/vv_edit_var(vname, vval)
if(vname == NAMEOF(src, amount))
add(clamp(vval, 1-amount, max_amount - amount)) //there must always be one.
return TRUE
else if(vname == NAMEOF(src, max_amount))
max_amount = max(vval, 1)
add((max_amount < amount) ? (max_amount - amount) : 0) //update icon, weight, ect
return TRUE
return ..()
/// Checks if we can build here, validly.
/obj/item/stack/proc/building_checks(mob/builder, datum/stack_recipe/recipe, multiplier)
if (get_amount() < recipe.req_amount * multiplier)
builder.balloon_alert(builder, "not enough material!")
return FALSE
var/turf/dest_turf = get_turf(builder)
if(recipe.one_per_turf && (locate(recipe.result_type) in dest_turf))
builder.balloon_alert(builder, "already one here!")
return FALSE
if(recipe.check_direction)
if(!valid_build_direction(dest_turf, builder.dir, is_fulltile = recipe.is_fulltile))
builder.balloon_alert(builder, "won't fit here!")
return FALSE
if(recipe.on_solid_ground)
if(isclosedturf(dest_turf))
builder.balloon_alert(builder, "cannot be made on a wall!")
return FALSE
if(is_type_in_typecache(dest_turf, GLOB.turfs_without_ground))
if(!locate(/obj/structure/thermoplastic) in dest_turf) // for tram construction
builder.balloon_alert(builder, "must be made on solid ground!")
return FALSE
if(recipe.check_density)
for(var/obj/object in dest_turf)
if(object.density && !(object.obj_flags & IGNORE_DENSITY) || object.obj_flags & BLOCKS_CONSTRUCTION)
builder.balloon_alert(builder, "something is in the way!")
return FALSE
if(recipe.placement_checks & STACK_CHECK_CARDINALS)
var/turf/nearby_turf
for(var/direction in GLOB.cardinals)
nearby_turf = get_step(dest_turf, direction)
if(locate(recipe.result_type) in nearby_turf)
to_chat(builder, span_warning("\The [recipe.title] must not be built directly adjacent to another!"))
builder.balloon_alert(builder, "can't be adjacent to another!")
return FALSE
if(recipe.placement_checks & STACK_CHECK_ADJACENT)
if(locate(recipe.result_type) in range(1, dest_turf))
builder.balloon_alert(builder, "can't be near another!")
return FALSE
if(recipe.placement_checks & STACK_CHECK_TRAM_FORBIDDEN)
if(locate(/obj/structure/transport/linear/tram) in dest_turf || locate(/obj/structure/thermoplastic) in dest_turf)
builder.balloon_alert(builder, "can't be on tram!")
return FALSE
if(recipe.placement_checks & STACK_CHECK_TRAM_EXCLUSIVE)
if(!locate(/obj/structure/transport/linear/tram) in dest_turf)
builder.balloon_alert(builder, "must be made on a tram!")
return FALSE
return TRUE
/obj/item/stack/use(used, transfer = FALSE, check = TRUE) // return 0 = borked; return 1 = had enough
if(check && is_zero_amount(delete_if_zero = TRUE))
return FALSE
if(is_cyborg)
return source.use_charge(used * cost)
if (amount < used)
return FALSE
amount -= used
if(check && is_zero_amount(delete_if_zero = TRUE))
return TRUE
if(length(mats_per_unit))
update_custom_materials()
update_appearance()
update_weight()
return TRUE
/obj/item/stack/tool_use_check(mob/living/user, amount)
if(get_amount() < amount)
// general balloon alert that says they don't have enough
user.balloon_alert(user, "not enough material!")
// then a more specific message about how much they need and what they need specifically
if(singular_name)
if(amount > 1)
to_chat(user, span_warning("You need at least [amount] [singular_name]\s to do this!"))
else
to_chat(user, span_warning("You need at least [amount] [singular_name] to do this!"))
else
to_chat(user, span_warning("You need at least [amount] to do this!"))
return FALSE
return TRUE
/**
* Returns TRUE if the item stack is the equivalent of a 0 amount item.
*
* Also deletes the item if delete_if_zero is TRUE and the stack does not have
* is_cyborg set to true.
*/
/obj/item/stack/proc/is_zero_amount(delete_if_zero = TRUE)
if(is_cyborg)
return source.energy < cost
if(amount < 1)
if(delete_if_zero)
qdel(src)
return TRUE
return FALSE
/** Adds some number of units to this stack.
*
* Arguments:
* - _amount: The number of units to add to this stack.
*/
/obj/item/stack/proc/add(_amount)
if(is_cyborg)
source.add_charge(_amount * cost)
else
amount += _amount
if(length(mats_per_unit))
update_custom_materials()
update_appearance()
update_weight()
/** Checks whether this stack can merge itself into another stack.
*
* Arguments:
* - [check][/obj/item/stack]: The stack to check for mergeability.
* - [inhand][boolean]: Whether or not the stack to check should act like it's in a mob's hand.
*/
/obj/item/stack/proc/can_merge(obj/item/stack/check, inhand = FALSE)
// We don't only use istype here, since that will match subtypes, and stack things that shouldn't stack
if(!istype(check, merge_type) || check.merge_type != merge_type)
return FALSE
if(mats_per_unit ~! check.mats_per_unit) // ~! in case of lists this operator checks only keys, but not values
return FALSE
if(is_cyborg) // No merging cyborg stacks into other stacks
return FALSE
if(ismob(loc) && !inhand) // no merging with items that are on the mob
return FALSE
if(istype(loc, /obj/machinery)) // no merging items in machines that aren't both in componentparts
var/obj/machinery/machine = loc
if(!(src in machine.component_parts) || !(check in machine.component_parts))
return FALSE
if(SEND_SIGNAL(src, COMSIG_STACK_CAN_MERGE, check, inhand) & CANCEL_STACK_MERGE)
return FALSE
return TRUE
/**
* Merges as much of src into target_stack as possible. If present, the limit arg overrides target_stack.max_amount for transfer.
*
* This calls use() without check = FALSE, preventing the item from qdeling itself if it reaches 0 stack size.
*
* As a result, this proc can leave behind a 0 amount stack.
*/
/obj/item/stack/proc/merge_without_del(obj/item/stack/target_stack, limit)
// Cover edge cases where multiple stacks are being merged together and haven't been deleted properly.
// Also cover edge case where a stack is being merged into itself, which is supposedly possible.
if(QDELETED(target_stack))
CRASH("Stack merge attempted on qdeleted target stack.")
if(QDELETED(src))
CRASH("Stack merge attempted on qdeleted source stack.")
if(target_stack == src)
CRASH("Stack attempted to merge into itself.")
var/transfer = get_amount()
if(target_stack.is_cyborg)
transfer = min(transfer, round((target_stack.source.max_energy - target_stack.source.energy) / target_stack.cost))
else
transfer = min(transfer, (limit ? limit : target_stack.max_amount) - target_stack.amount)
if(pulledby)
pulledby.start_pulling(target_stack)
target_stack.copy_evidences(src)
use(transfer, transfer = TRUE, check = FALSE)
target_stack.add(transfer)
if(target_stack.mats_per_unit != mats_per_unit) // We get the average value of mats_per_unit between two stacks getting merged
var/list/temp_mats_list = list() // mats_per_unit is passed by ref into this coil, and that same ref is used in other places. If we didn't make a new list here we'd end up contaminating those other places, which leads to batshit behavior
for(var/mat_type in target_stack.mats_per_unit)
temp_mats_list[mat_type] = (target_stack.mats_per_unit[mat_type] * (target_stack.amount - transfer) + mats_per_unit[mat_type] * transfer) / target_stack.amount
target_stack.mats_per_unit = temp_mats_list
return transfer
/**
* Merges as much of src into target_stack as possible. If present, the limit arg overrides target_stack.max_amount for transfer.
*
* This proc deletes src if the remaining amount after the transfer is 0.
*/
/obj/item/stack/proc/merge(obj/item/stack/target_stack, limit)
. = merge_without_del(target_stack, limit)
is_zero_amount(delete_if_zero = TRUE)
/// Signal handler for connect_loc element. Called when a movable enters the turf we're currently occupying. Merges if possible.
/obj/item/stack/proc/on_movable_entered_occupied_turf(datum/source, atom/movable/arrived)
SIGNAL_HANDLER
// Edge case. This signal will also be sent when src has entered the turf. Don't want to merge with ourselves.
if(arrived == src)
return
if(!arrived.throwing && can_merge(arrived))
INVOKE_ASYNC(src, PROC_REF(merge), arrived)
/obj/item/stack/hitby(atom/movable/hitting, skipcatch, hitpush, blocked, datum/thrownthing/throwingdatum)
if(can_merge(hitting, inhand = TRUE))
merge(hitting)
. = ..()
//ATTACK HAND IGNORING PARENT RETURN VALUE
/obj/item/stack/attack_hand(mob/user, list/modifiers)
if(user.get_inactive_held_item() == src)
if(is_zero_amount(delete_if_zero = TRUE))
return
return split_stack(user, 1)
else
. = ..()
/obj/item/stack/attack_hand_secondary(mob/user, modifiers)
. = ..()
if(. == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return
if(is_cyborg || !user.can_perform_action(src, NEED_DEXTERITY))
return SECONDARY_ATTACK_CONTINUE_CHAIN
if(is_zero_amount(delete_if_zero = TRUE))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
var/max = get_amount()
var/stackmaterial = tgui_input_number(user, "How many sheets do you wish to take out of this stack?", "Stack Split", max_value = max)
if(!stackmaterial || QDELETED(user) || QDELETED(src) || !usr.can_perform_action(src, FORBID_TELEKINESIS_REACH))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
split_stack(user, stackmaterial)
to_chat(user, span_notice("You take [stackmaterial] sheets out of the stack."))
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/** Splits the stack into two stacks.
*
* Arguments:
* - [user][/mob]: The mob splitting the stack.
* - amount: The number of units to split from this stack.
*/
/obj/item/stack/proc/split_stack(mob/user, amount)
if(!use(amount, TRUE, FALSE))
return null
var/obj/item/stack/F = new type(user? user : drop_location(), amount, FALSE, mats_per_unit)
. = F
F.copy_evidences(src)
loc.atom_storage?.refresh_views()
if(user)
if(!user.put_in_hands(F, merge_stacks = FALSE))
F.forceMove(user.drop_location())
add_fingerprint(user)
F.add_fingerprint(user)
is_zero_amount(delete_if_zero = TRUE)
/obj/item/stack/attackby(obj/item/W, mob/user, params)
if(can_merge(W, inhand = TRUE))
var/obj/item/stack/S = W
if(merge(S))
to_chat(user, span_notice("Your [S.name] stack now contains [S.get_amount()] [S.singular_name]\s."))
else
. = ..()
/obj/item/stack/proc/copy_evidences(obj/item/stack/from)
add_blood_DNA(GET_ATOM_BLOOD_DNA(from))
add_fingerprint_list(GET_ATOM_FINGERPRINTS(from))
add_hiddenprint_list(GET_ATOM_HIDDENPRINTS(from))
fingerprintslast = from.fingerprintslast
//TODO bloody overlay
#undef STACK_CHECK_CARDINALS
#undef STACK_CHECK_ADJACENT