Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds height #16203

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 103 additions & 35 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,42 @@
///Comment out if you don't want VOX to be enabled and have players download the voice sounds.
#define AI_VOX

// Overlay Indexes
#define BODYPARTS_LAYER 28
#define WOUND_LAYER 27
#define MOTH_WINGS_LAYER 26
#define DAMAGE_LAYER 25
#define UNIFORM_LAYER 24
#define ID_LAYER 23
#define SHOES_LAYER 22
#define GLOVES_LAYER 21
#define BELT_LAYER 20
#define GLASSES_LAYER 19
#define SUIT_LAYER 18 //Possible make this an overlay of somethign required to wear a belt?
#define HAIR_LAYER 17 //TODO: make part of head layer?
#define EARS_LAYER 16
#define FACEMASK_LAYER 15
#define GOGGLES_LAYER 14 //For putting Ballistic goggles and potentially other things above masks
#define HEAD_LAYER 13
#define COLLAR_LAYER 12
#define SUIT_STORE_LAYER 11
#define BACK_LAYER 10
#define KAMA_LAYER 9
#define CAPE_LAYER 8
#define HANDCUFF_LAYER 7
#define L_HAND_LAYER 6
#define R_HAND_LAYER 5
#define BURST_LAYER 4 //Chestburst overlay
#define OVERHEALTH_SHIELD_LAYER 3
#define FIRE_LAYER 2 //If you're on fire
#define LASER_LAYER 1 //For sniper targeting laser

#define TOTAL_LAYERS 28

#define MOTH_WINGS_BEHIND_LAYER 1

#define TOTAL_UNDERLAYS 1

//Mob movement define

///Speed mod for walk intent
Expand Down Expand Up @@ -378,6 +414,73 @@ GLOBAL_LIST_INIT(xenoupgradetiers, list(XENO_UPGRADE_BASETYPE, XENO_UPGRADE_INVA
#define MOB_SIZE_XENO 2
#define MOB_SIZE_BIG 3

// Height defines
// - They are numbers so you can compare height values (x height < y height)
// - They do not start at 0 for futureproofing
// - They skip numbers for futureproofing as well
// Otherwise they are completely arbitrary
#define MONKEY_HEIGHT_DWARF 2
#define MONKEY_HEIGHT_MEDIUM 4
#define MONKEY_HEIGHT_TALL HUMAN_HEIGHT_DWARF
#define HUMAN_HEIGHT_DWARF 6
#define HUMAN_HEIGHT_SHORTEST 8
#define HUMAN_HEIGHT_SHORT 10
#define HUMAN_HEIGHT_MEDIUM 12
#define HUMAN_HEIGHT_TALL 14
#define HUMAN_HEIGHT_TALLER 16
#define HUMAN_HEIGHT_TALLEST 18

/// Assoc list of all heights, cast to strings, to """"tuples"""""
/// The first """tuple""" index is the upper body offset
/// The second """tuple""" index is the lower body offset
GLOBAL_LIST_INIT(human_heights_to_offsets, list(
"[MONKEY_HEIGHT_DWARF]" = list(-9, -3),
"[MONKEY_HEIGHT_MEDIUM]" = list(-7, -4),
"[HUMAN_HEIGHT_DWARF]" = list(-5, -4),
"[HUMAN_HEIGHT_SHORTEST]" = list(-2, -1),
"[HUMAN_HEIGHT_SHORT]" = list(-1, -1),
"[HUMAN_HEIGHT_MEDIUM]" = list(0, 0),
"[HUMAN_HEIGHT_TALL]" = list(1, 1),
"[HUMAN_HEIGHT_TALLER]" = list(2, 1),
"[HUMAN_HEIGHT_TALLEST]" = list(3, 2),
))

#define UPPER_BODY "upper body"
#define LOWER_BODY "lower body"
#define NO_MODIFY "do not modify"


//tivi todo finish below with our used stuff
/// Used for human height overlay adjustments
/// Certain standing overlay layers shouldn't have a filter applied and should instead just offset by a pixel y
/// This list contains all the layers that must offset, with its value being whether it's a part of the upper half of the body (TRUE) or not (FALSE)
GLOBAL_LIST_INIT(layers_to_offset, list(
// Very tall hats will get cut off by filter
"[HEAD_LAYER]" = UPPER_BODY,
// Hair will get cut off by filter
"[HAIR_LAYER]" = UPPER_BODY,
// Long belts (sabre sheathe) will get cut off by filter
"[BELT_LAYER]" = LOWER_BODY,
// Everything below looks fine with or without a filter, so we can skip it and just offset
// (In practice they'd be fine if they got a filter but we can optimize a bit by not.)
"[GLASSES_LAYER]" = UPPER_BODY,
"[GLOVES_LAYER]" = LOWER_BODY,
"[HANDCUFF_LAYER]" = LOWER_BODY,
"[ID_LAYER]" = UPPER_BODY,
// These DO get a filter, I'm leaving them here as reference,
// to show how many filters are added at a glance
// BACK_LAYER (backpacks are big)
// BODYPARTS_HIGH_LAYER (arms)
// BODY_LAYER (body markings (full body), underwear (full body), eyes)
// BODY_ADJ_LAYER (external organs like wings)
// BODY_BEHIND_LAYER (external organs like wings)
// BODY_FRONT_LAYER (external organs like wings)
// DAMAGE_LAYER (full body)
// HIGHEST_LAYER (full body)
// UNIFORM_LAYER (full body)
// WOUND_LAYER (full body)
))

//taste sensitivity defines, used in mob/living/proc/taste
#define TASTE_HYPERSENSITIVE 5 //anything below 5% is not tasted
#define TASTE_SENSITIVE 10 //anything below 10%
Expand All @@ -393,41 +496,6 @@ GLOBAL_LIST_INIT(xenoupgradetiers, list(XENO_UPGRADE_BASETYPE, XENO_UPGRADE_INVA
#define BLOOD_VOLUME_BAD 224
#define BLOOD_VOLUME_SURVIVE 122

// Overlay Indexes
#define WOUND_LAYER 27
#define MOTH_WINGS_LAYER 26
#define DAMAGE_LAYER 25
#define UNIFORM_LAYER 24
#define ID_LAYER 23
#define SHOES_LAYER 22
#define GLOVES_LAYER 21
#define BELT_LAYER 20
#define GLASSES_LAYER 19
#define SUIT_LAYER 18 //Possible make this an overlay of somethign required to wear a belt?
#define HAIR_LAYER 17 //TODO: make part of head layer?
#define EARS_LAYER 16
#define FACEMASK_LAYER 15
#define GOGGLES_LAYER 14 //For putting Ballistic goggles and potentially other things above masks
#define HEAD_LAYER 13
#define COLLAR_LAYER 12
#define SUIT_STORE_LAYER 11
#define BACK_LAYER 10
#define KAMA_LAYER 9
#define CAPE_LAYER 8
#define HANDCUFF_LAYER 7
#define L_HAND_LAYER 6
#define R_HAND_LAYER 5
#define BURST_LAYER 4 //Chestburst overlay
#define OVERHEALTH_SHIELD_LAYER 3
#define FIRE_LAYER 2 //If you're on fire
#define LASER_LAYER 1 //For sniper targeting laser

#define TOTAL_LAYERS 27

#define MOTH_WINGS_BEHIND_LAYER 1

#define TOTAL_UNDERLAYS 1

#define BASE_GRAB_SLOWDOWN 3 //Slowdown called by /mob/setGrabState(newstate) in mob.dm when grabbing a target aggressively.

///Stamina exhaustion
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
#define PISTOL_LACE_TRAIT "pistol_lace"
#define NIGHT_VISION_GOGGLES_TRAIT "night_vision_goggles"
#define SUBMERGED_TRAIT "submerged_trait"
#define TRAIT_DWARF "dwarf"
/// Makes you way too tall. Like just too much, dude, it's kind of creepy. Humanoid only.
#define TRAIT_TOO_TALL "too_tall"

#define ABSTRACT_ITEM_TRAIT "abstract_item"
/// A trait given by any status effect
Expand Down
116 changes: 116 additions & 0 deletions code/datums/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
*/
var/list/cooldowns

/// List for handling persistent filters.
var/list/filter_data

#ifdef DATUMVAR_DEBUGGING_MODE
var/list/cached_vars
#endif
Expand Down Expand Up @@ -291,3 +294,116 @@
if(QDELETED(source))
return
TIMER_COOLDOWN_END(source, index)

/** Add a filter to the datum.
* This is on datum level, despite being most commonly / primarily used on atoms, so that filters can be applied to images / mutable appearances.
* Can also be used to assert a filter's existence. I.E. update a filter regardless if it exists or not.
*
* Arguments:
* * name - Filter name
* * priority - Priority used when sorting the filter.
* * params - Parameters of the filter.
*/
/datum/proc/add_filter(name, priority, list/params)
LAZYINITLIST(filter_data)
var/list/copied_parameters = params.Copy()
copied_parameters["priority"] = priority
filter_data[name] = copied_parameters
update_filters()

///A version of add_filter that takes a list of filters to add rather than being individual, to limit calls to update_filters().
/datum/proc/add_filters(list/list/filters)
LAZYINITLIST(filter_data)
for(var/list/individual_filter as anything in filters)
var/list/params = individual_filter["params"]
var/list/copied_parameters = params.Copy()
copied_parameters["priority"] = individual_filter["priority"]
filter_data[individual_filter["name"]] = copied_parameters
update_filters()

///Sorts our filters by priority and reapplies them
/datum/proc/update_filters()
ASSERT(isatom(src) || isimage(src))
var/atom/atom_cast = src // filters only work with images or atoms.
atom_cast.filters = null
filter_data = sortTim(filter_data, GLOBAL_PROC_REF(cmp_filter_data_priority), TRUE)
for(var/f in filter_data)
var/list/data = filter_data[f]
var/list/arguments = data.Copy()
arguments -= "priority"
atom_cast.filters += filter(arglist(arguments))
UNSETEMPTY(filter_data)
/** Update a filter's parameter to the new one. If the filter doesnt exist we won't do anything.
*
* Arguments:
* * name - Filter name
* * new_params - New parameters of the filter
* * overwrite - TRUE means we replace the parameter list completely. FALSE means we only replace the things on new_params.
*/
/datum/proc/modify_filter(name, list/new_params, overwrite = FALSE)
var/filter = get_filter(name)
if(!filter)
return
if(overwrite)
filter_data[name] = new_params
else
for(var/thing in new_params)
filter_data[name][thing] = new_params[thing]
update_filters()

/** Update a filter's parameter and animate this change. If the filter doesnt exist we won't do anything.
* Basically a [datum/proc/modify_filter] call but with animations. Unmodified filter parameters are kept.
*
* Arguments:
* * name - Filter name
* * new_params - New parameters of the filter
* * time - time arg of the BYOND animate() proc.
* * easing - easing arg of the BYOND animate() proc.
* * loop - loop arg of the BYOND animate() proc.
*/
/datum/proc/transition_filter(name, list/new_params, time, easing, loop)
var/filter = get_filter(name)
if(!filter)
return
// This can get injected by the filter procs, we want to support them so bye byeeeee
new_params -= "type"
animate(filter, new_params, time = time, easing = easing, loop = loop)
modify_filter(name, new_params)

/// Updates the priority of the passed filter key
/datum/proc/change_filter_priority(name, new_priority)
if(!filter_data || !filter_data[name])
return

filter_data[name]["priority"] = new_priority
update_filters()

/// Returns the filter associated with the passed key
/datum/proc/get_filter(name)
ASSERT(isatom(src) || isimage(src))
if(filter_data && filter_data[name])
var/atom/atom_cast = src // filters only work with images or atoms.
return atom_cast.filters[filter_data.Find(name)]

/// Returns the indice in filters of the given filter name.
/// If it is not found, returns null.
/datum/proc/get_filter_index(name)
return filter_data?.Find(name)

/// Removes the passed filter, or multiple filters, if supplied with a list.
/datum/proc/remove_filter(name_or_names)
if(!filter_data)
return

var/list/names = islist(name_or_names) ? name_or_names : list(name_or_names)

for(var/name in names)
if(filter_data[name])
filter_data -= name
update_filters()

/datum/proc/clear_filters()
ASSERT(isatom(src) || isimage(src))
var/atom/atom_cast = src // filters only work with images or atoms.
filter_data = null
atom_cast.filters = null
65 changes: 1 addition & 64 deletions code/game/atoms/_atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
///a very temporary list of overlays to add
var/list/add_overlays

///Lazy assoc list for managing filters attached to us
var/list/filter_data

///Related to do_after/do_mob overlays, I can't get my hopes high.
var/list/display_icons
Expand Down Expand Up @@ -508,72 +506,11 @@ directive is properly returned.
//we were deleted
return

///Add filters by priority to an atom
/atom/proc/add_filter(name,priority,list/params)
LAZYINITLIST(filter_data)
var/list/p = params.Copy()
p["priority"] = priority
filter_data[name] = p
update_filters()

///Sorts our filters by priority and reapplies them
/atom/proc/update_filters()
filters = null
filter_data = sortTim(filter_data, GLOBAL_PROC_REF(cmp_filter_data_priority), TRUE)
for(var/f in filter_data)
var/list/data = filter_data[f]
var/list/arguments = data.Copy()
arguments -= "priority"
filters += filter(arglist(arguments))
UNSETEMPTY(filter_data)

/atom/proc/transition_filter(name, time, list/new_params, easing, loop)
var/filter = get_filter(name)
if(!filter)
return

var/list/old_filter_data = filter_data[name]

var/list/params = old_filter_data.Copy()
for(var/thing in new_params)
params[thing] = new_params[thing]

animate(filter, new_params, time = time, easing = easing, loop = loop)
for(var/param in params)
filter_data[name][param] = params[param]

/atom/proc/change_filter_priority(name, new_priority)
if(!filter_data || !filter_data[name])
return

filter_data[name]["priority"] = new_priority
update_filters()

/obj/item/update_filters()
/obj/item/update_filters() // tivi todo move this to items
. = ..()
for(var/datum/action/A AS in actions)
A.update_button_icon()

///returns a filter in the managed filters list by name
/atom/proc/get_filter(name)
if(filter_data && filter_data[name])
return filters[filter_data.Find(name)]

///removes a filter from the atom
/atom/proc/remove_filter(name_or_names)
if(!filter_data)
return
var/list/names = islist(name_or_names) ? name_or_names : list(name_or_names)

for(var/name in names)
if(filter_data[name])
filter_data -= name
update_filters()

/atom/proc/clear_filters()
filter_data = null
filters = null

/*
Atom Colour Priority System
A System that gives finer control over which atom colour to colour the atom with.
Expand Down
2 changes: 1 addition & 1 deletion code/game/atoms/atom_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ GLOBAL_LIST_EMPTY(submerge_filter_timer_list)
var/height_to_use = (64 - AM_icon.Height()) * 0.5 //gives us the right height based on AM's icon height relative to the 64 high alpha mask

if(!new_height && !new_depth)
GLOB.submerge_filter_timer_list[ref(src)] = addtimer(CALLBACK(src, TYPE_PROC_REF(/atom, remove_filter), AM_SUBMERGE_MASK), duration, TIMER_STOPPABLE)
GLOB.submerge_filter_timer_list[ref(src)] = addtimer(CALLBACK(src, TYPE_PROC_REF(/datum, remove_filter), AM_SUBMERGE_MASK), duration, TIMER_STOPPABLE)
REMOVE_TRAIT(src, TRAIT_SUBMERGED, SUBMERGED_TRAIT)
else if(!HAS_TRAIT(src, TRAIT_SUBMERGED)) //we use a trait to avoid some edge cases if things are moving fast or unusually
if(GLOB.submerge_filter_timer_list[ref(src)])
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
/// This is the cooldown on suffering additional effects for when shock gets high
COOLDOWN_DECLARE(last_shock_effect)

/// Height of the mob
VAR_PROTECTED/mob_height = HUMAN_HEIGHT_MEDIUM

///copies over clothing preferences like underwear to another human
/mob/living/carbon/human/proc/copy_clothing_prefs(mob/living/carbon/human/destination)
destination.underwear = underwear
Expand Down
Loading
Loading