Skip to content

Commit

Permalink
TGUI fixes, part 3 (#16560)
Browse files Browse the repository at this point in the history
* a

* TGUI fixes part 3

* ugh

* bwuh

* ambiguous my ass

* AOAOAOAO

* pt 4

* extra foolproof

* a

* ok good thing i caught that

* enable that for AI

---------

Co-authored-by: Matt Atlas <[email protected]>
Co-authored-by: Werner <[email protected]>
  • Loading branch information
3 people authored Jun 27, 2023
1 parent 06f8ced commit e237808
Show file tree
Hide file tree
Showing 25 changed files with 262 additions and 181 deletions.
4 changes: 2 additions & 2 deletions code/__defines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@
// This only works on 511 because it relies on 511's `var/something = foo = bar` syntax.
#define WEAKREF(D) (istype(D, /datum) && !D:gcDestroyed ? (D:weakref || (D:weakref = new/datum/weakref(D))) : null)

#define ADD_VERB_IN(the_atom,time,verb) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(add_verb), verb), time, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_NO_HASH_WAIT)
#define ADD_VERB_IN_IF(the_atom,time,verb,callback) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(add_verb), verb, callback), time, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_NO_HASH_WAIT)
#define ADD_VERB_IN(the_atom,time,verb) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(add_verb), the_atom, verb), time, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_NO_HASH_WAIT)
#define ADD_VERB_IN_IF(the_atom,time,verb,callback) addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(add_verb), the_atom, verb, callback), time, TIMER_UNIQUE | TIMER_OVERRIDE | TIMER_NO_HASH_WAIT)

// Maploader bounds indices
#define MAP_MINX 1
Expand Down
81 changes: 36 additions & 45 deletions code/_onclick/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
return
..()

/mob/living/silicon/ai/AltClickOn(var/atom/A)
if(!control_disabled && A.AIAltClick(src))
/mob/living/silicon/ai/AltClickOn(var/mob/living/silicon/user)
if(!control_disabled && user.AIAltClick(src))
return

/mob/living/silicon/ai/MiddleClickOn(var/atom/A)
Expand All @@ -122,64 +122,55 @@
/atom/proc/AICtrlShiftClick()
return

/atom/proc/AIShiftClick()
/atom/proc/AIShiftClick(var/mob/user)
return

/obj/machinery/door/airlock/AIShiftClick() // Opens and closes doors!
if(density)
Topic(src, list("command"="open", "activate" = "1"))
else
Topic(src, list("command"="open", "activate" = "0"))
return 1
/obj/machinery/door/airlock/AIShiftClick(var/mob/user) // Opens and closes doors!
open_interact(user, density)
return TRUE

/atom/proc/AICtrlClick(mob/user)
return

/obj/machinery/door/airlock/AICtrlClick(mob/user) // Bolts doors
var/command = player_is_antag(user.mind) ? "bolts_override" : "bolts"
if(locked)
Topic(src, list("command"=command, "activate" = "0"))
if(player_is_antag(user.mind))
bolts_override(user, !locked, FALSE, player_is_antag(user.mind))
else
Topic(src, list("command"=command, "activate" = "1"))
return 1
bolts_interact(user, !locked, FALSE, player_is_antag(user.mind))
return TRUE

/obj/machinery/power/apc/AICtrlClick() // turns off/on APCs.
Topic(src, list("breaker"="1"))
return 1
toggle_breaker()
return TRUE

/obj/machinery/turretid/AICtrlClick() //turns off/on Turrets
Topic(src, list("turret_ref" = "this", "command"="enable", "value"="[!enabled]"))
return 1

/atom/proc/AIAltClick(var/atom/A)
return AltClick(A)

/obj/machinery/door/airlock/AIAltClick() // Electrifies doors.
if(!electrified_until)
// permanent shock
Topic(src, list("command"="electrify_permanently", "activate" = "1"))
enabled = !enabled
updateTurrets()
return TRUE

/atom/proc/AIAltClick(var/mob/living/silicon/user)
return AltClick(user)

/obj/machinery/door/airlock/AIAltClick(var/mob/living/silicon/user) // Electrifies doors.
var/antag = player_is_antag(user.mind)
if(!antag && (electrified_until == 0))
to_chat(user, SPAN_WARNING("Your programming prevents you from electrifying the door."))
return FALSE
else
// disable/6 is not in Topic; disable/5 disables both temporary and permanent shock
Topic(src, list("command"="electrify_permanently", "activate" = "0"))
return 1

/obj/machinery/turretid/AIAltClick() //toggles lethal on turrets
Topic(src, list("turret_ref" = "this", "command"="lethal", "value"="[!lethal]"))
return 1
if(!electrified_until)
// permanent shock
electrify(-1, 1)
else
electrify(0)
return TRUE

/obj/machinery/turretid/AIAltClick(var/mob/living/silicon/user) //toggles lethal on turrets
lethal = !lethal
updateTurrets()
return TRUE

/atom/proc/AIMiddleClick(var/mob/living/silicon/user)
return 0

/obj/machinery/door/airlock/AIMiddleClick() // Toggles door bolt lights.
if(..())
return

if(!src.lights)
Topic(src, list("command"="lights", "activate" = "1"))
else
Topic(src, list("command"="lights", "activate" = "0"))
return 1

return FALSE
//
// Override AdjacentQuick for AltClicking
//
Expand Down
31 changes: 14 additions & 17 deletions code/_onclick/cyborg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,42 +111,39 @@
if (doClickAction)
A.BorgAltClick(src)



/atom/proc/BorgCtrlShiftClick(var/mob/living/silicon/robot/user) //forward to human click if not overriden
CtrlShiftClick(user)

/obj/machinery/door/airlock/BorgCtrlShiftClick()
AICtrlShiftClick()
/obj/machinery/door/airlock/BorgCtrlShiftClick(var/mob/living/silicon/robot/user)
AICtrlShiftClick(user)

/atom/proc/BorgShiftClick(var/mob/living/silicon/robot/user) //forward to human click if not overriden
ShiftClick(user)

/obj/machinery/door/airlock/BorgShiftClick() // Opens and closes doors! Forwards to AI code.
AIShiftClick()

/obj/machinery/door/airlock/BorgShiftClick(var/mob/living/silicon/robot/user) // Opens and closes doors! Forwards to AI code.
AIShiftClick(user)

/atom/proc/BorgCtrlClick(var/mob/living/silicon/robot/user) //forward to human click if not overriden
CtrlClick(user)

/obj/machinery/door/airlock/BorgCtrlClick(mob/user) // Bolts doors. Forwards to AI code.
/obj/machinery/door/airlock/BorgCtrlClick(var/mob/living/silicon/robot/user) // Bolts doors. Forwards to AI code.
AICtrlClick(user)

/obj/machinery/power/apc/BorgCtrlClick() // turns off/on APCs. Forwards to AI code.
AICtrlClick()
/obj/machinery/power/apc/BorgCtrlClick(var/mob/living/silicon/robot/user) // turns off/on APCs. Forwards to AI code.
AICtrlClick(user)

/obj/machinery/turretid/BorgCtrlClick() //turret control on/off. Forwards to AI code.
AICtrlClick()
/obj/machinery/turretid/BorgCtrlClick(var/mob/living/silicon/robot/user) //turret control on/off. Forwards to AI code.
AICtrlClick(user)

/atom/proc/BorgAltClick(var/mob/living/silicon/robot/user)
AltClick(user)
return

/obj/machinery/door/airlock/BorgAltClick() // Eletrifies doors. Forwards to AI code.
AIAltClick()
/obj/machinery/door/airlock/BorgAltClick(var/mob/living/silicon/robot/user) // Eletrifies doors. Forwards to AI code.
AIAltClick(user)

/obj/machinery/turretid/BorgAltClick() //turret lethal on/off. Forwards to AI code.
AIAltClick()
/obj/machinery/turretid/BorgAltClick(var/mob/living/silicon/robot/user) //turret lethal on/off. Forwards to AI code.
AIAltClick(user)

/*
As with AI, these are not used in click code,
Expand All @@ -163,4 +160,4 @@

/atom/proc/attack_robot(mob/user)
attack_ai(user)
return
return
2 changes: 1 addition & 1 deletion code/datums/late_choices.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
our_ui = null

/datum/late_choices/proc/update_character_icon()
if(our_ui.status < UI_INTERACTIVE)
if(our_ui && our_ui.status < UI_INTERACTIVE)
do_update_character_icon()
else
update_icon_on_next_open = TRUE
Expand Down
109 changes: 59 additions & 50 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -930,45 +930,9 @@ About the new airlock wires panel:
if(!backup_power_lost_until)
src.loseBackupPower()
if("bolts")
if(isrobot(usr) && !Adjacent(usr))
to_chat(usr, SPAN_WARNING("Your frame does not allow long distance wireless bolt control, you will need be adjacent the door."))
return
if(src.isWireCut(AIRLOCK_WIRE_DOOR_BOLTS)) // cut wire is noop
to_chat(usr, SPAN_WARNING("The door bolt control wire is cut - Door bolts permanently dropped."))
else if(isAdmin || issilicon(usr)) // controls for silicons, "stealthy" antag silicons and "stealthy" admins
if(!src.arePowerSystemsOn()) // cannot queue actions or "speak" from unpowered doors
to_chat(usr, SPAN_WARNING("The door is unpowered - Cannot [activate ? "drop" : "raise"] bolts."))
else if(!aiBolting)
to_chat(usr, SPAN_WARNING("The door is configured not to allow remote bolt operation."))
else if(!isnull(src.aiActionTimer))
to_chat(usr, SPAN_WARNING("An action is already queued. Please wait for it to complete."))
else if(activate)
to_chat(usr, SPAN_NOTICE("The door bolts should drop in [src.aiBoltingDelay] seconds."))
src.audible_message("[icon2html(src.icon, viewers(get_turf(src)))] <b>[src]</b> announces, <span class='notice'>\"Bolts set to drop in <strong>[src.aiBoltingDelay] seconds</strong>.\"</span>")
src.aiActionTimer = addtimer(CALLBACK(src, PROC_REF(lock)), src.aiBoltingDelay SECONDS, TIMER_UNIQUE|TIMER_NO_HASH_WAIT|TIMER_STOPPABLE)
else
to_chat(usr, SPAN_NOTICE("The door bolts should raise in [src.aiUnBoltingDelay] seconds."))
src.audible_message("[icon2html(src.icon, viewers(get_turf(src)))] <b>[src]</b> announces, <span class='notice'>\"Bolts set to raise in <strong>[src.aiUnBoltingDelay] seconds</strong>.\"</span>")
src.aiActionTimer = addtimer(CALLBACK(src, PROC_REF(unlock)), src.aiUnBoltingDelay SECONDS, TIMER_UNIQUE|TIMER_NO_HASH_WAIT|TIMER_STOPPABLE)
else // everyone else
if(activate)
if(src.lock())
to_chat(usr, SPAN_NOTICE("The door bolts have been dropped."))
else
if(src.unlock())
to_chat(usr, SPAN_NOTICE("The door bolts have been raised."))
bolts_interact(usr, activate, isAdmin, antag)
if("bolts_override")
if(isAdmin || (issilicon(usr) && antag)) // admin and silicon antag can override
if(!isAdmin && src.isWireCut(AIRLOCK_WIRE_DOOR_BOLTS)) // cut wire is noop, except for admins
to_chat(usr, SPAN_WARNING("The door bolt control wire is cut - Door bolts permanently dropped."))
else if(!isAdmin && !src.arePowerSystemsOn()) // door must be powered - display friendly message if not (admins can magically skip this)
to_chat(usr, SPAN_WARNING("The door is unpowered - Cannot [activate ? "drop" : "raise"] bolts."))
else if(activate)
if(src.lock())
to_chat(usr, SPAN_NOTICE("The door bolts have been dropped."))
else
if(src.unlock())
to_chat(usr, SPAN_NOTICE("The door bolts have been raised."))
bolts_override(usr, activate, antag)
if("electrify_temporary")
if(!isAdmin && issilicon(usr) && !antag)
to_chat(usr, SPAN_WARNING("Your programming prevents you from electrifying the door."))
Expand All @@ -980,18 +944,7 @@ About the new airlock wires panel:
else
electrify(-1 * activate, 1)
if("open")
if(src.welded)
to_chat(usr, SPAN_WARNING("The airlock has been welded shut!"))
else if(src.locked)
to_chat(usr, SPAN_WARNING("The door bolts are down!"))
else if(!src.arePowerSystemsOn() && issilicon(usr)) // AIs get a nice notice that the door is unpowered
to_chat(usr, SPAN_WARNING("The door is unpowered, its motors do not respond to your commands."))
else if(activate && density)
open()
if (isAI(usr))
SSfeedback.IncrementSimpleStat("AI_DOOR")
else if(!activate && !density)
close()
open_interact(usr, activate)
if("safeties")
if(!isAdmin && safe && issilicon(usr) && !antag)
to_chat(usr, SPAN_WARNING("Your programming prevents you from disabling the door safeties."))
Expand All @@ -1018,6 +971,62 @@ About the new airlock wires panel:
update_icon()
return TRUE

/obj/machinery/door/airlock/proc/bolts_interact(var/mob/user, var/activate, var/isAdmin, var/antag)
if(isrobot(user) && !Adjacent(user))
to_chat(user, SPAN_WARNING("Your frame does not allow long distance wireless bolt control, you will need be adjacent the door."))
return
if(isWireCut(AIRLOCK_WIRE_DOOR_BOLTS)) // cut wire is noop
to_chat(user, SPAN_WARNING("The door bolt control wire is cut - Door bolts permanently dropped."))
else if(isAdmin || issilicon(user)) // controls for silicons, "stealthy" antag silicons and "stealthy" admins
if(!arePowerSystemsOn()) // cannot queue actions or "speak" from unpowered doors
to_chat(user, SPAN_WARNING("The door is unpowered - Cannot [activate ? "drop" : "raise"] bolts."))
else if(!aiBolting)
to_chat(user, SPAN_WARNING("The door is configured not to allow remote bolt operation."))
else if(!isnull(aiActionTimer))
to_chat(user, SPAN_WARNING("An action is already queued. Please wait for it to complete."))
else if(activate)
to_chat(user, SPAN_NOTICE("The door bolts should drop in [aiBoltingDelay] seconds."))
audible_message("[icon2html(icon, viewers(get_turf(src)))] <b>[src]</b> announces, <span class='notice'>\"Bolts set to drop in <strong>[aiBoltingDelay] seconds</strong>.\"</span>")
aiActionTimer = addtimer(CALLBACK(src, PROC_REF(lock)), aiBoltingDelay SECONDS, TIMER_UNIQUE|TIMER_NO_HASH_WAIT|TIMER_STOPPABLE)
else
to_chat(user, SPAN_NOTICE("The door bolts should raise in [aiUnBoltingDelay] seconds."))
audible_message("[icon2html(icon, viewers(get_turf(src)))] <b>[src]</b> announces, <span class='notice'>\"Bolts set to raise in <strong>[aiUnBoltingDelay] seconds</strong>.\"</span>")
aiActionTimer = addtimer(CALLBACK(src, PROC_REF(unlock)), aiUnBoltingDelay SECONDS, TIMER_UNIQUE|TIMER_NO_HASH_WAIT|TIMER_STOPPABLE)
else // everyone else
if(activate)
if(lock())
to_chat(user, SPAN_NOTICE("The door bolts have been dropped."))
else
if(unlock())
to_chat(user, SPAN_NOTICE("The door bolts have been raised."))

/obj/machinery/door/airlock/proc/bolts_override(var/mob/user, var/activate, var/isAdmin, var/antag)
if(isAdmin || (issilicon(user) && antag)) // admin and silicon antag can override
if(!isAdmin && src.isWireCut(AIRLOCK_WIRE_DOOR_BOLTS)) // cut wire is noop, except for admins
to_chat(user, SPAN_WARNING("The door bolt control wire is cut - Door bolts permanently dropped."))
else if(!isAdmin && !arePowerSystemsOn()) // door must be powered - display friendly message if not (admins can magically skip this)
to_chat(user, SPAN_WARNING("The door is unpowered - Cannot [activate ? "drop" : "raise"] bolts."))
else if(activate)
if(lock())
to_chat(user, SPAN_NOTICE("The door bolts have been dropped."))
else
if(unlock())
to_chat(user, SPAN_NOTICE("The door bolts have been raised."))

/obj/machinery/door/airlock/proc/open_interact(var/mob/user, var/activate)
if(welded)
to_chat(usr, SPAN_WARNING("The airlock has been welded shut!"))
else if(locked)
to_chat(usr, SPAN_WARNING("The door bolts are down!"))
else if(!arePowerSystemsOn() && issilicon(usr)) // AIs get a nice notice that the door is unpowered
to_chat(usr, SPAN_WARNING("The door is unpowered, its motors do not respond to your commands."))
else if(activate && density)
open()
if (isAI(usr))
SSfeedback.IncrementSimpleStat("AI_DOOR")
else if(!activate && !density)
close()

/obj/machinery/door/airlock/proc/hack(mob/user as mob)
if(src.aiHacking==0)
src.aiHacking=1
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/turret_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
/obj/machinery/turretid/ui_data(mob/user)
var/list/data = list()
data["turrets"] = list()
data["locked"] = locked
data["locked"] = isAI(user) ? FALSE : locked
data["enabled"] = enabled
data["is_lethal"] = TRUE
data["lethal"] = lethal
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/diona_gestalt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
M.gestalt = src
add_verb(M, /mob/living/carbon/alien/diona/proc/merge_back_to_gestalt)
add_verb(M, /mob/living/carbon/alien/diona/proc/switch_to_gestalt)
add_verb(src, /mob/living/carbon/human/proc/switch_to_nymph)
add_verb(M, /mob/living/carbon/human/proc/switch_to_nymph)
M.detached = TRUE
M.update_verbs(TRUE)
M.languages = languages.Copy()
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/default_language.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/mob/living
var/datum/language/default_language

/mob/living/verb/set_default_language(language as null|anything in languages)
/mob/living/verb/set_default_language()
set name = "Set Default Language"
set category = "IC"

var/datum/language/language = input(src, "Choose a language.", "Set Default Language") as null|anything in languages
if(language)
to_chat(src, "<span class='notice'>You will now speak [language] if you do not specify a language when speaking.</span>")
else
Expand Down
5 changes: 0 additions & 5 deletions code/modules/mob/living/silicon/silicon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,11 @@
if(next_alarm_notice && (world.time > next_alarm_notice))
next_alarm_notice = 0

var/alarm_raised = FALSE
for(var/datum/alarm_handler/AH in queued_alarms)
var/list/alarms = queued_alarms[AH]
var/reported = FALSE
for(var/datum/alarm/A in alarms)
if(alarms[A] == 1)
alarm_raised = TRUE
if(!reported)
reported = TRUE
to_chat(src, SPAN_WARNING("--- [AH.category] Detected ---"))
Expand All @@ -316,9 +314,6 @@
to_chat(src, SPAN_NOTICE("--- [AH.category] Cleared ---"))
to_chat(src, "\The [A.alarm_name()].")

if(alarm_raised)
to_chat(src, "<A HREF=?src=\ref[src];showalerts=1>\[Show Alerts\]</A>")

for(var/datum/alarm_handler/AH in queued_alarms)
var/list/alarms = queued_alarms[AH]
alarms.Cut()
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/mob_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1250,8 +1250,9 @@ var/list/intents = list(I_HELP,I_DISARM,I_GRAB,I_HURT)
/mob/proc/in_neck_grab()
for(var/thing in grabbed_by)
var/obj/item/grab/G = thing
if(G.state >= GRAB_NECK)
return TRUE
if(istype(G))
if(G.state >= GRAB_NECK)
return TRUE
return FALSE

/mob/get_cell()
Expand Down
Loading

0 comments on commit e237808

Please sign in to comment.