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.
This commit is contained in:
Yenwodyah
2020-11-09 12:26:31 +13:00
committed by GitHub
parent 5de8455725
commit 62311ee1a8
12 changed files with 35 additions and 57 deletions
+3
View File
@@ -380,3 +380,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
@@ -65,14 +65,14 @@
"<span class='hear'>You hear squelching...</span>")
/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)
@@ -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
@@ -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("<span class='danger'>[M] falls free of [src]!</span>"))
unbuckle_mob(M,force=1)
@@ -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, "<span class='noticealien'>You begin to evolve!</span>")
visible_message("<span class='alertalien'>[src] begins to twist and contort!</span>")
@@ -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("<span class='danger'>[src] smashes into [hit_atom]!</span>", "<span class='alertalien'>[src] smashes into [hit_atom]!</span>")
Paralyze(40, ignore_canstun = TRUE)
if(leaping)
leaping = FALSE
update_icons()
/mob/living/carbon/alien/humanoid/float(on)
if(leaping)
return
@@ -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
@@ -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()
-6
View File
@@ -404,12 +404,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
@@ -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)
+5 -9
View File
@@ -531,6 +531,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.
@@ -540,6 +541,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
@@ -947,7 +949,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
@@ -1035,8 +1037,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().
@@ -1053,12 +1055,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
@@ -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