Files
Bubberstation/code/modules/loadout/loadout_helpers.dm
MrMelbert d578965582 Wallout Loadout equips itself / Lipstick Loadout comes applies itself (and is customizable) (#89808)
## About The Pull Request

- Selecting Wallet in the loadout, will equip the wallet when you load
into the game. It will auto-fill the wallet with small items from your
roundstart kit like quirk items or other loadout items.

- Selecting Lipstick in the loadout will automatically apply it to your
character. You still get the lipstick item at game start.

- Deletes all the preset lipstick colors, now you can just pick what
color you want. You can also pick what layer the lipstick starts at
(high, middle, low).

## Why It's Good For The Game

- Makes it work like the station trait (except the money part) 

- Convenience

- Extra customization

## Changelog

🆑 Melbert
qol: Wallet loadout item comes pre-equipped
qol: Lipstick loadout item comes pre-applied
qol: You can choose your lipstick color from any color now. You can also
choose what layer it defaults to.
/🆑
2025-03-12 22:28:24 -04:00

77 lines
2.7 KiB
Plaintext

/**
* Equips this mob with a given outfit and loadout items as per the passed preferences.
*
* Loadout items override the pre-existing item in the corresponding slot of the job outfit.
* Some job items are preserved after being overridden - belt items, ear items, and glasses.
* The rest of the slots, the items are overridden completely and deleted.
*
* Species with special outfits are snowflaked to have loadout items placed in their bags instead of overriding the outfit.
*
* * outfit - the job outfit we're equipping
* * preference_source - the preferences to draw loadout items from.
* * visuals_only - whether we call special equipped procs, or if we just look like we equipped it
*/
/mob/living/carbon/human/proc/equip_outfit_and_loadout(
datum/outfit/outfit = /datum/outfit,
datum/preferences/preference_source,
visuals_only = FALSE,
)
if(isnull(preference_source))
return equipOutfit(outfit, visuals_only)
var/datum/outfit/equipped_outfit
if(ispath(outfit, /datum/outfit))
equipped_outfit = new outfit()
else if(istype(outfit, /datum/outfit))
equipped_outfit = outfit
else
CRASH("Invalid outfit passed to equip_outfit_and_loadout ([outfit])")
var/list/preference_list = preference_source.read_preference(/datum/preference/loadout)
var/list/loadout_datums = loadout_list_to_datums(preference_list)
// Slap our things into the outfit given
for(var/datum/loadout_item/item as anything in loadout_datums)
item.insert_path_into_outfit(equipped_outfit, src, visuals_only)
// Equip the outfit loadout items included
if(!equipped_outfit.equip(src, visuals_only))
return FALSE
// Handle any snowflake on_equips
var/list/new_contents = get_all_gear()
var/update = NONE
for(var/datum/loadout_item/item as anything in loadout_datums)
update |= item.on_equip_item(
equipped_item = locate(item.item_path) in new_contents,
preference_source = preference_source,
preference_list = preference_list,
equipper = src,
visuals_only = visuals_only,
)
if(update)
update_clothing(update)
return TRUE
/**
* Takes a list of paths (such as a loadout list)
* and returns a list of their singleton loadout item datums
*
* loadout_list - the list being checked
*
* Returns a list of singleton datums
*/
/proc/loadout_list_to_datums(list/loadout_list) as /list
var/list/datums = list()
if(!length(GLOB.all_loadout_datums))
CRASH("No loadout datums in the global loadout list!")
for(var/path in loadout_list)
var/actual_datum = GLOB.all_loadout_datums[path]
if(!istype(actual_datum, /datum/loadout_item))
stack_trace("Could not find ([path]) loadout item in the global list of loadout datums!")
continue
datums += actual_datum
return datums