From 9be5423b76b108de8f3429f01f2ab4c654272388 Mon Sep 17 00:00:00 2001 From: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:49:13 -0400 Subject: [PATCH] Exosuit QOL: Action Buttons (#25131) * Mech Buttons * Added "Please Make A Bug Report" Co-authored-by: 1080pCat <96908085+1080pCat@users.noreply.github.com> * Action fix * Removed duplicate mecha define * Corrected new() syntax Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> * Removed extraneous proc * Better boolean in playsound Co-authored-by: Matt <116982774+Burzah@users.noreply.github.com> Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> * Update code/modules/tgui/states.dm Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com> --------- Signed-off-by: PollardTheDragon <144391971+PollardTheDragon@users.noreply.github.com> Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Co-authored-by: 1080pCat <96908085+1080pCat@users.noreply.github.com> Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Co-authored-by: Matt <116982774+Burzah@users.noreply.github.com> --- code/game/mecha/equipment/mecha_equipment.dm | 15 +++++++++++ code/game/mecha/mecha.dm | 7 ++--- code/game/mecha/mecha_actions.dm | 27 +++++++++++++++++++- code/modules/tgui/states.dm | 2 ++ 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/code/game/mecha/equipment/mecha_equipment.dm b/code/game/mecha/equipment/mecha_equipment.dm index 4af1b23ae6d..ddac0b7cd48 100644 --- a/code/game/mecha/equipment/mecha_equipment.dm +++ b/code/game/mecha/equipment/mecha_equipment.dm @@ -111,6 +111,15 @@ if(!M.selected) M.selected = src update_chassis_page() + if(M.occupant) + give_targeted_action() + +/obj/item/mecha_parts/mecha_equipment/proc/give_targeted_action() + if(!selectable) + return + var/datum/action/innate/mecha/select_module/select_action = new() + select_action.Grant(chassis.occupant, chassis, src) + chassis.select_actions[src] = select_action /obj/item/mecha_parts/mecha_equipment/proc/detach(atom/moveto = null) moveto = moveto || get_turf(chassis) @@ -123,6 +132,12 @@ chassis = null set_ready_state(1) +/obj/item/mecha_parts/mecha_equipment/proc/remove_targeted_action() + if(!selectable) + return + if(chassis.select_actions[src]) + var/datum/action/innate/mecha/select_module/select_action = chassis.select_actions[src] + select_action.Remove(chassis.occupant) /obj/item/mecha_parts/mecha_equipment/Topic(href,href_list) if(href_list["detach"]) diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index ee12fd81f94..f482f564ee2 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -103,8 +103,6 @@ var/phasing_energy_drain = 200 var/phase_state = "" //icon_state when phasing - hud_possible = list (DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_TRACK_HUD) - //Action datums var/datum/action/innate/mecha/mech_eject/eject_action = new var/datum/action/innate/mecha/mech_toggle_internals/internals_action = new @@ -118,6 +116,9 @@ var/datum/action/innate/mecha/mech_zoom/zoom_action = new var/datum/action/innate/mecha/mech_toggle_phasing/phasing_action = new var/datum/action/innate/mecha/mech_switch_damtype/switch_damtype_action = new + var/list/select_actions = list() + + hud_possible = list (DIAG_STAT_HUD, DIAG_BATT_HUD, DIAG_MECH_HUD, DIAG_TRACK_HUD) /obj/mecha/Initialize() . = ..() @@ -264,7 +265,7 @@ ////////////////////////////////// -//////// MARK: Movement procs +//////// MARK: Movement procs ////////////////////////////////// /obj/mecha/Process_Spacemove(movement_dir = 0) diff --git a/code/game/mecha/mecha_actions.dm b/code/game/mecha/mecha_actions.dm index f508739cb1b..7121ebcc87b 100644 --- a/code/game/mecha/mecha_actions.dm +++ b/code/game/mecha/mecha_actions.dm @@ -6,6 +6,8 @@ stats_action.Grant(user, src) if(locate(/obj/item/mecha_parts/mecha_equipment/thrusters) in equipment) add_thrusters() + for(var/obj/item/mecha_parts/mecha_equipment/equipment_mod in equipment) + equipment_mod.give_targeted_action() /obj/mecha/proc/RemoveActions(mob/living/user, human_occupant = 0) if(human_occupant) @@ -14,6 +16,8 @@ lights_action.Remove(user) stats_action.Remove(user) thrusters_action.Remove(user) + for(var/obj/item/mecha_parts/mecha_equipment/equipment_mod in equipment) + equipment_mod.remove_targeted_action() /datum/action/innate/mecha check_flags = AB_CHECK_RESTRAINED | AB_CHECK_STUNNED | AB_CHECK_CONSCIOUS @@ -214,5 +218,26 @@ chassis.occupant_message("A bone-chillingly thick plasteel needle protracts from the exosuit's palm.") chassis.damtype = new_damtype button_icon_state = "mech_damtype_[new_damtype]" - playsound(src, 'sound/mecha/mechmove01.ogg', 50, 1) + playsound(src, 'sound/mecha/mechmove01.ogg', 50, TRUE) UpdateButtons() + +/datum/action/innate/mecha/select_module + name = "Hey, you shouldn't see this please make a bug report" + var/obj/item/mecha_parts/mecha_equipment/equipment + +/datum/action/innate/mecha/select_module/Grant(mob/living/L, obj/mecha/M, obj/item/mecha_parts/mecha_equipment/_equipment) + if(!_equipment) + return FALSE + equipment = _equipment + icon_icon = equipment.icon + button_icon_state = equipment.icon_state + . = ..() + name = "Switch module to [equipment.name]" + +/datum/action/innate/mecha/select_module/Activate() + if(!owner || !chassis || chassis.occupant != owner) + return + chassis.selected = equipment + chassis.occupant_message("You switch to [equipment.name].") + chassis.visible_message("[chassis] raises [equipment.name]") + send_byjax(chassis.occupant, "exosuit.browser", "eq_list", chassis.get_equipment_list()) diff --git a/code/modules/tgui/states.dm b/code/modules/tgui/states.dm index 8b801d5e2a2..5890084e1ed 100644 --- a/code/modules/tgui/states.dm +++ b/code/modules/tgui/states.dm @@ -128,4 +128,6 @@ /mob/living/carbon/human/shared_living_ui_distance(atom/movable/src_object, viewcheck) if(HAS_TRAIT(src, TRAIT_TELEKINESIS) && (get_dist(src, src_object) <= 2)) return UI_INTERACTIVE + if(ismecha(loc) && get_dist(loc, src_object) <= 1) + return UI_INTERACTIVE return ..()