Files
Bubberstation/code/modules/power/cable.dm
Useroth 20c0599ce6 Some more mirrors again (#27366)
* Ports additional Felinid ears from Orbstation (#82066)

Adds 5 new ear options from Orbstation, originally PRed in
lizardqueenlexi/orbstation#360. Sprites by @Or-Fi-S.

Big:

![image](https://github.com/tgstation/tgstation/assets/7019927/5f847130-e5f5-44cc-adb4-c740c4c4f69b)

Coeurl (FFXIV Miqo'te style):

![image](https://github.com/tgstation/tgstation/assets/7019927/34448bee-d6af-4d3c-b796-384ec9904368)

Fold:

![image](https://github.com/tgstation/tgstation/assets/7019927/a7dafd05-f652-460e-9386-f7fcbef696e9)

Lynx:

![image](https://github.com/tgstation/tgstation/assets/7019927/174ff630-6eb8-4bb9-8f4f-791b70356c58)

Round:

![image](https://github.com/tgstation/tgstation/assets/7019927/b3a24d1b-66fa-4883-8c27-871ae8966d6c)

Also makes it so the code guarantees that custom ears on a felinid
actually count as felinid ears and not human ones, as the code wasn't
checking properly when preferences were applied. There's probably a
cleaner, more permanent way to do this and a refactor is needed
somewhere down the line (man that sprite accessories file is getting
long huh) but I'll leave that to a more competent coder.

More customization options are good also Cobby said I could

![image](https://github.com/tgstation/tgstation/assets/7019927/56bbe285-068f-41a1-92cc-9f3861875090)

🆑
add: Added 5 new Felinid ear options, ported from Orbstation! (Sprites
by Or-Fi-S)
/🆑

---------

Co-authored-by: _0Steven <jaydondegenerschool@gmail.com>

* Standardizes object deconstruction  throughout the codebase.  (#82280)

When it comes to deconstructing an object we have `proc/deconstruct()` &
`NO_DECONSTRUCT`

Lets talk about the flag first.

**Problems with `NO_DECONSTRUCTION`**
I know what the comment says on what it should do

b5593bc693/code/__DEFINES/obj_flags.dm (L18)

But everywhere people have decided to give their own meaning/definition
to this flag. Here are some examples on how this flag is used

**1. Make the object just disappear(not drop anything) when
deconstructed**
This is by far the largest use case everywhere. If an object is
deconstructed(either via tools or smashed apart) then if it has this
flag it should not drop any of its contents but just disappear. You have
seen this code pattern used everywhere

b5593bc693/code/game/machinery/constructable_frame.dm (L26-L31)

This behaviour is then leveraged by 2 important components.

When an object is frozen, if it is deconstructed it should just
disappear without leaving any traces behind

b5593bc693/code/datums/elements/frozen.dm (L66-L67)

By hologram objects. Obviously if you destroy an hologram nothing real
should drop out

b5593bc693/code/modules/holodeck/computer.dm (L301-L304)

And there are other use cases as well but we won't go into them as they
aren't as significant as these.

**2. To stop an object from being wrenched ??**
Yeah this one is weird. Like why? I understand in some instances (chair,
table, rack etc) a wrench can be used to deconstruct a object so using
the flag there to stop it from happening makes sense but why can't we
even anchor an object just because of this flag?

b5593bc693/code/game/objects/objs.dm (L368-L369)
This is one of those instances where somebody just decided this
behaviour for their own convenience just like the above example with no
explanation as to why

**3. To stop using tools to deconstruct the object**
This was the original intent of the flag but it is enforced in few
places far & between. One example is when deconstructing the a machine
via crowbar.

b5593bc693/code/game/machinery/_machinery.dm (L811)

But machines are a special dual use case for this flag. Because if you
look at its deconstruct proc the flag also prevents the machine from
spawning a frame.

b5593bc693/code/game/machinery/_machinery.dm (L820-L822)

How can 1 flag serve 2 purposes within the same type?

**4. Simply forget to check for this flag altogether**
Yup if you find this flag not doing its job for some objects don't be
surprised. People & sometimes even maintainers just forget that it even
exists

b5593bc693/code/game/objects/items/piggy_bank.dm (L66-L67)

**Solution**
These are the main examples i found. As you can see the same flag can
perform 2 different functions within the same type and do something else
in a different object & in some instances don't even work cause people
just forget, etc.

In order to bring consistency to this flag we need to move it to the
atom level where it means the same thing everywhere. Where in the atom
you may ask? .Well, I'll just post what MrMelbert said in
https://github.com/tgstation/tgstation/pull/81656#discussion_r1503086862

> ...Ideally the .deconstruct call would handle NO_DECONSTRUCTION
handling as it wants,

Yup that's the ideal case now. This flag is checked directly in
`deconstruct()`. Now like i said we want to give a universal definition
to this flag and as you have seen from my examples it is used in 3 cases
1) Make an object disappear(doesn't dropping anything) when
deconstructed
2) Stop it from being wrenched
3) Stop it from being deconstructed via tools

We can't enforce points 2 & 3 inside `deconstruct()` which leaves us
with only case 1) i.e. make the object disappear. And that's what i have
done. Therefore after more than a decade or since this flag got
introduced `NO_DECONSTRUCT` now has a new definition as of 2024

_"Make an object disappear(don't dropping anything) when deconstructed
either via tools or forcefully smashed apart"_

Now i very well understand this will open up bugs in places where cases
2 & 3 are required but its worth it. In fact they could even be qol
changes for all we know so who knows it might even benefit us but for
now we need to give a universal definition to this flag to bring some
consistency & that's what this PR does.

**Problem with deconstruct()**
This proc actually sends out a signal which is currently used by the
material container but could be used by other objects later on.

3e84c3e6da/code/game/objects/obj_defense.dm (L160)

So objects that override this proc should call its parent. Sadly that
isn't the case in many instances like such

3e84c3e6da/code/game/machinery/deployable.dm (L20-L23)

Instead of `return ..()` which would delete the object & send the signal
it deletes the object directly thus the signal never gets sent.

**Solution**
Make this proc non overridable. For objects to add their own custom
deconstruction behaviour a new proc has been introduced
`atom_deconstruct()` Subtypes should now override this proc to handle
object deconstruction.

If objects have certain important stuff inside them (like mobs in
machines for example) they want to drop by handling `NO_DECONSTRUCT`
flag in a more carefully customized way they can do this by overriding
`handle_deconstruct()` which by default delegates to
`atom_deconstruct()` if the `NO_DECONSTRUCT` flag is absent. This proc
will allow you to handle the flag in a more customized way if you ever
need to.

1) I'm goanna post the full comment from MrMelbert
https://github.com/tgstation/tgstation/pull/81656#discussion_r1503086862

> ...Ideally the .deconstruct call would handle NO_DECONSTRUCTION
handling as it wants, but there's a shocking lack of consistency around
NO_DECONSTRUCTION, where some objects treat it as "allow deconstruction,
but make it drop no parts" and others simply "disallow deconstruction at
all"

This PR now makes `NO_DECONSTRUCTION` handled by `deconstruct()` & gives
this flag the consistency it deserves. Not to mention as shown in case 4
there are objects that simply forgot to check for this flag. Now it
applies for those missing instances as well.

2) No more copying pasting the most overused code pattern in this code
base history `if(obj_flags & NO_DECONSTRUCTION)`. Just makes code
cleaner everywhere

3) All objects now send the `COMSIG_OBJ_DECONSTRUCT` signal on object
deconstruction which is now available for use should you need it

🆑
refactor: refactors how objects are deconstructed in relation to the
`NO_DECONSTRUCTION` flag. Certain objects & machinery may display
different tool interactions & behaviours when destroyed/deconstructed.
Report these changes if you feel like they are bugs
/🆑

---------

Co-authored-by: san7890 <the@san7890.com>

* Makes attempting to refresh the logs not just throw a runtime error (#82432)

## About The Pull Request

Really all this seems to be is a mismatch between the tgui and dm side
of the menu.

3c71b14df0/tgui/packages/tgui/interfaces/LogViewer.tsx (L71)

3c71b14df0/code/modules/logging/log_holder.dm (L110-L113)
Making these line up by renaming `re-render` to `refresh` seems to make
it work just fine, and not just throw an error.
## Why It's Good For The Game

Life tends to be better when refreshing to see new runtimes doesn't just
add its own lovely little runtimes.

![image](https://github.com/tgstation/tgstation/assets/42909981/79bee3db-5c28-409b-9ff5-3a315fb4ed1c)

![image](https://github.com/tgstation/tgstation/assets/42909981/82a25038-ba7a-430a-bb79-f59d5f4b262b)
And then not show them til you re-open the window cause it doesn't
refresh.
## Changelog
🆑
admin: Refresh button on the View Round Logs menu actually works,
instead of just adding a runtime to the logs (and not updating them).
/🆑

* Creates a "busy" animation for players (#82416)

Little indicator above a player when they're currently doing something.

<details>
<summary>vids</summary>

Perspective: You are the moth

![dreamseeker_b2LA4PpPAr](https://github.com/tgstation/tgstation/assets/42397676/3a38dd3c-23f2-430f-acf4-444ad5c478d3)

Hides under runechat

![dreamseeker_ZgkCWTGqDz](https://github.com/tgstation/tgstation/assets/42397676/ec1d9665-4ff0-47f7-85b6-65998c31b9be)

</details>

Todo:

- [x] Feedback?
- [x] Sneaky params so it doesn't spoil your stealth run
- [x] Possible refactor
- [x] Probably missed some "sneaky" actions
- [x] coggers

<details>
<summary>sound on:</summary>

https://github.com/tgstation/tgstation/assets/42397676/ad71c567-0202-4158-ba50-c2946375f988

</details>

🆑 jlsnow301, infraredbaron
add: Added a new UI element over players that are interacting, building,
etc.
/🆑

---------

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>

* New operative reinforcement option: Intelligence Overwatch Agent (#82307)

## About The Pull Request

Introducing a new Nuclear Operative reinforcement option: The Overwatch
Intelligence Agent.

Equipped with multi-hudglasses, they have an advanced camera console,
station alerts, and bodycams of every operative! If something can be
known, they will know about it.

They can also remotely pilot your ship. Finally, everyone can ride in
the Steel Rain without getting stuck on the station!

This role spawns in the formerly unused outpost just north of the nukie
base. With a few shelves of supplies and some tools in the back room,
they can set up their workplace however they like. This also gives them
something to work on while they wait for the operatives to gear up.


![image](https://github.com/tgstation/tgstation/assets/28870487/4a39ec5f-0578-4825-8c6b-cc4db47bf726)

As you can see, it's rather cramped and the lights are quite dim in the
backroom. Set it up however you like, this is how I did mine:


![image](https://github.com/tgstation/tgstation/assets/28870487/f80b65fa-dcd1-425e-a6ce-c0ed94a8a3a5)

Total price? 12 TC per agent. It might get a bit cramped, but you could
buy a second to make sure the first guy doesn't get lonely!

This turned into a 30-commit ugly because the bodycams were originally
meant to be accomplished via a refactoring of the spyglass kit. Big
mistake that made me shelve the project -- until Melbert's simple
bodycam component conveniently did exactly what I needed in a much
simpler way.
## Why It's Good For The Game

Having a "guy in the chair" for your kickass murder operator squad
enables more brainy strategizing, and is thematically sound. Also,
nukies have the opportunity to bring in another player to participate in
the fun!
## Changelog
🆑 Rhials
add: Nuclear Operatives now purchase an Intelligence Agent, who can
watch cameras and bodycams, move the shuttle, and provide radio support.
Only 12 Telecrystals!
/🆑

* re-adds list of components for admins to remove (#82461)

## About The Pull Request

The list of components on a mob when admins try to remove one didn't
actually show them, now it does.

![image](https://github.com/tgstation/tgstation/assets/53777086/a6102c3a-df30-4e9c-b7fd-29a4d8ddaa89)

## Why It's Good For The Game

Messing with components/elements on mobs are such a pain, in this case
was broken entirely.

![admin-toolings](https://github.com/tgstation/tgstation/assets/53777086/3d190c66-34e4-4424-824b-37f95e88b003)

## Changelog

🆑
admin: Removing components button now lists components to remove
/🆑

* Reboots the CNS Rebooter Implant. (#82441)

## About The Pull Request
The CNS Rebooter Implant will now pull you out of stuns and stamcrit,
while granting you a few seconds of stun immunity, comes with a 60
seconds cooldown
## Why It's Good For The Game
The CNS Rebooter Implant is a strong candidate for the absolute worst
implant in the game, it caps your stuns at 4 seconds
(which is plenty of time to get murdered) and does nothing to prevent
stamina damage, for something accessible in one of the latest research
nodes and in the nukie uplink it should perform better than it does now.
Besides, the game is in dire need for more tools to keep the stun meta
at bay, and this is a good place to start.

This PR makes it so the rebooter will bail you out stamcrit every 60
seconds, along with giving you a few seconds of immunity to run away or
get a couple of hits in.
## Changelog
🆑
balance: CNS Rebooter Implant will now pull you out of stamcrit and
grant you a few seconds of stun immunity
/🆑

---------

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

* Fix "Aheal" for ears deafness (#82448)

## About The Pull Request
Make the admin button "Aheal" and Magic Wand of Healing (resurrection)
actually full heal carbon's Ears.

File _ears.dm contains timer variable "deaf" that should be updated to 0
after complete healing.

But I think this must be properly code-refactored because looks like
it's just duplicates(?) standart variable "damage" for organ type.

## Why It's Good For The Game
Aheal - means FULLY HEAL.

## Changelog

🆑
fix: aheal now properly heals ears deafness
/🆑

---------

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

* Medipens can't have reagents removed from them anymore. (#82451)

## About The Pull Request

This will be needed for
https://github.com/tgstation/tgstation/pull/82449 because this removes
the machine's ability to make infinite chems.
Basically in https://github.com/tgstation/tgstation/pull/29139 they
removed medipen's ability to have reagents injected into them, but never
removed the ability to take reagents out.
You could take a syringe, remove all chemicals from a medipen, put the
main ingredient in a medipen refiller, then refill. You could do this
right now on live servers with an epipen for infinite formaldehyde.

This doesn't affect the hypospray.

## Why It's Good For The Game

Removes a way of infinitely making reagents with a medipen refiller and
also removes a dumb mechanic.
You could take all chemicals out of an EHMS autoinjector, which removes
the visual and feedback tell to the target that they've been injected,
and even with 0 chemicals they get the disease anyways.
You could buy medipens as a miner, take the chemicals out, and put them
in a syringe or pill that you can inject yourself instantly with.
You can take otherwise hard-to-get chemicals like fungal TB's 2-use cure
injector, and make 40 cure pills instead.

## Changelog

🆑
fix: You can no longer take chemicals out of medipens with a syringe.
/🆑

* Search string in catalogs in char prefs (#82423)

* actually just removes stamina damage and knockdown from punches (#82400)

removes punch knockdowns and stamina damage from them

knockdown punches were also around the time disarm could just hardstun
you to RNG
this is dumb so we remove that
also watermelon supposedly wanted to remove stamina damage from punches
so idk about that

anyway so this is a problem because you could be randomly floored by
sheer luck through thick plates of metal and is overall not a very fun
thing to play against especially with northstar gloves

resolves unfun RNG by removing knockdowns and does something watermelon
wanted by removing stam damage from it

🆑
balance: punches no longer knock down or deal stamina damage
/🆑

* Fix slime `check_item_passthrough` effect (#82484)

## About The Pull Request

This proc expects a user but is not passed one. 

## Changelog

🆑 Melbert
fix: Items will properly pass through slime on occasion
/🆑

* Basic mobs now use z-level turnoff instead of simple (#82469)

## About The Pull Request

On one compile of MetaStation, I saw that there's 45 basic mobs on the
station, 256 on lavaland (the number growing from tendrils), and 59 in
all other z levels combined.

While we do expect Lavaland to be visited every round, at least it won't
be running during the times when no one is there, but even more
importantly, space exploration is something not done every round, so we
don't have any reason to waste our resources on AIs that will never be
interacted with.

Simple animals had an easy solution to this:
If no one is on the Z level, their AI turns off
If someone is on the Z level, they are idle unless needed.

The last simple animals that exists right now are bots, megafauna,
geese, gondolas, and some minor ones like mimic, zombie, dark wizard,
soulscythe, etc.
Point is, we're very much nearly done going through all simple animals,
so this code is being wasted just to ensure things like cleanbots won't
work if no one is on the z level, something I doubt happens often, so I
took their code and made it work for basic mobs instead. I could've done
both but I thought it would look very bad, and maybe this is a good
incentivize to get more basic mob conversions.

There's one major change here and it's that we're missing the "Idle"
mode, some basic mobs like the Lavaland village seems to be made with
intent that they'll be running even if players aren't around, so this
sets up a future PR that makes idle AI easier to add, and I want to make
sure those cases are taken into account.

## Why It's Good For The Game

We don't need to always be processing these basic mobs, and sets us in
the future to hopefully also implement idle AIs.

## Changelog

🆑
balance: Basic mob AIs with no mobs on the Z level now stop.
/🆑

---------

Co-authored-by: san7890 <the@san7890.com>

* adds preferences to transhumanist (#82435)

## About The Pull Request
You may remember this, that's because I accidentally deleted it before
while trying to change things. Anyways!
Adds drop-down selections and new options to transhumanist. also fixes a
minor typo
Previously, you could choose your replaced limb by taking prosthetic
limb, setting what you want changed, and then switching to
transhumanist, since they used the same preference previously.

## Why It's Good For The Game

Transhumanist felt strange because it was hypothetically a voluntary
operation, but the augmentation clinic just spun the wheel on what you
got replaced. From a role-playing perspective, being unable to choose is
uninteresting and confusing. Also it always says your limb being was
being replaced with a robotic arm and that annoyed me. Now that you are
able to select your replacement part, I've added two new options, the
robotic voice box, good for a more prominent change then a limb that
will be hidden for most of a round, and flashlight eyes, for when you
are truly committed to being rushed directly to robotics seeing the
bright future ahead of humanity!

## Changelog
🆑
add: Transhumanist now allows you to select your augmentation
add: Transhumanist can now provide a robotic voice box, or flashlight
eyes
spellcheck: Transhumanist's roundstart text has been re-written to not
be wrong
/🆑

---------

Co-authored-by: san7890 <the@san7890.com>

* Watcher wreaths; Normal and Icewing varieties (#82457)

Adds Watcher Wreaths. An item that makes it look like you have a
slightly floating thorn crown that you can make from some of their
material parts (and the icewing crusher trophy for the icewing variant).

The wreath has emissives. They don't do anything mechanically, they're
just for show.

![wreath](https://github.com/tgstation/tgstation/assets/40847847/84b7cf89-2087-4c5c-85c1-d911c2e7ea13)

![image](https://github.com/tgstation/tgstation/assets/40847847/77bcda12-e29f-45f0-ad4a-8f25de12c0ef)

![image](https://github.com/tgstation/tgstation/assets/40847847/da3321bb-b24d-4e60-8648-455483e955d6)

I really like the whole thing with turning lavaland monsters into
trophies and cosmetics. Going down and coming back up looking like
someone who just crawled through a horror movie and took some souvenirs
is great. Stuff like the trophy accessories, bone and drake armor and
many of the various lavaland items have this quality, and it always
amuses me when a tech sees a dressed up miner and just goes 'holy shit,
where did you get that'?

Drip is the ultimate reward for playing miner. Nobody can tell me
otherwise. this is the endgame every miner craves. And I crave a goddamn
crown made from the broken remains of my enemies.

🆑
add: Watcher wreaths. Made from the mangled remains of a watcher, now a
handsome accessory for you to wear a few inches behind your head. Comes
in Normal and Icewing variants.
add: Some bounties for the two variants of watcher wreaths.
/🆑

* CHEAP_HYPOTENUSE() no longer makes the differences between the coordinates absolute. (#82468)

## About The Pull Request
CHEAP_HYPOTENUSE() no longer absolutes the differences between the
coordinates.
## Why It's Good For The Game
It gets squared so it doesn't need to be done.

* Neutered symptoms no longer activate (#82467)

## About The Pull Request

Stops activation of all neutered symptoms in a advanced disease.

## Why It's Good For The Game

Closes https://github.com/tgstation/tgstation/issues/68944

## Changelog

🆑
fix: Narcolepsy is no longer activated while neutered.
/🆑

* Fixes the color matrix editor (#82478)

## About The Pull Request

It was sending back stringified numbers as inputs. This came from a
typescript cleanup pr from sync (#82000) and was ultimately caused by
a... I think misunderstanding of how the color list works (#67967)

## Why It's Good For The Game

Works like a charm now, which is good cause I use it a lot

## Changelog
🆑
fix: The color matrix editor now works properly again
/🆑

* Hats no longer cover mouths (#82498)

* Fixes banned/days remaining preferences display for non-dynamic ruleset antagonists. (#82506)

* Reverts reversion: tgui will 516 or else (#82527)

## About The Pull Request
Context: #82522

Apparently you cant just stuff the byond helper functions into an
external js file, but if you do, byond won't even let you know its a
problem until the servers crash and you have to run `bin/clean` just to
unbork your entire repo

This reimplements the changes from #82473 without:
- moving the byond helper functions externally
- causing a tooltip render issue in panel

## Why It's Good For The Game
516 prep (again this time)

* Final Objective: Battle Royale (#82258)

## About The Pull Request

Adds a new final objective option with a classic premise; the forced
battle to the death.
The concept is that the Syndicate will provide you with an implanter
tool you can use on an arbitrary number of crew members. Once you have
at least 6 (though there is no ceiling) you can activate the implants to
start the Battle Royale and broadcast the perspectives of everyone you
implanted live to the entertainment monitor.

After activation these implants cause you to explode upon death. If at
the end of 10 minutes, more than one person remains unexploded then all
of the remaining implants will detonate simultaneously.
Additionally, one of the station's departments (Medbay, Cargo, Science,
or Engineering) will be chosen as the arena. If after 5 minutes pass
you're not within that department (or if you leave it after that time
has passed) then you will be killed.

The Syndicate plan on both using the recorded footage to study
Nanotrasen technology, and also to sell it as an underground blood
sport, and so have employed a pirate broadcasting station to provide
colour commentary.

The implantation is silent, however it requires you and your target to
be adjacent and stood still for one and a half seconds.
Once implanted, it will occasionally itch and eventually signal to the
implantee that something is up, so once you start implanting someone
you're on a soft timer until you are given away. You can also implant
yourself if you want to do that for some reason.

Removing an implant from someone has a 70% chance of setting it off
instantly, but it _is_ possible. If the implant is exposed to EMP, this
value is randomised between 0 and 100%. You could also try doing surgery
while the patient is wearing a bomb suit or something, that puzzle is
for you to solve and I'm not going to tell you the answers. I'm sure
you'll think of ones I haven't.

## Why It's Good For The Game

Adds a somewhat more down-to-earth but still hopefully exciting and
threatening option which should let people mess around with the sandbox.
The mutual death element provides some roleplaying prompts; nothing
actually _forces_ you to fight apart from fear of death and it may be
possible to find other ways to survive, or perform some kind of
solidarity behaviour with your fellow contestants. Maybe you'll try that
but one of your fellow contestants just wants to be the last survivor
anyway. Maybe you'll pretend you're setting up some kind of mutual
survivorship thing in order to make sure you're the sole survivor.
Gives some people to watch on the bar TV channel.
The crew apparently love playing Deathmatch while dead so we might as
well enable doing it while alive.

Also I'm going to follow this up with a separate PR to remove the Space
Dragon objective and it felt like it'd be a good idea to do one out one
in

## Changelog

🆑
add: Adds a new Final Objective where you force your fellow crew to
fight to the death on pain of... death.
/🆑

---------

Co-authored-by: _0Steven <jaydondegenerschool@gmail.com>
Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
Co-authored-by: Jeremiah <42397676+jlsnow301@users.noreply.github.com>
Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com>
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: EnterTheJake <102721711+EnterTheJake@users.noreply.github.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Artemchik542 <32270644+Artemchik542@users.noreply.github.com>
Co-authored-by: Yaroslav Nurkov <78199449+AnywayFarus@users.noreply.github.com>
Co-authored-by: jimmyl <70376633+mc-oofert@users.noreply.github.com>
Co-authored-by: Skeleton-In-Disguise <49223093+Skeleton-In-Disguise@users.noreply.github.com>
Co-authored-by: necromanceranne <40847847+necromanceranne@users.noreply.github.com>
Co-authored-by: Pickle-Coding <58013024+Pickle-Coding@users.noreply.github.com>
Co-authored-by: Bilbo367 <163439532+Bilbo367@users.noreply.github.com>
Co-authored-by: FlufflesTheDog <piecopresident@gmail.com>
Co-authored-by: AnturK <AnturK@users.noreply.github.com>
Co-authored-by: Jacquerel <hnevard@gmail.com>
2024-04-17 22:59:33 -04:00

774 lines
25 KiB
Plaintext

//Use this only for things that aren't a subtype of obj/machinery/power
//For things that are, override "should_have_node()" on them
GLOBAL_LIST_INIT(wire_node_generating_types, typecacheof(list(/obj/structure/grille)))
#define UNDER_SMES -1
#define UNDER_TERMINAL 1
///////////////////////////////
//CABLE STRUCTURE
///////////////////////////////
////////////////////////////////
// Definitions
////////////////////////////////
/obj/structure/cable
name = "power cable"
desc = "A flexible, superconducting insulated cable for heavy-duty power transfer."
icon = 'icons/obj/pipes_n_cables/layer_cable.dmi'
icon_state = "l2-1-2-4-8-node"
color = CABLE_HEX_COLOR_YELLOW
plane = FLOOR_PLANE
layer = WIRE_LAYER //Above hidden pipes, GAS_PIPE_HIDDEN_LAYER
anchored = TRUE
obj_flags = CAN_BE_HIT
var/linked_dirs = 0 //bitflag
var/node = FALSE //used for sprites display
var/cable_layer = CABLE_LAYER_2 //bitflag
var/datum/powernet/powernet
var/cable_color = CABLE_COLOR_YELLOW
var/is_fully_initialized = FALSE
/obj/structure/cable/layer1
color = CABLE_HEX_COLOR_RED
cable_color = CABLE_COLOR_RED
cable_layer = CABLE_LAYER_1
layer = WIRE_LAYER - 0.01
icon_state = "l1-1-2-4-8-node"
/obj/structure/cable/layer3
color = CABLE_HEX_COLOR_BLUE
cable_color = CABLE_COLOR_BLUE
cable_layer = CABLE_LAYER_3
layer = WIRE_LAYER + 0.01
icon_state = "l4-1-2-4-8-node"
/obj/structure/cable/Initialize(mapload)
. = ..()
GLOB.cable_list += src //add it to the global cable list
Connect_cable()
AddElement(/datum/element/undertile, TRAIT_T_RAY_VISIBLE)
RegisterSignal(src, COMSIG_RAT_INTERACT, PROC_REF(on_rat_eat))
if(isturf(loc))
var/turf/turf_loc = loc
turf_loc.add_blueprints_preround(src)
return INITIALIZE_HINT_LATELOAD
/obj/structure/cable/LateInitialize()
update_appearance(UPDATE_ICON)
is_fully_initialized = TRUE
/obj/structure/cable/examine(mob/user)
. = ..()
if(isobserver(user))
. += get_power_info()
/obj/structure/cable/proc/on_rat_eat(datum/source, mob/living/basic/regal_rat/king)
SIGNAL_HANDLER
if(avail())
king.apply_damage(10)
playsound(king, 'sound/effects/sparks2.ogg', 100, TRUE)
deconstruct()
return COMPONENT_RAT_INTERACTED
///Set the linked indicator bitflags
/obj/structure/cable/proc/Connect_cable(clear_before_updating = FALSE)
var/under_thing = NONE
if(clear_before_updating)
linked_dirs = 0
var/obj/machinery/power/search_parent
for(var/obj/machinery/power/P in loc)
if(istype(P, /obj/machinery/power/terminal))
under_thing = UNDER_TERMINAL
search_parent = P
break
if(istype(P, /obj/machinery/power/smes))
under_thing = UNDER_SMES
search_parent = P
break
for(var/check_dir in GLOB.cardinals)
var/TB = get_step(src, check_dir)
//don't link from smes to its terminal
if(under_thing)
switch(under_thing)
if(UNDER_SMES)
var/obj/machinery/power/terminal/term = locate(/obj/machinery/power/terminal) in TB
//Why null or equal to the search parent?
//during map init it's possible for a placed smes terminal to not have initialized to the smes yet
//but the cable underneath it is ready to link.
//I don't believe null is even a valid state for a smes terminal while the game is actually running
//So in the rare case that this happens, we also shouldn't connect
//This might break.
if(term && (!term.master || term.master == search_parent))
continue
if(UNDER_TERMINAL)
var/obj/machinery/power/smes/S = locate(/obj/machinery/power/smes) in TB
if(S && (!S.terminal || S.terminal == search_parent))
continue
var/inverse = REVERSE_DIR(check_dir)
for(var/obj/structure/cable/C in TB)
if(C.cable_layer & cable_layer)
linked_dirs |= check_dir
C.linked_dirs |= inverse
// We will update on LateInitialize otherwise.
if (C.is_fully_initialized)
C.update_appearance(UPDATE_ICON)
if (is_fully_initialized)
update_appearance(UPDATE_ICON)
///Clear the linked indicator bitflags
/obj/structure/cable/proc/Disconnect_cable()
for(var/check_dir in GLOB.cardinals)
var/inverse = REVERSE_DIR(check_dir)
if(linked_dirs & check_dir)
var/TB = get_step(loc, check_dir)
for(var/obj/structure/cable/C in TB)
if(cable_layer & C.cable_layer)
C.linked_dirs &= ~inverse
C.update_appearance()
/obj/structure/cable/Destroy() // called when a cable is deleted
Disconnect_cable()
if(powernet)
cut_cable_from_powernet() // update the powernets
GLOB.cable_list -= src //remove it from global cable list
return ..() // then go ahead and delete the cable
/obj/structure/cable/atom_deconstruct(disassembled = TRUE)
var/obj/item/stack/cable_coil/cable = new(drop_location(), 1)
cable.set_cable_color(cable_color)
///////////////////////////////////
// General procedures
///////////////////////////////////
/obj/structure/cable/update_icon_state()
if(!linked_dirs)
icon_state = "l[cable_layer]-noconnection"
return ..()
// TODO: stop doing this shit in update_icon_state, this should be event based for the love of all that is holy
var/list/dir_icon_list = list()
for(var/check_dir in GLOB.cardinals)
if(linked_dirs & check_dir)
dir_icon_list += "[check_dir]"
var/dir_string = dir_icon_list.Join("-")
if(dir_icon_list.len > 1)
for(var/obj/O in loc)
if(GLOB.wire_node_generating_types[O.type])
dir_string = "[dir_string]-node"
break
else if(istype(O, /obj/machinery/power))
var/obj/machinery/power/P = O
if(P.should_have_node())
dir_string = "[dir_string]-node"
break
dir_string = "l[cable_layer]-[dir_string]"
icon_state = dir_string
return ..()
/obj/structure/cable/proc/handlecable(obj/item/W, mob/user, params)
var/turf/T = get_turf(src)
if(T.underfloor_accessibility < UNDERFLOOR_INTERACTABLE)
return
if(W.tool_behaviour == TOOL_WIRECUTTER)
if (shock(user, 50))
return
user.visible_message(span_notice("[user] cuts the cable."), span_notice("You cut the cable."))
investigate_log("was cut by [key_name(usr)] in [AREACOORD(src)]", INVESTIGATE_WIRES)
deconstruct()
return
else if(W.tool_behaviour == TOOL_MULTITOOL)
to_chat(user, get_power_info())
shock(user, 5, 0.2)
add_fingerprint(user)
/obj/structure/cable/proc/get_power_info()
if(powernet?.avail > 0)
return span_danger("Total power: [display_power(powernet.avail)]\nLoad: [display_power(powernet.load)]\nExcess power: [display_power(surplus())]")
else
return span_danger("The cable is not powered.")
// Items usable on a cable :
// - Wirecutters : cut it duh !
// - Multitool : get the power currently passing through the cable
//
/obj/structure/cable/attackby(obj/item/W, mob/user, params)
handlecable(W, user, params)
// shock the user with probability prb
/obj/structure/cable/proc/shock(mob/user, prb, siemens_coeff = 1)
if(!prob(prb))
return FALSE
if(electrocute_mob(user, powernet, src, siemens_coeff))
do_sparks(5, TRUE, src)
return TRUE
else
return FALSE
/obj/structure/cable/singularity_pull(S, current_size)
..()
if(current_size >= STAGE_FIVE)
deconstruct()
////////////////////////////////////////////
// Power related
///////////////////////////////////////////
// All power generation handled in add_avail()
// Machines should use add_load(), surplus(), avail()
// Non-machines should use add_delayedload(), delayed_surplus(), newavail()
/obj/structure/cable/proc/add_avail(amount)
if(powernet)
powernet.newavail += amount
/obj/structure/cable/proc/add_load(amount)
if(powernet)
powernet.load += amount
/obj/structure/cable/proc/surplus()
if(powernet)
return clamp(powernet.avail-powernet.load, 0, powernet.avail)
else
return 0
/obj/structure/cable/proc/avail(amount)
if(powernet)
return amount ? powernet.avail >= amount : powernet.avail
else
return 0
/obj/structure/cable/proc/add_delayedload(amount)
if(powernet)
powernet.delayedload += amount
/obj/structure/cable/proc/delayed_surplus()
if(powernet)
return clamp(powernet.newavail - powernet.delayedload, 0, powernet.newavail)
else
return 0
/obj/structure/cable/proc/newavail()
if(powernet)
return powernet.newavail
else
return 0
/////////////////////////////////////////////////
// Cable laying helpers
////////////////////////////////////////////////
// merge with the powernets of power objects in the given direction
/obj/structure/cable/proc/mergeConnectedNetworks(direction)
var/inverse_dir = (!direction)? 0 : REVERSE_DIR(direction) //flip the direction, to match with the source position on its turf
var/turf/TB = get_step(src, direction)
for(var/obj/structure/cable/C in TB)
if(!C)
continue
if(src == C)
continue
if(!(cable_layer & C.cable_layer))
continue
if(C.linked_dirs & inverse_dir) //we've got a matching cable in the neighbor turf
if(!C.powernet) //if the matching cable somehow got no powernet, make him one (should not happen for cables)
var/datum/powernet/newPN = new()
newPN.add_cable(C)
if(powernet) //if we already have a powernet, then merge the two powernets
merge_powernets(powernet, C.powernet)
else
C.powernet.add_cable(src) //else, we simply connect to the matching cable powernet
// merge with the powernets of power objects in the source turf
/obj/structure/cable/proc/mergeConnectedNetworksOnTurf()
var/list/to_connect = list()
node = FALSE
if(!powernet) //if we somehow have no powernet, make one (should not happen for cables)
var/datum/powernet/newPN = new()
newPN.add_cable(src)
//first let's add turf cables to our powernet
//then we'll connect machines on turf where a cable is present
for(var/atom/movable/AM in loc)
if(istype(AM, /obj/machinery/power/apc))
var/obj/machinery/power/apc/N = AM
if(!N.terminal)
continue // APC are connected through their terminal
if(N.terminal.powernet == powernet) //already connected
continue
to_connect += N.terminal //we'll connect the machines after all cables are merged
else if(istype(AM, /obj/machinery/power)) //other power machines
var/obj/machinery/power/M = AM
if(M.powernet == powernet)
continue
to_connect += M //we'll connect the machines after all cables are merged
//now that cables are done, let's connect found machines
for(var/obj/machinery/power/PM in to_connect)
node = TRUE
if(!PM.connect_to_network())
PM.disconnect_from_network() //if we somehow can't connect the machine to the new powernet, remove it from the old nonetheless
//////////////////////////////////////////////
// Powernets handling helpers
//////////////////////////////////////////////
/obj/structure/cable/proc/get_cable_connections(powernetless_only)
. = list()
var/turf/T = get_turf(src)
for(var/check_dir in GLOB.cardinals)
if(linked_dirs & check_dir)
T = get_step(src, check_dir)
for(var/obj/structure/cable/C in T)
if(cable_layer & C.cable_layer)
. += C
/obj/structure/cable/proc/get_all_cable_connections(powernetless_only)
. = list()
var/turf/T
for(var/check_dir in GLOB.cardinals)
T = get_step(src, check_dir)
for(var/obj/structure/cable/C in T.contents - src)
. += C
/obj/structure/cable/proc/get_machine_connections(powernetless_only)
. = list()
for(var/obj/machinery/power/P in get_turf(src))
if(!powernetless_only || !P.powernet)
if(P.anchored)
. += P
/obj/structure/cable/proc/auto_propagate_cut_cable(obj/O)
if(O && !QDELETED(O))
var/datum/powernet/newPN = new()// creates a new powernet...
propagate_network(O, newPN)//... and propagates it to the other side of the cable
//Makes a new network for the cable and propgates it. If we already have one, just die
/obj/structure/cable/proc/propagate_if_no_network()
if(powernet)
return
var/datum/powernet/newPN = new()
propagate_network(src, newPN)
// cut the cable's powernet at this cable and updates the powergrid
/obj/structure/cable/proc/cut_cable_from_powernet(remove = TRUE)
if(!powernet)
return
var/turf/T1 = loc
if(!T1)
return
//clear the powernet of any machines on tile first
for(var/obj/machinery/power/P in T1)
P.disconnect_from_network()
var/list/P_list = list()
for(var/dir_check in GLOB.cardinals)
if(linked_dirs & dir_check)
T1 = get_step(loc, dir_check)
P_list += locate(/obj/structure/cable) in T1
// remove the cut cable from its turf and powernet, so that it doesn't get count in propagate_network worklist
if(remove)
moveToNullspace()
powernet.remove_cable(src) //remove the cut cable from its powernet
var/first = TRUE
for(var/obj/O in P_list)
if(first)
first = FALSE
continue
addtimer(CALLBACK(O, PROC_REF(auto_propagate_cut_cable), O), 0) //so we don't rebuild the network X times when singulo/explosion destroys a line of X cables
///////////////////////////////////////////////
// The cable coil object, used for laying cable
///////////////////////////////////////////////
////////////////////////////////
// Definitions
////////////////////////////////
#define CABLE_RESTRAINTS_COST 15
/obj/item/stack/cable_coil
name = "cable coil"
custom_price = PAYCHECK_LOWER * 0.8
gender = NEUTER //That's a cable coil sounds better than that's some cable coils
icon = 'icons/obj/stack_objects.dmi'
icon_state = "coil"
inhand_icon_state = "coil_yellow"
base_icon_state = "coil"
novariants = FALSE
lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi'
max_amount = MAXCOIL
amount = MAXCOIL
merge_type = /obj/item/stack/cable_coil // This is here to let its children merge between themselves
color = CABLE_HEX_COLOR_YELLOW
desc = "A coil of insulated power cable."
throwforce = 0
w_class = WEIGHT_CLASS_SMALL
throw_speed = 3
throw_range = 5
mats_per_unit = list(/datum/material/iron=SMALL_MATERIAL_AMOUNT*0.1, /datum/material/glass=SMALL_MATERIAL_AMOUNT*0.1)
obj_flags = CONDUCTS_ELECTRICITY
slot_flags = ITEM_SLOT_BELT
attack_verb_continuous = list("whips", "lashes", "disciplines", "flogs")
attack_verb_simple = list("whip", "lash", "discipline", "flog")
singular_name = "cable piece"
full_w_class = WEIGHT_CLASS_SMALL
grind_results = list(/datum/reagent/copper = 2) //2 copper per cable in the coil
usesound = 'sound/items/deconstruct.ogg'
cost = 1
source = /datum/robot_energy_storage/wire
var/cable_color = CABLE_COLOR_YELLOW
var/obj/structure/cable/target_type = /obj/structure/cable
var/target_layer = CABLE_LAYER_2
/obj/item/stack/cable_coil/Initialize(mapload, new_amount, merge = TRUE, list/mat_override=null, mat_amt=1)
. = ..()
pixel_x = base_pixel_x + rand(-2, 2)
pixel_y = base_pixel_y + rand(-2, 2)
AddElement(/datum/element/update_icon_updates_onmob)
update_appearance()
/obj/item/stack/cable_coil/examine(mob/user)
. = ..()
. += "<b>Use it in hand</b> to change the layer you are placing on, amongst other things."
/obj/item/stack/cable_coil/update_name()
. = ..()
name = "cable [(amount < 3) ? "piece" : "coil"]"
/obj/item/stack/cable_coil/update_desc()
. = ..()
desc = "A [(amount < 3) ? "piece" : "coil"] of insulated power cable."
/obj/item/stack/cable_coil/proc/set_cable_color(new_color)
color = GLOB.cable_colors[new_color]
cable_color = new_color
update_appearance(UPDATE_ICON)
/obj/item/stack/cable_coil/update_icon_state()
if(novariants)
return
. = ..()
icon_state = "[base_icon_state][amount < 3 ? amount : ""]"
inhand_icon_state = "coil_[cable_color]"
/obj/item/stack/cable_coil/suicide_act(mob/living/user)
if(locate(/obj/structure/chair/stool) in get_turf(user))
user.visible_message(span_suicide("[user] is making a noose with [src]! It looks like [user.p_theyre()] trying to commit suicide!"))
else
user.visible_message(span_suicide("[user] is strangling [user.p_them()]self with [src]! It looks like [user.p_theyre()] trying to commit suicide!"))
return OXYLOSS
/obj/item/stack/cable_coil/proc/check_menu(mob/living/user)
if(!istype(user))
return FALSE
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, span_warning("You don't have the dexterity to do this!"))
return FALSE
if(user.incapacitated() || !user.Adjacent(src))
return FALSE
return TRUE
/obj/item/stack/cable_coil/attack_self(mob/living/user)
if(!user)
return
var/image/restraints_icon = image(icon = 'icons/obj/restraints.dmi', icon_state = "cuff")
restraints_icon.maptext = MAPTEXT("<span [amount >= CABLE_RESTRAINTS_COST ? "" : "style='color: red'"]>[CABLE_RESTRAINTS_COST]</span>")
restraints_icon.color = color
var/list/radial_menu = list(
"Layer 1" = image(icon = 'icons/hud/radial.dmi', icon_state = "coil-red"),
"Layer 2" = image(icon = 'icons/hud/radial.dmi', icon_state = "coil-yellow"),
"Layer 3" = image(icon = 'icons/hud/radial.dmi', icon_state = "coil-blue"),
"Multilayer cable hub" = image(icon = 'icons/obj/pipes_n_cables/structures.dmi', icon_state = "cable_bridge"),
"Multi Z layer cable hub" = image(icon = 'icons/obj/pipes_n_cables/structures.dmi', icon_state = "cablerelay-broken-cable"),
"Cable restraints" = restraints_icon
)
var/layer_result = show_radial_menu(user, src, radial_menu, custom_check = CALLBACK(src, PROC_REF(check_menu), user), require_near = TRUE, tooltips = TRUE)
if(!check_menu(user))
return
switch(layer_result)
if("Layer 1")
set_cable_color(CABLE_COLOR_RED)
target_type = /obj/structure/cable/layer1
target_layer = CABLE_LAYER_1
novariants = FALSE
if("Layer 2")
set_cable_color(CABLE_COLOR_YELLOW)
target_type = /obj/structure/cable
target_layer = CABLE_LAYER_2
novariants = FALSE
if("Layer 3")
set_cable_color(CABLE_COLOR_BLUE)
target_type = /obj/structure/cable/layer3
target_layer = CABLE_LAYER_3
novariants = FALSE
if("Multilayer cable hub")
name = "multilayer cable hub"
desc = "A multilayer cable hub."
icon_state = "cable_bridge"
set_cable_color(CABLE_COLOR_WHITE)
target_type = /obj/structure/cable/multilayer
target_layer = CABLE_LAYER_2
novariants = TRUE
if("Multi Z layer cable hub")
name = "multi z layer cable hub"
desc = "A multi-z layer cable hub."
icon_state = "cablerelay-broken-cable"
set_cable_color(CABLE_COLOR_WHITE)
target_type = /obj/structure/cable/multilayer/multiz
target_layer = CABLE_LAYER_2
novariants = TRUE
if("Cable restraints")
if (amount >= CABLE_RESTRAINTS_COST)
if(use(CABLE_RESTRAINTS_COST))
var/obj/item/restraints/handcuffs/cable/restraints = new(null, cable_color)
user.put_in_hands(restraints)
update_appearance()
///////////////////////////////////
// General procedures
///////////////////////////////////
//you can use wires to heal robotics
/obj/item/stack/cable_coil/attack(mob/living/carbon/human/H, mob/user)
if(!istype(H))
return ..()
var/obj/item/bodypart/affecting = H.get_bodypart(check_zone(user.zone_selected))
if(affecting && IS_ROBOTIC_LIMB(affecting))
if(user == H)
user.visible_message(span_notice("[user] starts to fix some of the wires in [H]'s [affecting.name]."), span_notice("You start fixing some of the wires in [H == user ? "your" : "[H]'s"] [affecting.name]."))
/* SKYRAT EDIT START - ORIGINAL:
if(!do_after(user, 5 SECONDS, H))
return
*/
// SKYRAT EDIT CHANGE START
if(!do_after(user, (user == H ? self_delay : other_delay)))
return
// SKYRAT EDIT CHANGE END
if(item_heal_robotic(H, user, 0, 15))
user.visible_message(span_green("[user] fixes some of the wires in to [H]'s [affecting.name]."), span_green("You fix some of the wires in [H == user ? "your" : "[H]'s"] [affecting.name].")) // SKYRAT EDIT ADD
use(1)
return
else
return ..()
///////////////////////////////////////////////
// Cable laying procedures
//////////////////////////////////////////////
// called when cable_coil is clicked on a turf
/obj/item/stack/cable_coil/proc/place_turf(turf/T, mob/user, dirnew)
if(!isturf(user.loc))
return
if(!isturf(T) || T.underfloor_accessibility < UNDERFLOOR_INTERACTABLE || !T.can_have_cabling())
to_chat(user, span_warning("You can only lay cables on catwalks and plating!"))
return
if(get_amount() < 1) // Out of cable
to_chat(user, span_warning("There is no cable left!"))
return
if(get_dist(T,user) > 1) // Too far
to_chat(user, span_warning("You can't lay cable at a place that far away!"))
return
for(var/obj/structure/cable/C in T)
if(C.cable_layer & target_layer)
to_chat(user, span_warning("There's already a cable at that position!"))
return
var/obj/structure/cable/C = new target_type(T)
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/PN = new()
PN.add_cable(C)
for(var/dir_check in GLOB.cardinals)
C.mergeConnectedNetworks(dir_check) //merge the powernet with adjacents powernets
C.mergeConnectedNetworksOnTurf() //merge the powernet with on turf powernets
use(1)
if(C.shock(user, 50))
if(prob(50)) //fail
C.deconstruct()
return C
/obj/item/stack/cable_coil/five
amount = 5
/obj/item/stack/cable_coil/thirty
amount = 30
/obj/item/stack/cable_coil/cut
amount = null
icon_state = "coil2"
worn_icon_state = "coil"
base_icon_state = "coil2"
/obj/item/stack/cable_coil/cut/Initialize(mapload, new_amount, merge = TRUE, list/mat_override=null, mat_amt=1)
if(!amount)
amount = rand(1,2)
. = ..()
pixel_x = base_pixel_x + rand(-2, 2)
pixel_y = base_pixel_y + rand(-2, 2)
update_appearance()
#undef CABLE_RESTRAINTS_COST
#undef UNDER_SMES
#undef UNDER_TERMINAL
///multilayer cable to connect different layers
/obj/structure/cable/multilayer
name = "multilayer cable hub"
desc = "A flexible, superconducting insulated multilayer hub for heavy-duty multilayer power transfer."
icon = 'icons/obj/pipes_n_cables/structures.dmi'
icon_state = "cable_bridge"
cable_layer = CABLE_LAYER_2
layer = WIRE_LAYER - 0.02 //Below all cables Disabled layers can lay over hub
color = CABLE_COLOR_WHITE
/obj/structure/cable/multilayer/update_icon_state()
SHOULD_CALL_PARENT(FALSE)
return
/obj/structure/cable/multilayer/update_icon()
. = ..()
underlays.Cut()
var/mutable_appearance/cable_node_3 = mutable_appearance('icons/obj/pipes_n_cables/layer_cable.dmi', "l4-1-2-4-8-node")
cable_node_3.color = CABLE_COLOR_BLUE
cable_node_3?.alpha = cable_layer & CABLE_LAYER_3 ? 255 : 0
underlays += cable_node_3
var/mutable_appearance/cable_node_2 = mutable_appearance('icons/obj/pipes_n_cables/layer_cable.dmi', "l2-1-2-4-8-node")
cable_node_2.color = CABLE_COLOR_YELLOW
cable_node_2?.alpha = cable_layer & CABLE_LAYER_2 ? 255 : 0
underlays += cable_node_2
var/mutable_appearance/cable_node_1 = mutable_appearance('icons/obj/pipes_n_cables/layer_cable.dmi', "l1-1-2-4-8-node")
cable_node_1.color = CABLE_COLOR_RED
cable_node_1?.alpha = cable_layer & CABLE_LAYER_1 ? 255 : 0
underlays += cable_node_1
var/mutable_appearance/machinery_node = mutable_appearance('icons/obj/pipes_n_cables/layer_cable.dmi', "l2-noconnection")
machinery_node.color = "black"
underlays += machinery_node
/obj/structure/cable/multilayer/Initialize(mapload)
. = ..()
var/turf/T = get_turf(src)
for(var/obj/structure/cable/C in T.contents - src)
if(C.cable_layer & cable_layer)
C.deconstruct() // remove adversary cable
if(!mapload)
auto_propagate_cut_cable(src)
update_appearance()
/obj/structure/cable/multilayer/examine(mob/user)
. += ..()
. += span_notice("L1:[cable_layer & CABLE_LAYER_1 ? "Connect" : "Disconnect"].")
. += span_notice("L2:[cable_layer & CABLE_LAYER_2 ? "Connect" : "Disconnect"].")
. += span_notice("L3:[cable_layer & CABLE_LAYER_3 ? "Connect" : "Disconnect"].")
GLOBAL_LIST(hub_radial_layer_list)
/obj/structure/cable/multilayer/attack_robot(mob/user)
attack_hand(user)
/obj/structure/cable/multilayer/attack_hand(mob/living/user, list/modifiers)
if(!user)
return
if(!GLOB.hub_radial_layer_list)
GLOB.hub_radial_layer_list = list(
"Layer 1" = image(icon = 'icons/hud/radial.dmi', icon_state = "coil-red"),
"Layer 2" = image(icon = 'icons/hud/radial.dmi', icon_state = "coil-yellow"),
"Layer 3" = image(icon = 'icons/hud/radial.dmi', icon_state = "coil-blue")
)
var/layer_result = show_radial_menu(user, src, GLOB.hub_radial_layer_list, custom_check = CALLBACK(src, PROC_REF(check_menu), user), require_near = TRUE, tooltips = TRUE)
if(!check_menu(user))
return
var/CL
switch(layer_result)
if("Layer 1")
CL = CABLE_LAYER_1
to_chat(user, span_warning("You toggle L1 connection."))
if("Layer 2")
CL = CABLE_LAYER_2
to_chat(user, span_warning("You toggle L2 connection."))
if("Layer 3")
CL = CABLE_LAYER_3
to_chat(user, span_warning("You toggle L3 connection."))
cut_cable_from_powernet(FALSE)
Disconnect_cable()
cable_layer ^= CL
Connect_cable(TRUE)
Reload()
/obj/structure/cable/multilayer/proc/check_menu(mob/living/user)
if(!istype(user))
return FALSE
if(!ISADVANCEDTOOLUSER(user))
to_chat(user, span_warning("You don't have the dexterity to do this!"))
return FALSE
if(user.incapacitated() || !user.Adjacent(src))
return FALSE
return TRUE
///Reset powernet in this hub.
/obj/structure/cable/multilayer/proc/Reload()
var/turf/T = get_turf(src)
for(var/obj/structure/cable/C in T.contents - src)
if(C.cable_layer & cable_layer)
C.deconstruct() // remove adversary cable
auto_propagate_cut_cable(src) // update the powernets
/obj/structure/cable/multilayer/CtrlClick(mob/living/user)
to_chat(user, span_warning("You push the reset button."))
addtimer(CALLBACK(src, PROC_REF(Reload)), 10, TIMER_UNIQUE) //spam protect
// This is a mapping aid. In order for this to be placed on a map and function, all three layers need to have their nodes active
/obj/structure/cable/multilayer/connected
cable_layer = CABLE_LAYER_1 | CABLE_LAYER_2 | CABLE_LAYER_3