Grab and Drag Animations

Grab and Drag Animations, allowing players to see whos dragging who, via a pixel shift.
This commit is contained in:
QuoteFox
2020-07-02 09:58:24 +01:00
parent df2cab8aa0
commit ad898efb9e
10 changed files with 137 additions and 67 deletions
+46 -2
View File
@@ -247,7 +247,7 @@
AM.setDir(current_dir)
now_pushing = 0
/mob/living/start_pulling(atom/movable/AM, supress_message = 0)
/mob/living/start_pulling(atom/movable/AM, state, supress_message = FALSE)
if(!AM || !src)
return FALSE
if(!(AM.can_be_pulled(src)))
@@ -305,6 +305,44 @@
var/mob/living/carbon/C = L
if(HAS_TRAIT(src, TRAIT_STRONG_GRABBER))
C.grippedby(src)
set_pull_offsets(M, state)
/mob/living/proc/set_pull_offsets(mob/living/M, grab_state = GRAB_PASSIVE)
if(M.buckled)
return //don't make them change direction or offset them if they're buckled into something or in combat mode.
var/offset = 0
switch(grab_state)
if(GRAB_PASSIVE)
offset = GRAB_PIXEL_SHIFT_PASSIVE
if(GRAB_AGGRESSIVE)
offset = GRAB_PIXEL_SHIFT_AGGRESSIVE
if(GRAB_NECK)
offset = GRAB_PIXEL_SHIFT_NECK
if(GRAB_KILL)
offset = GRAB_PIXEL_SHIFT_NECK
M.setDir(get_dir(M, src))
switch(M.dir)
if(NORTH)
animate(M, pixel_x = 0, pixel_y = offset, 3)
if(SOUTH)
animate(M, pixel_x = 0, pixel_y = -offset, 3)
if(EAST)
if(M.lying == 270) //update the dragged dude's direction if we've turned
M.lying = 90
M.update_transform() //force a transformation update, otherwise it'll take a few ticks for update_mobility() to do so
M.lying_prev = M.lying
animate(M, pixel_x = offset, pixel_y = 0, 3)
if(WEST)
if(M.lying == 90)
M.lying = 270
M.update_transform()
M.lying_prev = M.lying
animate(M, pixel_x = -offset, pixel_y = 0, 3)
/mob/living/proc/reset_pull_offsets(mob/living/M, override)
if(!override && M.buckled)
return
animate(M, pixel_x = 0, pixel_y = 0, 1)
//mob verbs are a lot faster than object verbs
//for more info on why this is not atom/pull, see examinate() in mob.dm
@@ -318,6 +356,8 @@
stop_pulling()
/mob/living/stop_pulling()
if(ismob(pulling))
reset_pull_offsets(pulling)
..()
update_pull_hud_icon()
@@ -547,8 +587,12 @@
var/turf/T = loc
. = ..()
if(pulledby && moving_diagonally != FIRST_DIAG_STEP && get_dist(src, pulledby) > 1)//separated from our puller and not in the middle of a diagonal move.
if(pulledby && moving_diagonally != FIRST_DIAG_STEP && get_dist(src, pulledby) > 1 && (pulledby != moving_from_pull))//separated from our puller and not in the middle of a diagonal move.
pulledby.stop_pulling()
else
if(isliving(pulledby))
var/mob/living/L = pulledby
L.set_pull_offsets(src, pulledby.grab_state)
if(active_storage && !(CanReach(active_storage.parent,view_only = TRUE)))
active_storage.close(src)
@@ -203,6 +203,7 @@
update_canmove() //we fall down
if(!buckled && !density)
Move(user.loc)
user.set_pull_offsets(src, grab_state)
return 1
@@ -26,3 +26,11 @@
add_movespeed_modifier(MOVESPEED_ID_LIVING_TURF_SPEEDMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = T.slowdown)
else
remove_movespeed_modifier(MOVESPEED_ID_LIVING_TURF_SPEEDMOD)
/mob/living/Move_Pulled(atom/A)
. = ..()
if(!. || !isliving(A))
return
var/mob/living/L = A
set_pull_offsets(L, grab_state)
+4 -3
View File
@@ -117,15 +117,16 @@
for(var/obj/O in mob.user_movement_hooks)
O.intercept_user_move(direct, mob, n, oldloc)
var/atom/movable/P = mob.pulling
if(P && !ismob(P) && P.density)
mob.setDir(turn(mob.dir, 180))
if(L.pulling)
L.setDir(turn(L.dir, 180))
///Process_Grab()
///Called by client/Move()
///Checks to see if you are being grabbed and if so attemps to break it
/client/proc/Process_Grab()
if(mob.pulledby)
if((mob.pulledby == mob.pulling) && (mob.pulledby.grab_state == GRAB_PASSIVE)) //Don't autoresist passive grabs if we're grabbing them too.
return
if(mob.incapacitated(ignore_restraints = 1))
move_delay = world.time + 10
return TRUE