Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exosuit Voice Commands: Toggle Power and Maintenance #20481

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/modules/heavy_vehicle/interface/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@
maptext_x = 1
maptext_y = 11

/atom/movable/screen/mecha/toggle/power_control/toggled()
/atom/movable/screen/mecha/toggle/power_control/toggled(var/remote = FALSE)
toggled = !toggled
owner.toggle_power(usr)
owner.toggle_power(usr, remote)
var/main_color = toggled ? "#d1d1d1" : "#525252"
maptext = "<span style=\"font-family: 'Small Fonts'; color: [main_color]; -dm-text-outline: 1 #242424; font-size: 6px;\">POWER</span>"

Expand Down
23 changes: 17 additions & 6 deletions code/modules/heavy_vehicle/mech_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,29 @@

/mob/living/heavy_vehicle/proc/toggle_maintenance_protocols()
var/atom/movable/screen/mecha/toggle/maint/M = locate() in hud_elements
M.toggled()
return TRUE
if(M)
M.toggled()
return TRUE

/mob/living/heavy_vehicle/proc/toggle_hatch()
var/atom/movable/screen/mecha/toggle/hatch_open/H = locate() in hud_elements
H.toggled()
return TRUE
if(H)
H.toggled()
return TRUE

/// Called by voice command
/// Ensures the hud element for power is updated, and sends special condition to have messages not be sent to the user
/mob/living/heavy_vehicle/proc/toggle_power_remote()
var/atom/movable/screen/mecha/toggle/power_control/P = locate() in hud_elements
if(P)
P.toggled(TRUE)
return TRUE

/mob/living/heavy_vehicle/proc/toggle_lock()
var/atom/movable/screen/mecha/toggle/hatch/L = locate() in hud_elements
L.toggled()
return TRUE
if(L)
L.toggled()
return TRUE

/mob/living/heavy_vehicle/proc/can_listen()
return TRUE
Expand Down
19 changes: 19 additions & 0 deletions code/modules/heavy_vehicle/mech_interaction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,13 @@

// Checking whether we have a leader or not
if(!leader)
if(findtext(text, "toggle maintenance protocols")) // Allow for engaging maintenance protocols if no pilot
if(pilots)
say("Unlinked toggling of maintenance protocols requires no active pilots.")
return
if(toggle_maintenance_protocols())
say("Maintenance protocols toggled [maintenance_protocols ? "on" : "off"].")
return
if(!maintenance_protocols) // don't select a leader unless we have maintenance protocols set
say("Maintenance protocols must be enabled to link.")
return
Expand Down Expand Up @@ -684,6 +691,18 @@
say("Hatch [hatch_closed ? "closed" : "opened"].")
return

// simply toggle on or off the power
if(findtext(text, "toggle power"))
if(power == MECH_POWER_TRANSITION)
say("Power transition in progress. Please wait.")
return
else if(power == MECH_POWER_OFF && !get_cell(TRUE))
say("Insufficent power to power systems.")
return
if(toggle_power_remote())
say("Systems [power == MECH_POWER_ON ? "online" : "offline"].")
return

// simply toggle the lock status
if(findtext(text, "toggle lock"))
if(!hatch_closed)
Expand Down
17 changes: 12 additions & 5 deletions code/modules/heavy_vehicle/mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -250,25 +250,32 @@
/mob/living/heavy_vehicle/GetIdCard()
return access_card

/mob/living/heavy_vehicle/proc/toggle_power(var/mob/user)
/// Checks if mech can be powered on/off, sends message to pilot if failed
/// `var/remote` can be set to TRUE to have proc adjust where messages and hud elements are presented
/// If `remote` is TRUE, messages and other hud elements are called on the exosuit itself to prevent wierdness, and errors are handled in `handle_hear_say()`
/mob/living/heavy_vehicle/proc/toggle_power(var/mob/user, var/remote = FALSE)
// if remotely called, send these messages to the exosuit, not the person calling this proc
var/reciever = user
if(remote)
reciever = src
if(power == MECH_POWER_TRANSITION)
to_chat(user, SPAN_NOTICE("Power transition in progress. Please wait."))
to_chat(reciever, SPAN_NOTICE("Power transition in progress. Please wait."))
else if(power == MECH_POWER_ON) //Turning it off is instant
playsound(src, 'sound/mecha/mech-shutdown.ogg', 100, 0)
power = MECH_POWER_OFF
else if(get_cell(TRUE))
//Start power up sequence
power = MECH_POWER_TRANSITION
playsound(src, 'sound/mecha/powerup.ogg', 50, 0)
if(do_after(user, 1.5 SECONDS) && power == MECH_POWER_TRANSITION)
if(do_after(reciever, 1.5 SECONDS) && power == MECH_POWER_TRANSITION)
playsound(src, 'sound/mecha/nominal.ogg', 50, 0)
power = MECH_POWER_ON
else
to_chat(user, SPAN_WARNING("You abort the powerup sequence."))
to_chat(reciever, SPAN_WARNING("You abort the powerup sequence."))
power = MECH_POWER_OFF
hud_power_control?.queue_icon_update()
else
to_chat(user, SPAN_WARNING("Error: No power cell was detected."))
to_chat(reciever, SPAN_WARNING("Error: No power cell was detected."))

/obj/item/device/radio/exosuit
name = "exosuit radio"
Expand Down
59 changes: 59 additions & 0 deletions html/changelogs/Ben10083 - Remote Power.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# - (fixes bugs)
# wip
# - (work in progress)
# qol
# - (quality of life)
# soundadd
# - (adds a sound)
# sounddel
# - (removes a sound)
# rscadd
# - (adds a feature)
# rscdel
# - (removes a feature)
# imageadd
# - (adds an image or sprite)
# imagedel
# - (removes an image or sprite)
# spellcheck
# - (fixes spelling or grammar)
# experiment
# - (experimental change)
# balance
# - (balance changes)
# code_imp
# - (misc internal code change)
# refactor
# - (refactors code)
# config
# - (makes a change to the config files)
# admin
# - (makes changes to administrator tools)
# server
# - (miscellaneous changes to server)
#################################

# Your name.
author: Ben10083

# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True

# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, this gets changed to [] after reading. Just remove the brackets when you add new shit.
# Please surround your changes in double quotes ("). It works without them, but if you use certain characters it screws up compiling. The quotes will not show up in the changelog.
changes:
- rscadd: "New voice command for exosuits: toggle power."
- qol: "Exosuits with no pilot and no link can be given a command to toggle maintenance protocols, allowing the exosuit to be linked without needing to enter the exosuit."
Loading