Skip to content

Commit

Permalink
Merge pull request #363 from KoboldCommando/dwarf-visuals
Browse files Browse the repository at this point in the history
Fixes dwarfs and giants for real this time
  • Loading branch information
dwasint authored Oct 9, 2023
2 parents daf7add + 053599f commit 8d21f40
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 31 deletions.
19 changes: 11 additions & 8 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -651,20 +651,22 @@ GLOBAL_LIST_INIT(human_heights_to_offsets, list(
/// Total number of layers for mob overlays
/// KEEP THIS UP-TO-DATE OR SHIT WILL BREAK
/// Also consider updating layers_to_offset
#define TOTAL_LAYERS 34
#define TOTAL_LAYERS 35
/// Mutant race multiparts - Lbelly
#define ACCESSORIES_LAYER 34
#define ACCESSORIES_LAYER 35
/// Mutations layer - Tk headglows, cold resistance glow, etc
#define MUTATIONS_LAYER 33
#define MUTATIONS_LAYER 34
/// Mutantrace features (tail when looking south) that must appear behind the body parts
#define BODY_BEHIND_LAYER 32
#define BODY_BEHIND_LAYER 33
/// Layer for bodyparts that should appear behind every other bodypart - Mostly, legs when facing WEST or EAST
#define BODYPARTS_LOW_LAYER 31
#define BODYPARTS_LOW_LAYER 32
/// Layer for most bodyparts, appears above BODYPARTS_LOW_LAYER and below BODYPARTS_HIGH_LAYER
#define BODYPARTS_LAYER 30
#define BODYPARTS_LAYER 31
/// Mutantrace features (snout, body markings) that must appear above the body parts
#define BODY_ADJ_LAYER 29
/// Underwear, undershirts, socks, eyes, lips(makeup)
#define BODY_ADJ_LAYER 30
// Eyes, lips(makeup)
#define FACE_LAYER 29
/// Underwear, undershirts, socks
#define BODY_LAYER 28
/// Mutations that should appear above body, body_adj and bodyparts layer (e.g. laser eyes)
#define FRONT_MUTATIONS_LAYER 27
Expand Down Expand Up @@ -748,6 +750,7 @@ GLOBAL_LIST_INIT(layers_to_offset, list(
"[ID_CARD_LAYER]" = UPPER_BODY, // unused
"[ID_LAYER]" = UPPER_BODY,
"[FACEMASK_LAYER]" = UPPER_BODY,
"[FACE_LAYER]" = UPPER_BODY,
// These two are cached, and have their appearance shared(?), so it's safer to just not touch it
"[MUTATIONS_LAYER]" = NO_MODIFY,
"[FRONT_MUTATIONS_LAYER]" = NO_MODIFY,
Expand Down
19 changes: 9 additions & 10 deletions code/datums/mutations/body.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@
/datum/mutation/human/dwarfism/on_losing(mob/living/carbon/human/owner)
if(..())
return
// REMOVE_TRAIT(owner, TRAIT_DWARF, GENETIC_MUTATION)
// owner.visible_message(span_danger("[owner] suddenly grows!"), span_notice("Everything around you seems to shrink.."))
//We're leaving the size traits permanent until someone wants to separate the mutation from customization aspects
//REMOVE_TRAIT(owner, TRAIT_DWARF, GENETIC_MUTATION)
//owner.visible_message(span_danger("[owner] suddenly grows!"), span_notice("Everything around you seems to shrink.."))

//Clumsiness has a very large amount of small drawbacks depending on item.
/datum/mutation/human/clumsy
Expand Down Expand Up @@ -370,27 +371,25 @@
playsound(owner,'sound/weapons/sear.ogg', 50, TRUE)

/datum/mutation/human/gigantism
name = "Gigantism"//negative version of dwarfism
name = "Gigantism"
desc = "The cells within the subject spread out to cover more area, making the subject appear larger."
quality = MINOR_NEGATIVE
difficulty = 12
conflicts = list(/datum/mutation/human/dwarfism)
locked = TRUE

/datum/mutation/human/gigantism/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
ADD_TRAIT(owner, TRAIT_GIANT, GENETIC_MUTATION)
owner.resize = 1.25
owner.update_transform()
owner.visible_message(span_danger("[owner] suddenly grows!"), span_notice("Everything around you seems to shrink.."))
//handled in init_signals.dm

/datum/mutation/human/gigantism/on_losing(mob/living/carbon/human/owner)
if(..())
return
// REMOVE_TRAIT(owner, TRAIT_GIANT, GENETIC_MUTATION)
// owner.resize = 0.8
// owner.update_transform()
// owner.visible_message(span_danger("[owner] suddenly shrinks!"), span_notice("Everything around you seems to grow.."))
//We're leaving the size traits permanent until someone wants to separate the mutation from customization aspects
//REMOVE_TRAIT(owner, TRAIT_GIANT, GENETIC_MUTATION)
//handled in init_signals.dm

/datum/mutation/human/spastic
name = "Spastic"
Expand Down
4 changes: 3 additions & 1 deletion code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if (isnull(body))
create_body()
else
body.wipe_state()
//body.wipe_state()
QDEL_NULL(body)
create_body()
appearance = preferences.render_new_preview_appearance(body)

/atom/movable/screen/map_view/char_preview/proc/create_body()
Expand Down
4 changes: 4 additions & 0 deletions code/modules/clothing/head/_head.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
head_icon = selected_hat.icon
var/mutable_appearance/hat_adding = selected_hat.build_worn_icon(HEAD_LAYER, head_icon, FALSE, FALSE)
hat_adding.pixel_y = ((current_hat * 4) - 1)
if(ismob(loc))
if(ishuman(loc))
var/mob/living/carbon/human/user = loc
hat_adding.pixel_y -= GLOB.human_heights_to_offsets[num2text(user.get_mob_height())][1]
hat_adding.pixel_x = (rand(-1, 1))
current_hat++
. += hat_adding
Expand Down
18 changes: 18 additions & 0 deletions code/modules/mob/living/carbon/carbon_update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,15 @@
if(iter_part.burnstate)
damage_overlay.add_overlay("[iter_part.dmg_overlay_type]_[iter_part.body_zone]_0[iter_part.burnstate]")

var/mob/living/carbon/human/human = src
if(human)
var/height = human.get_mob_height()
if(height == HUMAN_HEIGHT_DWARF)
height += 2
height = num2text(height)
var/offsets = GLOB.human_heights_to_offsets[height]
damage_overlay.pixel_y += offsets[1]

apply_overlay(DAMAGE_LAYER)

/mob/living/carbon/update_wound_overlays()
Expand All @@ -345,6 +354,15 @@
if(iter_part.bleed_overlay_icon)
wound_overlay.add_overlay(iter_part.bleed_overlay_icon)

var/mob/living/carbon/human/human = src
if(human)
var/height = human.get_mob_height()
if(height == HUMAN_HEIGHT_DWARF)
height += 2
height = num2text(height)
var/offsets = GLOB.human_heights_to_offsets[height]
wound_overlay.pixel_y += offsets[1]

apply_overlay(WOUND_LAYER)

/mob/living/carbon/update_worn_mask()
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/human/human_update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ generate/load female uniform sprites matching all previously decided variables
if(HD && !(HAS_TRAIT(src, TRAIT_HUSK)))
// lipstick
if(lip_style && (LIPS in dna.species.species_traits))
var/mutable_appearance/lip_overlay = mutable_appearance('icons/mob/species/human/human_face.dmi', "lips_[lip_style]", -BODY_LAYER)
var/mutable_appearance/lip_overlay = mutable_appearance('icons/mob/species/human/human_face.dmi', "lips_[lip_style]", -FACE_LAYER)
lip_overlay.color = lip_color
if(OFFSET_FACE in dna.species.offset_features)
lip_overlay.pixel_x += dna.species.offset_features[OFFSET_FACE][1]
Expand All @@ -860,7 +860,7 @@ generate/load female uniform sprites matching all previously decided variables
if(parent_eyes)
add_overlay(parent_eyes.generate_body_overlay(src))
else
var/mutable_appearance/missing_eyes = mutable_appearance('icons/mob/species/human/human_face.dmi', "eyes_missing", -BODY_LAYER)
var/mutable_appearance/missing_eyes = mutable_appearance('icons/mob/species/human/human_face.dmi', "eyes_missing", -FACE_LAYER)
if(OFFSET_FACE in dna.species.offset_features)
missing_eyes.pixel_x += dna.species.offset_features[OFFSET_FACE][1]
missing_eyes.pixel_y += dna.species.offset_features[OFFSET_FACE][2]
Expand Down
15 changes: 15 additions & 0 deletions code/modules/mob/living/carbon/human/init_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

RegisterSignals(src, list(SIGNAL_ADDTRAIT(TRAIT_UNKNOWN), SIGNAL_REMOVETRAIT(TRAIT_UNKNOWN)), PROC_REF(on_unknown_trait))
RegisterSignals(src, list(SIGNAL_ADDTRAIT(TRAIT_DWARF), SIGNAL_REMOVETRAIT(TRAIT_DWARF)), PROC_REF(on_dwarf_trait))
RegisterSignals(src, list(SIGNAL_ADDTRAIT(TRAIT_GIANT)), PROC_REF(on_gain_giant_trait))
RegisterSignals(src, list(SIGNAL_REMOVETRAIT(TRAIT_GIANT)), PROC_REF(on_lose_giant_trait))

/// Gaining or losing [TRAIT_UNKNOWN] updates our name and our sechud
/mob/living/carbon/human/proc/on_unknown_trait(datum/source)
Expand All @@ -19,3 +21,16 @@
regenerate_icons()
// No more passtable for you, bub

/mob/living/carbon/human/proc/on_gain_giant_trait(datum/source)
SIGNAL_HANDLER

src.resize = 1.25
src.update_transform()
src.visible_message(span_danger("[src] suddenly grows!"), span_notice("Everything around you seems to shrink.."))

/mob/living/carbon/human/proc/on_lose_giant_trait(datum/source)
SIGNAL_HANDLER
//We're leaving the size traits permanent until someone wants to separate the mutation from customization aspects
//src.resize = 0.8
//src.update_transform()
//src.visible_message(span_danger("[src] suddenly shrinks!"), span_notice("Everything around you seems to grow.."))
13 changes: 9 additions & 4 deletions code/modules/mob/living/carbon/human/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -653,23 +653,25 @@ GLOBAL_LIST_EMPTY(features_by_species)
*/
/datum/species/proc/handle_body(mob/living/carbon/human/species_human)
species_human.remove_overlay(BODY_LAYER)
species_human.remove_overlay(FACE_LAYER)
var/height_offset = species_human.get_top_offset() // From high changed by varying limb height
if(HAS_TRAIT(species_human, TRAIT_INVISIBLE_MAN))
return handle_mutant_bodyparts(species_human)
var/list/standing = list()
var/list/standing_face = list()

var/obj/item/bodypart/head/noggin = species_human.get_bodypart(BODY_ZONE_HEAD)

if(noggin && !(HAS_TRAIT(species_human, TRAIT_HUSK)))
// lipstick
if(species_human.lip_style && (LIPS in species_traits))
var/mutable_appearance/lip_overlay = mutable_appearance('icons/mob/species/human/human_face.dmi', "lips_[species_human.lip_style]", -BODY_LAYER)
var/mutable_appearance/lip_overlay = mutable_appearance('icons/mob/species/human/human_face.dmi', "lips_[species_human.lip_style]", -FACE_LAYER)
lip_overlay.color = species_human.lip_color
if(OFFSET_FACE in species_human.dna.species.offset_features)
lip_overlay.pixel_x += species_human.dna.species.offset_features[OFFSET_FACE][1]
lip_overlay.pixel_y += species_human.dna.species.offset_features[OFFSET_FACE][2]
lip_overlay.pixel_y += height_offset
standing += lip_overlay
standing_face += lip_overlay

// eyes
if(!(NOEYESPRITES in species_traits))
Expand All @@ -687,7 +689,7 @@ GLOBAL_LIST_EMPTY(features_by_species)
add_pixel_y += height_offset

if(!eye_organ)
no_eyeslay = mutable_appearance('icons/mob/species/human/human_face.dmi', "eyes_missing", -BODY_LAYER)
no_eyeslay = mutable_appearance('icons/mob/species/human/human_face.dmi', "eyes_missing", -FACE_LAYER)
no_eyeslay.pixel_x += add_pixel_x
no_eyeslay.pixel_y += add_pixel_y
standing += no_eyeslay
Expand All @@ -697,7 +699,7 @@ GLOBAL_LIST_EMPTY(features_by_species)
if(!no_eyeslay)
for(var/mutable_appearance/eye_overlay in eye_organ.generate_body_overlay(species_human))
eye_overlay.pixel_y += height_offset
standing += eye_overlay
standing_face += eye_overlay

// organic body markings
if(HAS_MARKINGS in species_traits)
Expand Down Expand Up @@ -770,8 +772,11 @@ GLOBAL_LIST_EMPTY(features_by_species)

if(standing.len)
species_human.overlays_standing[BODY_LAYER] = standing
if(standing_face.len)
species_human.overlays_standing[FACE_LAYER] = standing_face

species_human.apply_overlay(BODY_LAYER)
species_human.apply_overlay(FACE_LAYER)
handle_mutant_bodyparts(species_human)

/**
Expand Down
7 changes: 7 additions & 0 deletions code/modules/surgery/bodyparts/hair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,25 @@
facial_hairstyle = human_head_owner.facial_hairstyle

var/atom/location = loc || owner || src
var/height = human_head_owner.get_mob_height()
if(height == HUMAN_HEIGHT_DWARF)
height += 2
height = num2text(height)
var/offsets = GLOB.human_heights_to_offsets[height]

if(facial_hairstyle && !facial_hair_hidden && (FACEHAIR in species_flags_list))
sprite_accessory = GLOB.facial_hairstyles_list[facial_hairstyle]
if(sprite_accessory)
//Create the overlay
facial_overlay = mutable_appearance(sprite_accessory.icon, sprite_accessory.icon_state, -HAIR_LAYER)
facial_overlay.overlays += emissive_blocker(facial_overlay.icon, facial_overlay.icon_state, location, alpha = hair_alpha)
facial_overlay.pixel_y += offsets[1]
//Gradients
facial_hair_gradient_style = LAZYACCESS(human_head_owner.grad_style, GRADIENT_FACIAL_HAIR_KEY)
if(facial_hair_gradient_style)
facial_hair_gradient_color = LAZYACCESS(human_head_owner.grad_color, GRADIENT_FACIAL_HAIR_KEY)
facial_gradient_overlay = make_gradient_overlay(sprite_accessory.icon, sprite_accessory.icon_state, HAIR_LAYER, GLOB.facial_hair_gradients_list[facial_hair_gradient_style], facial_hair_gradient_color)
facial_gradient_overlay.pixel_y += offsets[1]

facial_overlay.overlays += emissive_blocker(sprite_accessory.icon, sprite_accessory.icon_state, location, alpha = hair_alpha)

Expand Down
8 changes: 4 additions & 4 deletions code/modules/surgery/bodyparts/head.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
. += facial_overlay

if(!eyes)
. += image('icons/mob/species/human/human_face.dmi', "eyes_missing", -BODY_LAYER, SOUTH)
. += image('icons/mob/species/human/human_face.dmi', "eyes_missing", -FACE_LAYER, SOUTH)

//Applies the debrained overlay if there is no brain
if(!brain)
Expand All @@ -229,14 +229,14 @@

// lipstick
if(lip_style)
var/image/lips_overlay = image('icons/mob/species/human/human_face.dmi', "lips_[lip_style]", -BODY_LAYER, SOUTH)
var/image/lips_overlay = image('icons/mob/species/human/human_face.dmi', "lips_[lip_style]", -FACE_LAYER, SOUTH)
lips_overlay.color = lip_color
. += lips_overlay

// eyes
if(eyes) // This is a bit of copy/paste code from eyes.dm:generate_body_overlay
var/image/eye_left = image('icons/mob/species/human/human_face.dmi', "[eyes.eye_icon_state]_l", -BODY_LAYER, SOUTH)
var/image/eye_right = image('icons/mob/species/human/human_face.dmi', "[eyes.eye_icon_state]_r", -BODY_LAYER, SOUTH)
var/image/eye_left = image('icons/mob/species/human/human_face.dmi', "[eyes.eye_icon_state]_l", -FACE_LAYER, SOUTH)
var/image/eye_right = image('icons/mob/species/human/human_face.dmi', "[eyes.eye_icon_state]_r", -FACE_LAYER, SOUTH)
if(eyes.eye_color_left)
eye_left.color = eyes.eye_color_left
if(eyes.eye_color_right)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/surgery/organs/eyes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@

var/eye_icon = parent.dna?.species.eyes_icon || 'icons/mob/species/human/human_face.dmi'

var/mutable_appearance/eye_left = mutable_appearance(eye_icon, "[eye_icon_state]_l", -BODY_LAYER)
var/mutable_appearance/eye_right = mutable_appearance(eye_icon, "[eye_icon_state]_r", -BODY_LAYER)
var/mutable_appearance/eye_left = mutable_appearance(eye_icon, "[eye_icon_state]_l", -FACE_LAYER)
var/mutable_appearance/eye_right = mutable_appearance(eye_icon, "[eye_icon_state]_r", -FACE_LAYER)
var/list/overlays = list(eye_left, eye_right)

if(EYECOLOR in parent.dna?.species.species_traits)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8d21f40

Please sign in to comment.