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

Ports hotswappable robot limbs quirk from NovaSector #411

Merged
merged 25 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b7b388a
initial commit
siliconOpossum Jan 30, 2024
cba8dcd
removes pain from attach/detach
siliconOpossum Jan 30, 2024
f0a3bcd
Fixes a bug from the original PR
siliconOpossum Jan 30, 2024
6cda4a0
Actually fix it oops
siliconOpossum Jan 30, 2024
173acaf
Finalv2finalestv3v2final-copy
siliconOpossum Jan 30, 2024
9a90712
Fixes the bug for real this time, I'm good at this I swear, I even te…
siliconOpossum Jan 30, 2024
3243276
We don't need this, I don't think
siliconOpossum Jan 30, 2024
67daf83
Minor text tweaks
siliconOpossum Jan 30, 2024
cdfc5b3
Fixes cooldown
siliconOpossum Jan 30, 2024
0f570c8
Implements Melbert's recommendation on code layout
siliconOpossum Jan 30, 2024
af670ae
Tweaks cooldown and do_after lengths
siliconOpossum Jan 30, 2024
435bcc6
Uncomment dead (but still potentially useful in the future) code
siliconOpossum Jan 30, 2024
026cea9
Applies nullrod to code
siliconOpossum Jan 31, 2024
2196ee4
Applies some suggestions
siliconOpossum Jan 31, 2024
17ca42d
Adds extra_checks to do_after
siliconOpossum Jan 31, 2024
7375fdb
Makes it so you can keep moving if not detaching a leg
siliconOpossum Jan 31, 2024
fb107ba
Oh wait I didn't actually do that, lol, oops
siliconOpossum Jan 31, 2024
4a0345a
In fact I should probably put that back too, since it isn't necessary…
siliconOpossum Jan 31, 2024
80bc488
Oops! I was wrong, reverts last commit
siliconOpossum Jan 31, 2024
6dcc27e
How the hell did that get there?
siliconOpossum Jan 31, 2024
4b89ef9
Oh, I misunderstood the review earlier, I think this should work, though
siliconOpossum Jan 31, 2024
4a1065d
Apply suggestions from code review
siliconOpossum Feb 3, 2024
16d8e95
cast_on > target
siliconOpossum Feb 3, 2024
d55bfac
Final touches (hopefully)
siliconOpossum Feb 4, 2024
c7e0dba
Assuming direct control
MrMelbert Feb 4, 2024
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
3 changes: 3 additions & 0 deletions code/__DEFINES/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@

/// If the mob enters shock, they will have +1 cure condition (helps cure it faster)
#define TRAIT_ABATES_SHOCK "shock_abated"

/// The trait that determines if someone has the robotic limb reattachment quirk.
#define TRAIT_ROBOTIC_LIMBATTACHMENT "trait_robotic_limbattachment" // Sticking this here because Melbert told me to
6 changes: 5 additions & 1 deletion code/modules/surgery/bodyparts/_bodyparts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@

if(ishuman(victim))
var/mob/living/carbon/human/human_victim = victim
if(HAS_TRAIT(victim, TRAIT_LIMBATTACHMENT))
// NON-MODULE CHANGE START
if (!HAS_TRAIT(victim, TRAIT_LIMBATTACHMENT) && !(bodytype & BODYTYPE_ROBOTIC)) //if we're trying to attach something that's not robotic, and we don't have the generic trait, end out
return
if(HAS_TRAIT(victim, TRAIT_LIMBATTACHMENT) || HAS_TRAIT(victim, TRAIT_ROBOTIC_LIMBATTACHMENT))
// NON-MODULE CHANGE END
if(!human_victim.get_bodypart(body_zone))
user.temporarilyRemoveItemFromInventory(src, TRUE)
if(!try_attach_limb(victim))
Expand Down
1 change: 1 addition & 0 deletions maplestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6445,6 +6445,7 @@
#include "maplestation_modules\code\modules\research\machinery\_production.dm"
#include "maplestation_modules\code\modules\research\techweb\_research.dm"
#include "maplestation_modules\code\modules\research\techweb\all_nodes.dm"
#include "maplestation_modules\code\modules\robotic_limb_detach\robot_limb_detach_quirk.dm"
#include "maplestation_modules\code\modules\surgery\organs\augments_arms.dm"
#include "maplestation_modules\code\modules\surgery\organs\autosurgeon.dm"
#include "maplestation_modules\code\modules\surgery\organs\ears.dm"
Expand Down
11 changes: 6 additions & 5 deletions maplestation_modules/code/datums/pain/pain.dm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

body_zones[new_limb.body_zone] = new_limb

if(special)
if(special || (HAS_TRAIT(source, TRAIT_ROBOTIC_LIMBATTACHMENT) && (new_limb.bodytype & BODYTYPE_ROBOTIC)))
new_limb.pain = 0
else
adjust_bodypart_pain(new_limb.body_zone, new_limb.pain)
Expand All @@ -152,10 +152,11 @@
body_zones -= bad_zone
UnregisterSignal(lost_limb, COMSIG_QDELETING)

if(!QDELETED(parent) && !special)
var/limb_removed_pain = (dismembered ? PAIN_LIMB_DISMEMBERED : PAIN_LIMB_REMOVED)
adjust_bodypart_pain(BODY_ZONE_CHEST, limb_removed_pain)
adjust_bodypart_pain(BODY_ZONES_MINUS_CHEST, limb_removed_pain / 3)
if(!QDELETED(parent))
if(!special && !(HAS_TRAIT(source, TRAIT_ROBOTIC_LIMBATTACHMENT) && (lost_limb.bodytype & BODYTYPE_ROBOTIC)))
var/limb_removed_pain = (dismembered ? PAIN_LIMB_DISMEMBERED : PAIN_LIMB_REMOVED)
adjust_bodypart_pain(BODY_ZONE_CHEST, limb_removed_pain)
adjust_bodypart_pain(BODY_ZONES_MINUS_CHEST, limb_removed_pain / 3)

if(!QDELETED(lost_limb))
lost_limb.pain = initial(lost_limb.pain)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/datum/quirk/robot_limb_detach
name = "Cybernetic Limb Mounts"
desc = "You are able to detach and reattach any installed robotic limbs with very little effort." // ", as long as they're in good condition."
MrMelbert marked this conversation as resolved.
Show resolved Hide resolved
gain_text = span_notice("Internal sensors report limb disengagement protocols are ready and waiting.")
lose_text = span_notice("ERROR: LIMB DISENGAGEMENT PROTOCOLS OFFLINE.")
medical_record_text = "Patient bears quick-attach and release limb joint cybernetics."
value = 0
mob_trait = TRAIT_ROBOTIC_LIMBATTACHMENT
icon = FA_ICON_HANDSHAKE_SIMPLE_SLASH
quirk_flags = QUIRK_HUMAN_ONLY
/// The action we add with this quirk in add(), used for easy deletion later
var/datum/action/cooldown/added_action

/datum/quirk/robot_limb_detach/add(client/client_source)
var/mob/living/carbon/human/human_holder = quirk_holder
var/datum/action/cooldown/robot_self_amputation/limb_action = new /datum/action/cooldown/robot_self_amputation()
siliconOpossum marked this conversation as resolved.
Show resolved Hide resolved
limb_action.Grant(human_holder)
added_action = limb_action

/datum/quirk/robot_limb_detach/remove()
QDEL_NULL(added_action)

/datum/action/cooldown/robot_self_amputation
name = "Detach a robotic limb"
desc = "Disengage one of your robotic limbs from your cybernetic mounts. Requires you to not be restrained or otherwise under duress." // " Will not function on wounded limbs - tend to them first."
MrMelbert marked this conversation as resolved.
Show resolved Hide resolved
button_icon = 'icons/mob/actions/actions_spells.dmi'
button_icon_state = "autotomy"

cooldown_time = 1 SECONDS
check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_HANDS_BLOCKED | AB_CHECK_INCAPACITATED

var/list/exclusions = list(BODY_ZONE_CHEST, BODY_ZONE_HEAD)
var/obj/item/bodypart/limb_to_detach
siliconOpossum marked this conversation as resolved.
Show resolved Hide resolved

/datum/action/cooldown/robot_self_amputation/proc/detaching_check(mob/living/carbon/human/cast_on)
return !QDELETED(limb_to_detach) && limb_to_detach.owner == cast_on
siliconOpossum marked this conversation as resolved.
Show resolved Hide resolved

/datum/action/cooldown/robot_self_amputation/Activate(mob/living/carbon/human/cast_on)
siliconOpossum marked this conversation as resolved.
Show resolved Hide resolved
if(!ishuman(cast_on))
return

if(HAS_TRAIT(cast_on, TRAIT_NODISMEMBER))
to_chat(cast_on, span_warning("ERROR: LIMB DISENGAGEMENT PROTOCOLS OFFLINE. Seek out a maintenance technician."))
return

// The code below is redundant in our codebase, but I'm keeping it commented in case someone in the future wants to make it useful
// if (!issynthetic(cast_on))
// exclusions += BODY_ZONE_HEAD // no decapitating yourself unless you're a synthetic, who keep their brains in their chest

var/list/robot_parts = list()
for (var/obj/item/bodypart/possible_part as anything in cast_on.bodyparts)
if ((possible_part.bodytype & BODYTYPE_ROBOTIC) && !(possible_part.body_zone in exclusions)) //only robot limbs and only if they're not crucial to our like, ongoing life, you know?
robot_parts += possible_part

if (!length(robot_parts))
to_chat(cast_on, "ERROR: Limb disengagement protocols report no compatible cybernetics currently installed. Seek out a maintenance technician.")
return

limb_to_detach = tgui_input_list(cast_on, "Limb to detach", "Cybernetic Limb Detachment", sort_names(robot_parts))
if (QDELETED(src) || QDELETED(cast_on) || QDELETED(limb_to_detach) || limb_to_detach.owner != cast_on)
return SPELL_CANCEL_CAST
MrMelbert marked this conversation as resolved.
Show resolved Hide resolved

if (length(limb_to_detach.wounds) >= 1)
cast_on.balloon_alert(cast_on, "can't detach wounded limbs!")
playsound(cast_on, 'sound/machines/buzz-sigh.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
return
var/leg_check = IGNORE_USER_LOC_CHANGE
if (istype(limb_to_detach, /obj/item/bodypart/leg))
leg_check = null
siliconOpossum marked this conversation as resolved.
Show resolved Hide resolved

cast_on.balloon_alert(cast_on, "detaching limb...")
playsound(cast_on, 'sound/items/rped.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
cast_on.visible_message(span_notice("[cast_on] shuffles [cast_on.p_their()] [limb_to_detach.name] forward, actuators hissing and whirring as [cast_on.p_they()] disengage[cast_on.p_s()] the limb from its mount..."))

if(do_after(cast_on, 1 SECONDS, timed_action_flags = leg_check, extra_checks = CALLBACK(src, PROC_REF(detaching_check), cast_on)))
StartCooldown()
cast_on.visible_message(span_notice("With a gentle twist, [cast_on] finally pries [cast_on.p_their()] [limb_to_detach.name] free from its socket."))
limb_to_detach.drop_limb()
cast_on.put_in_hands(limb_to_detach)
cast_on.balloon_alert(cast_on, "limb detached!")
if(prob(5))
playsound(cast_on, 'sound/items/champagne_pop.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
else
playsound(cast_on, 'sound/items/deconstruct.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
else
cast_on.balloon_alert(cast_on, "interrupted!")
playsound(cast_on, 'sound/machines/buzz-sigh.ogg', 25, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
siliconOpossum marked this conversation as resolved.
Show resolved Hide resolved
limb_to_detach = null
siliconOpossum marked this conversation as resolved.
Show resolved Hide resolved
siliconOpossum marked this conversation as resolved.
Show resolved Hide resolved
Loading