Skip to content

Commit

Permalink
bugfix: APC usability again. (#4486)
Browse files Browse the repository at this point in the history
* Update apc.dm

* MEGAPROVERKA slaying.

* textiki

* Ahem.

* Deleting dead code.
  • Loading branch information
Daeberdir authored Feb 28, 2024
1 parent 960cd9d commit 250bb39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion code/_onclick/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
// APC

/obj/machinery/power/apc/AICtrlClick(mob/living/user) // turns off/on APCs.
if(!can_use(user, TRUE))
if(!can_use(user))
to_chat(user, "<span class='warning'>AI control for \the [src] interface has been disabled.</span>")
return
toggle_breaker(user)
Expand Down
33 changes: 18 additions & 15 deletions code/modules/power/apc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@

/obj/machinery/power/apc/CtrlClick(mob/user)
SEND_SIGNAL(src, COMSIG_CLICK_CTRL, user)
if(!can_use(usr, TRUE) || (is_locked(usr)))
if(!can_use(usr) || (is_locked(usr)))
return
toggle_breaker(user)

Expand Down Expand Up @@ -1107,26 +1107,29 @@
INVOKE_ASYNC(light, TYPE_PROC_REF(/obj/machinery/light, update), FALSE)


/obj/machinery/power/apc/proc/can_use(mob/user, loud = FALSE) //used by attack_hand() and Topic()
/obj/machinery/power/apc/proc/can_use(mob/user) //used by attack_hand() and Topic()
if(stat & BROKEN)
return FALSE
if(user.can_admin_interact())
return TRUE

autoflag = 5
if(ispAI(user))
var/mob/living/silicon/pai/pAI = user
if(!pAI.syndipai || !pAI.ai_capability || pAI.capa_is_cooldown)
return FALSE
else if(issilicon(user))
var/mob/living/silicon/ai/AI = user
var/mob/living/silicon/robot/robot = user
if(aidisabled || malfhack && istype(malfai) && ((istype(AI) && malfai != AI && malfai != AI.parent) || (istype(robot) && !(robot in malfai.connected_robots))))
if(!loud)
to_chat(user, span_danger("[src] has AI control disabled!"))
user << browse(null, "window=apc")
user.unset_machine()

if(issilicon(user))
if(ispAI(user))
var/mob/living/silicon/pai/pAI = user
if(!pAI.syndipai || !pAI.ai_capability || pAI.capa_is_cooldown)
return FALSE
if(aidisabled)
return FALSE
if(malfhack && istype(malfai)) // Malfhacked APC can be used...
if(isAI(user))
var/mob/living/silicon/ai/AI = user // Only by its hacker...
if(malfai != AI && malfai != AI.parent)
return FALSE
else if(!(user in malfai.connected_robots)) // Or by Malf's borg. No exception for other silicons.
return FALSE

else if(!in_range(src, user) || !isturf(loc))
return FALSE

Expand Down Expand Up @@ -1157,7 +1160,7 @@
return locked

/obj/machinery/power/apc/ui_act(action, params)
if(..() || !can_use(usr, TRUE) || (is_locked(usr) && (action != "toggle_nightshift")))
if(..() || !can_use(usr) || (is_locked(usr) && (action != "toggle_nightshift")))
return
. = TRUE
switch(action)
Expand Down

0 comments on commit 250bb39

Please sign in to comment.