From 4a483e2065d833bcf3a774dc8c6e9f583a7602ca Mon Sep 17 00:00:00 2001 From: Geeves Date: Tue, 2 Mar 2021 00:42:36 +0200 Subject: [PATCH] Hardsuit Engagement (#11301) --- code/_onclick/hud/human.dm | 8 +++++--- code/_onclick/hud/screen_objects.dm | 17 ++++++++++++++++- code/_onclick/rig.dm | 2 +- code/game/objects/items/weapons/RFD.dm | 4 ++++ .../clothing/spacesuits/rig/modules/combat.dm | 1 + .../clothing/spacesuits/rig/modules/computer.dm | 2 +- .../clothing/spacesuits/rig/modules/modules.dm | 13 ++++++++++--- .../clothing/spacesuits/rig/modules/ninja.dm | 14 +++++++------- .../clothing/spacesuits/rig/modules/utility.dm | 16 +++++++++++++++- code/modules/clothing/spacesuits/rig/rig.dm | 2 +- .../clothing/spacesuits/rig/rig_pieces.dm | 2 +- .../clothing/spacesuits/rig/rig_verbs.dm | 6 +++--- .../living/carbon/human/species/species_hud.dm | 2 +- html/changelogs/geeves-hardsuit_engagement.yml | 7 +++++++ 14 files changed, 73 insertions(+), 23 deletions(-) create mode 100644 html/changelogs/geeves-hardsuit_engagement.yml diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index 68f2a4c6ba3..50d7b09a2a7 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -22,15 +22,17 @@ // Draw the various inventory equipment slots. var/has_hidden_gear for(var/gear_slot in hud_data.gear) - - inv_box = new /obj/screen/inventory() + var/list/slot_data = hud_data.gear[gear_slot] + var/hud_type = /obj/screen/inventory + if(slot_data["slot_type"]) + hud_type = slot_data["slot_type"] + inv_box = new hud_type() inv_box.icon = ui_style inv_box.layer = SCREEN_LAYER inv_box.color = ui_color inv_box.alpha = ui_alpha inv_box.hud = src - var/list/slot_data = hud_data.gear[gear_slot] inv_box.name = slot_data["name"] inv_box.screen_loc = slot_data["loc"] inv_box.slot_id = slot_data["slot"] diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index a75d55fe935..9c3691a7e66 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -28,10 +28,10 @@ maptext_height = 480 maptext_width = 480 - /obj/screen/inventory var/slot_id //The identifier for the slot. It has nothing to do with ID cards. var/list/object_overlays = list() // Required for inventory/screen overlays. + var/color_changed = FALSE /obj/screen/inventory/MouseEntered() ..() @@ -59,6 +59,18 @@ object_overlays += item_overlay add_overlay(object_overlays) +/obj/screen/inventory/proc/set_color_for(var/set_color, var/set_time) + if(color_changed) + return + var/old_color = color + color = set_color + color_changed = TRUE + addtimer(CALLBACK(src, .proc/set_color_to, old_color), set_time) + +/obj/screen/inventory/proc/set_color_to(var/set_color) + color = set_color + color_changed = FALSE + /obj/screen/close name = "close" @@ -486,3 +498,6 @@ add_overlay(disabled_hand_overlay) if(H.handcuffed) add_overlay(handcuff_overlay) + +/obj/screen/inventory/back + name = "back" \ No newline at end of file diff --git a/code/_onclick/rig.dm b/code/_onclick/rig.dm index 2b8419f6195..bb09a579977 100644 --- a/code/_onclick/rig.dm +++ b/code/_onclick/rig.dm @@ -71,7 +71,7 @@ if(istype(rig) && !rig.offline && rig.selected_module) if(src != rig.wearer && !rig.ai_can_move_suit(src, TRUE)) return FALSE - rig.selected_module.engage(A, src, alert_ai) + rig.selected_module.do_engage(A, src, alert_ai) if(ismob(A)) // No instant mob attacking - though modules have their own cooldowns setClickCooldown(DEFAULT_ATTACK_COOLDOWN) return TRUE diff --git a/code/game/objects/items/weapons/RFD.dm b/code/game/objects/items/weapons/RFD.dm index 325aaa09b17..83c29994ac8 100644 --- a/code/game/objects/items/weapons/RFD.dm +++ b/code/game/objects/items/weapons/RFD.dm @@ -490,6 +490,8 @@ RFD Mining-Class stored_matter-- to_chat(user, SPAN_NOTICE("The RFD now holds [stored_matter]/30 fabrication-units.")) + return TRUE + // Malf AI RFD Transformer. @@ -546,6 +548,8 @@ RFD Mining-Class if(R.cell) R.cell.use(used_energy) + return TRUE + /* RFD Piping-Class diff --git a/code/modules/clothing/spacesuits/rig/modules/combat.dm b/code/modules/clothing/spacesuits/rig/modules/combat.dm index 29f9c3de727..895badbeda9 100644 --- a/code/modules/clothing/spacesuits/rig/modules/combat.dm +++ b/code/modules/clothing/spacesuits/rig/modules/combat.dm @@ -85,6 +85,7 @@ holder.wearer.visible_message(SPAN_DANGER("[user] launches \a [new_grenade]!")) new_grenade.activate(user) new_grenade.throw_at(target, fire_force, fire_distance) + return TRUE /obj/item/rig_module/grenade_launcher/frag name = "mounted frag grenade launcher" diff --git a/code/modules/clothing/spacesuits/rig/modules/computer.dm b/code/modules/clothing/spacesuits/rig/modules/computer.dm index 094ab4fd41c..87633d7a4a9 100644 --- a/code/modules/clothing/spacesuits/rig/modules/computer.dm +++ b/code/modules/clothing/spacesuits/rig/modules/computer.dm @@ -425,7 +425,7 @@ /obj/item/rig_module/power_sink/accepts_item(var/obj/item/input_device, var/mob/living/user) var/can_drain = input_device.drain_power(1) if(can_drain > 0) - engage(input_device, user) + do_engage(input_device, user) return TRUE return FALSE diff --git a/code/modules/clothing/spacesuits/rig/modules/modules.dm b/code/modules/clothing/spacesuits/rig/modules/modules.dm index 6fa30a39191..8d3e52650ca 100644 --- a/code/modules/clothing/spacesuits/rig/modules/modules.dm +++ b/code/modules/clothing/spacesuits/rig/modules/modules.dm @@ -150,6 +150,15 @@ holder = new_holder return +/obj/item/rig_module/proc/do_engage(atom/target, mob/living/carbon/human/user) + . = engage(target, user) + if(.) + var/old_next_use = next_use + next_use = world.time + module_cooldown + if(next_use > old_next_use) + var/obj/screen/inventory/back/B = locate(/obj/screen/inventory/back) in user.hud_used.adding + B.set_color_for(COLOR_RED, module_cooldown) + //Proc for one-use abilities like teleport. /obj/item/rig_module/proc/engage(atom/target, mob/user) if(damage >= 2) @@ -183,15 +192,13 @@ to_chat(user, SPAN_DANGER("You cannot use the suit in the confined space.")) return FALSE - next_use = world.time + module_cooldown - return TRUE // Proc for toggling on active abilities. /obj/item/rig_module/proc/activate(mob/user) if(active) return FALSE - if(engage_on_activate && !engage(null, user)) + if(engage_on_activate && !do_engage(null, user)) return FALSE active = TRUE diff --git a/code/modules/clothing/spacesuits/rig/modules/ninja.dm b/code/modules/clothing/spacesuits/rig/modules/ninja.dm index 01bb8e7ffe9..2e75828975c 100644 --- a/code/modules/clothing/spacesuits/rig/modules/ninja.dm +++ b/code/modules/clothing/spacesuits/rig/modules/ninja.dm @@ -203,7 +203,7 @@ //OH SHIT. if(holder.wearer.stat == DEAD) - engage(1) + do_engage(1) /obj/item/rig_module/self_destruct/engage(var/skip_check) if(!skip_check && usr && alert(usr, "Are you sure you want to push that button?", "Self-destruct", "No", "Yes") == "No") @@ -288,12 +288,12 @@ if(cooldown) to_chat(user, SPAN_DANGER("There isn't enough power stored up yet!")) return FALSE - else - message_user(user, SPAN_NOTICE("You inject a burst of power into \the [holder]."), SPAN_NOTICE("Your suit emits a loud sound as power is rapidly injected into your suit's battery!")) - playsound(H.loc, 'sound/effects/sparks2.ogg', 50, 1) - holder.cell.give(generation_amount) - cooldown = 1 - addtimer(CALLBACK(src, /obj/item/rig_module/emergency_powergenerator/proc/reset_cooldown), 2 MINUTES) + message_user(user, SPAN_NOTICE("You inject a burst of power into \the [holder]."), SPAN_NOTICE("Your suit emits a loud sound as power is rapidly injected into your suit's battery!")) + playsound(H.loc, 'sound/effects/sparks2.ogg', 50, 1) + holder.cell.give(generation_amount) + cooldown = 1 + addtimer(CALLBACK(src, /obj/item/rig_module/emergency_powergenerator/proc/reset_cooldown), 2 MINUTES) + return TRUE /obj/item/rig_module/emergency_powergenerator/proc/reset_cooldown() cooldown = 0 diff --git a/code/modules/clothing/spacesuits/rig/modules/utility.dm b/code/modules/clothing/spacesuits/rig/modules/utility.dm index e2572c43e6a..7add829a5c7 100644 --- a/code/modules/clothing/spacesuits/rig/modules/utility.dm +++ b/code/modules/clothing/spacesuits/rig/modules/utility.dm @@ -126,6 +126,15 @@ category = MODULE_UTILITY +/obj/item/rig_module/device/rfd_c/handle_device_engage(atom/target, mob/user) + var/resolved = target.attackby(device, user) + if(!resolved && device && target) + if(device.afterattack(target, user, TRUE)) + return TRUE + else + return FALSE + return TRUE + /obj/item/rig_module/device/Initialize() . = ..() if(device_type) @@ -147,6 +156,9 @@ if(istype(target, /obj/machinery/disposal)) return FALSE + return handle_device_engage(target, user) + +/obj/item/rig_module/device/proc/handle_device_engage(atom/target, mob/user) var/resolved = target.attackby(device, user) if(!resolved && device && target) device.afterattack(target, user, TRUE) @@ -783,6 +795,7 @@ T.ChangeTurf(T.baseturf) else T.ChangeTurf(/turf/space) + return TRUE var/global/list/lattice_users = list() @@ -858,4 +871,5 @@ var/global/list/lattice_users = list() new /obj/effect/effect/foam/spray(t, TRUE) counter-- previous_turf = T - sleep(1) \ No newline at end of file + sleep(1) + return TRUE \ No newline at end of file diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm index 0c246aedb88..a828d31ae32 100644 --- a/code/modules/clothing/spacesuits/rig/rig.dm +++ b/code/modules/clothing/spacesuits/rig/rig.dm @@ -600,7 +600,7 @@ if("deactivate") module.deactivate(user) if("engage") - module.engage(null, user) + module.do_engage(null, user) if("select") selected_module = module if("select_charge_type") diff --git a/code/modules/clothing/spacesuits/rig/rig_pieces.dm b/code/modules/clothing/spacesuits/rig/rig_pieces.dm index e48451d8c03..77ac4d5d91e 100644 --- a/code/modules/clothing/spacesuits/rig/rig_pieces.dm +++ b/code/modules/clothing/spacesuits/rig/rig_pieces.dm @@ -91,7 +91,7 @@ for(var/obj/item/rig_module/module in suit.installed_modules) if(module.active && module.activates_on_touch) - if(module.engage(A, H)) + if(module.do_engage(A, H)) return 1 return 0 diff --git a/code/modules/clothing/spacesuits/rig/rig_verbs.dm b/code/modules/clothing/spacesuits/rig/rig_verbs.dm index bdb37b80da1..a80068b9978 100644 --- a/code/modules/clothing/spacesuits/rig/rig_verbs.dm +++ b/code/modules/clothing/spacesuits/rig/rig_verbs.dm @@ -175,7 +175,7 @@ to_chat(usr, SPAN_WARNING("The visor is suffering a hardware fault and cannot be configured.")) return - visor.engage(null, usr) + visor.do_engage(null, usr) /obj/item/rig/verb/alter_voice() set name = "Configure Voice Synthesiser" @@ -198,7 +198,7 @@ to_chat(usr, SPAN_WARNING("The hardsuit does not have a speech synthesiser.")) return - speech.engage(null, usr) + speech.do_engage(null, usr) /obj/item/rig/verb/select_module() set name = "Select Module" @@ -303,4 +303,4 @@ return to_chat(usr, "You attempt to engage the [module.interface_name].") - module.engage(null, usr) \ No newline at end of file + module.do_engage(null, usr) \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/species/species_hud.dm b/code/modules/mob/living/carbon/human/species/species_hud.dm index 9b0a909c273..8c7e4c0f191 100644 --- a/code/modules/mob/living/carbon/human/species/species_hud.dm +++ b/code/modules/mob/living/carbon/human/species/species_hud.dm @@ -31,7 +31,7 @@ "shoes" = list("loc" = ui_shoes, "name" = "shoes", "slot" = slot_shoes, "state" = "shoes", "toggle" = 1), "wrists" = list("loc" = ui_wrists, "name" = "wrists", "slot" = slot_wrists, "state" = "wrists", "toggle" = 1), "suit storage" = list("loc" = ui_sstore1, "name" = "suit storage", "slot" = slot_s_store, "state" = "suitstore"), - "back" = list("loc" = ui_back, "name" = "back", "slot" = slot_back, "state" = "back"), + "back" = list("loc" = ui_back, "name" = "back", "slot" = slot_back, "state" = "back", "slot_type" = /obj/screen/inventory/back), "id" = list("loc" = ui_id, "name" = "id", "slot" = slot_wear_id, "state" = "id"), "storage1" = list("loc" = ui_storage1, "name" = "left pocket", "slot" = slot_l_store, "state" = "pocket"), "storage2" = list("loc" = ui_storage2, "name" = "right pocket", "slot" = slot_r_store, "state" = "pocket"), diff --git a/html/changelogs/geeves-hardsuit_engagement.yml b/html/changelogs/geeves-hardsuit_engagement.yml new file mode 100644 index 00000000000..e6c1078e44e --- /dev/null +++ b/html/changelogs/geeves-hardsuit_engagement.yml @@ -0,0 +1,7 @@ +author: Geeves + +delete-after: True + +changes: + - tweak: "Using hardsuit modules now generally only applies the module's cooldown if the action was successful. Standard click-cooldown still applies, however." + - rscadd: "Using a hardsuit module will now colour your back HUD icon red until the cooldown ends." \ No newline at end of file