Skip to content

Commit

Permalink
Living Flesh limbs won't try to grab underfloor objects (tgstation#87736
Browse files Browse the repository at this point in the history
)

## About The Pull Request

There were checks in living limbs that were checking the wrong thing, at
least one of which was introduced by a feature change in a PR I merged
but didn't notice.
Notably:
- We were checking if the person with the limb was invisible, not the
thing they were trying to touch.
- We were checking if the person with the limb was anchored, not the
thing they were trying to grab.

Now your arm will no longer reach out and grab wires that are under the
floor.

Additionally to this:
- I made all of the output say "Your left arm" or "Your left leg"
instead of "Your flesh left leg" because it sounded stupid.
- I removed an unused argument from `can_be_pulled` because it was
confusing me when I looked at the proc.
- I reworded some of the user feedback messages because "the thing
pretending to be your left arm feels funny" just isn't very evocative.

The diff is long because I reversed the order of arm/leg operations
because the leg block is much smaller :clueless:

## Why It's Good For The Game

Fixes bug.
I like it more.

## Changelog

🆑
fix: Living Limbs no longer try to grab things that are under the floor.
spellcheck: Living Limb feedback messages now don't redundantly specify
that they are flesh arms.
/🆑

---------

Co-authored-by: Ghom <[email protected]>
  • Loading branch information
Jacquerel and Ghommie authored Nov 8, 2024
1 parent 7c9da8c commit 4664b63
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 42 deletions.
2 changes: 1 addition & 1 deletion code/datums/components/wormborn.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
/mob/living/basic/wizard_worm/has_gravity(turf/gravity_turf)
return TRUE

/mob/living/basic/wizard_worm/can_be_pulled()
/mob/living/basic/wizard_worm/can_be_pulled(user, force)
return FALSE

/mob/living/basic/wizard_worm/Initialize(mapload, spawn_bodyparts = TRUE)
Expand Down
4 changes: 2 additions & 2 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
/atom/movable/proc/start_pulling(atom/movable/pulled_atom, state, force = move_force, supress_message = FALSE)
if(QDELETED(pulled_atom))
return FALSE
if(!(pulled_atom.can_be_pulled(src, state, force)))
if(!(pulled_atom.can_be_pulled(src, force)))
return FALSE

// If we're pulling something then drop what we're currently pulling and pull this instead.
Expand Down Expand Up @@ -1643,7 +1643,7 @@
/atom/movable/proc/get_cell(atom/movable/interface, mob/user)
return

/atom/movable/proc/can_be_pulled(user, grab_state, force)
/atom/movable/proc/can_be_pulled(user, force)
if(src == user || !isturf(loc))
return FALSE
if(SEND_SIGNAL(src, COMSIG_ATOM_CAN_BE_PULLED, user) & COMSIG_ATOM_CANT_PULL)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@
if(istype(mover) && (mover.pass_flags & PASSGLASS))
return !opacity

/obj/structure/fluff/airlock_filler/can_be_pulled(user, grab_state, force)
/obj/structure/fluff/airlock_filler/can_be_pulled(user, force)
return FALSE

/obj/structure/fluff/airlock_filler/singularity_act()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/theft_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
/obj/item/nuke_core/supermatter_sliver/attack_tk(mob/user) // no TK dusting memes
return

/obj/item/nuke_core/supermatter_sliver/can_be_pulled(user) // no drag memes
/obj/item/nuke_core/supermatter_sliver/can_be_pulled(user, force) // no drag memes
return FALSE

/obj/item/nuke_core/supermatter_sliver/attackby(obj/item/W, mob/living/user, params)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/basic/heretic/flesh_worm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
/mob/living/basic/heretic_summon/armsy/has_gravity(turf/gravity_turf)
return TRUE

/mob/living/basic/heretic_summon/armsy/can_be_pulled()
/mob/living/basic/heretic_summon/armsy/can_be_pulled(user, force)
return FALSE // The component does this but not on the head. We don't want the head to be pulled either.

/mob/living/basic/heretic_summon/armsy/proc/build_tail(worm_length)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/basic/pets/orbie/orbie.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
happy_state = !happy_state
update_appearance()

/mob/living/basic/orbie/can_be_pulled(user, grab_state, force)
/mob/living/basic/orbie/can_be_pulled(user, force)
return FALSE

/mob/living/basic/orbie/proc/on_level_up(datum/source, new_level)
Expand Down
72 changes: 40 additions & 32 deletions code/modules/mob/living/basic/ruin_defender/flesh.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/// Chance per second to print a warning text
#define LIVING_FLESH_WARN_CHANCE 3
/// Chance per second to perform an unwanted interaction
#define LIVING_FLESH_INTERFERENCE_CHANCE 1.5
/// Chance to caress instead of grab something nearby without combat mode
#define LIVING_FLESH_TOUCH_CHANCE 30
/// Chance to punch instead of grab something nearby in combat mode
#define LIVING_FLESH_COMBAT_TOUCH_CHANCE 70

/datum/ai_controller/basic_controller/living_limb_flesh
Expand Down Expand Up @@ -59,47 +65,47 @@
if(isnull(current_bodypart) || isnull(current_bodypart.owner))
return
var/mob/living/carbon/human/victim = current_bodypart.owner
if(SPT_PROB(3, SSMOBS_DT))
to_chat(victim, span_warning("The thing posing as your limb makes you feel funny...")) //warn em
//firstly as a sideeffect we drain nutrition from our host
if(SPT_PROB(LIVING_FLESH_WARN_CHANCE, SSMOBS_DT))
to_chat(victim, span_warning("The skin on your [current_bodypart.plaintext_zone] crawls."))

victim.adjust_nutrition(-1.5)

if(!SPT_PROB(1.5, SSMOBS_DT))
if(!SPT_PROB(LIVING_FLESH_INTERFERENCE_CHANCE, SSMOBS_DT))
return

if(istype(current_bodypart, /obj/item/bodypart/arm))
var/list/candidates = list()
for(var/atom/movable/movable in orange(victim, 1))
if(movable == victim)
continue
if(!victim.CanReach(movable) || victim.invisibility)
continue
candidates += movable
if(!length(candidates))
return
var/atom/movable/candidate = pick(candidates)
if(isnull(candidate))
return

victim.visible_message(span_warning("[victim]'s [current_bodypart.name] instinctively starts feeling [candidate]!"))
if (!victim.anchored && !prob(victim.combat_mode ? LIVING_FLESH_COMBAT_TOUCH_CHANCE : LIVING_FLESH_TOUCH_CHANCE))
INVOKE_ASYNC(victim, TYPE_PROC_REF(/atom/movable, start_pulling), candidate, supress_message = TRUE)
if(istype(current_bodypart, /obj/item/bodypart/leg))
if(HAS_TRAIT(victim, TRAIT_IMMOBILIZED))
return
step(victim, pick(GLOB.cardinals))
to_chat(victim, span_warning("Your [current_bodypart.plaintext_zone] moves on its own!"))
return

var/active_hand = victim.active_hand_index
var/new_index = (current_bodypart.body_zone == BODY_ZONE_L_ARM) ? LEFT_HANDS : RIGHT_HANDS
if (active_hand != new_index)
victim.swap_hand(new_index, TRUE)
victim.resolve_unarmed_attack(candidate)
if (active_hand != victim.active_hand_index) // Different check in case we failed to swap hands previously due to holding a bulky item
victim.swap_hand(active_hand, TRUE)
var/list/candidates = list()
for(var/atom/movable/movable in orange(victim, 1))
if(movable == victim)
continue
if(!victim.CanReach(movable) || movable.invisibility > victim.see_invisible)
continue
candidates += movable
if(!length(candidates))
return
var/atom/movable/candidate = pick(candidates)
if(isnull(candidate))
return

if(HAS_TRAIT(victim, TRAIT_IMMOBILIZED))
if (!prob(victim.combat_mode ? LIVING_FLESH_COMBAT_TOUCH_CHANCE : LIVING_FLESH_TOUCH_CHANCE) && candidate.can_be_pulled(user = victim, force = victim.pull_force))
victim.visible_message(span_warning("[victim]'s [current_bodypart.plaintext_zone] suddenly fastens around [candidate]!"))
INVOKE_ASYNC(victim, TYPE_PROC_REF(/atom/movable, start_pulling), candidate, supress_message = TRUE)
return
step(victim, pick(GLOB.cardinals))
to_chat(victim, span_warning("Your [current_bodypart] moves on its own!"))

victim.visible_message(span_warning("[victim]'s [current_bodypart.plaintext_zone] suddenly spasms towards [candidate]!"))
var/active_hand = victim.active_hand_index
var/new_index = (current_bodypart.body_zone == BODY_ZONE_L_ARM) ? LEFT_HANDS : RIGHT_HANDS
if (active_hand != new_index)
victim.swap_hand(new_index, TRUE)
victim.resolve_unarmed_attack(candidate)
if (active_hand != victim.active_hand_index) // Different check in case we failed to swap hands previously due to holding a bulky item
victim.swap_hand(active_hand, TRUE)

/mob/living/basic/living_limb_flesh/melee_attack(mob/living/carbon/human/target, list/modifiers, ignore_cooldown)
. = ..()
Expand Down Expand Up @@ -157,7 +163,7 @@
if(!detach_self())
return
var/turf/our_location = get_turf(src)
our_location.visible_message(span_warning("[part_owner][part_owner.p_s()] [current_bodypart] begins to convulse wildly!"))
our_location.visible_message(span_warning("[part_owner][part_owner.p_s()] [current_bodypart.plaintext_zone] begins to convulse wildly!"))

/mob/living/basic/living_limb_flesh/proc/owner_died(datum/source, gibbed)
SIGNAL_HANDLER
Expand Down Expand Up @@ -200,3 +206,5 @@

#undef LIVING_FLESH_TOUCH_CHANCE
#undef LIVING_FLESH_COMBAT_TOUCH_CHANCE
#undef LIVING_FLESH_WARN_CHANCE
#undef LIVING_FLESH_INTERFERENCE_CHANCE
4 changes: 2 additions & 2 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
/mob/living/start_pulling(atom/movable/AM, state, force = pull_force, supress_message = FALSE)
if(!AM || !src)
return FALSE
if(!(AM.can_be_pulled(src, state, force)))
if(!(AM.can_be_pulled(src, force)))
return FALSE
if(throwing || !(mobility_flags & MOBILITY_PULL))
return FALSE
Expand Down Expand Up @@ -1890,7 +1890,7 @@ GLOBAL_LIST_EMPTY(fire_appearances)
"[C] leaps out of [src]'s way!")))
C.Paralyze(40)

/mob/living/can_be_pulled()
/mob/living/can_be_pulled(user, force)
return ..() && !(buckled?.buckle_prevents_pull)


Expand Down
2 changes: 1 addition & 1 deletion code/modules/religion/religion_structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
new /obj/effect/decal/cleanable/ash(drop_location())
qdel(src)

/obj/item/ritual_totem/can_be_pulled(user, grab_state, force)
/obj/item/ritual_totem/can_be_pulled(user, force)
. = ..()
return FALSE //no

Expand Down

0 comments on commit 4664b63

Please sign in to comment.