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

Finishes the Mobility Refactor #10083

Merged
merged 16 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
1 change: 1 addition & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
#include "code\__DEFINES\language.dm"
#include "code\__DEFINES\layers.dm"
#include "code\__DEFINES\lighting.dm"
#include "code\__DEFINES\living.dm"
#include "code\__DEFINES\logging.dm"
#include "code\__DEFINES\machines.dm"
#include "code\__DEFINES\magic.dm"
Expand Down
21 changes: 14 additions & 7 deletions code/__DEFINES/dcs/signals/signals_mob/signals_living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,20 @@
#define COMSIG_LIVING_HANDLE_BREATHING "living_handle_breathing"

//ALL OF THESE DO NOT TAKE INTO ACCOUNT WHETHER AMOUNT IS 0 OR LOWER AND ARE SENT REGARDLESS!
#define COMSIG_LIVING_STATUS_STUN "living_stun" //! from base of mob/living/Stun() (amount, update, ignore)
#define COMSIG_LIVING_STATUS_KNOCKDOWN "living_knockdown" //! from base of mob/living/Knockdown() (amount, update, ignore)
#define COMSIG_LIVING_STATUS_PARALYZE "living_paralyze" //! from base of mob/living/Paralyze() (amount, update, ignore)
#define COMSIG_LIVING_STATUS_IMMOBILIZE "living_immobilize" //! from base of mob/living/Immobilize() (amount, update, ignore)
#define COMSIG_LIVING_STATUS_UNCONSCIOUS "living_unconscious" //! from base of mob/living/Unconscious() (amount, update, ignore)
#define COMSIG_LIVING_STATUS_SLEEP "living_sleeping" //! from base of mob/living/Sleeping() (amount, update, ignore)
#define COMPONENT_NO_STUN 1 //For all of them

///from base of mob/living/Stun() (amount, ignore_canstun)
#define COMSIG_LIVING_STATUS_STUN "living_stun"
///from base of mob/living/Knockdown() (amount, ignore_canstun)
#define COMSIG_LIVING_STATUS_KNOCKDOWN "living_knockdown"
///from base of mob/living/Paralyze() (amount, ignore_canstun)
#define COMSIG_LIVING_STATUS_PARALYZE "living_paralyze"
///from base of mob/living/Immobilize() (amount, ignore_canstun)
#define COMSIG_LIVING_STATUS_IMMOBILIZE "living_immobilize"
///from base of mob/living/Unconscious() (amount, ignore_canstun)
#define COMSIG_LIVING_STATUS_UNCONSCIOUS "living_unconscious"
///from base of mob/living/Sleeping() (amount, ignore_canstun)
#define COMSIG_LIVING_STATUS_SLEEP "living_sleeping"
#define COMPONENT_NO_STUN (1<<0) //For all of them

#define COMSIG_LIVING_ENTER_STASIS "living_enter_stasis" //! sent when a mob is put into stasis.
#define COMSIG_LIVING_EXIT_STASIS "living_exit_stasis" //! sent when a mob exits stasis.
Expand Down
1 change: 0 additions & 1 deletion code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
#define MOBILITY_PULL (1<<6) //! can pull things

#define MOBILITY_FLAGS_DEFAULT (MOBILITY_MOVE | MOBILITY_STAND | MOBILITY_PICKUP | MOBILITY_USE | MOBILITY_UI | MOBILITY_STORAGE | MOBILITY_PULL)
#define MOBILITY_FLAGS_INTERACTION (MOBILITY_USE | MOBILITY_PICKUP | MOBILITY_UI | MOBILITY_STORAGE)

// radiation
#define RAD_PROTECT_CONTENTS (1<<0)
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/living.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// living_flags
/// Simple mob trait, indicating it may follow continuous move actions controlled by code instead of by user input.
#define MOVES_ON_ITS_OWN (1<<0)
17 changes: 13 additions & 4 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@
#define BODYTYPE_DIGITIGRADE (1<<4) //Cancer
#define NUMBER_OF_BODYTYPES 5 //KEEP THIS UPDATED OR SHIT WILL BREAK

#define BODYPART_NOT_DISABLED 0
#define BODYPART_DISABLED_DAMAGE 1
#define BODYPART_DISABLED_PARALYSIS 2

#define DEFAULT_BODYPART_ICON_ORGANIC 'icons/mob/human_parts_greyscale.dmi'
#define DEFAULT_BODYPART_ICON_ROBOTIC 'icons/mob/augmentation/augments.dmi'

Expand Down Expand Up @@ -299,6 +295,10 @@ GLOBAL_LIST_INIT(available_random_trauma_list, list(
#define SENTIENCE_BOSS 5

//Mob AI Status
#define POWER_RESTORATION_OFF 0
#define POWER_RESTORATION_START 1
#define POWER_RESTORATION_SEARCH_APC 2
#define POWER_RESTORATION_APC_FOUND 3

//Hostile simple animals
//If you add a new status, be sure to add a list for it to the simple_animals global in _globalvars/lists/mobs.dm
Expand Down Expand Up @@ -573,3 +573,12 @@ GLOBAL_LIST_INIT(available_random_trauma_list, list(

/// Returns whether or not the given mob can succumb
#define CAN_SUCCUMB(target) (HAS_TRAIT(target, TRAIT_CRITICAL_CONDITION) && !HAS_TRAIT(target, TRAIT_NODEATH))

/// Possible value of [/atom/movable/buckle_lying]. If set to a different (positive-or-zero) value than this, the buckling thing will force a lying angle on the buckled.
#define NO_BUCKLE_LYING -1

// Body position defines.
/// Mob is standing up, usually associated with lying_angle value of 0.
#define STANDING_UP 0
/// Mob is lying down, usually associated with lying_angle values of 90 or 270.
#define LYING_DOWN 1
23 changes: 19 additions & 4 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_FORCED_STANDING "forcedstanding"
/// Prevents usage of manipulation appendages (picking, holding or using items, manipulating storage).
#define TRAIT_HANDS_BLOCKED "handsblocked"
/* All to replace update_mobility with traits
/// Inability to access UI hud elements. Turned into a trait from [MOBILITY_UI] to be able to track sources.
#define TRAIT_UI_BLOCKED "uiblocked"
/// Inability to pull things. Turned into a trait from [MOBILITY_PULL] to be able to track sources.
#define TRAIT_PULL_BLOCKED "pullblocked"
*/
/// Abstract condition that prevents movement if being pulled and might be resisted against. Handcuffs and straight jackets, basically.
#define TRAIT_RESTRAINED "restrained"
#define TRAIT_INCAPACITATED "incapacitated"
Expand Down Expand Up @@ -280,11 +278,13 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_MADNESS_IMMUNE "supermatter_madness_immune"

//non-mob traits
//Used for limb-based paralysis, where replacing the limb will fix it
/// Used for limb-based paralysis, where replacing the limb will fix it.
#define TRAIT_PARALYSIS "paralysis"
/// Used for limbs.
#define TRAIT_DISABLED_BY_WOUND "disabled-by-wound"

///Used for managing KEEP_TOGETHER in [appearance_flags]
#define TRAIT_KEEP_TOGETHER "keep-together"
#define TRAIT_KEEP_TOGETHER "keep-together"

#define TRAIT_HEARING_SENSITIVE "hearing_sensitive"

Expand Down Expand Up @@ -391,6 +391,10 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define STAT_TRAIT "stat"
/// Trait associated to wearing a suit
#define SUIT_TRAIT "suit"
/// Trait associated to lying down (having a [lying_angle] of a different value than zero).
#define LYING_DOWN_TRAIT "lying-down"
/// Trait associated to lacking electrical power.
#define POWER_LACK_TRAIT "power-lack"
#define GLASSES_TRAIT "glasses"
#define CURSE_TRAIT "eldritch"
#define STATION_TRAIT "station-trait"
Expand Down Expand Up @@ -455,10 +459,21 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define BUSY_FLOORBOT_TRAIT "busy-floorbot"
#define PULLED_WHILE_SOFTCRIT_TRAIT "pulled-while-softcrit"
#define LOCKED_BORG_TRAIT "locked-borg"
#define LACKING_LOCOMOTION_APPENDAGES_TRAIT "lacking-locomotion-appengades" //trait associated to not having locomotion appendages nor the ability to fly or float
#define LACKING_MANIPULATION_APPENDAGES_TRAIT "lacking-manipulation-appengades" //trait associated to not having fine manipulation appendages such as hands
#define HANDCUFFED_TRAIT "handcuffed"
/// Trait granted by [/obj/item/warpwhistle]
#define WARPWHISTLE_TRAIT "warpwhistle"
/// Trait applied by by [/datum/component/soulstoned]
#define SOULSTONE_TRAIT "soulstone"
/// Trait applied to slimes by low temperature
#define SLIME_COLD "slime-cold"
/// Trait applied to bots by being tipped over
#define BOT_TIPPED_OVER "bot-tipped-over"
/// Trait applied to PAIs by being folded
#define PAI_FOLDED "pai-folded"
/// Trait applied to brain mobs when they lack external aid for locomotion, such as being inside a mech.
#define BRAIN_UNAIDED "brain-unaided"
#define TRAIT_PRESERVE_UI_WITHOUT_CLIENT "preserve_ui_without_client" //this mob should never close ui even if it doesn't have a client
#define EXPERIMENTAL_SURGERY_TRAIT "experimental_surgery"
#define NINJA_KIDNAPPED_TRAIT "ninja_kidnapped"
Expand Down
14 changes: 13 additions & 1 deletion code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,18 @@ GLOBAL_LIST_EMPTY(species_list)
if(!HAS_TRAIT(L, TRAIT_PASSTABLE))
L.pass_flags &= ~PASSTABLE

/proc/dance_rotate(atom/movable/AM, datum/callback/callperrotate, set_original_dir=FALSE)
set waitfor = FALSE
var/originaldir = AM.dir
for(var/i in list(NORTH,SOUTH,EAST,WEST,EAST,SOUTH,NORTH,SOUTH,EAST,WEST,EAST,SOUTH))
if(!AM)
return
AM.setDir(i)
callperrotate?.Invoke()
sleep(0.1 SECONDS)
if(set_original_dir)
AM.setDir(originaldir)

//Gets the sentient mobs that are not on centcom and are alive
/proc/get_sentient_mobs()
. = list()
Expand Down Expand Up @@ -552,7 +564,7 @@ GLOBAL_LIST_EMPTY(species_list)
/*This can be used to add additional effects on interactions between mobs depending on how the mobs are facing each other, such as adding a crit damage to blows to the back of a guy's head.
Given how click code currently works (Nov '13), the initiating mob will be facing the target mob most of the time
That said, this proc should not be used if the change facing proc of the click code is overridden at the same time*/
if(!ismob(target) || !(target.mobility_flags & MOBILITY_STAND))
if(!isliving(target) || target.body_position == LYING_DOWN)
//Make sure we are not doing this for things that can't have a logical direction to the players given that the target would be on their side
return FALSE
if(initator.dir == target.dir) //mobs are facing the same direction
Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
/mob/living/changeNext_move(num)
var/mod = next_move_modifier
var/adj = next_move_adjust
for(var/i in status_effects)
var/datum/status_effect/S = i
for(var/datum/status_effect/S as anything in status_effects)
mod *= S.nextmove_modifier()
adj += S.nextmove_adjust()
next_move = world.time + ((num + adj)*mod)
Expand All @@ -41,6 +40,7 @@
/atom/Click(location,control,params)
if(flags_1 & INITIALIZED_1)
SEND_SIGNAL(src, COMSIG_CLICK, location, control, params, usr)

usr.ClickOn(src, params)

/atom/DblClick(location,control,params)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
if(!..())
return
var/mob/living/silicon/pai/pAI = usr
pAI.lay_down()
pAI.toggle_resting()

/atom/movable/screen/pai/light
name = "Toggle Integrated Lights"
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
/atom/movable/screen/rest/Click()
if(isliving(usr))
var/mob/living/L = usr
L.lay_down()
L.toggle_resting()

/atom/movable/screen/rest/update_icon_state()
var/mob/living/user = hud?.mymob
Expand Down
5 changes: 5 additions & 0 deletions code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
check_self_for_injuries()
return
if(!has_active_hand()) //can't attack without a hand.
var/obj/item/bodypart/check_arm = get_active_hand()
if(check_arm?.bodypart_disabled)
to_chat(src, "<span class='warning'>Your [check_arm.name] is in no condition to be used.</span>")
return

to_chat(src, "<span class='notice'>You look at your arm and sigh.</span>")
return

Expand Down
13 changes: 8 additions & 5 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
return FALSE
if((check_flags & AB_CHECK_LYING) && isliving(owner))
var/mob/living/action_user = owner
if(!(action_user.mobility_flags & MOBILITY_STAND))
if(action_user.body_position == LYING_DOWN)
return FALSE
if((check_flags & AB_CHECK_CONSCIOUS) && owner.stat != CONSCIOUS)
return FALSE
Expand Down Expand Up @@ -514,11 +514,14 @@
owner.put_in_hands(target_item)
target_item.attack_self(owner)
return
if(!isliving(owner))
to_chat(owner, "<span class='warning'>You lack the necessary living force for this action.</span>")
return
var/mob/living/living_owner = owner
if (living_owner.usable_hands <= 0)
to_chat(living_owner, "<span class='warning'>You dont have any usable hands!</span>")
else
if (owner.get_num_arms() <= 0)
to_chat(owner, "<span class='warning'>You don't have any usable hands!</span>")
else
to_chat(owner, "<span class='warning'>Your hands are full!</span>")
to_chat(living_owner, "<span class='warning'>Your hands are full!</span>")


///MGS BOX!
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ai/basic_mobs/basic_subtrees/speech_subtree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@

/datum/ai_planning_subtree/random_speech/mothroach
speech_chance = 2
emote_hear = list("flutters.", "flaps its wings.", "flaps its wings agressively!")
emote_hear = list("flutters.", "flaps its wings.", "flaps its wings aggressively!")
2 changes: 1 addition & 1 deletion code/datums/brain_damage/mild.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
var/fall_chance = 1
if(owner.m_intent == MOVE_INTENT_RUN)
fall_chance += 2
if(prob(fall_chance) && (owner.mobility_flags & MOBILITY_STAND))
if(prob(fall_chance) && owner.body_position == STANDING_UP)
to_chat(owner, "<span class='warning'>Your leg gives out!</span>")
owner.Paralyze(35)

Expand Down
2 changes: 0 additions & 2 deletions code/datums/brain_damage/severe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@
..()
for(var/X in paralysis_traits)
ADD_TRAIT(owner, X, "trauma_paralysis")
owner.update_disabled_bodyparts()

/datum/brain_trauma/severe/paralysis/on_lose()
..()
for(var/X in paralysis_traits)
REMOVE_TRAIT(owner, X, "trauma_paralysis")
owner.update_disabled_bodyparts()

/datum/brain_trauma/severe/paralysis/paraplegic
paralysis_type = "legs"
Expand Down
8 changes: 4 additions & 4 deletions code/datums/components/bloodysoles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
return
if(QDELETED(wielder) || is_obscured())
return
if(!(wielder.mobility_flags & MOBILITY_STAND) || !wielder.has_gravity(wielder.loc))
if(wielder.body_position == LYING_DOWN || !wielder.has_gravity(wielder.loc))
return

var/half_our_blood = bloody_shoes[last_blood_state] / 2
Expand Down Expand Up @@ -262,7 +262,7 @@
for(var/X in wielder.bodyparts)
var/obj/item/bodypart/affecting = X
if(affecting.body_part == LEG_RIGHT || affecting.body_part == LEG_LEFT)
if(!affecting.disabled)
if(!affecting.bodypart_disabled)
FP.species_types |= affecting.limb_id
break

Expand All @@ -273,13 +273,13 @@
return ITEM_SLOT_FEET in wielder.check_obscured_slots(TRUE)

/datum/component/bloodysoles/feet/on_moved(datum/source, OldLoc, Dir, Forced)
if(wielder.get_num_legs(FALSE) < 2)
if(wielder.num_legs < 2)
return

..()

/datum/component/bloodysoles/feet/on_step_blood(datum/source, obj/effect/decal/cleanable/pool)
if(wielder.get_num_legs(FALSE) < 2)
if(wielder.num_legs < 2)
return

..()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/caltrop.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
if(!(flags & CALTROP_BYPASS_SHOES) && (H.shoes || feetCover))
return

if((H.movement_type & FLYING) || !(H.mobility_flags & MOBILITY_STAND)|| H.buckled)
if((H.movement_type & FLYING) || (H.body_position == LYING_DOWN)|| H.buckled)
return

var/damage = rand(min_damage, max_damage)
Expand Down
4 changes: 2 additions & 2 deletions code/datums/components/embedded.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
if(pain_stam_pct && HAS_TRAIT_FROM(victim, TRAIT_INCAPACITATED, STAMINA)) //if it's a less-lethal embed, give them a break if they're already stamcritted
pain_chance_current *= 0.2
damage *= 0.5
else if(victim.mobility_flags & ~MOBILITY_STAND)
else if(victim.body_position == LYING_DOWN)
pain_chance_current *= 0.2

if(harmful && prob(pain_chance_current))
Expand Down Expand Up @@ -164,7 +164,7 @@

var/mob/living/carbon/victim = parent
var/chance = jostle_chance
if(victim.m_intent == MOVE_INTENT_WALK || !(victim.mobility_flags & MOBILITY_STAND))
if(victim.m_intent == MOVE_INTENT_WALK || victim.body_position == LYING_DOWN)
chance *= 0.5

if(harmful && prob(chance))
Expand Down
4 changes: 2 additions & 2 deletions code/datums/components/riding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
return override_allow_spacemove || AM.has_gravity()

/datum/component/riding/proc/account_limbs(mob/living/M)
if(M.get_num_legs() < 2 && !slowed)
if(M.usable_legs < 2 && !slowed)
vehicle_move_delay = vehicle_move_delay + slowvalue
slowed = TRUE
else if(slowed)
Expand Down Expand Up @@ -289,7 +289,7 @@
return
if(iscarbon(user))
var/mob/living/carbon/carbonuser = user
if(!carbonuser.get_num_arms())
if(!carbonuser.usable_hands)
Unbuckle(user)
to_chat(user, "<span class='userdanger'>You can't grab onto [AM] with no hands!</span>")
return
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/toggle_suit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
source.balloon_alert(user, "you're incapacitated!")
return

if(living_user.get_num_arms() <= 0)
if(living_user.usable_hands <= 0)
source.balloon_alert(user, "you don't have hands!")
return

Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/twohanded.dm
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
else
to_chat(user, "<span class='warning'>You need your other hand to be empty!</span>")
return
if(user.get_num_arms() < 2)
if(user.usable_hands < 2)
if(require_twohands)
user.dropItemToGround(parent, force=TRUE)
to_chat(user, "<span class='warning'>You don't have enough intact hands.</span>")
Expand Down
Loading
Loading