Files
Bubberstation/code/datums/wires/mod.dm
John Willard 1880003270 Reworks silicon/ai access checking & fixes some ui_act's (#84964)
## About The Pull Request

Currently to check for Silicon access, we do:
``if is silicon or is admin ghost or has unlimited silicon privileges or
has machine remote in hand``
What has unlimited silicon privileges? Bots, Drones, and admin ghosts.
To check for AI access, it just checks for AI instead of silicon, and
doesnt check for unlimited silicon privileges.

This was kinda silly, so I thought I should make this a little easier to
understand.
Now all silicon/ai traits come from ``AI_ACCESS_TRAIT`` or
``SILICON_ACCESS_TRAIT``. I made a single exception to keep Admin ghost,
since now instead of being a var on the client, we moved it to using the
same trait but giving it to the client instead, but since we have to
keep parity with previous functionality (admins can spawn in and not
have this on, it only works while as a ghost), I kept previous checks as
well.

No more type checks, removes a silly var on the mob level and another on
the client.

Now while I was doing this, I found a lot of tgui's ``ui_act`` still
uses ``usr`` and the wrong args, so I fixed those wherever I saw them,
and used a mass replace for the args.

Other changes:

- machinery's ``ui_act`` from
https://github.com/tgstation/tgstation/pull/81250 had ``isAI`` replaced
with ``HAS_AI_ACCESS``, this has been reverted. Machine wands and admin
ghosts no longer get kicked off things not on cameras. This was my
fault, I overlooked this when adding Human AI.
- Human AI's wand gives AI control as long as it's in your hand, you can
swap to your offhand. I hope this doesn't end up going horribly,
otherwise I'll revert this part. It should let human AIs not have their
UI closed on them when swapping to eat food or use their door wand or
whatnot.
- Bots previously had special checks to scan reagents and be
unobservant, I replaced this with giving them the trait. I also fixed an
instance of unobservant not being used, so now statues don't affect the
basic creature, whatever that is.

## Why It's Good For The Game

This is an easier to understand way of handling silicon access and makes
these mobs more consistent between eachother.
Other than what I've mentioned above, this should have no impact on
gameplay itself.

## Changelog

🆑
fix: Statues don't count as eyes to creatures.
fix: Human AIs and Admin ghosts no longer get kicked off of machines
that aren't on cameranets.
/🆑
2024-08-19 10:43:45 +00:00

64 lines
1.8 KiB
Plaintext

/datum/wires/mod
holder_type = /obj/item/mod/control
proper_name = "MOD control unit"
/datum/wires/mod/New(atom/holder)
wires = list(WIRE_HACK, WIRE_DISABLE, WIRE_SHOCK, WIRE_INTERFACE)
add_duds(2)
..()
/datum/wires/mod/interactable(mob/user)
if(!..())
return FALSE
var/obj/item/mod/control/mod = holder
return mod.open
/datum/wires/mod/get_status()
var/obj/item/mod/control/mod = holder
var/list/status = list()
status += "The orange light is [mod.seconds_electrified ? "on" : "off"]."
status += "The red light is [mod.malfunctioning ? "off" : "blinking"]."
status += "The green light is [mod.locked ? "on" : "off"]."
status += "The yellow light is [mod.interface_break ? "off" : "on"]."
return status
/datum/wires/mod/on_pulse(wire)
var/obj/item/mod/control/mod = holder
switch(wire)
if(WIRE_HACK)
mod.locked = !mod.locked
if(WIRE_DISABLE)
mod.malfunctioning = TRUE
if(WIRE_SHOCK)
mod.seconds_electrified = MACHINE_DEFAULT_ELECTRIFY_TIME
if(WIRE_INTERFACE)
mod.interface_break = !mod.interface_break
/datum/wires/mod/on_cut(wire, mend, source)
var/obj/item/mod/control/mod = holder
switch(wire)
if(WIRE_HACK)
if(!mend)
mod.req_access = list()
if(WIRE_DISABLE)
mod.malfunctioning = !mend
if(WIRE_SHOCK)
if(mend)
mod.seconds_electrified = MACHINE_NOT_ELECTRIFIED
else
mod.seconds_electrified = MACHINE_ELECTRIFIED_PERMANENT
if(WIRE_INTERFACE)
mod.interface_break = !mend
/datum/wires/mod/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
var/obj/item/mod/control/mod = holder
var/mob/user = ui.user
if(!HAS_SILICON_ACCESS(user) && mod.seconds_electrified && mod.shock(user))
return FALSE
return ..()
/datum/wires/mod/can_reveal_wires(mob/user)
if(HAS_TRAIT(user, TRAIT_KNOW_ROBO_WIRES))
return TRUE
return ..()