mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-14 19:51:59 +00:00
* Fixes incorrect operator usage in mecha code (#82570) ## About The Pull Request I completely screwed up and told the original PR author of #82415 (9922d2f237) to use the `XOR` operator instead of the `OR` operator (I wasn't thinking right for some reason when I was reading the ref), anyways this PR just fixes that because I misled the contributor into doing something that wasn't correct and actually would BREAK functionality instead. * Fixes TGUI debugging tools (#82569) This project doesn't interfere with the game logic and aims to fix multiple debugging features that are currently broken. Unfortunately, kitchen sink and debug layout became broken after migration to Redux. This PR aims to fix those features. * Removes unused code for HTML UIs (#82589) ## About The Pull Request This is the final PR for https://hackmd.io/XLt5MoRvRxuhFbwtk4VAUA that I've been slowly inching towards the past few months. This removes ``updateDialog``, ``updateUsrDialog``, ``IN_USE``, ``INTERACT_MACHINE_SET_MACHINE``, and everything surrounding it. Also fixes advanced camera consoles not booting you off when you're moved out of reach. We called ``check_eye`` on mob life whenever they had their machine var set, but their machine var would never be set to anything that actually used it, which I found to be a little funny but was also probably my fault. ## Why It's Good For The Game This is poor and unmaintained code used for HTML UIs that we no longer need thanks to TGUI, we should get rid of it to encourage the use of TGUI in the future instead. ## Changelog 🆑 fix: Advanced camera consoles now boots you off when you're moved out of reach. /🆑 * Fixes a variety of input stalling exploits (#82577) ## About The Pull Request Fixes the following input stalling exploits (maybe missed some): - Changing GPS tag - Setting teleporter destination - Request Console Reply - Various AI law board interactions - Note, I used `is_holding` but technically this means these fail with telekinesis. I can swap them to `can_perform_action(...)`, which allows TK, but I noticed some places explicitly deny TK interactions with Ai law boards. Not sure which is preferred. - Borg Rename Board - Plumbing Machines and Ducts - APCs and SMES terminal placements - Stargazers Telepathy - Go Go Gadget Hat ## Changelog 🆑 Melbert fix: You can't change the GPS tag of something unless you can actually use the GPS fix: You can't set the teleporter to a location unless you can actually use the teleporter fix: You can't reply to request console requests unless you can actually use the console fix: You can't update AI lawboards unless you're actually holding them fix: You can't update a borg rename board unless you're actually holding it fix: You can't mess with plumbing machines unless you can actually use them fix: You can't recolor / relayer ducts unless you're actually holding them fix: You can't magically wire APCs and SMESs unless you're right by them fix: You can't use Stargazer Telepathy on people who you can't see fix: You can't configure the Inspector Hat unless you can actually use it /🆑 * [NO GBP] Power outage operation fixes for chem master (#82591) ## About The Pull Request - If the chem master runs out of power mid printing, it will properly stop the printing process and its animation - When transferring reagents it correctly checks if we have enough power without forcing it ## Changelog 🆑 fix: chem master properly shuts down if it loses power mid printing and won't transfer reagents for the same /🆑 * Refactor renaming UNIQUE_RENAME items from the pen to an element (#82491) ## About The Pull Request So a bit ago someone in code_general wanted to make plushies renamable, but learnt that just adding the `UNIQUE_RENAME` flag wouldn't work as pens would murder the plushie and only THEN let you rename it. I noted refactoring both pens and plushies to use the new `item_interaction(...)` procs would Just Solve This, but, well, they didn't really have any coding experience. But, hey, renaming being hardcoded to the pens has annoyed me ever since I laid my eyes upon the hot mess that is paperwork code. So here we are! ### We're making it an element. There's not really much to this, this is mostly the same code but moved to an element and with some minor cleanups. First, we move it all from `/obj/item/pen` to a new element we called `/datum/element/tool_renaming`. With this, instead of having it proc on `/obj/item/pen/afterattack(...)`, we register it to proc on the `COMSIG_ITEM_INTERACTING_WITH_ATOM` signal.6e36ed9840/code/__DEFINES/dcs/signals/signals_atom/signals_atom_x_act.dm (L59-L62)Secondly, we realize the code is just going through each if statement regardless of whether the previous was correct.6e36ed9840/code/modules/paperwork/pen.dm (L225-L258)And, as we're dealing with text, just make it a switch statement instead. ```dm switch(pen_choice) if("Rename") (...) if("Description") (...) if("Reset") (...) ``` Then, we replace all single letter variables with descriptive ones, replace the if-elses with early returns, and make it actually return item interaction flags. Finally, we slap this onto the pen, and we're done. Now we can slap it onto other fitting renaming tools, and it uses the proper item interaction system. ## Why It's Good For The Game I feel it's generally better to not hardcode this to just pens, we have plenty other writing utensils and possible renaming tools. It's also a bit cleaner than before. Apart from that, moves it from using `afterattack(...)` to the proper item interaction chain by using `COMSIG_ITEM_INTERACTING_WITH_ATOM`, which should reduce janky interactions. ## Changelog 🆑 refactor: Instead of being hardcoded to the pen, renaming items is now an element. Currently only pens have this, and functionality should be the same, but please report it if you find any items that were renamable but now aren't. /🆑 * Adds various quality of life changes for cooking to make it less click intensive. (#82566) ## About The Pull Request - Increases tray item size by 1 item. - Ranges and griddles can now be fed from trays. Click when closed => fill soup pot. Click when open => fill associated oven tray. Right click when open => fill tray from oven tray Click griddle => fill griddle surface. Right click => fill tray from griddle surface - Martian batter is now 5u of each ingredient into 10u of batter. Hopefully will make it bug out less where it makes far fewer reagents than it is supposed to, fixing reagents, or well soups specifically... is out of scope for this PR. - Adds the ability to print soup pots and large trays from the service lathe Soup pot: 5 Iron sheets, 0.4 bluespace crystal (given their size of 200U) Large serving tray: 2 iron sheets ## Why It's Good For The Game Makes cooking a lot less tedious. Especially for people with low precision when it comes to filling oven trays. This also bring the behavior up to parity with how you can click microwaves with trays to fill them, ditto for the food processor. It also allows chef to use the whole capacity of an oven, as previously you couldn't easily click 6 cake batters or other giant sprites onto the tiny tray. The tray is now sized to be able to easily feed a griddle 8 items. ## Changelog 🆑 qol: chef equipment can now deposit and withdraw to/from trays! qol: chef now has access to griddle and oven sized trays! qol: service can now print soup pots /🆑 --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> * Removes grid usage + heavy refactors (#82571) ## About The Pull Request Grid has been deprecated for quite some time and we still use it. I won't completely remove the component, this way downstreams won't immediately suffer, but I can remove it from usage. Some of these UIs had issues with them and as a hobby project I've refactored them into typescript / rebuilt them. Airlock electronics, for instance, looks substantially better. <details> <summary>before/after as requested</summary> current airlock electronics scrolls into oblivion  updated  </details> ## Why It's Good For The Game Code improvement + probably UI bug fixes ## Changelog 🆑 fix: Airlock electronics and other access-config type UIs should look much better. /🆑 * modular fixes * [No GBP] Removes cogbar from some stealthy actions (#82593) Issue brought some missed hidden actions to my attention. I left cogbars in for _breaking_ handcuffs because resisting is sort of a gray area. On one hand, you don't want someone to see you doing it; on the other, there is a visible warning that you started doing it. So, meet in the the middle, breaking handcuffs is still visible while resisting isn't. Closes #82583 Cogbars are not intended to ruin stealth 🆑 fix: Deviants buffed: Rogue shoelacing, pickpocketing and restraint resisting no longer give cogbar icons. /🆑 * [NO GBP] ...Remember to add SIGNAL_HANDLER (#82630) ## About The Pull Request Just realized I forgot to add `SIGNAL_HANDLER` to the all-nighter `on_removed_limb(...)` proc, even though it handles signals. ## Why It's Good For The Gamefe26373572/code/__DEFINES/dcs/helpers.dm (L9-L11)* React cleanup (#82607) ## About The Pull Request - No defaultHooks in react. Might fix issues where pages were not scrollable on hover. - createRef in a functional component. should be useref ## Why It's Good For The Game Code improvement * Security photobooths have their own ID (#82628) ## About The Pull Request Prevents the HoP's photobooth button from connecting to the security photobooth via having the same ID. ## Why It's Good For The Game I forgot to add this when I made the security photobooth but it's important that by default without any varedits, the HoP and security photobooths stay separate. ## Changelog 🆑 fix: The HoP's photobooth button is now consistently connected to the HoP's photobooth. /🆑 * Fix buckled alert unbuckling not working properly (#82627) ## About The Pull Request So funny thing, while trying to reproduce a different issue on the current master, I coincidentally let my local instance start without reading, latejoined on the shuttle, and I noticed it wasn't letting me unbuckle as easily. Looking into this a bit later, it seems as if it's a line #82593 accidentally changed while moving around the `/mob/living/carbon/resist_buckle()` proc's flow.fe26373572/code/modules/mob/living/carbon/carbon.dm (L238-L241)While before it was ```dm /mob/living/carbon/resist_buckle() if(HAS_TRAIT(src, TRAIT_RESTRAINED)) (...) else buckled.user_unbuckle_mob(src,src) ``` Just changing this to `buckled.user_unbuckle_mob(src, src)` fixes this. ## Why It's Good For The Game Fixes buckled alert unbuckling not working properly. Fixes #82627. ## Changelog 🆑 fix: Clicking the buckled alert unbuckles you again. /🆑 * Advanced camera consoles correctly deactivates when something happens to it or the user (#82619) ## About The Pull Request - Fixes #82520 1. The eye deactivates when the machine is destroyed/deleted 2. The eye deactivates when the machine loses power 3. The computer constantly moniters the users status inside `process()` and will deactivate when anything happens to them. Its not enough to just hook onto to the mobs `COMSIG_MOVABLE_MOVED` signal. Literarly anything can happen to them so we have to check constantly for any changes ## Changelog 🆑 fix: advanced camera consoles correctly deactivate when something happens(no proximity, no power etc) to its user /🆑 * Oven tray checks for ovens (#82615) ## About The Pull Request - Fixes #82610 Only oven trays have this proc not serving trays or other stuff  Also oven trays have a null atom storage which prevents it from being put back in the oven after taking it out. So we remove that check ## Changelog 🆑 fix: you can put back the oven tray after you take it out fix: only oven trays are allowed in ovens preventing baked food runtimes /🆑 * Living Limb fixes (feat: Basic mobs attack random body zones again) (#82556) ## About The Pull Request Reworks Living Limb code to fix a bunch of runtimes and issues I saw while testing Bioscrambler. Specifically, the contained mobs are now initialised via element following attachment so that signal registration can occur at the correct time. This allows limbs to function correctly when added from nullspace via admin panel or bioscrambler. Secondarily (and more wide-ranging) at some point (probably #79563) we inadvertently made basic mobs only attack the target's chest instead of spreading damage. This is problematic for Living Flesh which can only attach itself to damaged limbs but was left unable to attack damaged limbs. I've fixed this in a way which is maybe stupid: adding an element which randomises attack zone pre-attack. Living limbs also limit this to _only_ limbs (although it will fall back to chest if you have no limbs at all). This is _technically_ still different, the previous behaviour used `adjustBruteLoss` and `adjustFireLoss` and would spread the damage across your entire body, but there isn't a route to that via the new interface and this seems close enough. ## Changelog 🆑 fix: Living Limbs created by Bioscrambler will be alive. fix: Living Limbs can once more attach themselves to your body. balance: Living Limbs will prioritise attacking your limbs. fix: Basic Mobs will once again spread their damage across body zones instead of only attacking your chest. /🆑 * RPG Loot: Revisited & READY (#82533) Revival of #72881 A new alt click window with a tarkov-y loading spinner. Replaces the object item window in stat panel. <details> <summary>vids</summary> toggleable grouping:  now lists the floor as first obj:  in action:  </details> - search by name - 515 image generator is much faster than alt click menu - opening a gargantuan amount of items shouldnt freeze your screen - groups similar items together in stacks by default, toggleable - shows tile as first item - <kbd>Shift</kbd> and <kbd>Ctrl</kbd> compatible with LMB 🖱️ - RMB points points at items (sry i could not get MMB working) - key <kbd>Esc</kbd> to exit the window. For devs: - A new image generation tech. - An error refetch mechanic to the Image component - It does not "smart track" the items being added to the pile, just reopen or refresh. This was a design decision. Honestly I just dislike the stat panel Fixes #53824 Fixes  🆑 add: Added a loot window for alt-clicking tiles. del: Removed the item browser from the stat panel. /🆑 --------- Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com> Co-authored-by: AnturK <AnturK@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> * Reverts parts of #82602 (nodeath checks) (#82637) ## About The Pull Request Reverts the nodeath checks of #82602 I opened a review thinking these checks were sus and the PR author said they would remove them, but it was merged before that happened. TL;DR 1. I just noticed this now but it only affects carbons / humans it doesn't even cover living or any other subtypes 2. Kinda sus. Some code intentionally skips checking nodeath (I guess? Like removing the brain for example) so we would need a larger audit of this rather than haphazardly throwing it in. * Fixes to battle arcade (#82620) ## About The Pull Request Added gear for world nine, removed the "Gear" gear that did nothing. Made counterattacks to kill an enemy properly kill the enemy. I renamed some gear items to fit the theme of the area they are unlocked in just as a small thing. ## Why It's Good For The Game Closes https://github.com/tgstation/tgstation/issues/82613 ## Changelog 🆑 fix: Battle arcade's higher levels no longer gives you a "Gear" gear, and counterattacks can now properly kill enemies. /🆑 * Fixes SMES terminal placing under the SMES and not under the player (#82665) ## About The Pull Request Changes `src` to`user` to get intended behavior. * Birdshot: Toy crate (#82633) ## About The Pull Request Gives the clown+mime their toy crate. ## Why It's Good For The Game *honk* * tram ai sat starts with a full smes (#82646) ## About The Pull Request consistency and also this is fixes a bug introduced by that one power refactor ## Why It's Good For The Game bug bad ## Changelog 🆑 fix: tramstation AI sat starts full /🆑 * [no gbp] Space Ruin bioscramblers shouldn't chase people around (#82649) ## About The Pull Request See title They wouldn't lock on to people on the station from a space ruin, but would to whoever entered their z level the second it was entered. Also fixes bug where I changed `status_flags` to `status_effects` for some reason which isn't where you look for godmode ## Why It's Good For The Game We have a space ruin whcih several (coreless) anomalies spawn on, the bioscrambler was put as an option because it was already immortal. It's weird though to zone into the ruin and immediately have every anomaly in there lock onto you, the best intended effect is probably for these ones specifically not to be bloodthirsty. We kind of only care about that behaviour on the station. ## Changelog 🆑 fix: Anomalous Research ruin Bioscrambler anomalies won't home in on targets fix: Bioscrambler won't randomly drop its target for no reason /🆑 * Sunders the many unused sprites and organizes what's left in structures.dmi (#82658) ## About The Pull Request Hello again, I noticed the /obj/structures.dmi file had a lot of unused stuff like tables from two generations ago, so I changed some stuff around: - Many unused, old icons deleted, mostly window variants used in old smoothing systems I imagine - Reorganized many sprites in the file so they're more grouped together - Tweaked some barricade sprite naming to be consistent/standardized, and to let others know they're not _too_ old... - Fixed a misnomer that I believe was making directional tinted windows look like frosted windows ## Why It's Good For The Game Saves on file space, and satisfies your brain's pattern recognition bits ### Spriting Old:  New:  also good lord those linen bin sprites are a crime ## Changelog 🆑 fix: Probably fixed directional tinted windows looking like directional frosted windows image: Deleted a bunch of unused structure sprites /🆑 * Birdshot Wall Sanity Pass (#82598) ## About The Pull Request Cleans up minor artifacting in the Birdshot Sec-Tram Closed Turfs ## Why It's Good For The Game Someone definitely didn't mean to place some machines under Closed Turfs. This barely qualifies as player facing. ## Changelog 🆑 fix: Cleans up some rocks on Birdshot /🆑 * [NO GBP] Fixes deconstruction of closets & crates under a special case (#82612) ## About The Pull Request So if a closet/crate has the `NO_DEBRIS_AFTER_DECONSTRUCTION` set on it and if someone/something is still inside, then after deconstruction they get deleted rather than getting dumped out first. Could cause potential hard delete of mobs & stuff. We don't want to deal with that ## Changelog 🆑 fix: closets & crates will dump all contents out first before deleting itself regardless of `NO_DEBRIS_AFTER_DECONSTRUCTION` thus not for e.g. hard deleting mobs inside it /🆑 * Fixes ordinance lab igniter in IceBox (#82595) ## About The Pull Request - Fixes #82294 Basically the same idea of merging ordanance lab with the burn chamber so they share the same apc as already implemented in #82322 ## Changelog 🆑 fix: Ordinance lab igniter in Icebox works again /🆑 * Birdshot: engi wardrope. (#82639) ## About The Pull Request Add engi wardrope on Birdshot. ## Why It's Good For The Game Birdshot doesn't have engi wardrope. 🆑 fix: Birdshot now have engi wardrope /🆑 * Gives shadow walk a new, spookier, and shorter sound effect that no longer ignores walls (#82689) ## About The Pull Request This gives shadow walk a snazzy new sound effect for entering/exiting jaunt. https://github.com/tgstation/tgstation/assets/28870487/c25f720f-5bad-4063-8d6e-140fd41bd740 This also has the sounds it plays no longer passes through walls. ## Why It's Good For The Game The ethereal_entrance/exit sound effects are drawn out, and pretty grating. They work for the other jaunts they're used for because a jaunt typically lasts longer than the sound itself. Nightmares are frequently dancing in and out of jaunt, and the sound effects for entering/exiting tend to overlap. It gets loud and annoying really fast. This sound effect is quicker, spookier, and more distinct. As for making the sound not ignore walls, I think it's pretty dumb how easy it is to detect the spooky scary shadow antag just by sitting in your department. It takes a lot of the initial fear and paranoia they have the potential for is wasted when Joe Geneticist can hear them messing around in their territory without having to leave their chair. ## Changelog 🆑 Rhials sound: Nightmare has a new sound effect for entering/exiting shadow jaunt. It also no longer can be heard through walls. /🆑 * [MIRROR] Alt click refactor (#2029) * Alt click refactor * Some early conflict removal * Big modular refactor * Update console.dm * Update paper.dm --------- Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> Co-authored-by: Mal <13398309+vinylspiders@users.noreply.github.com> * Yeets `ATTACK_QDELETED`, fixes welding torches not using fuel on attacking non-mobs (2 year old bug) (#82694) ## About The Pull Request - Deletes `ATTACK_QDELETED` - May have been necessary in the past but it's pointless now. All it does is clutter the attack chain. Perish. - Fixes welders not using fuel on attacking non-mobs - #65762 "fixed" welders consuming fuel on clicking turfs by adding an `isliving` check and not an `ismovable` check? ## Changelog 🆑 Melbert fix: Blobs may rejoice, welding torches now consume fuel when attacking objects again after two years. /🆑 * electric_welder fire * Quirks, which give items, now have quirk_item arg specified as obj/item, instead of being just a var (#82650) ## About The Pull Request quirk_item is now /obj/item, since it will allow for calling procs or getting variables from this item It's required for non-modular translation to call for item's name to remove articles ## Why It's Good For The Game It's always an item, and if it's a path, it's already checked for it. Better usage in the future. * turns martial arts gloves into a component (#82599) sleeping carp gloves also work on mind init this means for the sake of deathmatch you dont have to put them off and on fixes #82321 🆑 fix: you no longer need to put your sleeping carp gloves off and on in Deathmatch to get the martial art /🆑 --------- Co-authored-by: san7890 <the@san7890.com> * Regal Rats can now tear down posters (#82673) ## About The Pull Request i was fixing something on bagil and someone who was playing a regal rat (after the round ended) said they wanted to be able to tear down posters as a regal rat so i decided to code it because it made sense. it's an element so literally any mob can tear down posters but i can't think of any other mobs that would make sense to let it tear down posters so we'll leave it just for _The Champion of All Mislaid Creatures_ for now ## Why It's Good For The Game Regal Rats should be all about sludgemaxxing and fucking up maintenance to make it look even more grody than it should be. Being able to tear up those disgusting and well-drawn posters to leave behind nothing but scraps fits that motif. The element has a `do_after()` just to make sure His Holiness doesn't accidentally tear down his posters while clicking (i think all mobs should have this but that's a different issue man) also includes some code improvement and user feedback in some failure cases that already existed in the code. ## Changelog 🆑 add: Regal Rats are now able to tear down those colorful posters those weird grey creatures keep spackling up on the walls of their rightful domain. /🆑 * Adds "Strong Stomach" quirk, a core CDDA/PZ quirk we've sorely been missing. Also Deviant Tastes dirty food re-nerf. (#82562) ## About The Pull Request - Adds Strong Stomach quirk. - 4 points - You can eat dirty food without risk of getting disease. - You suffer less negative effects from vomiting. Vomit stuns you for half the duration, and you lose half as much nutrition. - Reverts https://github.com/tgstation/tgstation/pull/76864 , integrates its effects into Strong Stomach instead. ## Why It's Good For The Game - Lotta people (namely Lizards and sometimes Felines with Deviant Tastes) run gimmicks involving them being a gremlin person and eating trash off the ground, and it's rather hard to accomplish this now since it makes you a public medbay enemy # 1. This quirk should give them an option to avoid that. - Also (as mentioned in the title) both CDDA and PZ have this trait and I can't believe we're missing it! This is something in modifiable-character-traits/quirks-101. - I moved the effects from #76864 to this quirk because 1. I thought it was more fitting and 2. I thought the original PR was kinda wack for what is (generally) a neutral quirk. ## Changelog 🆑 Melbert add: Adds the Strong Stomach quirk, which allows you to eat grimy food without worry about disease, and makes you a bit more resilient to the effects of vomiting. del: Deviant Tastes no longer prevents you from getting a negative moodlet from eating dirty food. Strong Stomach does that now. /🆑 --------- Co-authored-by: Jacquerel <hnevard@gmail.com> * Remove several functions from collections.js which have ES5 equivalents (#82417) * Makes it EVEN EASIER to work with atom item interactions ft. "Leaf and Branch" & "Death to Chains" (#82625) * apc fix * Gulag Adjustments Two (#82561) ## About The Pull Request I have received feedback that after the prior changes in #81971, the gulag is still a little bit too subject to RNG. The main culprit (as in my previous PR) is Iron being kind of cheap and the fact that unlike the old Gulag you no longer have any way of headhunting more valuable materials (everything appears as boulders on your ore scanner). My solution to this is wider than the last one of tweaking point values, but also much simpler: Just make every boulder you mine be worth the same amount of points regardless of what is inside of it. On the average test I made I could comfortably mine about 40-45 boulders in ten minutes. We'll make some adjustments to that rather than leaving 40 as the target number; Most players upon being teleported to the gulag are going to spend a few minutes whining and bemoaning their fate instead of getting straight to work. I had the benefit of being able to make sure my run started as soon as a storm ended so I wouldn't need any kind of midpoint break. I was also always the only person playing on my local instance, there hadn't been any other pesky prisoners before me who had already mined out all the nearest available deposits. And of course, let us not forget, I am an MLG master league ss13 player who was surely performing well above average. So we'll round that down to: Each boulder is worth 33 points, meaning you need to collect 31 boulders to complete a 1000 point (roughly ten minute) sentence. How do I ensure that every boulder is worth the same amount of points? Well it's pretty easy. One boulder = one material sheet. One material sheet = 33 points. Simple. "Now Jacquerel", I hear you not saying because you don't want me to know about this thing you would prefer to do instead of hitting rocks outside; "if I simply smash all of the tables and microwaves and botany trays and bed in the gulag I can easily get like 65 sheets of Iron, which is almost enough to buy the freedom for two entire people!" Unfortunately I knew you were going to try and do that and the prisoner point machine will only give you points for material sheets which have been printed from the material smelter (well, any material smelter actually but you should probably use the one in the gulag). You'll be able to tell because if you examine a valid material sheet it will mention a little maker's mark on it, which is absent in the beat-up iron that you get from smashing furniture to bits. Also glass is worth 0 points. Don't waste time digging up that shit. As glass has had all of its point value removed, I have added a "work pit" to the gulag to compensate. You can pull boulders out of this indefinitely via effort, however it also stamcrits you every time. It's not very fun to do this, but that's because I would prefer you to go find the rocks out in the field instead. This is a last resort. You can do this if there's no boulders left to mine or if you really really really hate mining and would rather very slowly click on one tile repeatedly to get your boulders instead. As a tiny bonus doing this gives workout experience. This isn't a totally ideal solution but I think it'll do for now. ## Why It's Good For The Game What we want out of the gulag is: - Something where officers can vaguely approximate an expected sentence duration. - A task that requires players to actually be spending that time doing something to get out of here. - Produces at least some amount of useful materials. In I think roughly that order. I hope this change accomplishes all three of these in a way that is somewhat predictable rather than throwing darts at a board. ## Changelog 🆑 balance: Gulag mining has been rebalanced so that every boulder is worth the same amount of points to mine for a prisoner regardless of what it contains, and should be more consistent. add: A vent which boulders can be hauled out of by hand has been added to the gulag which you can use if there's nothing left to mine. It is very slow, but at least it gives you a workout... /🆑 * stone * Makes test merge bot continue with other PRs if updating one fails. (#82717) Right now updating https://github.com/tgstation/tgstation/pull/81089#issuecomment-1907296233 fails because it exceeds github character limit for comments. This will make it work until backed is updated. * Fixes the RnD console by adding a removed import (#82750) ## About The Pull Request The 'map' import was removed from this file by #82417 but it's still used in place in code. This re-adds the import ## Why It's Good For The Game Fixes RnD consoles ## Changelog 🆑 fix: Fixed RnD consoles not being able to be opened. /🆑 Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com> * Fixes cargo import (#82755) ## About The Pull Request One of the imports got removed and there were no warnings... Man if only there were a technology that could warn us in advance ## Why It's Good For The Game UI fixes ## Changelog 🆑 fix: Fixed a bluescreen in cargo console /🆑 * fixes * Fixes, fixes. * Pre-emptive mirror of https://github.com/tgstation/tgstation/pull/82892 * Turf weakref persists in changeturf / Fix plasma cutters (#82906) ## About The Pull Request Turf references don't change so logically, turf weakrefs wouldn't change if the turf changes. By not doing this this can cause bugs: See #82886 . (This Fixes #82886) (Projectiles hold a list of weakrefs to atoms hit to determine what they have already hit. Because turf weakrefs reset, we could "hit" the same turf twice if it destroyed the turf. Old behavior - this was fine but now that they're weakrefs, we get two weakref datums in the list that point to the same ref.) Less hacky alternative to #82901 . (Closes #82901) ## Changelog 🆑 Melbert fix: Plasma cutters work again /🆑 --------- Co-authored-by: san7890 <the@san7890.com> Co-authored-by: Interception&? <137328283+intercepti0n@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: Ketrai <zottielolly@gmail.com> Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com> Co-authored-by: Jacquerel <hnevard@gmail.com> Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com> Co-authored-by: AnturK <AnturK@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Iajret <8430839+Iajret@users.noreply.github.com> Co-authored-by: vect0r <71346830+Vect0r2@users.noreply.github.com> Co-authored-by: jimmyl <70376633+mc-oofert@users.noreply.github.com> Co-authored-by: AMyriad <143908044+AMyriad@users.noreply.github.com> Co-authored-by: Zytolg <33048583+Zytolg@users.noreply.github.com> Co-authored-by: Xackii <120736708+Xackii@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: NovaBot <154629622+NovaBot13@users.noreply.github.com> Co-authored-by: Mal <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: larentoun <31931237+larentoun@users.noreply.github.com> Co-authored-by: Arthri <41360489+Arthri@users.noreply.github.com> Co-authored-by: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com> Co-authored-by: Useroth <37159550+Useroth@users.noreply.github.com>
770 lines
31 KiB
Plaintext
770 lines
31 KiB
Plaintext
/*!
|
|
This datum should be used for handling mineral contents of machines and whatever else is supposed to hold minerals and make use of them.
|
|
|
|
Variables:
|
|
amount - raw amount of the mineral this container is holding, calculated by the defined value SHEET_MATERIAL_AMOUNT=SHEET_MATERIAL_AMOUNT.
|
|
max_amount - max raw amount of mineral this container can hold.
|
|
sheet_type - type of the mineral sheet the container handles, used for output.
|
|
parent - object that this container is being used by, used for output.
|
|
MAX_STACK_SIZE - size of a stack of mineral sheets. Constant.
|
|
*/
|
|
|
|
//The full item was consumed
|
|
#define MATERIAL_INSERT_ITEM_SUCCESS 1
|
|
|
|
/datum/component/material_container
|
|
/// The maximum amount of materials this material container can contain
|
|
var/max_amount
|
|
/// Map of material ref -> amount
|
|
var/list/materials //Map of key = material ref | Value = amount
|
|
/// The list of materials that this material container can accept
|
|
var/list/allowed_materials
|
|
/// The typecache of things that this material container can accept
|
|
var/list/allowed_item_typecache
|
|
/// Whether or not this material container allows specific amounts from sheets to be inserted
|
|
var/precise_insertion = FALSE
|
|
/// The material container flags. See __DEFINES/materials.dm.
|
|
var/mat_container_flags
|
|
/// Signals that are registered with this contained
|
|
var/list/registered_signals
|
|
|
|
/// Sets up the proper signals and fills the list of materials with the appropriate references.
|
|
/datum/component/material_container/Initialize(
|
|
list/init_mats,
|
|
max_amt = 0,
|
|
_mat_container_flags = NONE,
|
|
list/allowed_mats = init_mats,
|
|
list/allowed_items,
|
|
list/container_signals
|
|
)
|
|
|
|
if(!isatom(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
materials = list()
|
|
max_amount = max(0, max_amt)
|
|
mat_container_flags = _mat_container_flags
|
|
|
|
allowed_materials = allowed_mats || list()
|
|
if(allowed_items)
|
|
if(ispath(allowed_items) && allowed_items == /obj/item/stack)
|
|
allowed_item_typecache = GLOB.typecache_stack
|
|
else
|
|
allowed_item_typecache = typecacheof(allowed_items)
|
|
|
|
for(var/mat in init_mats) //Make the assoc list material reference -> amount
|
|
var/mat_ref = GET_MATERIAL_REF(mat)
|
|
if(isnull(mat_ref))
|
|
continue
|
|
var/mat_amt = init_mats[mat]
|
|
if(isnull(mat_amt))
|
|
mat_amt = 0
|
|
materials[mat_ref] += mat_amt
|
|
|
|
//all user handled signals
|
|
if(length(container_signals))
|
|
for(var/signal in container_signals)
|
|
parent.RegisterSignal(src, signal, container_signals[signal])
|
|
|
|
//drop sheets when the object is deconstructed but not deleted
|
|
RegisterSignal(parent, COMSIG_OBJ_DECONSTRUCT, PROC_REF(drop_sheets))
|
|
|
|
if(_mat_container_flags & MATCONTAINER_NO_INSERT)
|
|
return
|
|
|
|
var/atom/atom_target = parent
|
|
atom_target.flags_1 |= HAS_CONTEXTUAL_SCREENTIPS_1
|
|
|
|
RegisterSignal(atom_target, COMSIG_ATOM_REQUESTING_CONTEXT_FROM_ITEM, PROC_REF(on_requesting_context_from_item))
|
|
|
|
/datum/component/material_container/Destroy(force)
|
|
materials = null
|
|
allowed_materials = null
|
|
return ..()
|
|
|
|
/datum/component/material_container/RegisterWithParent()
|
|
. = ..()
|
|
|
|
if(!(mat_container_flags & MATCONTAINER_NO_INSERT))
|
|
RegisterSignal(parent, COMSIG_ATOM_ATTACKBY, PROC_REF(on_attackby))
|
|
if(mat_container_flags & MATCONTAINER_EXAMINE)
|
|
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
|
|
|
|
/datum/component/material_container/proc/drop_sheets()
|
|
SIGNAL_HANDLER
|
|
|
|
retrieve_all()
|
|
|
|
/datum/component/material_container/proc/on_examine(datum/source, mob/user, list/examine_texts)
|
|
SIGNAL_HANDLER
|
|
|
|
for(var/I in materials)
|
|
var/datum/material/M = I
|
|
var/amt = materials[I] / SHEET_MATERIAL_AMOUNT
|
|
if(amt)
|
|
examine_texts += span_notice("It has [amt] sheets of [LOWER_TEXT(M.name)] stored.")
|
|
|
|
/datum/component/material_container/vv_edit_var(var_name, var_value)
|
|
var/old_flags = mat_container_flags
|
|
. = ..()
|
|
if(var_name == NAMEOF(src, mat_container_flags) && parent)
|
|
if(!(old_flags & MATCONTAINER_EXAMINE) && mat_container_flags & MATCONTAINER_EXAMINE)
|
|
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
|
|
else if(old_flags & MATCONTAINER_EXAMINE && !(mat_container_flags & MATCONTAINER_EXAMINE))
|
|
UnregisterSignal(parent, COMSIG_ATOM_EXAMINE)
|
|
|
|
if(old_flags & MATCONTAINER_NO_INSERT && !(mat_container_flags & MATCONTAINER_NO_INSERT))
|
|
RegisterSignal(parent, COMSIG_ATOM_ATTACKBY, PROC_REF(on_attackby))
|
|
else if(!(old_flags & MATCONTAINER_NO_INSERT) && mat_container_flags & MATCONTAINER_NO_INSERT)
|
|
UnregisterSignal(parent, COMSIG_ATOM_ATTACKBY)
|
|
|
|
/**
|
|
* 3 Types of Procs
|
|
* Material Insertion : Insert materials into the container
|
|
* Material Validation : Checks how much materials are available, Extracts materials from items if the container can hold them
|
|
* Material Removal : Removes material from the container
|
|
*
|
|
* Each Proc furthur belongs to a specific category
|
|
* LOW LEVEL: Procs that are used internally & should not be used anywhere else unless you know what your doing
|
|
* MID LEVEL: Procs that can be used by machines(like recycler, stacking machines) to bypass majority of checks
|
|
* HIGH LEVEL: Procs that can be used by anyone publically and guarentees safty checks & limits
|
|
*/
|
|
|
|
//================================Material Insertion procs==============================
|
|
|
|
//======================================LOW LEVEL=========================================
|
|
/**
|
|
* Inserts the relevant materials from an item into this material container.
|
|
* This low level proc should not be used directly by anyone
|
|
*
|
|
* Arguments:
|
|
* - [source][/obj/item]: The source of the materials we are inserting.
|
|
* - multiplier: The multiplier for the materials extract from this item being inserted.
|
|
* - context: the atom performing the operation, this is the last argument sent in COMSIG_MATCONTAINER_ITEM_CONSUMED
|
|
* and is used mostly for silo logging, the silo resends this signal on the context to give it a
|
|
* chance to process the item
|
|
*/
|
|
/datum/component/material_container/proc/insert_item_materials(obj/item/source, multiplier = 1, atom/context = parent)
|
|
var/primary_mat
|
|
var/max_mat_value = 0
|
|
var/material_amount = 0
|
|
|
|
var/list/item_materials = source.get_material_composition()
|
|
var/list/mats_consumed = list()
|
|
for(var/MAT in item_materials)
|
|
if(!can_hold_material(MAT))
|
|
continue
|
|
var/mat_amount = OPTIMAL_COST(item_materials[MAT] * multiplier)
|
|
materials[MAT] += mat_amount
|
|
if(item_materials[MAT] > max_mat_value)
|
|
max_mat_value = item_materials[MAT]
|
|
primary_mat = MAT
|
|
mats_consumed[MAT] = mat_amount
|
|
material_amount += mat_amount
|
|
if(length(mats_consumed))
|
|
SEND_SIGNAL(src, COMSIG_MATCONTAINER_ITEM_CONSUMED, source, primary_mat, mats_consumed, material_amount, context)
|
|
|
|
return primary_mat
|
|
//===================================================================================
|
|
|
|
|
|
//===============================MID LEVEL===================================================
|
|
/**
|
|
* For inserting an amount of material. Use this to add materials to the container directly
|
|
*
|
|
* Arguments:
|
|
* - amt: amount of said material to insert
|
|
* - mat: the material type to insert
|
|
*/
|
|
/datum/component/material_container/proc/insert_amount_mat(amt, datum/material/mat)
|
|
if(amt <= 0)
|
|
return 0
|
|
amt = OPTIMAL_COST(amt)
|
|
if(!has_space(amt))
|
|
return 0
|
|
|
|
var/total_amount_saved = total_amount()
|
|
if(mat)
|
|
if(!istype(mat))
|
|
mat = GET_MATERIAL_REF(mat)
|
|
materials[mat] += amt
|
|
else
|
|
var/num_materials = length(materials)
|
|
if(!num_materials)
|
|
return 0
|
|
|
|
amt /= num_materials
|
|
for(var/i in materials)
|
|
materials[i] += amt
|
|
return (total_amount() - total_amount_saved)
|
|
|
|
/**
|
|
* Proc specifically for inserting items, use this when you want to insert any item into the container
|
|
* this bypasses most of the material flag checks so much be used by machines like recycler, stacking machine etc that
|
|
* does not care for such checks
|
|
*
|
|
* Arguments:
|
|
* - [weapon][obj/item]: the item you are trying to insert
|
|
* - multiplier: The multiplier for the materials being inserted
|
|
* - context: the atom performing the operation, this is the last argument sent in COMSIG_MATCONTAINER_ITEM_CONSUMED and is used mostly for silo logging
|
|
*/
|
|
/datum/component/material_container/proc/insert_item(obj/item/weapon, multiplier = 1, atom/context = parent)
|
|
if(QDELETED(weapon))
|
|
return MATERIAL_INSERT_ITEM_NO_MATS
|
|
multiplier = CEILING(multiplier, 0.01)
|
|
|
|
var/obj/item/target = weapon
|
|
|
|
var/material_amount = OPTIMAL_COST(get_item_material_amount(target) * multiplier)
|
|
if(!material_amount)
|
|
return MATERIAL_INSERT_ITEM_NO_MATS
|
|
var/obj/item/stack/item_stack
|
|
if(isstack(weapon) && !has_space(material_amount)) //not enough space split and feed as many sheets possible
|
|
item_stack = weapon
|
|
var/space_left = max_amount - total_amount()
|
|
if(!space_left)
|
|
return MATERIAL_INSERT_ITEM_NO_SPACE
|
|
var/material_per_sheet = material_amount / item_stack.amount
|
|
var/sheets_to_insert = round(space_left / material_per_sheet)
|
|
if(!sheets_to_insert)
|
|
return MATERIAL_INSERT_ITEM_NO_SPACE
|
|
target = fast_split_stack(item_stack, sheets_to_insert)
|
|
material_amount = get_item_material_amount(target) * multiplier
|
|
material_amount = OPTIMAL_COST(material_amount)
|
|
|
|
//not enough space, time to bail
|
|
if(!has_space(material_amount))
|
|
return MATERIAL_INSERT_ITEM_NO_SPACE
|
|
|
|
//do the insert
|
|
var/last_inserted_id = insert_item_materials(target, multiplier, context)
|
|
if(!isnull(last_inserted_id))
|
|
qdel(target) //item gone
|
|
return material_amount
|
|
else if(!isnull(item_stack) && item_stack != target) //insertion failed, merge the split stack back into the original
|
|
var/obj/item/stack/inserting_stack = target
|
|
item_stack.add(inserting_stack.amount)
|
|
qdel(inserting_stack)
|
|
|
|
return MATERIAL_INSERT_ITEM_FAILURE
|
|
//============================================================================================
|
|
|
|
|
|
//===================================HIGH LEVEL===================================================
|
|
/**
|
|
* inserts an item from the players hand into the container. Loops through all the contents inside reccursively
|
|
* Does all explicit checking for mat flags & callbacks to check if insertion is valid
|
|
* This proc is what you should be using for almost all cases
|
|
*
|
|
* Arguments:
|
|
* * held_item - the item to insert
|
|
* * user - the mob inserting this item
|
|
* * context - the atom performing the operation, this is the last argument sent in COMSIG_MATCONTAINER_ITEM_CONSUMED and is used mostly for silo logging
|
|
*/
|
|
/datum/component/material_container/proc/user_insert(obj/item/held_item, mob/living/user, atom/context = parent)
|
|
set waitfor = FALSE
|
|
. = 0
|
|
|
|
//All items that do not have any contents
|
|
var/list/obj/item/child_items = list()
|
|
//All items that do have contents but they were already processed by the above list
|
|
var/list/obj/item/parent_items = list(held_item)
|
|
//is this the first item we are ever processing
|
|
var/first_checks = TRUE
|
|
//The status of the last insert attempt
|
|
var/inserted = 0
|
|
//All messages to be displayed to chat
|
|
var/list/chat_msgs = list()
|
|
//differs from held_item when using TK
|
|
var/active_held = user.get_active_held_item()
|
|
//storage items to retrive items from
|
|
var/static/list/storage_items
|
|
if(isnull(storage_items))
|
|
storage_items = list(
|
|
/obj/item/storage/backpack,
|
|
/obj/item/storage/bag,
|
|
/obj/item/storage/box,
|
|
)
|
|
|
|
//1st iteration consumes all items that do not have contents inside
|
|
//2nd iteration consumes items who do have contents inside(but they were consumed in the 1st iteration so its empty now)
|
|
for(var/i in 1 to 2)
|
|
//no point inserting more items
|
|
if(inserted == MATERIAL_INSERT_ITEM_NO_SPACE)
|
|
break
|
|
|
|
//transfer all items for processing
|
|
if(!parent_items.len)
|
|
break
|
|
child_items += parent_items
|
|
parent_items.Cut()
|
|
|
|
while(child_items.len)
|
|
//Pop the 1st item out from the list
|
|
var/obj/item/target_item = child_items[1]
|
|
child_items -= target_item
|
|
|
|
//e.g. projectiles inside bullets are not objects
|
|
if(!istype(target_item))
|
|
continue
|
|
//can't allow abstract, hologram items
|
|
if((target_item.item_flags & ABSTRACT) || (target_item.flags_1 & HOLOGRAM_1))
|
|
continue
|
|
//user defined conditions
|
|
if(SEND_SIGNAL(src, COMSIG_MATCONTAINER_PRE_USER_INSERT, target_item, user) & MATCONTAINER_BLOCK_INSERT)
|
|
continue
|
|
//item is either indestructible, not allowed for redemption or not in the allowed types
|
|
if((target_item.resistance_flags & INDESTRUCTIBLE) || (target_item.item_flags & NO_MAT_REDEMPTION) || (allowed_item_typecache && !is_type_in_typecache(target_item, allowed_item_typecache)))
|
|
if(!(mat_container_flags & MATCONTAINER_SILENT) && i == 1) //count only child items the 1st time around
|
|
var/list/status_data = chat_msgs["[MATERIAL_INSERT_ITEM_FAILURE]"] || list()
|
|
var/list/item_data = status_data[target_item.name] || list()
|
|
item_data["count"] += 1
|
|
status_data[target_item.name] = item_data
|
|
chat_msgs["[MATERIAL_INSERT_ITEM_FAILURE]"] = status_data
|
|
|
|
if(target_item.resistance_flags & INDESTRUCTIBLE)
|
|
if(i == 1 && target_item != active_held) //move it out of any storage medium its in so it doesn't get consumed with its parent, but only if that storage medium is not our hand
|
|
target_item.forceMove(get_turf(context))
|
|
continue
|
|
//storage items usually come here but we make the exception only on the 1st iteration
|
|
//this is so players can insert items from their bags into machines for convinience
|
|
if(!is_type_in_list(target_item, storage_items))
|
|
continue
|
|
else if(!target_item.contents.len || i == 2)
|
|
continue
|
|
//at this point we can check if we have enough for all items & other stuff
|
|
if(first_checks)
|
|
//duffle bags needs to be unzipped
|
|
if(target_item.atom_storage?.locked)
|
|
if(!(mat_container_flags & MATCONTAINER_SILENT))
|
|
to_chat(user, span_warning("[target_item] has its storage locked"))
|
|
return
|
|
|
|
//anything that isn't a stack cannot be split so find out if we have enough space, we don't want to consume half the contents of an object & leave it in a broken state
|
|
//for duffle bags and other storage items we can check for space 1 item at a time
|
|
if(!isstack(target_item) && !is_type_in_list(target_item, storage_items))
|
|
var/total_amount = 0
|
|
for(var/obj/item/weapon as anything in target_item.get_all_contents_type(/obj/item))
|
|
total_amount += get_item_material_amount(weapon)
|
|
if(!has_space(total_amount))
|
|
if(!(mat_container_flags & MATCONTAINER_SILENT))
|
|
to_chat(user, span_warning("[parent] does not have enough space for [target_item]!"))
|
|
return
|
|
|
|
first_checks = FALSE
|
|
|
|
//All hard checks have passed, at this point we can consume the item
|
|
//If it has children then we will process them first and then the item in the 2nd round
|
|
//This is done so we don't delete the children when the parent is consumed
|
|
//We only do this on the 1st iteration so we don't re-iterate through its children again
|
|
if(target_item.contents.len && i == 1)
|
|
if(target_item.atom_storage?.locked) //can't access contents of locked storage(like duffle bags)
|
|
continue
|
|
//process children
|
|
child_items += target_item.contents
|
|
//in the 2nd round only after its children are consumed do we consume this next, FIFO order
|
|
parent_items.Insert(1, target_item)
|
|
//leave it here till we get to its children
|
|
continue
|
|
|
|
//if stack, check if we want to read precise amount of sheets to insert
|
|
var/obj/item/stack/item_stack = null
|
|
if(isstack(target_item) && precise_insertion)
|
|
var/atom/current_parent = parent
|
|
item_stack = target_item
|
|
var/requested_amount = tgui_input_number(user, "How much do you want to insert?", "Inserting [item_stack.singular_name]s", item_stack.amount, item_stack.amount)
|
|
if(!requested_amount || QDELETED(target_item) || QDELETED(user) || QDELETED(src))
|
|
continue
|
|
if(parent != current_parent || user.get_active_held_item() != active_held)
|
|
continue
|
|
if(requested_amount != item_stack.amount) //only split if its not the whole amount
|
|
target_item = fast_split_stack(item_stack, requested_amount) //split off the requested amount
|
|
requested_amount = 0
|
|
|
|
//is this item a stack and was it split by the player?
|
|
var/was_stack_split = !isnull(item_stack) && item_stack != target_item
|
|
//if it was split then item_stack has the reference to the original stack/item
|
|
var/original_item = was_stack_split ? item_stack : target_item
|
|
//if this item is not the one the player is holding then don't remove it from their hand
|
|
if(original_item != active_held)
|
|
original_item = null
|
|
if(!isnull(original_item) && !user.temporarilyRemoveItemFromInventory(original_item)) //remove from hand(if split remove the original stack else the target)
|
|
return
|
|
|
|
//insert the item
|
|
var/item_name = target_item.name
|
|
var/item_count = 1
|
|
var/is_stack = FALSE
|
|
if(isstack(target_item))
|
|
var/obj/item/stack/the_stack = target_item
|
|
item_name = the_stack.singular_name
|
|
item_count = the_stack.amount
|
|
is_stack = TRUE
|
|
inserted = insert_item(target_item, 1, context)
|
|
if(inserted > 0)
|
|
. += inserted
|
|
inserted /= SHEET_MATERIAL_AMOUNT // display units inserted as sheets for improved readability
|
|
|
|
//stack was either split by the container(!QDELETED(target_item) means the container only consumed a part of it) or by the player, put whats left back of the original stack back in players hand
|
|
if((!QDELETED(target_item) || was_stack_split))
|
|
|
|
//stack was split by player and that portion was not fully consumed, merge whats left back with the original stack
|
|
if(!QDELETED(target_item) && was_stack_split)
|
|
var/obj/item/stack/inserting_stack = target_item
|
|
item_stack.add(inserting_stack.amount)
|
|
qdel(inserting_stack)
|
|
|
|
//was this the original item in the players hand? put what's left back in the player's hand
|
|
if(!isnull(original_item))
|
|
user.put_in_active_hand(original_item)
|
|
|
|
//collect all messages to print later
|
|
var/list/status_data = chat_msgs["[MATERIAL_INSERT_ITEM_SUCCESS]"] || list()
|
|
var/list/item_data = status_data[item_name] || list()
|
|
item_data["count"] += item_count
|
|
item_data["amount"] += inserted
|
|
item_data["stack"] = is_stack
|
|
status_data[item_name] = item_data
|
|
chat_msgs["[MATERIAL_INSERT_ITEM_SUCCESS]"] = status_data
|
|
|
|
else
|
|
//collect all messages to print later
|
|
var/list/status_data = chat_msgs["[inserted]"] || list()
|
|
var/list/item_data = status_data[item_name] || list()
|
|
item_data["count"] += item_count
|
|
status_data[item_name] = item_data
|
|
chat_msgs["[inserted]"] = status_data
|
|
|
|
//player split the stack by the requested amount but even that split amount could not be salvaged. merge it back with the original
|
|
if(!isnull(item_stack) && was_stack_split)
|
|
var/obj/item/stack/inserting_stack = target_item
|
|
item_stack.add(inserting_stack.amount)
|
|
qdel(inserting_stack)
|
|
|
|
//was this the original item in the players hand? put it back because we coudn't salvage it
|
|
if(!isnull(original_item))
|
|
user.put_in_active_hand(original_item)
|
|
|
|
//we can stop here as remaining items will fail to insert as well
|
|
if(inserted == MATERIAL_INSERT_ITEM_NO_SPACE)
|
|
break
|
|
|
|
//we now summarize the chat msgs collected
|
|
if(!(mat_container_flags & MATCONTAINER_SILENT))
|
|
for(var/status as anything in chat_msgs)
|
|
var/list/status_data = chat_msgs[status]
|
|
|
|
for(var/item_name as anything in status_data)
|
|
//read the params
|
|
var/list/chat_data = status_data[item_name]
|
|
var/count = chat_data["count"]
|
|
var/amount = chat_data["amount"]
|
|
|
|
//decode the message
|
|
switch(text2num(status))
|
|
if(MATERIAL_INSERT_ITEM_SUCCESS) //no problems full item was consumed
|
|
if(chat_data["stack"])
|
|
var/sheets = min(count, amount) //minimum between sheets inserted vs sheets consumed(values differ for alloys)
|
|
to_chat(user, span_notice("[sheets > 1 ? sheets : ""] [item_name][sheets > 1 ? "s were" : " was"] added to [parent]."))
|
|
else
|
|
to_chat(user, span_notice("[count > 1 ? count : ""] [item_name][count > 1 ? "s" : ""], worth [amount] sheets, [count > 1 ? "were" : "was"] added to [parent]."))
|
|
if(MATERIAL_INSERT_ITEM_NO_SPACE) //no space
|
|
to_chat(user, span_warning("[parent] has no space to accept [item_name]!"))
|
|
if(MATERIAL_INSERT_ITEM_NO_MATS) //no materials inside these items
|
|
to_chat(user, span_warning("[item_name][count > 1 ? "s have" : " has"] no materials that can be accepted by [parent]!"))
|
|
if(MATERIAL_INSERT_ITEM_FAILURE) //could be because the material type was not accepted or other stuff
|
|
to_chat(user, span_warning("[item_name][count > 1 ? "s were" : " was"] rejected by [parent]!"))
|
|
|
|
/// Proc that allows players to fill the parent with mats
|
|
/datum/component/material_container/proc/on_attackby(datum/source, obj/item/weapon, mob/living/user)
|
|
SIGNAL_HANDLER
|
|
|
|
//Allows you to attack the machine with iron sheets for e.g.
|
|
if(!(mat_container_flags & MATCONTAINER_ANY_INTENT) && user.combat_mode)
|
|
return
|
|
|
|
user_insert(weapon, user)
|
|
|
|
return COMPONENT_NO_AFTERATTACK
|
|
//===============================================================================================
|
|
|
|
|
|
//======================================Material Validation=======================================
|
|
|
|
//=========================================LOW LEVEL===================================
|
|
/**
|
|
* Proc that returns TRUE if the container has space
|
|
*
|
|
* Arguments:
|
|
* * amt - can this container hold this much amount of materials
|
|
*/
|
|
/datum/component/material_container/proc/has_space(amt = 0)
|
|
return (total_amount() + amt) <= max_amount
|
|
|
|
/**
|
|
* The default check for whether we can add materials to this material container.
|
|
*
|
|
* Arguments:
|
|
* - [mat][/atom/material]: The material we are checking for insertability.
|
|
*/
|
|
/datum/component/material_container/proc/can_hold_material(datum/material/mat)
|
|
if(mat in allowed_materials)
|
|
return TRUE
|
|
if(istype(mat) && ((mat.id in allowed_materials) || (mat.type in allowed_materials)))
|
|
allowed_materials += mat // This could get messy with passing lists by ref... but if you're doing that the list expansion is probably being taken care of elsewhere anyway...
|
|
return TRUE
|
|
if(SEND_SIGNAL(src, COMSIG_MATCONTAINER_MAT_CHECK, mat) & MATCONTAINER_ALLOW_MAT)
|
|
allowed_materials += mat
|
|
return TRUE
|
|
return FALSE
|
|
//========================================================================================
|
|
|
|
|
|
//===================================MID LEVEL=============================================
|
|
/**
|
|
* Returns the amount of a specific material in this container.
|
|
*
|
|
* Arguments:
|
|
* -[mat][datum/material] : the material type to check for 3 cases
|
|
* a) If it's an path its ref is retrieved
|
|
* b) If it's text then its an category material & there is no way to deal with it so return 0
|
|
* c) If normal material proceeds as usual
|
|
*/
|
|
/datum/component/material_container/proc/get_material_amount(datum/material/mat)
|
|
if(!istype(mat))
|
|
mat = GET_MATERIAL_REF(mat)
|
|
return materials[mat]
|
|
|
|
/**
|
|
* Returns the amount of material relevant to this container;
|
|
* if this container does not support glass, any glass in 'I' will not be taken into account
|
|
*
|
|
* Arguments:
|
|
* - [I][obj/item]: the item whos materials must be retrieved
|
|
*/
|
|
/datum/component/material_container/proc/get_item_material_amount(obj/item/I)
|
|
if(!istype(I) || !I.custom_materials)
|
|
return 0
|
|
var/material_amount = 0
|
|
var/list/item_materials = I.get_material_composition()
|
|
for(var/MAT in item_materials)
|
|
if(!can_hold_material(MAT))
|
|
continue
|
|
material_amount += item_materials[MAT]
|
|
return material_amount
|
|
//================================================================================================
|
|
|
|
|
|
//=========================================HIGH LEVEL==========================================
|
|
/// returns the total amount of material in the container
|
|
/datum/component/material_container/proc/total_amount()
|
|
. = 0
|
|
for(var/i in materials)
|
|
. += get_material_amount(i)
|
|
|
|
/**
|
|
* Returns TRUE if you have enough of the specified material.
|
|
*
|
|
* Arguments:
|
|
* - [req_mat][datum/material]: the material to check for
|
|
* - amount: how much material do we need
|
|
*/
|
|
/datum/component/material_container/proc/has_enough_of_material(datum/material/req_mat, amount = 1)
|
|
return get_material_amount(req_mat) >= OPTIMAL_COST(amount)
|
|
|
|
|
|
/**
|
|
* Checks if its possible to afford a certain amount of materials. Takes a dictionary of materials.
|
|
* coefficient can be thought of as the machines efficiency & multiplier as the print quantity
|
|
*
|
|
* Arguments:
|
|
* - mats: list of materials(key=material, value= 1 unit of material) to check for
|
|
* - coefficient: scaling applied to 1 unit of material in the mats list
|
|
* - multiplier: how many units(after scaling) do we require
|
|
*/
|
|
/datum/component/material_container/proc/has_materials(list/mats, coefficient = 1, multiplier = 1)
|
|
if(!length(mats))
|
|
return FALSE
|
|
|
|
for(var/x in mats) //Loop through all required materials
|
|
var/wanted = OPTIMAL_COST(mats[x] * coefficient) * multiplier
|
|
if(!has_enough_of_material(x, wanted))//Not a category, so just check the normal way
|
|
testing("didnt have: [x] wanted: [wanted]")
|
|
return FALSE
|
|
|
|
return TRUE
|
|
//==========================================================================================================
|
|
|
|
|
|
//================================================Material Usage============================================
|
|
|
|
//==================================================LOW LEVEL=======================================
|
|
/**
|
|
* Uses an amount of a specific material, effectively removing it.
|
|
*
|
|
* Arguments:
|
|
* - amt: amount of said material to use
|
|
* - [mat][datum/material]: type of mat to use
|
|
*/
|
|
/datum/component/material_container/proc/use_amount_mat(amt, datum/material/mat)
|
|
//round amount
|
|
amt = OPTIMAL_COST(amt)
|
|
|
|
//get ref if nessassary
|
|
if(!istype(mat))
|
|
mat = GET_MATERIAL_REF(mat)
|
|
|
|
//check if sufficient is available
|
|
if(materials[mat] < amt)
|
|
return 0
|
|
|
|
//consume & return amount consumed
|
|
materials[mat] -= amt
|
|
return amt
|
|
//==============================================================================================
|
|
|
|
//=========================================MID LEVEL==========================================
|
|
/**
|
|
* For consuming a dictionary of materials.
|
|
*
|
|
* Arguments:
|
|
* - mats: map of materials to consume(key = material type, value = amount)
|
|
* - coefficient: how much fraction of unit material in the mats list must be consumed. This is usually your machines efficiency
|
|
* - multiplier: how many units of material in the mats list(after each unit is multiplied and rounded with coefficient) must be consumed, This is usually your print quantity
|
|
*/
|
|
/datum/component/material_container/proc/use_materials(list/mats, coefficient = 1, multiplier = 1)
|
|
if(!mats || !length(mats))
|
|
return FALSE
|
|
|
|
var/amount_removed = 0
|
|
for(var/i in mats)
|
|
amount_removed += use_amount_mat(OPTIMAL_COST(mats[i] * coefficient) * multiplier, i)
|
|
|
|
return amount_removed
|
|
//============================================================================================
|
|
|
|
|
|
//===========================================HIGH LEVEL=======================================
|
|
|
|
/**
|
|
* For spawning mineral sheets at a specific location. Used by machines to output sheets.
|
|
*
|
|
* Arguments:
|
|
* sheet_amt: number of sheets to extract
|
|
* [material][datum/material]: type of sheets present in this container to extract
|
|
* [target][atom]: drop location
|
|
* [atom][context]: context - the atom performing the operation, this is the last argument sent in COMSIG_MATCONTAINER_SHEETS_RETRIEVED and is used mostly for silo logging
|
|
*/
|
|
/datum/component/material_container/proc/retrieve_sheets(sheet_amt, datum/material/material, atom/target = null, atom/context = parent)
|
|
//do we support sheets of this material
|
|
if(!material.sheet_type)
|
|
return 0 //Add greyscale sheet handling here later
|
|
if(!can_hold_material(material))
|
|
return 0
|
|
|
|
//requested amount greater than available amount or just an invalid value
|
|
sheet_amt = min(round(materials[material] / SHEET_MATERIAL_AMOUNT), sheet_amt)
|
|
if(sheet_amt <= 0)
|
|
return 0
|
|
//auto drop location
|
|
if(!target)
|
|
var/atom/parent_atom = parent
|
|
target = parent_atom.drop_location()
|
|
if(!target)
|
|
return 0
|
|
|
|
//eject sheets based on available amount after each iteration
|
|
var/count = 0
|
|
while(sheet_amt > 0)
|
|
//don't merge yet. we need to do stuff with it first
|
|
var/obj/item/stack/sheet/new_sheets = new material.sheet_type(target, min(sheet_amt, MAX_STACK_SIZE), FALSE)
|
|
new_sheets.manufactured = TRUE
|
|
count += new_sheets.amount
|
|
//use material & deduct work needed
|
|
use_amount_mat(new_sheets.amount * SHEET_MATERIAL_AMOUNT, material)
|
|
sheet_amt -= new_sheets.amount
|
|
//send signal
|
|
SEND_SIGNAL(src, COMSIG_MATCONTAINER_SHEETS_RETRIEVED, new_sheets, context)
|
|
//no point merging anything into an already full stack
|
|
if(new_sheets.amount == new_sheets.max_amount)
|
|
continue
|
|
//now we can merge since we are done with it
|
|
for(var/obj/item/stack/item_stack in target)
|
|
if(item_stack == new_sheets || item_stack.type != material.sheet_type) //don't merge with self or different type
|
|
continue
|
|
//speed merge
|
|
var/merge_amount = min(item_stack.amount, new_sheets.max_amount - new_sheets.get_amount())
|
|
item_stack.use(merge_amount)
|
|
new_sheets.add(merge_amount)
|
|
break
|
|
return count
|
|
|
|
/**
|
|
* Proc to get all the materials and dump them as sheets
|
|
*
|
|
* Arguments:
|
|
* - target: drop location of the sheets
|
|
* - context: the atom which is ejecting the sheets. Used mostly in silo logging
|
|
*/
|
|
/datum/component/material_container/proc/retrieve_all(target = null, atom/context = parent)
|
|
var/result = 0
|
|
for(var/MAT in materials)
|
|
result += retrieve_sheets(amount2sheet(materials[MAT]), MAT, target, context)
|
|
return result
|
|
//============================================================================================
|
|
|
|
|
|
/datum/component/material_container/ui_static_data(mob/user)
|
|
var/list/data = list()
|
|
data["SHEET_MATERIAL_AMOUNT"] = SHEET_MATERIAL_AMOUNT
|
|
return data
|
|
|
|
/// List format is list(material_name = list(amount = ..., ref = ..., etc.))
|
|
/datum/component/material_container/ui_data(mob/user)
|
|
var/list/data = list()
|
|
|
|
for(var/datum/material/material as anything in materials)
|
|
var/amount = materials[material]
|
|
|
|
data += list(list(
|
|
"name" = material.name,
|
|
"ref" = REF(material),
|
|
"amount" = amount,
|
|
"color" = material.greyscale_colors
|
|
))
|
|
|
|
return data
|
|
|
|
/**
|
|
* Adds context sensitivy directly to the material container file for screentips
|
|
* Arguments:
|
|
* * source - refers to item that will display its screentip
|
|
* * context - refers to, in this case, an item in the users hand hovering over the material container, such as an autolathe
|
|
* * held_item - refers to the item that has materials accepted by the material container
|
|
* * user - refers to user who will see the screentip when the proper context and tool are there
|
|
*/
|
|
/datum/component/material_container/proc/on_requesting_context_from_item(datum/source, list/context, obj/item/held_item, mob/living/user)
|
|
SIGNAL_HANDLER
|
|
|
|
if(isnull(held_item))
|
|
return NONE
|
|
if(!(mat_container_flags & MATCONTAINER_ANY_INTENT) && user.combat_mode)
|
|
return NONE
|
|
if(held_item.item_flags & ABSTRACT)
|
|
return NONE
|
|
if((held_item.flags_1 & HOLOGRAM_1) || (held_item.item_flags & NO_MAT_REDEMPTION) || (allowed_item_typecache && !is_type_in_typecache(held_item, allowed_item_typecache)))
|
|
return NONE
|
|
var/list/item_materials = held_item.get_material_composition()
|
|
if(!length(item_materials))
|
|
return NONE
|
|
for(var/material in item_materials)
|
|
if(can_hold_material(material))
|
|
continue
|
|
return NONE
|
|
|
|
context[SCREENTIP_CONTEXT_LMB] = "Insert"
|
|
|
|
return CONTEXTUAL_SCREENTIP_SET
|
|
|
|
#undef MATERIAL_INSERT_ITEM_SUCCESS
|