Skip to content

Commit

Permalink
Completely rewrite pulling & refactor a bit of multi-z movement (#629)
Browse files Browse the repository at this point in the history
* foundation

* refactor what i just wrote lol lmao

* saving progress

* IM DYING INSIDE

* it mf compiles

* tweaks and stuff

* make these things work without processing

* tweaks

* pain

* NICE

* LET'S GO MULTIZ MOVEMENT WORKS

* minor fix

* improvements

* bunch of work

* more grab things

* fix buckled movement

* more window slam funnies

* tweak

* Fix alot of shit

* rename release_grab

* fix lateral Z movement

* fix up defer_hand

* Fix linters

* fix tabling

* update vox test

* Struggle grab

* clean up

* oops

* fixes and tweaks

* fix minor conga interaction

* grab to reduce bleeding

* revert compile options change

* fix pull icon for real for real

* fix bugs

* Re-add recursive falling

* hubris

* fix butchering
  • Loading branch information
Kapu1178 authored Oct 9, 2023
1 parent 6ec5f78 commit 0ceb89d
Show file tree
Hide file tree
Showing 205 changed files with 3,383 additions and 3,271 deletions.
1,324 changes: 0 additions & 1,324 deletions _maps/shuttles/emergency_luxury.dmm

This file was deleted.

6 changes: 6 additions & 0 deletions code/__DEFINES/_multiz.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@

#define GetAbove(A) (HasAbove(A:z) ? get_step(A, UP) : null)
#define GetBelow(A) (HasBelow(A:z) ? get_step(A, DOWN) : null)


/// Vertical Z movement
#define ZMOVING_VERTICAL 1
/// Laterial Z movement
#define ZMOVING_LATERAL 2
2 changes: 1 addition & 1 deletion code/__DEFINES/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/// probability that the pawn should try resisting out of restraints
#define RESIST_SUBTREE_PROB 50
///macro for whether it's appropriate to resist right now, used by resist subtree
#define SHOULD_RESIST(source) (source.on_fire || source.buckled || HAS_TRAIT(source, TRAIT_RESTRAINED) || (source.pulledby && source.pulledby.grab_state > GRAB_PASSIVE))
#define SHOULD_RESIST(source) (source.on_fire || source.buckled || HAS_TRAIT(source, TRAIT_RESTRAINED) || HAS_TRAIT(source, TRAIT_AGGRESSIVE_GRAB))
///macro for whether the pawn can act, used generally to prevent some horrifying ai disasters
#define IS_DEAD_OR_INCAP(source) (source.incapacitated() || source.stat)

Expand Down
12 changes: 8 additions & 4 deletions code/__DEFINES/bodyparts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@
#define BP_CUT_AWAY (1<<10)
/// Limb cannot feel pain
#define BP_NO_PAIN (1<<11)
/// Limb can be dislocated
#define BP_CAN_BE_DISLOCATED (1<<12)
/// Limb is dislocated
#define BP_DISLOCATED (1<<13)

#define HATCH_CLOSED 1
#define HATCH_UNSCREWED 2
#define HATCH_OPENED 3

#define STOCK_BP_FLAGS_CHEST (BP_HAS_BLOOD | BP_HAS_BONES | BP_HAS_ARTERY)
#define STOCK_BP_FLAGS_HEAD (BP_HAS_BLOOD | BP_HAS_BONES | BP_HAS_ARTERY)
#define STOCK_BP_FLAGS_ARMS (BP_IS_GRABBY_LIMB | BP_HAS_BLOOD | BP_HAS_BONES | BP_HAS_TENDON | BP_HAS_ARTERY)
#define STOCK_BP_FLAGS_LEGS (BP_IS_MOVEMENT_LIMB | BP_HAS_BLOOD | BP_HAS_BONES | BP_HAS_TENDON | BP_HAS_ARTERY)
#define STOCK_BP_FLAGS_CHEST (BP_HAS_BLOOD | BP_HAS_BONES | BP_HAS_ARTERY | BP_CAN_BE_DISLOCATED)
#define STOCK_BP_FLAGS_HEAD (BP_HAS_BLOOD | BP_HAS_BONES | BP_HAS_ARTERY | BP_CAN_BE_DISLOCATED)
#define STOCK_BP_FLAGS_ARMS (BP_IS_GRABBY_LIMB | BP_HAS_BLOOD | BP_HAS_BONES | BP_HAS_TENDON | BP_HAS_ARTERY | BP_CAN_BE_DISLOCATED)
#define STOCK_BP_FLAGS_LEGS (BP_IS_MOVEMENT_LIMB | BP_HAS_BLOOD | BP_HAS_BONES | BP_HAS_TENDON | BP_HAS_ARTERY| BP_CAN_BE_DISLOCATED)

//check_bones() return values
#define CHECKBONES_NONE (1<<0)
Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

//the define for visible message range in combat
#define SAMETILE_MESSAGE_RANGE 1
#define COMBAT_MESSAGE_RANGE 3
#define COMBAT_MESSAGE_RANGE 4
#define DEFAULT_MESSAGE_RANGE 7

//Shove knockdown lengths (deciseconds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
///from base of atom/ShiftClick(): (/mob)
#define COMSIG_CLICK_SHIFT "shift_click"
#define COMPONENT_ALLOW_EXAMINATE (1<<0) //Allows the user to examinate regardless of client.eye.
///from base of atom/CtrlClickOn(): (/mob)
///from base of atom/CtrlClickOn(): (/mob, list/params)
#define COMSIG_CLICK_CTRL "ctrl_click"
///from base of atom/AltClick(): (/mob)
#define COMSIG_CLICK_ALT "alt_click"
Expand Down
31 changes: 14 additions & 17 deletions code/__DEFINES/dcs/signals/signals_atom/signals_atom_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@
// When the signal is called: (signal arguments)
// All signals send the source datum of the signal as the first argument

///signal sent out by an atom when it checks if it can be pulled, for additional checks
#define COMSIG_ATOM_CAN_BE_PULLED "movable_can_be_pulled"
#define COMSIG_ATOM_CANT_PULL (1 << 0)
///signal sent out by an atom when it checks if it can be grabbed, for additional checks
#define COMSIG_ATOM_CAN_BE_GRABBED "movable_can_be_grabbed"
#define COMSIG_ATOM_NO_GRAB (1 << 0)
///signal sent out by an atom when it is no longer being pulled by something else : (atom/puller)
#define COMSIG_ATOM_NO_LONGER_PULLED "movable_no_longer_pulled"
///signal sent out by an atom when it is no longer pulling something : (atom/pulling)
#define COMSIG_ATOM_NO_LONGER_PULLING "movable_no_longer_pulling"
#define COMSIG_ATOM_NO_LONGER_GRABBED "movable_no_longer_grabbed"
///signal sent out by a living mob when it is no longer pulling something : (atom/pulling)
#define COMSIG_LIVING_NO_LONGER_GRABBING "living_no_longer_grabbing"
///called for each movable in a turf contents on /turf/zImpact(): (atom/movable/A, levels)
#define COMSIG_ATOM_INTERCEPT_Z_FALL "movable_intercept_z_impact"
///called on a movable (NOT living) when it starts pulling (atom/movable/pulled, state, force)
#define COMSIG_ATOM_START_PULL "movable_start_pull"
///called on /living when someone starts pulling (atom/movable/pulled, state, force)
#define COMSIG_LIVING_START_PULL "living_start_pull"
///called on /living when someone is pulled (mob/living/puller)
#define COMSIG_LIVING_GET_PULLED "living_start_pulled"
///called on /living, when pull is attempted, but before it completes, from base of [/mob/living/start_pulling]: (atom/movable/thing, force)
#define COMSIG_LIVING_TRY_PULL "living_try_pull"
#define COMSIG_LIVING_CANCEL_PULL (1 << 0)
/// Called from /mob/living/update_pull_movespeed
#define COMSIG_LIVING_UPDATING_PULL_MOVESPEED "living_updating_pull_movespeed"
///called on a movable when it starts pulling (atom/movable/pulled, state, force)
#define COMSIG_LIVING_START_GRAB "movable_start_grab"
///called on a movable when it has been grabbed
#define COMSIG_ATOM_GET_GRABBED "movable_start_grabbed"
///called on /living, when a grab is attempted, but before it completes, from base of [/mob/living/make_grab]: (atom/movable/thing, grab_type)
#define COMSIG_LIVING_TRY_GRAB "living_try_pull"
#define COMSIG_LIVING_CANCEL_GRAB (1 << 0)

/// Called from /mob/living/PushAM -- Called when this mob is about to push a movable, but before it moves
/// (aotm/movable/being_pushed)
#define COMSIG_LIVING_PUSHING_MOVABLE "living_pushing_movable"
Expand Down
9 changes: 9 additions & 0 deletions code/__DEFINES/grab_defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Trait sources for grabs
#define AGGRESSIVE_GRAB "source_aggressive_grab"
#define NECK_GRAB "source_neck_grab"
#define KILL_GRAB "source_kill_grab"

/// Applied to movables that are aggressively grabbed OR HIGHER
#define TRAIT_AGGRESSIVE_GRAB "trait_aggressive_grab"
/// Applied to movables that are being strangled
#define TRAIT_KILL_GRAB "trait_strangle_grab"
3 changes: 3 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ GLOBAL_LIST_INIT(turfs_without_ground, typecacheof(list(

#define isfalsewall(A) (istype(A, /obj/structure/falsewall))

#define isgrab(A) (istype(A, /obj/item/hand_item/grab))

//Assemblies
#define isassembly(O) (istype(O, /obj/item/assembly))

Expand Down Expand Up @@ -271,3 +273,4 @@ GLOBAL_LIST_INIT(book_types, typecacheof(list(
#define is_security_officer_job(job_type) (istype(job_type, /datum/job/security_officer))
#define is_research_director_job(job_type) (istype(job_type, /datum/job/research_director))
#define is_unassigned_job(job_type) (istype(job_type, /datum/job/unassigned))

4 changes: 3 additions & 1 deletion code/__DEFINES/movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ GLOBAL_VAR_INIT(glide_size_multiplier, 1.0)
/// Used when the grip on a pulled object shouldn't be broken.
#define FALL_RETAIN_PULL (1<<3)

/// Runs check_pulling() by the end of [/atom/movable/proc/zMove] for every movable that's pulling something. Should be kept enabled unless you know what you are doing.
/// Runs recheck_grabs() by the end of [/atom/movable/proc/zMove] for every movable that's pulling something. Should be kept enabled unless you know what you are doing.
#define ZMOVE_CHECK_PULLING (1<<0)
/// Checks if pulledby is nearby. if not, stop being pulled.
#define ZMOVE_CHECK_PULLEDBY (1<<1)
Expand All @@ -79,6 +79,8 @@ GLOBAL_VAR_INIT(glide_size_multiplier, 1.0)
#define ZMOVE_INCLUDE_PULLED (1<<8)
/// Skips check for whether the moving atom is anchored or not.
#define ZMOVE_ALLOW_ANCHORED (1<<9)
/// Skip CanMoveOnto() checks
#define ZMOVE_SKIP_CANMOVEONTO (1<<10)

#define ZMOVE_CHECK_PULLS (ZMOVE_CHECK_PULLING|ZMOVE_CHECK_PULLEDBY)

Expand Down
7 changes: 4 additions & 3 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,10 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_SPRAY_PAINTABLE "spray_paintable"
/// This person is blushing
#define TRAIT_BLUSHING "blushing"

#define TRAIT_NOBLEED "nobleed" //This carbon doesn't bleed
/// This bodypart is being held in a grab, and reduces bleeding
#define TRAIT_BODYPART_GRABBED "bodypart_grabbed"
/// This carbon doesn't bleed
#define TRAIT_NOBLEED "nobleed"
/// This atom can ignore the "is on a turf" check for simple AI datum attacks, allowing them to attack from bags or lockers as long as any other conditions are met
#define TRAIT_AI_BAGATTACK "bagattack"
/// This mobs bodyparts are invisible but still clickable.
Expand Down Expand Up @@ -887,7 +889,6 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define STATION_TRAIT_UNIQUE_AI "station_trait_unique_ai"
#define STATION_TRAIT_CARP_INFESTATION "station_trait_carp_infestation"
#define STATION_TRAIT_PREMIUM_INTERNALS "station_trait_premium_internals"
#define STATION_TRAIT_RANDOM_ARRIVALS "station_trait_random_arrivals"
#define STATION_TRAIT_HANGOVER "station_trait_hangover"
#define STATION_TRAIT_FILLED_MAINT "station_trait_filled_maint"
#define STATION_TRAIT_EMPTY_MAINT "station_trait_empty_maint"
Expand Down
9 changes: 9 additions & 0 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@

GLOB.emote_list = init_emote_list()

for(var/datum/grab/G as anything in subtypesof(/datum/grab))
if(isabstract(G))
continue
GLOB.all_grabstates[G] = new G

for(var/path in GLOB.all_grabstates)
var/datum/grab/G = GLOB.all_grabstates[path]
G.refresh_updown()

init_crafting_recipes(GLOB.crafting_recipes)
init_loadout_references()
init_augment_references()
Expand Down
38 changes: 38 additions & 0 deletions code/_onclick/adjacent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,41 @@
else if( !border_only ) // dense, not on border, cannot pass over
return FALSE
return TRUE

/atom/proc/MultiZAdjacent(atom/neighbor)
var/turf/T = get_turf(src)
var/turf/N = get_turf(neighbor)

// Not on valid turfs.
if(QDELETED(src) || QDELETED(neighbor) || !istype(T) || !istype(N))
return FALSE

// On the same z-level, we don't need to care about multiz.
if(N.z == T.z)
return Adjacent(neighbor)

// More than one z-level away from each other.
if(abs(N.x - T.x) > 1 || abs(N.y - T.y) > 1 || abs(N.z - T.z) > 1)
return FALSE


// Are they below us?
if(N.z < T.z && HasBelow(T.z))
var/turf/B = GetBelow(T)
. = isopenspaceturf(T) && neighbor.Adjacent(B)
if(!.)
B = GetAbove(N)
. = isopenspaceturf(B) && src.Adjacent(B)
return


// Are they above us?
if(HasAbove(T.z))
var/turf/A = GetAbove(T)
. = isopenspaceturf(A) && neighbor.Adjacent(A)
if(!.)
A = GetBelow(N)
. = isopenspaceturf(N) && src.Adjacent(A)
return

return FALSE
2 changes: 1 addition & 1 deletion code/_onclick/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
A.AICtrlShiftClick(src)
/mob/living/silicon/ai/ShiftClickOn(atom/A)
A.AIShiftClick(src)
/mob/living/silicon/ai/CtrlClickOn(atom/A)
/mob/living/silicon/ai/CtrlClickOn(atom/A, list/params)
A.AICtrlClick(src)
/mob/living/silicon/ai/AltClickOn(atom/A)
A.AIAltClick(src)
Expand Down
20 changes: 13 additions & 7 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
AltClickOn(A)
return
if(LAZYACCESS(modifiers, CTRL_CLICK))
CtrlClickOn(A)
CtrlClickOn(A, modifiers)
return

//PARIAH EDIT ADDITION
Expand Down Expand Up @@ -351,11 +351,11 @@
* Ctrl click
* For most objects, pull
*/
/mob/proc/CtrlClickOn(atom/A)
A.CtrlClick(src)
/mob/proc/CtrlClickOn(atom/A, list/params)
A.CtrlClick(src, params)
return

/atom/proc/CtrlClick(mob/user)
/atom/proc/CtrlClick(mob/user, list/params)
SEND_SIGNAL(src, COMSIG_CLICK_CTRL, user)
SEND_SIGNAL(user, COMSIG_MOB_CTRL_CLICKED, src)
var/mob/living/ML = user
Expand All @@ -364,7 +364,7 @@
if(!can_interact(user))
return FALSE

/mob/living/CtrlClick(mob/user)
/mob/living/CtrlClick(mob/user, list/params)
if(!isliving(user) || !user.CanReach(src) || user.incapacitated())
return ..()

Expand All @@ -379,7 +379,7 @@
return ..()


/mob/living/carbon/human/CtrlClick(mob/user)
/mob/living/carbon/human/CtrlClick(mob/user, list/params)

if(!ishuman(user) || !user.CanReach(src) || user.incapacitated())
return ..()
Expand All @@ -388,7 +388,13 @@
return FALSE

var/mob/living/carbon/human/human_user = user
if(human_user.dna.species.grab(human_user, src, human_user.mind.martial_art))
// If they're wielding a grab item, do the normal click chain.
var/obj/item/hand_item/grab/G = user.get_active_held_item()
if(isgrab(G))
G.current_grab.hit_with_grab(G, src, params)
return TRUE

if(human_user.dna.species.grab(human_user, src, human_user.mind.martial_art, params))
human_user.changeNext_move(CLICK_CD_MELEE)
human_user.animate_interact(src, INTERACT_GRAB)
return TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/cyborg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
A.BorgCtrlShiftClick(src)
/mob/living/silicon/robot/ShiftClickOn(atom/A)
A.BorgShiftClick(src)
/mob/living/silicon/robot/CtrlClickOn(atom/A)
/mob/living/silicon/robot/CtrlClickOn(atom/A, list/params)
A.BorgCtrlClick(src)
/mob/living/silicon/robot/AltClickOn(atom/A)
A.BorgAltClick(src)
Expand Down
6 changes: 4 additions & 2 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,12 @@
/atom/movable/screen/pull/Click()
if(isobserver(usr))
return
usr.stop_pulling()
if(isliving(usr) && usr == hud.mymob)
var/mob/living/L = usr
L.release_all_grabs()

/atom/movable/screen/pull/update_icon_state()
icon_state = "[base_icon_state][hud?.mymob?.pulling ? null : 0]"
icon_state = "[base_icon_state][LAZYLEN(hud?.mymob?:get_active_grabs()) ? null : 0]"
return ..()

/atom/movable/screen/resist
Expand Down
13 changes: 13 additions & 0 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,16 @@

visible_message(span_danger("[attack_message_spectator]"), vision_distance = COMBAT_MESSAGE_RANGE)
return 1

/**
* Interaction handler for being clicked on with a grab. This is called regardless of user intent.
*
* **Parameters**:
* - `grab` - The grab item being used.
* - `click_params` - List of click parameters.
*
* Returns boolean to indicate whether the attack call was handled or not. If `FALSE`, the next `use_*` proc in the
* resolve chain will be called.
*/
/atom/proc/attack_grab(mob/living/user, atom/movable/victim, obj/item/hand_item/grab/grab, list/params)
return FALSE
2 changes: 1 addition & 1 deletion code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
return TRUE

if(isturf(A) && get_dist(src,A) <= 1)
Move_Pulled(A)
move_grabbed_atoms_towards(A)
return TRUE

/*
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/overmind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if(T)
rally_spores(T)

/mob/camera/blob/CtrlClickOn(atom/A) //Create a shield
/mob/camera/blob/CtrlClickOn(atom/A, list/params) //Create a shield
var/turf/T = get_turf(A)
if(T)
create_shield(T)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ai/generic/generic_behaviors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
if(get_dist(batman, big_guy) >= give_up_distance)
finish_action(controller, FALSE, target_key)

big_guy.start_pulling(batman)
big_guy.try_make_grab(batman)
big_guy.setDir(get_dir(big_guy, batman))

batman.visible_message(span_warning("[batman] gets a slightly too tight hug from [big_guy]!"), span_userdanger("You feel your body break as [big_guy] embraces you!"))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ai/idle_behaviors/idle_dog.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///Dog specific idle behavior.
/datum/idle_behavior/idle_dog/perform_idle_behavior(delta_time, datum/ai_controller/dog/controller)
var/mob/living/living_pawn = controller.pawn
if(!isturf(living_pawn.loc) || living_pawn.pulledby)
if(!isturf(living_pawn.loc) || LAZYLEN(living_pawn.grabbed_by))
return

// if we were just ordered to heel, chill out for a bit
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ai/idle_behaviors/idle_monkey.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/datum/idle_behavior/idle_monkey/perform_idle_behavior(delta_time, datum/ai_controller/controller)
var/mob/living/living_pawn = controller.pawn

if(DT_PROB(25, delta_time) && (living_pawn.mobility_flags & MOBILITY_MOVE) && isturf(living_pawn.loc) && !living_pawn.pulledby)
if(DT_PROB(25, delta_time) && (living_pawn.mobility_flags & MOBILITY_MOVE) && isturf(living_pawn.loc) && !LAZYLEN(living_pawn.grabbed_by))
var/move_dir = pick(GLOB.alldirs)
living_pawn.Move(get_step(living_pawn, move_dir), move_dir)
else if(DT_PROB(5, delta_time))
Expand Down
2 changes: 1 addition & 1 deletion code/datums/ai/idle_behaviors/idle_random_walk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
. = ..()
var/mob/living/living_pawn = controller.pawn

if(DT_PROB(walk_chance, delta_time) && (living_pawn.mobility_flags & MOBILITY_MOVE) && isturf(living_pawn.loc) && !living_pawn.pulledby)
if(DT_PROB(walk_chance, delta_time) && (living_pawn.mobility_flags & MOBILITY_MOVE) && isturf(living_pawn.loc) && !LAZYLEN(living_pawn.grabbed_by))
var/move_dir = pick(GLOB.alldirs)
living_pawn.Move(get_step(living_pawn, move_dir), move_dir)

Loading

0 comments on commit 0ceb89d

Please sign in to comment.