Skip to content

Commit

Permalink
add/refactor: Hands Blocked Trait (#4977)
Browse files Browse the repository at this point in the history
Hands Blocked Trait
  • Loading branch information
Gottfrei authored May 11, 2024
1 parent b857b31 commit 8fbecaf
Show file tree
Hide file tree
Showing 258 changed files with 1,203 additions and 1,079 deletions.
7 changes: 5 additions & 2 deletions code/__DEFINES/alerts.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/** Environment related */
#define ALERT_GRAVITY "gravity"

#define ALERT_BUCKLED "buckled"

#define ALERT_GHOST_NEST "ghost_nest"

/** Mob related */
#define ALERT_BUCKLED "buckled"
#define ALERT_HANDCUFFED "handcuffed"
#define ALERT_LEGCUFFED "legcuffed"

2 changes: 2 additions & 0 deletions code/__DEFINES/traits/sources.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@

/// Trait associated to being cuffed
#define HANDCUFFED_TRAIT "handcuffed_trait"
/// trait associated to not having fine manipulation appendages such as hands
#define LACKING_MANIPULATION_APPENDAGES_TRAIT "lacking-manipulation-appengades"
/// Trait associated to wearing a suit
#define SUIT_TRAIT "suit_trait"
/// Trait associated to lying down (having a [lying_angle] of a different value than zero).
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
|| (!(timed_action_flags & IGNORE_WEAKENED) && user.IsWeakened()) \
|| (!(timed_action_flags & IGNORE_PARALYZED) && user.IsParalyzed()) \
|| (!(timed_action_flags & IGNORE_LYING) && user.IsLying()) \
|| (!(timed_action_flags & IGNORE_RESTRAINED) && user.restrained()) \
|| (!(timed_action_flags & IGNORE_RESTRAINED) && HAS_TRAIT(user, TRAIT_RESTRAINED)) \
|| (gripper_check && gripper?.isEmpty()) \
|| extra_checks?.Invoke())
. = FALSE
Expand Down
10 changes: 1 addition & 9 deletions code/_onclick/ai.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/*
AI ClickOn()
Note currently ai restrained() returns 0 in all cases,
therefore restrained code has been removed
The AI can double click to move the camera (this was already true but is cleaner),
or double click a mob to track them.
Expand Down Expand Up @@ -97,12 +94,7 @@
set_waypoint(A)
waypoint_mode = 0
return
/*
AI restrained() currently does nothing
if(restrained())
RestrainedClickOn(A)
else
*/

A.add_hiddenprint(src)
A.attack_ai(src)

Expand Down
6 changes: 3 additions & 3 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
var/obj/mecha/M = loc
return M.click_action(A, src, params)

if(restrained())
if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED))
changeNext_move(CLICK_CD_HANDCUFFED) //Doing shit in cuffs shall be vey slow
RestrainedClickOn(A)
return
Expand Down Expand Up @@ -223,10 +223,10 @@
proximity_flag is not currently passed to attack_hand, and is instead used
in human click code to allow glove touches only at melee range.
*/
/mob/proc/UnarmedAttack(var/atom/A, var/proximity_flag)
/mob/proc/UnarmedAttack(atom/A, proximity_flag)
if(ismob(A))
changeNext_move(CLICK_CD_MELEE)
return


/*
Ranged unarmed attack:
Expand Down
13 changes: 6 additions & 7 deletions code/_onclick/cyborg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@
to_chat(src, "<span class='userdanger'>Your camera isn't functional.</span>")
return

/*
cyborg restrained() currently does nothing
if(restrained())
RestrainedClickOn(A)
return
*/

var/obj/item/W = get_active_hand()

// Cyborgs have no range-checking unless there is item use
Expand All @@ -75,6 +68,10 @@
A.attack_robot(src)
return

//if your "hands" are blocked you shouldn't be able to use modules
if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED))
return

// buckled cannot prevent machine interlinking but stops arm movement
if( buckled )
return
Expand Down Expand Up @@ -196,6 +193,8 @@
change attack_robot() above to the proper function
*/
/mob/living/silicon/robot/UnarmedAttack(atom/A)
if(!can_unarmed_attack())
return
A.attack_robot(src)

/mob/living/silicon/robot/RangedAttack(atom/A, params)
Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@


/obj/screen/storage/MouseDrop_T(obj/item/I, mob/user, params)
if(!user || !istype(I) || user.incapacitated(ignore_restraints = TRUE, ignore_lying = TRUE) || ismecha(user.loc) || !master)
if(!user || !master || !istype(I) || user.incapacitated(ignore_restraints = TRUE, ignore_lying = TRUE) || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || ismecha(user.loc))
return FALSE

if(is_ventcrawling(user))
Expand Down Expand Up @@ -529,7 +529,7 @@

/obj/screen/inventory/MouseDrop_T(obj/item/I, mob/user, params)

if(!user || !istype(I) || user.incapacitated() || ismecha(user.loc) || is_ventcrawling(user))
if(!user || !istype(I) || user.incapacitated() || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED) || ismecha(user.loc) || is_ventcrawling(user))
return FALSE

if(isalien(user) && !I.allowed_for_alien()) // We need to do this here
Expand Down
60 changes: 51 additions & 9 deletions code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
Otherwise pretty standard.
*/
/mob/living/carbon/human/UnarmedAttack(atom/A, proximity)
/mob/living/carbon/human/UnarmedAttack(atom/A, proximity_flag)
if(!can_unarmed_attack())
return

// Special glove functions:
// If the gloves do anything, have them return 1 to stop
// normal attack_hand() here.
var/obj/item/clothing/gloves/G = gloves // not typecast specifically enough in defines
if(proximity && istype(G) && G.Touch(A, 1))
if(proximity_flag && istype(G) && G.Touch(A, proximity_flag))
return


Expand Down Expand Up @@ -61,27 +64,60 @@
if(isturf(A) && get_dist(src, A) <= 1)
Move_Pulled(A)


/**
* Checks if this mob is in a valid state to punch someone.
*
* (Potentially) gives feedback to the mob if they cannot.
*/
/mob/living/proc/can_unarmed_attack()
return !HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)


/mob/living/carbon/human/can_unarmed_attack()
. = ..()
if(!.)
return FALSE

if(!get_active_hand()) //can't attack without a hand.
var/obj/item/organ/external/limb = get_organ(hand ? BODY_ZONE_PRECISE_L_HAND : BODY_ZONE_PRECISE_R_HAND)
if(!limb)
to_chat(src, span_warning("You look at your arm and sigh."))
return FALSE
if(!limb.is_usable())
to_chat(src, span_warning("Your [limb.name] is in no condition to be used."))
return FALSE

return TRUE


/*
Animals & All Unspecified
*/
/mob/living/UnarmedAttack(var/atom/A)
/mob/living/UnarmedAttack(atom/A, proximity_flag)
if(!can_unarmed_attack())
return
A.attack_animal(src)

/mob/living/simple_animal/hostile/UnarmedAttack(var/atom/A)
/mob/living/simple_animal/hostile/UnarmedAttack(atom/A, proximity_flag)
if(!can_unarmed_attack())
return
target = A
AttackingTarget()

/atom/proc/attack_animal(mob/user)
return

/mob/living/RestrainedClickOn(var/atom/A)
/mob/living/RestrainedClickOn(atom/A)
return

/*
Aliens
Defaults to same as monkey in most places
*/
/mob/living/carbon/alien/UnarmedAttack(atom/A)
/mob/living/carbon/alien/UnarmedAttack(atom/A, proximity_flag)
if(!can_unarmed_attack())
return
A.attack_alien(src)

/atom/proc/attack_alien(mob/living/carbon/alien/user)
Expand All @@ -91,7 +127,9 @@
return

// Babby aliens
/mob/living/carbon/alien/larva/UnarmedAttack(atom/A)
/mob/living/carbon/alien/larva/UnarmedAttack(atom/A, proximity_flag)
if(!can_unarmed_attack())
return
A.attack_larva(src)

/atom/proc/attack_larva(mob/user)
Expand All @@ -101,7 +139,9 @@
Slimes
Nothing happening here
*/
/mob/living/simple_animal/slime/UnarmedAttack(atom/A)
/mob/living/simple_animal/slime/UnarmedAttack(atom/A, proximity_flag)
if(!can_unarmed_attack())
return
A.attack_slime(src)

/atom/proc/attack_slime(mob/user)
Expand All @@ -117,6 +157,8 @@
/mob/new_player/ClickOn()
return


// pAIs are not intended to interact with anything in the world
/mob/living/silicon/pai/UnarmedAttack(var/atom/A)
/mob/living/silicon/pai/UnarmedAttack(atom/A, proximity_flag)
return

2 changes: 1 addition & 1 deletion code/controllers/subsystem/afk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SUBSYSTEM_DEF(afk)
// Only players and players with the AFK watch enabled
// No dead, unconcious, restrained, people without jobs or people on other Z levels than the station
if(!H.client || !(H.client.prefs.toggles2 & PREFTOGGLE_2_AFKWATCH) || !H.mind || \
H.stat || H.restrained() || !H.job || !is_station_level((T = get_turf(H)).z)) // Assign the turf as last. Small optimization
H.stat || HAS_TRAIT(H, TRAIT_RESTRAINED) || !H.job || !is_station_level((T = get_turf(H)).z)) // Assign the turf as last. Small optimization
if(afk_players[H.ckey])
toRemove += H.ckey
continue
Expand Down
25 changes: 20 additions & 5 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@
return FALSE
Remove(owner)
owner = user
user.actions += src
owner.actions += src

if(user.client)
user.client.screen += button
if(owner.client)
owner.client.screen += button
button.locked = TRUE
user.update_action_buttons()
owner.update_action_buttons()

if(check_flags & AB_CHECK_HANDS_BLOCKED)
RegisterSignal(owner, list(SIGNAL_ADDTRAIT(TRAIT_HANDS_BLOCKED), SIGNAL_REMOVETRAIT(TRAIT_HANDS_BLOCKED)), PROC_REF(update_status_on_signal))

return TRUE

Expand All @@ -60,9 +63,21 @@
user.actions -= src
user.update_action_buttons()

// Clean up our check_flag signals
UnregisterSignal(user, list(
SIGNAL_ADDTRAIT(TRAIT_HANDS_BLOCKED),
SIGNAL_REMOVETRAIT(TRAIT_HANDS_BLOCKED),
))

return TRUE


/// A general use signal proc that reacts to an event and updates JUST our button
/datum/action/proc/update_status_on_signal(datum/source, new_stat, old_stat)
SIGNAL_HANDLER
UpdateButtonIcon()


/datum/action/proc/Trigger(left_click = TRUE)
if(!IsAvailable())
return FALSE
Expand Down Expand Up @@ -101,7 +116,7 @@
return FALSE
var/owner_is_living = isliving(owner)
var/mob/living/living_owner = owner
if((check_flags & AB_CHECK_HANDS_BLOCKED) && owner.restrained())
if((check_flags & AB_CHECK_HANDS_BLOCKED) && HAS_TRAIT(owner, TRAIT_HANDS_BLOCKED))
return FALSE
if((check_flags & AB_CHECK_IMMOBILE) && owner_is_living && living_owner.IsImmobilized())
return FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Uncontrollable Aggression
aggressor.say(pick("ААААААААААА!!!!", "ГРРР!!!", "СУКА!! БЛЯТЬ!!!", "ЁБАНЫЕ ГОВНЮКИ!!", "ВАААААААГХХ!!"))

if(A.stage >= 5 && prob(50))
if(aggressor.incapacitated())
if(aggressor.incapacitated() || HAS_TRAIT(aggressor, TRAIT_HANDS_BLOCKED))
aggressor.visible_message(span_danger("[aggressor] spasms and twitches!"))
return
aggressor.visible_message(span_danger("[aggressor] thrashes around violently!"))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/emote/emote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
if(HAS_TRAIT(user, TRAIT_FAKEDEATH))
// Don't let people blow their cover by mistake
return FALSE
if(hands_use_check && !user.can_use_hands() && iscarbon(user))
if(hands_use_check && HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
if(!intentional)
return FALSE
to_chat(user, span_warning("You cannot use your hands to [key] right now!"))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/spells/alien_spells/corrosive_acid_spit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
if(target == user)
return ..()

if(!proximity || isalien(target) || !iscarbon(user) || user.incapacitated()) // Don't want xenos ditching out of cuffs
if(!proximity || isalien(target) || !iscarbon(user) || user.incapacitated() || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED)) // Don't want xenos ditching out of cuffs
return

if(!plasma_check(plasma_cost, user))
Expand Down
6 changes: 5 additions & 1 deletion code/datums/spells/alien_spells/transfer_plasma.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@


/obj/effect/proc_holder/spell/touch/alien_spell/transfer_plasma/Click(mob/living/carbon/user = usr)
if(HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
to_chat(user, span_warning("You can't control your hands!"))
return

if(attached_hand)
return ..()

Expand Down Expand Up @@ -62,7 +66,7 @@
if(target == user)
return ..()

if(!proximity || !isalien(target) || !iscarbon(user) || user.incapacitated())
if(!proximity || !isalien(target) || !iscarbon(user) || user.incapacitated() || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
return

var/mob/living/carbon/transfering_to = target
Expand Down
2 changes: 1 addition & 1 deletion code/datums/spells/banana_touch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


/obj/item/melee/touch_attack/banana/afterattack(atom/target, mob/living/carbon/user, proximity)
if(!proximity || target == user || !ishuman(target) || !iscarbon(user) || user.incapacitated())
if(!proximity || target == user || !ishuman(target) || !iscarbon(user) || user.incapacitated() || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
return

var/datum/effect_system/smoke_spread/smoke = new
Expand Down
2 changes: 1 addition & 1 deletion code/datums/spells/lavaland_spells/healtouch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
var/heal_self = FALSE

/obj/item/melee/touch_attack/healtouch/afterattack(atom/target, mob/living/carbon/user, proximity)
if(!proximity || (target == user && !heal_self) || !ismob(target) || !iscarbon(user) || user.incapacitated())
if(!proximity || (target == user && !heal_self) || !ismob(target) || !iscarbon(user) || user.incapacitated() || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
return
var/mob/living/M = target
new /obj/effect/temp_visual/heal(get_turf(M), "#899d39")
Expand Down
2 changes: 1 addition & 1 deletion code/datums/spells/mime_malaise.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/obj/item/melee/touch_attack/mime_malaise/afterattack(atom/target, mob/living/carbon/user, proximity)
if(!proximity || target == user || !ishuman(target) || !iscarbon(user) || user.incapacitated())
if(!proximity || target == user || !ishuman(target) || !iscarbon(user) || user.incapacitated() || HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
return

var/datum/effect_system/smoke_spread/s = new
Expand Down
3 changes: 3 additions & 0 deletions code/datums/spells/touch_attacks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@


/obj/effect/proc_holder/spell/touch/Click(mob/user = usr)
if(HAS_TRAIT(user, TRAIT_HANDS_BLOCKED))
to_chat(user, span_warning("You can't control your hands!!"))
return FALSE
if(attached_hand)
discharge_hand(user, TRUE)
return FALSE
Expand Down
Loading

0 comments on commit 8fbecaf

Please sign in to comment.