Skip to content

Commit

Permalink
Improves cyber implant UX (#2741)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Ports:
tgstation/tgstation#53893
tgstation/tgstation#54914
Adds custom sound capability for deploy/retract
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->
## Changelog

:cl: Zxaber
tweak: You can now use drop / use inhand hotkey to retract and deploy
arm implants
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
thgvr authored Apr 11, 2024
1 parent 16d95f6 commit a8c77d2
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 20 deletions.
2 changes: 0 additions & 2 deletions code/__DEFINES/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#define COLOR_INPUT_DISABLED "#F0F0F0"
#define COLOR_INPUT_ENABLED "#D3B5B5"

//BeginWS
#define COLOR_DARKMODE_DARKBACKGROUND "#383838"
#define COLOR_DARKMODE_BACKGROUND "#272727"
#define COLOR_DARKMODE_HEADER "#ffffff"
Expand All @@ -23,7 +22,6 @@
#define WOOD_COLOR_BLACK "#332521"
#define WOOD_COLOR_CHOCOLATE "#543C30"
#define WOOD_COLOR_YELLOW "#E3994E"
//EndWS

#define COLOR_WHITE "#FFFFFF"
#define COLOR_OFF_WHITE "#FFF5ED"
Expand Down
1 change: 1 addition & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
var/hitsound_type = PROJECTILE_HITSOUND_NON_LIVING
///volume wanted for being hit
var/hitsound_volume = 50

/**
* Called when an atom is created in byond (built in engine proc)
*
Expand Down
6 changes: 6 additions & 0 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,12 @@
else if(can_be_firemanned(target))
fireman_carry(target)

/mob/living/carbon/human/limb_attack_self()
var/obj/item/bodypart/arm = hand_bodyparts[active_hand_index]
if(arm)
arm.attack_self(src)
return ..()

/mob/living/carbon/human/MouseDrop(mob/over)
. = ..()
if(ishuman(over))
Expand Down
11 changes: 11 additions & 0 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,15 @@
var/msg = "<span class='smallnotice'>[src] makes eye contact with you.</span>"
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(to_chat), examined_mob, msg), 3)

/**
* Called by using Activate Held Object with an empty hand/limb
*
* Does nothing by default. The intended use is to allow limbs to call their
* own attack_self procs. It is up to the individual mob to override this
* parent and actually use it.
*/
/mob/proc/limb_attack_self()
return

///Can this mob resist (default FALSE)
/mob/proc/can_resist()
Expand Down Expand Up @@ -622,6 +631,8 @@
if(I)
I.attack_self(src)
update_inv_hands()
return
limb_attack_self()

/mob/verb/do_unique_action()
set name = "Do Unique Action"
Expand Down
55 changes: 39 additions & 16 deletions code/modules/surgery/organs/augments_arms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
var/list/items_list = list()// I would use contents, but they shuffle on every activation/deactivation leading to interface inconsistencies.
/// You can use this var for item path, it would be converted into an item on New().
var/obj/item/active_item
/// Sound played when extending
var/extend_sound = 'sound/mecha/mechmove03.ogg'
/// Sound played when retracting
var/retract_sound = 'sound/mecha/mechmove03.ogg'

/obj/item/organ/cyberimp/arm/Initialize()
. = ..()
Expand Down Expand Up @@ -68,18 +72,34 @@
to_chat(user, "<span class='notice'>You modify [src] to be installed on the [zone == BODY_ZONE_R_ARM ? "right" : "left"] arm.</span>")
update_appearance()

/obj/item/organ/cyberimp/arm/Insert(mob/living/carbon/M, special = FALSE, drop_if_replaced = TRUE)
. = ..()
var/side = zone == BODY_ZONE_R_ARM? RIGHT_HANDS : LEFT_HANDS
hand = owner.hand_bodyparts[side]
if(hand)
RegisterSignal(hand, COMSIG_ITEM_ATTACK_SELF, PROC_REF(ui_action_click)) //If the limb gets an attack-self, open the menu. Only happens when hand is empty
RegisterSignal(M, COMSIG_KB_MOB_DROPITEM_DOWN, PROC_REF(dropkey)) //We're nodrop, but we'll watch for the drop hotkey anyway and then stow if possible.

/obj/item/organ/cyberimp/arm/Remove(mob/living/carbon/M, special = 0)
Retract()
if(hand)
UnregisterSignal(hand, COMSIG_ITEM_ATTACK_SELF)
UnregisterSignal(M, COMSIG_KB_MOB_DROPITEM_DOWN)
..()

/obj/item/organ/cyberimp/arm/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_SELF)
return
if(prob(15/severity) && owner)
to_chat(owner, "<span class='warning'>[src] is hit by EMP!</span>")
// give the owner an idea about why his implant is glitching
Retract()
/**
* Called when the mob uses the "drop item" hotkey
*
* Items inside toolset implants have TRAIT_NODROP, but we can still use the drop item hotkey as a
* quick way to store implant items. In this case, we check to make sure the user has the correct arm
* selected, and that the item is actually owned by us, and then we'll hand off the rest to Retract()
**/
/obj/item/organ/cyberimp/arm/proc/dropkey(mob/living/carbon/host)
if(!host)
return //How did we even get here
if(hand != host.hand_bodyparts[host.active_hand_index])
return //wrong hand
Retract()

/obj/item/organ/cyberimp/arm/proc/Retract()
if(!active_item || (active_item in src))
Expand All @@ -89,13 +109,9 @@
"<span class='notice'>[active_item] snaps back into your [zone == BODY_ZONE_R_ARM ? "right" : "left"] arm.</span>",
"<span class='hear'>You hear a short mechanical noise.</span>")

if(istype(active_item, /obj/item/assembly/flash/armimplant))
var/obj/item/assembly/flash/F = active_item
F.set_light(0)

owner.transferItemToLoc(active_item, src, TRUE)
playsound(get_turf(owner), retract_sound, 50, TRUE)
active_item = null
playsound(get_turf(owner), 'sound/mecha/mechmove03.ogg', 50, TRUE)

/obj/item/organ/cyberimp/arm/proc/Extend(obj/item/item)
if(!(item in src))
Expand Down Expand Up @@ -135,7 +151,7 @@
owner.visible_message("<span class='notice'>[owner] extends [active_item] from [owner.p_their()] [zone == BODY_ZONE_R_ARM ? "right" : "left"] arm.</span>",
"<span class='notice'>You extend [active_item] from your [zone == BODY_ZONE_R_ARM ? "right" : "left"] arm.</span>",
"<span class='hear'>You hear a short mechanical noise.</span>")
playsound(get_turf(owner), 'sound/mecha/mechmove03.ogg', 50, TRUE)
playsound(get_turf(owner), extend_sound, 50, TRUE)

/obj/item/organ/cyberimp/arm/ui_action_click()
if((organ_flags & ORGAN_FAILING) || (!active_item && !contents.len))
Expand All @@ -161,6 +177,14 @@
else
Retract()

/obj/item/organ/cyberimp/arm/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_SELF)
return
if(prob(15/severity) && owner)
to_chat(owner, "<span class='warning'>[src] is hit by EMP!</span>")
// give the owner an idea about why his implant is glitching
Retract()

/obj/item/organ/cyberimp/arm/gun/emp_act(severity)
. = ..()
Expand Down Expand Up @@ -225,7 +249,6 @@
desc = "A cybernetic implant that allows the user to project a healing beam from their hand."
items_to_create = list(/obj/item/gun/medbeam)


/obj/item/organ/cyberimp/arm/flash
name = "integrated high-intensity photon projector" //Why not
desc = "An integrated projector mounted onto a user's arm that is able to be used as a powerful flash."
Expand Down Expand Up @@ -277,4 +300,4 @@
name = "power cord implant"
desc = "An internal power cord hooked up to a battery. Useful if you run on volts."
items_to_create = list(/obj/item/apc_powercord)
zone = "l_arm"
zone = BODY_ZONE_L_ARM
3 changes: 1 addition & 2 deletions code/modules/surgery/organs/augments_internal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/obj/item/organ/cyberimp
name = "cybernetic implant"
desc = "A state-of-the-art implant that improves a baseline's functionality."
icon = 'icons/obj/implants/implant.dmi'
status = ORGAN_ROBOTIC
organ_flags = ORGAN_SYNTHETIC
var/implant_color = "#FFFFFF"
Expand All @@ -17,8 +18,6 @@
add_overlay(overlay)
return ..()



//[[[[BRAIN]]]]

/obj/item/organ/cyberimp/brain
Expand Down
Binary file modified icons/mob/inhands/weapons/axes_lefthand.dmi
Binary file not shown.
Binary file added icons/obj/implants/implant.dmi
Binary file not shown.
Binary file modified icons/obj/surgery.dmi
Binary file not shown.

0 comments on commit a8c77d2

Please sign in to comment.