From 8db24d79e63cfaa95e47161aa0029c3512dfa3d3 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 11 Nov 2020 03:47:05 +0100 Subject: [PATCH] [MIRROR] Fix royal alien pixel offset, change getter to variable (#1641) * Fix royal alien pixel offset, change getter to variable (#54706) Fixed a bug where royal aliens would have their base pixel offset applied twice, making them off-center (https://i.imgur.com/BtspaM0.png) Changed the mob/living procs get_standard_pixel_x_offset() and get_standard_pixel_y_offset() to variables (body_position_pixel_x_offset and body_position_pixel_y_offset), to match the contribution guidelines. Also corrected a few random things that weren't using base pixels but should have been. * Fix royal alien pixel offset, change getter to variable * Update pixel_shift.dm Co-authored-by: Yenwodyah Co-authored-by: Azarak --- code/__DEFINES/mobs.dm | 3 +++ .../structures/beds_chairs/alien_nest.dm | 8 ++++---- .../game/objects/structures/beds_chairs/bed.dm | 7 ++++--- code/game/objects/structures/kitchen_spike.dm | 4 ++-- code/modules/mob/living/carbon/alien/alien.dm | 3 --- .../carbon/alien/humanoid/caste/hunter.dm | 14 +++++++------- .../living/carbon/alien/humanoid/humanoid.dm | 18 ------------------ .../alien/humanoid/humanoid_update_icons.dm | 4 ++-- code/modules/mob/living/carbon/carbon.dm | 6 ------ .../mob/living/carbon/carbon_update_icons.dm | 6 +++--- code/modules/mob/living/living.dm | 14 +++++--------- code/modules/mob/living/living_defines.dm | 5 +++++ .../modules/pixel_shift/code/pixel_shift.dm | 4 ++-- 13 files changed, 37 insertions(+), 59 deletions(-) diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index 30be85b3307..306b4724401 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -381,3 +381,6 @@ #define STANDING_UP 0 /// Mob is lying down, usually associated with lying_angle values of 90 or 270. #define LYING_DOWN 1 + +///How much a mob's sprite should be moved when they're lying down +#define PIXEL_Y_OFFSET_LYING -6 diff --git a/code/game/objects/structures/beds_chairs/alien_nest.dm b/code/game/objects/structures/beds_chairs/alien_nest.dm index 306f18db292..11eabcec749 100644 --- a/code/game/objects/structures/beds_chairs/alien_nest.dm +++ b/code/game/objects/structures/beds_chairs/alien_nest.dm @@ -65,14 +65,14 @@ "You hear squelching...") /obj/structure/bed/nest/post_buckle_mob(mob/living/M) - M.pixel_y = 0 - M.pixel_x = initial(M.pixel_x) + 2 + M.pixel_y = M.base_pixel_y + M.pixel_x = M.base_pixel_x + 2 M.layer = BELOW_MOB_LAYER add_overlay(nest_overlay) /obj/structure/bed/nest/post_unbuckle_mob(mob/living/M) - M.pixel_x = M.base_pixel_x + M.get_standard_pixel_x_offset(M.body_position == LYING_DOWN) - M.pixel_y = M.base_pixel_y + M.get_standard_pixel_y_offset(M.body_position == LYING_DOWN) + M.pixel_x = M.base_pixel_x + M.body_position_pixel_x_offset + M.pixel_y = M.base_pixel_y + M.body_position_pixel_y_offset M.layer = initial(M.layer) cut_overlay(nest_overlay) diff --git a/code/game/objects/structures/beds_chairs/bed.dm b/code/game/objects/structures/beds_chairs/bed.dm index 87a6d11660d..924a0602c46 100644 --- a/code/game/objects/structures/beds_chairs/bed.dm +++ b/code/game/objects/structures/beds_chairs/bed.dm @@ -90,7 +90,8 @@ /obj/structure/bed/roller/post_buckle_mob(mob/living/M) density = TRUE icon_state = "up" - M.pixel_y = initial(M.pixel_y) + //Push them up from the normal lying position + M.pixel_y = M.base_pixel_y /obj/structure/bed/roller/Moved() . = ..() @@ -101,8 +102,8 @@ /obj/structure/bed/roller/post_unbuckle_mob(mob/living/M) density = FALSE icon_state = "down" - M.pixel_x = M.base_pixel_x + M.get_standard_pixel_x_offset(M.body_position == LYING_DOWN) - M.pixel_y = M.base_pixel_y + M.get_standard_pixel_y_offset(M.body_position == LYING_DOWN) + //Set them back down to the normal lying position + M.pixel_y = M.base_pixel_y + M.body_position_pixel_y_offset /obj/item/roller diff --git a/code/game/objects/structures/kitchen_spike.dm b/code/game/objects/structures/kitchen_spike.dm index ab85eca0d73..f7d19edc81d 100644 --- a/code/game/objects/structures/kitchen_spike.dm +++ b/code/game/objects/structures/kitchen_spike.dm @@ -82,7 +82,7 @@ var/matrix/m180 = matrix(L.transform) m180.Turn(180) animate(L, transform = m180, time = 3) - L.pixel_y = L.get_standard_pixel_y_offset(TRUE) + L.pixel_y = L.base_pixel_y + PIXEL_Y_OFFSET_LYING else if (has_buckled_mobs()) for(var/mob/living/L in buckled_mobs) user_unbuckle_mob(L, user) @@ -124,7 +124,7 @@ var/matrix/m180 = matrix(M.transform) m180.Turn(180) animate(M, transform = m180, time = 3) - M.pixel_y = M.base_pixel_y + M.get_standard_pixel_y_offset(TRUE) + M.pixel_y = M.base_pixel_y + PIXEL_Y_OFFSET_LYING M.adjustBruteLoss(30) src.visible_message(text("[M] falls free of [src]!")) unbuckle_mob(M,force=1) diff --git a/code/modules/mob/living/carbon/alien/alien.dm b/code/modules/mob/living/carbon/alien/alien.dm index 8faac355aaf..b76ff32e8a6 100644 --- a/code/modules/mob/living/carbon/alien/alien.dm +++ b/code/modules/mob/living/carbon/alien/alien.dm @@ -116,9 +116,6 @@ Des: Removes all infected images from the alien. return FALSE return TRUE -/mob/living/carbon/alien/get_standard_pixel_y_offset(lying = FALSE) - return initial(pixel_y) - /mob/living/carbon/alien/proc/alien_evolve(mob/living/carbon/alien/new_xeno) to_chat(src, "You begin to evolve!") visible_message("[src] begins to twist and contort!") diff --git a/code/modules/mob/living/carbon/alien/humanoid/caste/hunter.dm b/code/modules/mob/living/carbon/alien/humanoid/caste/hunter.dm index 6b1f04bcf61..6490484b7e0 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/caste/hunter.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/caste/hunter.dm @@ -44,13 +44,18 @@ return else //Maybe uses plasma in the future, although that wouldn't make any sense... - leaping = 1 + leaping = TRUE + //Because the leaping sprite is bigger than the normal one + body_position_pixel_x_offset = -32 + body_position_pixel_y_offset = -32 LAZYADD(weather_immunities,"lava") update_icons() throw_at(A, MAX_ALIEN_LEAP_DIST, 1, src, FALSE, TRUE, callback = CALLBACK(src, .proc/leap_end)) /mob/living/carbon/alien/humanoid/hunter/proc/leap_end() - leaping = 0 + leaping = FALSE + body_position_pixel_x_offset = 0 + body_position_pixel_y_offset = 0 LAZYREMOVE(weather_immunities, "lava") update_icons() @@ -81,11 +86,6 @@ visible_message("[src] smashes into [hit_atom]!", "[src] smashes into [hit_atom]!") Paralyze(40, ignore_canstun = TRUE) - if(leaping) - leaping = FALSE - update_icons() - - /mob/living/carbon/alien/humanoid/float(on) if(leaping) return diff --git a/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm b/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm index 1cd3feddb2c..df98a288f52 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/humanoid.dm @@ -13,8 +13,6 @@ var/leap_on_click = 0 var/pounce_cooldown = 0 var/pounce_cooldown_time = 30 - var/custom_pixel_x_offset = 0 //for admin fuckery. - var/custom_pixel_y_offset = 0 var/sneaking = 0 //For sneaky-sneaky mode and appropriate slowdown var/drooling = 0 //For Neruotoxic spit overlays deathsound = 'sound/voice/hiss6.ogg' @@ -80,22 +78,6 @@ pulledby.stop_pulling() . = 0 -/mob/living/carbon/alien/humanoid/get_standard_pixel_y_offset(lying = FALSE) - if(leaping) - return -32 - else if(custom_pixel_y_offset) - return custom_pixel_y_offset - else - return initial(pixel_y) - -/mob/living/carbon/alien/humanoid/get_standard_pixel_x_offset(lying = 0) - if(leaping) - return -32 - else if(custom_pixel_x_offset) - return custom_pixel_x_offset - else - return initial(pixel_x) - /mob/living/carbon/alien/humanoid/get_permeability_protection(list/target_zones) return 0.8 diff --git a/code/modules/mob/living/carbon/alien/humanoid/humanoid_update_icons.dm b/code/modules/mob/living/carbon/alien/humanoid/humanoid_update_icons.dm index 8e402b2950e..ece2a9a46a3 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/humanoid_update_icons.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/humanoid_update_icons.dm @@ -41,8 +41,8 @@ var/old_icon = icon icon = alt_icon alt_icon = old_icon - pixel_x = base_pixel_x + get_standard_pixel_x_offset(body_position == LYING_DOWN) - pixel_y = base_pixel_y + get_standard_pixel_y_offset(body_position == LYING_DOWN) + pixel_x = base_pixel_x + body_position_pixel_x_offset + pixel_y = base_pixel_y + body_position_pixel_y_offset update_inv_hands() update_inv_handcuffed() diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 8710a3569fe..dc918ecdcd1 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -406,12 +406,6 @@ update_inv_legcuffed() return TRUE -/mob/living/carbon/get_standard_pixel_y_offset(lying = FALSE) - if(lying) - return -6 - else - return initial(pixel_y) - /mob/living/carbon/proc/accident(obj/item/I) if(!I || (I.item_flags & ABSTRACT) || HAS_TRAIT(I, TRAIT_NODROP)) return diff --git a/code/modules/mob/living/carbon/carbon_update_icons.dm b/code/modules/mob/living/carbon/carbon_update_icons.dm index 0971109f868..4d96b627938 100644 --- a/code/modules/mob/living/carbon/carbon_update_icons.dm +++ b/code/modules/mob/living/carbon/carbon_update_icons.dm @@ -8,11 +8,11 @@ changed++ ntransform.TurnTo(lying_prev , lying_angle) if(!lying_angle) //Lying to standing - final_pixel_y = base_pixel_y + get_standard_pixel_y_offset() + final_pixel_y = base_pixel_y else //if(lying != 0) if(lying_prev == 0) //Standing to lying - pixel_y = base_pixel_y + get_standard_pixel_y_offset() - final_pixel_y = base_pixel_y + get_standard_pixel_y_offset(lying_angle) + pixel_y = base_pixel_y + final_pixel_y = base_pixel_y + PIXEL_Y_OFFSET_LYING if(dir & (EAST|WEST)) //Facing east or west final_dir = pick(NORTH, SOUTH) //So you fall on your side rather than your face or ass if(resize != RESIZE_DEFAULT_SIZE) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 47b87cc474e..9b0f3d1d1ce 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -548,6 +548,7 @@ density = FALSE // We lose density and stop bumping passable dense things. if(HAS_TRAIT(src, TRAIT_FLOORED) && !(dir & (NORTH|SOUTH))) setDir(pick(NORTH, SOUTH)) // We are and look helpless. + body_position_pixel_y_offset = PIXEL_Y_OFFSET_LYING /// Proc to append behavior related to lying down. @@ -557,6 +558,7 @@ density = initial(density) // We were prone before, so we become dense and things can bump into us again. REMOVE_TRAIT(src, TRAIT_UI_BLOCKED, LYING_DOWN_TRAIT) REMOVE_TRAIT(src, TRAIT_PULL_BLOCKED, LYING_DOWN_TRAIT) + body_position_pixel_y_offset = 0 @@ -964,7 +966,7 @@ animate(src, pixel_y = pixel_y - 2, time = 10, loop = -1) setMovetype(movement_type | FLOATING) else if(((!on || fixed) && (movement_type & FLOATING))) - animate(src, pixel_y = base_pixel_y + get_standard_pixel_y_offset(lying_angle), time = 1 SECONDS) + animate(src, pixel_y = base_pixel_y + body_position_pixel_y_offset, time = 1 SECONDS) setMovetype(movement_type & ~FLOATING) // The src mob is trying to strip an item from someone @@ -1052,8 +1054,8 @@ var/amplitude = min(4, (jitteriness/100) + 1) var/pixel_x_diff = rand(-amplitude, amplitude) var/pixel_y_diff = rand(-amplitude/3, amplitude/3) - var/final_pixel_x = base_pixel_x + get_standard_pixel_x_offset(body_position == LYING_DOWN) - var/final_pixel_y = base_pixel_y + get_standard_pixel_y_offset(body_position == LYING_DOWN) + var/final_pixel_x = base_pixel_x + body_position_pixel_x_offset + var/final_pixel_y = base_pixel_y + body_position_pixel_y_offset animate(src, pixel_x = pixel_x + pixel_x_diff, pixel_y = pixel_y + pixel_y_diff , time = 2, loop = 6) animate(pixel_x = final_pixel_x , pixel_y = final_pixel_y , time = 2) setMovetype(movement_type & ~FLOATING) // If we were without gravity, the bouncing animation got stopped, so we make sure to restart it in next life(). @@ -1070,12 +1072,6 @@ loc_temp = heat_turf.temperature return loc_temp -/mob/living/proc/get_standard_pixel_x_offset(lying = FALSE) - return initial(pixel_x) - -/mob/living/proc/get_standard_pixel_y_offset(lying = FALSE) - return initial(pixel_y) - /mob/living/cancel_camera() ..() cameraFollow = null diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index 96e078aa69d..5eeb01ec012 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -157,3 +157,8 @@ /// Is this mob allowed to be buckled/unbuckled to/from things? var/can_buckle_to = TRUE + + ///The y amount a mob's sprite should be offset due to the current position they're in (e.g. lying down moves your sprite down) + var/body_position_pixel_x_offset = 0 + ///The x amount a mob's sprite should be offset due to the current position they're in + var/body_position_pixel_y_offset = 0 diff --git a/modular_skyrat/modules/pixel_shift/code/pixel_shift.dm b/modular_skyrat/modules/pixel_shift/code/pixel_shift.dm index 01ac380b458..5edf5e00850 100644 --- a/modular_skyrat/modules/pixel_shift/code/pixel_shift.dm +++ b/modular_skyrat/modules/pixel_shift/code/pixel_shift.dm @@ -33,8 +33,8 @@ /mob/living/unpixel_shift() if(is_shifted) is_shifted = FALSE - pixel_x = get_standard_pixel_x_offset(!mobility_flags & MOBILITY_STAND) - pixel_y = get_standard_pixel_y_offset(!mobility_flags & MOBILITY_STAND) + pixel_x = body_position_pixel_x_offset + pixel_y = body_position_pixel_y_offset /mob/proc/pixel_shift(direction) return