Files
Bubberstation/code/modules/loadout/loadout_helpers.dm
MrMelbert d244c86ce6 Adds Character Loadout Tab to preferences (with just a small handful of items to start) (#83521)
## About The Pull Request

Adds a Character Loadout Tab to the preference menu

This tab lets you pick items to start the round with


![image](https://private-user-images.githubusercontent.com/51863163/336254447-c5f7eefa-c44c-418d-b48e-0409bb5bb982.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgwNDAxMjMsIm5iZiI6MTcxODAzOTgyMywicGF0aCI6Ii81MTg2MzE2My8zMzYyNTQ0NDctYzVmN2VlZmEtYzQ0Yy00MThkLWI0OGUtMDQwOWJiNWJiOTgyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjEwVDE3MTcwM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYxYWFmYjI2NDU0YjUyODg3NjBmM2VjZDg4YWQ1YjlhMThmODU3MDYyMzYwOGVmYTcxYmY2MDhjZWVmYjQ5ZTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Y0_19Gisfp4yyUmLgW2atfKyneL7POWFRKNVgNWTbEs)

This also has some additional mechanics, such as being able to recolor
colorable items, rename certain items (such as plushies), set item skins
(such as the pride pin)


![image](https://github.com/tgstation/tgstation/assets/51863163/8a085d6c-a294-4538-95d2-ada902ab69b4)

## Why It's Good For The Game

This has been headcoder sanctioned for some time, just no one did it. So
here we are.

Allows players to add some additional customization to their characters.
Keeps us from cluttering the quirks list with quirks that do nothing but
grants items.

## Changelog

🆑 Melbert
add: Character Loadouts
del: Pride Pin quirk (it's in the Loadout menu now)
/🆑
2024-06-11 17:50:12 -07:00

81 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)
var/obj/item/equipped = locate(item.item_path) in new_contents
if(isnull(equipped))
continue
update |= item.on_equip_item(
equipped_item = equipped,
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