Skip to content

Commit

Permalink
Fix height filter runtime + related bugs (Monkestation#4693)
Browse files Browse the repository at this point in the history
* fix more height displacement runtimes and make tall mob head gear scale better

* deal with merge conflict

* fix a fucky wucky with mask.dmi

---------

Co-authored-by: Lucy <[email protected]>
  • Loading branch information
2 people authored and Gw0sty committed Jan 9, 2025
1 parent cfc7eac commit be67c99
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 30 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/obj_flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@
#define ANTI_TINFOIL_MANEUVER (1<<10)
/// Clothes that cause a larger notification when placed on a person.
#define DANGEROUS_OBJECT (1<<11)
//MONKESTATION REMOVAL START - Flag is no longer necessary
/*
/// Clothes that use large icons, for applying the proper overlays like blood
#define LARGE_WORN_ICON (1<<12)
*/
//MONKESTATION REMOVAL END
/// Clothes that block speech (i.e the muzzle). Can be applied to any clothing piece.
#define BLOCKS_SPEECH (1<<13)
/// prevents from placing on plasmaman helmet
Expand Down
2 changes: 1 addition & 1 deletion code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ DEFINE_BITFIELD(clothing_flags, list(
"GAS_FILTERING" = GAS_FILTERING,
"HEADINTERNALS" = HEADINTERNALS,
"INEDIBLE_CLOTHING" = INEDIBLE_CLOTHING,
"LARGE_WORN_ICON" = LARGE_WORN_ICON,
// "LARGE_WORN_ICON" = LARGE_WORN_ICON, MONKESTATION REMOVAL
"LAVAPROTECT" = LAVAPROTECT,
"MASKINTERNALS" = MASKINTERNALS,
"PLASMAMAN_HELMET_EXEMPT" = PLASMAMAN_HELMET_EXEMPT,
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!! */

///Dimensions of the icon file used when this item is worn, eg: hats.dmi (32x32 sprite, 64x64 sprite, etc.). Allows inhands/worn sprites to be of any size, but still centered on a mob properly
///Dimensions of the sprite used when this item is worn. Used to center sprites which aren't 32x32 on mobs
var/worn_x_dimension = 32
///Dimensions of the icon file used when this item is worn, eg: hats.dmi (32x32 sprite, 64x64 sprite, etc.). Allows inhands/worn sprites to be of any size, but still centered on a mob properly
///Dimensions of the sprite used when this item is worn. Used to center sprites which aren't 32x32 on mobs
var/worn_y_dimension = 32
///Same as for [worn_x_dimension][/obj/item/var/worn_x_dimension] but for inhands, uses the lefthand_ and righthand_ file vars
var/inhand_x_dimension = 32
Expand Down
5 changes: 5 additions & 0 deletions code/modules/clothing/clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,14 @@ BLIND // can't see anything

if(blood_overlay_type && appears_bloody())
var/mutable_appearance/blood_overlay
//MONKESTATION EDIT START
/* - MONKESTATION EDIT ORIGINAL -
if(clothing_flags & LARGE_WORN_ICON)
blood_overlay = mutable_appearance('icons/effects/64x64.dmi', "[blood_overlay_type]blood_large")
else
blood_overlay = mutable_appearance('icons/effects/blood.dmi', "[blood_overlay_type]blood")
*/
blood_overlay = mutable_appearance('icons/effects/blood.dmi', "[blood_overlay_type]blood")
//MONKESTATION EDIT END
blood_overlay.color = get_blood_dna_color()
. += blood_overlay
8 changes: 7 additions & 1 deletion code/modules/clothing/shoes/_shoes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
slowdown = SHOES_SLOWDOWN
strip_delay = 1 SECONDS
blood_overlay_type = "shoe"
var/offset = 0
// var/offset = 0 MONKESTATION REMOVAL - dead code
var/equipped_before_drop = FALSE
///Whether these shoes have laces that can be tied/untied
var/can_be_tied = TRUE
Expand Down Expand Up @@ -66,33 +66,39 @@
else if(tied == SHOES_KNOTTED)
. += "The shoelaces are all knotted together."

/* MONKESTATION REMOVAL - dead code
/obj/item/clothing/shoes/visual_equipped(mob/user, slot)
..()
if(offset && (slot_flags & slot))
user.pixel_y += offset
worn_y_dimension -= (offset * 2)
user.update_worn_shoes()
equipped_before_drop = TRUE
*/

/obj/item/clothing/shoes/equipped(mob/user, slot)
. = ..()
if(can_be_tied && tied == SHOES_UNTIED)
our_alert_ref = WEAKREF(user.throw_alert(ALERT_SHOES_KNOT, /atom/movable/screen/alert/shoes/untied))
RegisterSignal(src, COMSIG_SHOES_STEP_ACTION, PROC_REF(check_trip), override=TRUE)

/* MONKESTATION REMOVAL - dead code
/obj/item/clothing/shoes/proc/restore_offsets(mob/user)
equipped_before_drop = FALSE
user.pixel_y -= offset
worn_y_dimension = world.icon_size
*/

/obj/item/clothing/shoes/dropped(mob/user)
var/atom/movable/screen/alert/our_alert = our_alert_ref?.resolve()
if(!our_alert)
our_alert_ref = null
if(our_alert?.owner == user)
user.clear_alert(ALERT_SHOES_KNOT)
/* MONKESTATION REMOVAL - dead code
if(offset && equipped_before_drop)
restore_offsets(user)
*/
. = ..()

/obj/item/clothing/shoes/update_clothes_damaged_state(damaged_state = CLOTHING_DAMAGED)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/shoes/wheelys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
worn_icon = 'icons/mob/large-worn-icons/64x64/feet.dmi'
worn_x_dimension = 64
worn_y_dimension = 64
clothing_flags = LARGE_WORN_ICON
// clothing_flags = LARGE_WORN_ICON MONKESTATION REMOVAL - Flag is no longer necessary
actions_types = list(/datum/action/item_action/wheelys)
///False means wheels are not popped out
var/wheelToggle = FALSE
Expand Down
63 changes: 39 additions & 24 deletions code/modules/mob/living/carbon/human/human_update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -765,13 +765,27 @@ generate/load female uniform sprites matching all previously decided variables
if(!standing)
standing = mutable_appearance(file2use, t_state, -layer2use)

// MONKESTATION EDIT START
var/width = isinhands ? inhand_x_dimension : worn_x_dimension
var/height = isinhands ? inhand_y_dimension : worn_y_dimension
standing = center_image(standing, width, height)
// MONKESTATION EDIT END

//Get the overlays for this item when it's being worn
//eg: ammo counters, primed grenade flashes, etc.
var/list/worn_overlays = worn_overlays(standing, isinhands, file2use)
if(length(worn_overlays))
// MONKESTATION EDIT START
if (width != 32 || height != 32)
for (var/image/overlay in worn_overlays)
overlay.pixel_x -= standing.pixel_x
overlay.pixel_y -= standing.pixel_y
// MONKESTATION EDIT END
standing.overlays += worn_overlays

standing = center_image(standing, isinhands ? inhand_x_dimension : worn_x_dimension, isinhands ? inhand_y_dimension : worn_y_dimension)
// MONKESTATION EDIT START
// standing = center_image(standing, isinhands ? inhand_x_dimension : worn_x_dimension, isinhands ? inhand_y_dimension : worn_y_dimension) - moved up
// MONKESTATION EDIT END

//Worn offsets
var/list/offsets = get_worn_offsets(isinhands)
Expand Down Expand Up @@ -916,7 +930,7 @@ generate/load female uniform sprites matching all previously decided variables
/**
* Applies a filter to an appearance according to mob height
*/
/mob/living/carbon/human/proc/apply_height_filters(image/appearance, only_apply_in_prefs = FALSE)
/mob/living/carbon/human/proc/apply_height_filters(image/appearance, only_apply_in_prefs = FALSE, parent_adjust_y=0)
//MONKESTATION EDIT START
// Pick a displacement mask depending on the height of the icon, ?x48 icons are used for features which would otherwise get clipped when tall players use them
// Note: Due to how this system works it's okay to use a mask which is wider than the appearence but NOT okay if the mask is thinner, taller or shorter
Expand All @@ -926,15 +940,16 @@ generate/load female uniform sprites matching all previously decided variables

var/mask_icon = 'icons/effects/cut.dmi'
if(icon_width != 0 && icon_height != 0)
if(icon_height == 48)
if(icon_height == 48 && icon_width <= 96)
mask_icon = 'monkestation/icons/effects/cut_96x48.dmi'
if(icon_width > 96)
stack_trace("Bad dimensions (w[icon_width],h[icon_height]) for icon '[appearance.icon]'")
else if(icon_height != 32)
stack_trace("Bad dimensions (w[icon_width],h[icon_height]) for icon '[appearance.icon]'")
else if(icon_width > 32)
else if(icon_height == 64 && icon_width <= 64)
mask_icon = 'monkestation/icons/effects/cut_64x64.dmi'
else if(icon_height != 32 || icon_width > 32)
stack_trace("Bad dimensions (w[icon_width],h[icon_height]) for icon '[appearance.icon]'")

// Move the filter up if the image has been moved down, and vice versa
var/adjust_y = -appearance.pixel_y - parent_adjust_y

var/icon/cut_torso_mask = icon(mask_icon, "Cut1")
var/icon/cut_legs_mask = icon(mask_icon, "Cut2")
var/icon/lenghten_torso_mask = icon(mask_icon, "Cut3")
Expand Down Expand Up @@ -963,25 +978,25 @@ generate/load female uniform sprites matching all previously decided variables
list(
"name" = "Monkey_Gnome_Cut_Torso",
"priority" = 1,
"params" = displacement_map_filter(cut_torso_mask, x = 0, y = 0, size = 3),
"params" = displacement_map_filter(cut_torso_mask, x = 0, y = adjust_y, size = 3),
),
list(
"name" = "Monkey_Gnome_Cut_Legs",
"priority" = 1,
"params" = displacement_map_filter(cut_legs_mask, x = 0, y = 0, size = 4),
"params" = displacement_map_filter(cut_legs_mask, x = 0, y = adjust_y, size = 4),
),
))
if(MONKEY_HEIGHT_MEDIUM)
appearance.add_filters(list(
list(
"name" = "Monkey_Torso",
"priority" = 1,
"params" = displacement_map_filter(cut_torso_mask, x = 0, y = 0, size = 2),
"params" = displacement_map_filter(cut_torso_mask, x = 0, y = adjust_y, size = 2),
),
list(
"name" = "Monkey_Legs",
"priority" = 1,
"params" = displacement_map_filter(cut_legs_mask, x = 0, y = 0, size = 4),
"params" = displacement_map_filter(cut_legs_mask, x = 0, y = adjust_y, size = 4),
),
))
// Don't set this one directly, use TRAIT_DWARF
Expand All @@ -990,61 +1005,61 @@ generate/load female uniform sprites matching all previously decided variables
list(
"name" = "Gnome_Cut_Torso",
"priority" = 1,
"params" = displacement_map_filter(cut_torso_mask, x = 0, y = 0, size = 2),
"params" = displacement_map_filter(cut_torso_mask, x = 0, y = adjust_y, size = 2),
),
list(
"name" = "Gnome_Cut_Legs",
"priority" = 1,
"params" = displacement_map_filter(cut_legs_mask, x = 0, y = 0, size = 3),
"params" = displacement_map_filter(cut_legs_mask, x = 0, y = adjust_y, size = 3),
),
))
if(HUMAN_HEIGHT_SHORTEST)
appearance.add_filters(list(
list(
"name" = "Cut_Torso",
"priority" = 1,
"params" = displacement_map_filter(cut_torso_mask, x = 0, y = 0, size = 1),
"params" = displacement_map_filter(cut_torso_mask, x = 0, y = adjust_y, size = 1),
),
list(
"name" = "Cut_Legs",
"priority" = 1,
"params" = displacement_map_filter(cut_legs_mask, x = 0, y = 0, size = 1),
"params" = displacement_map_filter(cut_legs_mask, x = 0, y = adjust_y, size = 1),
),
))
if(HUMAN_HEIGHT_SHORT)
appearance.add_filter("Cut_Legs", 1, displacement_map_filter(cut_legs_mask, x = 0, y = 0, size = 1))
appearance.add_filter("Cut_Legs", 1, displacement_map_filter(cut_legs_mask, x = 0, y = adjust_y, size = 1))
if(HUMAN_HEIGHT_TALL)
appearance.add_filter("Lenghten_Legs", 1, displacement_map_filter(lenghten_legs_mask, x = 0, y = 0, size = 1))
appearance.add_filter("Lenghten_Legs", 1, displacement_map_filter(lenghten_legs_mask, x = 0, y = adjust_y, size = 1))
if(HUMAN_HEIGHT_TALLER)
appearance.add_filters(list(
list(
"name" = "Lenghten_Torso",
"priority" = 1,
"params" = displacement_map_filter(lenghten_torso_mask, x = 0, y = 0, size = 1),
"params" = displacement_map_filter(lenghten_torso_mask, x = 0, y = adjust_y, size = 1),
),
list(
"name" = "Lenghten_Legs",
"priority" = 1,
"params" = displacement_map_filter(lenghten_legs_mask, x = 0, y = 0, size = 1),
"params" = displacement_map_filter(lenghten_legs_mask, x = 0, y = adjust_y, size = 1),
),
))
if(HUMAN_HEIGHT_TALLEST)
appearance.add_filters(list(
list(
"name" = "Lenghten_Torso",
"priority" = 1,
"params" = displacement_map_filter(lenghten_torso_mask, x = 0, y = 0, size = 1),
"params" = displacement_map_filter(lenghten_torso_mask, x = 0, y = adjust_y, size = 1),
),
list(
"name" = "Lenghten_Legs",
"priority" = 1,
"params" = displacement_map_filter(lenghten_legs_mask, x = 0, y = 0, size = 1 /* monke edit: 2 -> 1 */),
"params" = displacement_map_filter(lenghten_legs_mask, x = 0, y = adjust_y, size = 1 /* monke edit: 2 -> 1 */),
),
// MONKESTATION EDIT START
list(
"name" = "Lenghten_Ankles",
"priority" = 1,
"params" = displacement_map_filter(lenghten_ankles_mask, x = 0, y = 0, size = 1),
"params" = displacement_map_filter(lenghten_ankles_mask, x = 0, y = adjust_y, size = 1),
),
// MONKESTATION EDIT END
))
Expand All @@ -1053,7 +1068,7 @@ generate/load female uniform sprites matching all previously decided variables
// Otherwise overlays, such as worn overlays on icons, won't have the filter "applied", and the effect kinda breaks
if(!(appearance.appearance_flags & KEEP_TOGETHER))
for(var/image/overlay in list() + appearance.underlays + appearance.overlays)
apply_height_filters(overlay)
apply_height_filters(overlay, parent_adjust_y=adjust_y)

return appearance

Expand Down
Binary file modified icons/effects/64x64.dmi
Binary file not shown.
Binary file modified icons/mob/clothing/ears.dmi
Binary file not shown.
Binary file modified icons/mob/clothing/eyes.dmi
Binary file not shown.
Binary file modified icons/mob/clothing/mask.dmi
Binary file not shown.
2 changes: 1 addition & 1 deletion monkestation/code/modules/clothing/masks/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
/obj/item/clothing/mask/breath/sec_bandana
desc = "An incredibly dense synthetic thread bandana that can be used as an internals mask."
name = "sec bandana"
worn_icon = 'monkestation/icons/mob/mask.dmi'
worn_icon = 'monkestation/icons/mob/clothing/mask.dmi'
icon = 'monkestation/icons/obj/clothing/masks.dmi'
icon_state = "sec_bandana_default"
var/obj/item/clothing/suit/armor/secduster/suit
Expand Down
Binary file added monkestation/icons/effects/cut_64x64.dmi
Binary file not shown.
Binary file modified monkestation/icons/mob/clothing/mask.dmi
Binary file not shown.

0 comments on commit be67c99

Please sign in to comment.