mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-30 15:37:36 +01:00
Merge pull request #11712 from Markolie/lazy
Custom outfit manager and spawn with outfit on transform/reincarnate
This commit is contained in:
@@ -1269,7 +1269,12 @@
|
||||
return
|
||||
src.debug_variables(DAT)
|
||||
|
||||
return
|
||||
if(href_list["copyoutfit"])
|
||||
if(!check_rights(R_EVENT))
|
||||
return
|
||||
var/mob/living/carbon/human/H = locateUID(href_list["copyoutfit"])
|
||||
if(istype(H))
|
||||
H.copy_outfit()
|
||||
|
||||
/client/proc/view_var_Topic_list(href, href_list, hsrc)
|
||||
if(href_list["VarsList"])
|
||||
|
||||
@@ -22,11 +22,15 @@
|
||||
var/pda = null
|
||||
var/internals_slot = null //ID of slot containing a gas tank
|
||||
var/list/backpack_contents = list() // In the list(path=count,otherpath=count) format
|
||||
var/list/implants = null
|
||||
var/list/cybernetic_implants = null
|
||||
var/box // Internals box. Will be inserted at the start of backpack_contents
|
||||
var/list/implants = list()
|
||||
var/list/cybernetic_implants = list()
|
||||
var/list/accessories = list()
|
||||
|
||||
var/list/chameleon_extras //extra types for chameleon outfit changes, mostly guns
|
||||
|
||||
var/can_be_admin_equipped = TRUE // Set to FALSE if your outfit requires runtime parameters
|
||||
|
||||
/datum/outfit/proc/pre_equip(mob/living/carbon/human/H, visualsOnly = FALSE)
|
||||
//to be overriden for customization depending on client prefs,species etc
|
||||
return
|
||||
@@ -82,12 +86,24 @@
|
||||
if(pda)
|
||||
equip_item(H, pda, slot_wear_pda)
|
||||
|
||||
if(uniform)
|
||||
for(var/path in accessories)
|
||||
var/obj/item/clothing/accessory/A = new path()
|
||||
var/obj/item/clothing/under/U = uniform
|
||||
U.attach_accessory(A, H)
|
||||
|
||||
if(!visualsOnly) // Items in pockets or backpack don't show up on mob's icon.
|
||||
if(l_pocket)
|
||||
equip_item(H, l_pocket, slot_l_store)
|
||||
if(r_pocket)
|
||||
equip_item(H, r_pocket, slot_r_store)
|
||||
|
||||
if(box)
|
||||
if(!backpack_contents)
|
||||
backpack_contents = list()
|
||||
backpack_contents.Insert(1, box)
|
||||
backpack_contents[box] = 1
|
||||
|
||||
for(var/path in backpack_contents)
|
||||
var/number = backpack_contents[path]
|
||||
for(var/i in 1 to number)
|
||||
@@ -159,3 +175,95 @@
|
||||
types += chameleon_extras
|
||||
listclearnulls(types)
|
||||
return types
|
||||
|
||||
/datum/outfit/proc/save_to_file(mob/admin)
|
||||
var/stored_data = get_json_data()
|
||||
var/json = json_encode(stored_data)
|
||||
// Kinda annoying but as far as I can tell you need to make actual file.
|
||||
var/f = file("data/TempOutfitUpload")
|
||||
fdel(f)
|
||||
WRITE_FILE(f, json)
|
||||
admin << ftp(f, "[name].json")
|
||||
|
||||
/datum/outfit/proc/load_from(list/outfit_data)
|
||||
// This could probably use more strict validation.
|
||||
name = outfit_data["name"]
|
||||
uniform = text2path(outfit_data["uniform"])
|
||||
suit = text2path(outfit_data["suit"])
|
||||
back = text2path(outfit_data["back"])
|
||||
belt = text2path(outfit_data["belt"])
|
||||
gloves = text2path(outfit_data["gloves"])
|
||||
shoes = text2path(outfit_data["shoes"])
|
||||
head = text2path(outfit_data["head"])
|
||||
mask = text2path(outfit_data["mask"])
|
||||
l_ear = text2path(outfit_data["l_ear"])
|
||||
r_ear = text2path(outfit_data["r_ear"])
|
||||
glasses = text2path(outfit_data["glasses"])
|
||||
id = text2path(outfit_data["id"])
|
||||
pda = text2path(outfit_data["pda"])
|
||||
l_pocket = text2path(outfit_data["l_pocket"])
|
||||
r_pocket = text2path(outfit_data["r_pocket"])
|
||||
suit_store = text2path(outfit_data["suit_store"])
|
||||
r_hand = text2path(outfit_data["r_hand"])
|
||||
l_hand = text2path(outfit_data["l_hand"])
|
||||
internals_slot = text2path(outfit_data["internals_slot"])
|
||||
|
||||
var/list/backpack = outfit_data["backpack_contents"]
|
||||
backpack_contents = list()
|
||||
for(var/item in backpack)
|
||||
var/itype = text2path(item)
|
||||
if(itype)
|
||||
backpack_contents[itype] = backpack[item]
|
||||
box = text2path(outfit_data["box"])
|
||||
|
||||
var/list/impl = outfit_data["implants"]
|
||||
implants = list()
|
||||
for(var/I in impl)
|
||||
var/imptype = text2path(I)
|
||||
if(imptype)
|
||||
implants += imptype
|
||||
|
||||
var/list/cybernetic_impl = outfit_data["cybernetic_implants"]
|
||||
cybernetic_implants = list()
|
||||
for(var/I in cybernetic_impl)
|
||||
var/cybtype = text2path(I)
|
||||
if(cybtype)
|
||||
cybernetic_implants += cybtype
|
||||
|
||||
var/list/accessories = outfit_data["accessories"]
|
||||
accessories = list()
|
||||
for(var/A in accessories)
|
||||
var/accessorytype = text2path(A)
|
||||
if(accessorytype)
|
||||
accessories += accessorytype
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/outfit/proc/get_json_data()
|
||||
. = list()
|
||||
.["outfit_type"] = type
|
||||
.["name"] = name
|
||||
.["uniform"] = uniform
|
||||
.["suit"] = suit
|
||||
.["back"] = back
|
||||
.["belt"] = belt
|
||||
.["gloves"] = gloves
|
||||
.["shoes"] = shoes
|
||||
.["head"] = head
|
||||
.["mask"] = mask
|
||||
.["l_ear"] = l_ear
|
||||
.["r_ear"] = r_ear
|
||||
.["glasses"] = glasses
|
||||
.["id"] = id
|
||||
.["pda"] = pda
|
||||
.["l_pocket"] = l_pocket
|
||||
.["r_pocket"] = r_pocket
|
||||
.["suit_store"] = suit_store
|
||||
.["r_hand"] = r_hand
|
||||
.["l_hand"] = l_hand
|
||||
.["internals_slot"] = internals_slot
|
||||
.["backpack_contents"] = backpack_contents
|
||||
.["box"] = box
|
||||
.["implants"] = implants
|
||||
.["cybernetic_implants"] = cybernetic_implants
|
||||
.["accessories"] = accessories
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
// This outfit preserves varedits made on the items
|
||||
// Created from admin helpers.
|
||||
/datum/outfit/varedit
|
||||
var/list/vv_values
|
||||
var/list/stored_access
|
||||
var/update_id_name = FALSE //If the name of the human is same as the name on the id they're wearing we'll update provided id when equipping
|
||||
|
||||
/datum/outfit/varedit/pre_equip(mob/living/carbon/human/H, visualsOnly)
|
||||
H.delete_equipment() //Applying VV to wrong objects is not reccomended.
|
||||
. = ..()
|
||||
|
||||
/datum/outfit/varedit/proc/set_equipment_by_slot(slot, item_path)
|
||||
switch(slot)
|
||||
if(slot_w_uniform)
|
||||
uniform = item_path
|
||||
if(slot_back)
|
||||
back = item_path
|
||||
if(slot_wear_suit)
|
||||
suit = item_path
|
||||
if(slot_belt)
|
||||
belt = item_path
|
||||
if(slot_gloves)
|
||||
gloves = item_path
|
||||
if(slot_shoes)
|
||||
shoes = item_path
|
||||
if(slot_head)
|
||||
head = item_path
|
||||
if(slot_wear_mask)
|
||||
mask = item_path
|
||||
if(slot_l_ear)
|
||||
l_ear = item_path
|
||||
if(slot_r_ear)
|
||||
r_ear = item_path
|
||||
if(slot_glasses)
|
||||
glasses = item_path
|
||||
if(slot_wear_id)
|
||||
id = item_path
|
||||
if(slot_wear_pda)
|
||||
pda = item_path
|
||||
if(slot_s_store)
|
||||
suit_store = item_path
|
||||
if(slot_l_store)
|
||||
l_pocket = item_path
|
||||
if(slot_r_store)
|
||||
r_pocket = item_path
|
||||
|
||||
|
||||
/proc/collect_vv(obj/item/I)
|
||||
//Temporary/Internal stuff, do not copy these.
|
||||
var/static/list/ignored_vars = list("vars","x","y","z","plane","layer","override","animate_movement","pixel_step_size","screen_loc","fingerprintslast","tip_timer")
|
||||
|
||||
if(istype(I))
|
||||
var/list/vedits = list()
|
||||
for(var/varname in I.vars)
|
||||
if(!I.can_vv_get(varname))
|
||||
continue
|
||||
if(varname in ignored_vars)
|
||||
continue
|
||||
var/vval = I.vars[varname]
|
||||
//Does it even work ?
|
||||
if(vval == initial(I.vars[varname]))
|
||||
continue
|
||||
//Only text/numbers and icons variables to make it less weirdness prone.
|
||||
if(!istext(vval) && !isnum(vval) && !isicon(vval))
|
||||
continue
|
||||
vedits[varname] = I.vars[varname]
|
||||
return vedits
|
||||
|
||||
/mob/living/carbon/human/proc/copy_outfit()
|
||||
var/datum/outfit/varedit/O = new
|
||||
|
||||
//Copy equipment
|
||||
var/list/result = list()
|
||||
var/list/slots_to_check = list(slot_w_uniform, slot_back, slot_wear_suit, slot_belt, slot_gloves, slot_shoes, slot_head, slot_wear_mask, slot_l_ear, slot_r_ear, slot_glasses, slot_wear_id, slot_wear_pda, slot_s_store, slot_l_store, slot_r_store)
|
||||
for(var/s in slots_to_check)
|
||||
var/obj/item/I = get_item_by_slot(s)
|
||||
var/vedits = collect_vv(I)
|
||||
if(vedits)
|
||||
result["[s]"] = vedits
|
||||
if(istype(I))
|
||||
O.set_equipment_by_slot(s, I.type)
|
||||
|
||||
//Copy access
|
||||
O.stored_access = list()
|
||||
var/obj/item/id_slot = get_item_by_slot(slot_wear_id)
|
||||
if(id_slot)
|
||||
O.stored_access |= id_slot.GetAccess()
|
||||
var/obj/item/card/id/ID = id_slot.GetID()
|
||||
if(ID && ID.registered_name == real_name)
|
||||
O.update_id_name = TRUE
|
||||
|
||||
//Copy hands
|
||||
if(l_hand || r_hand) //Not in the mood to let outfits transfer amputees
|
||||
var/obj/item/left_hand = l_hand
|
||||
var/obj/item/right_hand = r_hand
|
||||
if(istype(left_hand))
|
||||
O.l_hand = left_hand.type
|
||||
var/vedits = collect_vv(left_hand)
|
||||
if(vedits)
|
||||
result["LHAND"] = vedits
|
||||
if(istype(right_hand))
|
||||
O.r_hand = right_hand.type
|
||||
var/vedits = collect_vv(left_hand)
|
||||
if(vedits)
|
||||
result["RHAND"] = vedits
|
||||
O.vv_values = result
|
||||
|
||||
//Copy backpack contents if exist.
|
||||
var/obj/item/backpack = get_item_by_slot(slot_back)
|
||||
if(istype(backpack) && LAZYLEN(backpack.contents) > 0)
|
||||
var/list/typecounts = list()
|
||||
for(var/obj/item/I in backpack)
|
||||
if(typecounts[I.type])
|
||||
typecounts[I.type] += 1
|
||||
else
|
||||
typecounts[I.type] = 1
|
||||
O.backpack_contents = typecounts
|
||||
//TODO : Copy varedits from backpack stuff too.
|
||||
|
||||
//Copy implants
|
||||
O.implants = list()
|
||||
for(var/obj/item/implant/I in contents)
|
||||
if(istype(I))
|
||||
O.implants |= I.type
|
||||
|
||||
// Copy cybernetic implants
|
||||
O.cybernetic_implants = list()
|
||||
for(var/obj/item/organ/internal/CI in contents)
|
||||
if(istype(CI))
|
||||
O.cybernetic_implants |= CI.type
|
||||
|
||||
// Copy accessories
|
||||
var/obj/item/clothing/under/uniform_slot = get_item_by_slot(slot_w_uniform)
|
||||
if(uniform_slot)
|
||||
O.accessories = list()
|
||||
for(var/obj/item/clothing/accessory/A in uniform_slot.accessories)
|
||||
if(istype(A))
|
||||
O.accessories |= A
|
||||
|
||||
//Copy to outfit cache
|
||||
var/outfit_name = stripped_input(usr, "Enter the outfit name")
|
||||
O.name = outfit_name
|
||||
GLOB.custom_outfits += O
|
||||
to_chat(usr, "Outfit registered, use select equipment to equip it.")
|
||||
|
||||
/datum/outfit/varedit/post_equip(mob/living/carbon/human/H, visualsOnly)
|
||||
. = ..()
|
||||
//Apply VV
|
||||
for(var/slot in vv_values)
|
||||
var/list/edits = vv_values[slot]
|
||||
var/obj/item/I
|
||||
switch(slot)
|
||||
if("LHAND")
|
||||
I = H.l_hand
|
||||
if("RHAND")
|
||||
I = H.r_hand
|
||||
else
|
||||
I = H.get_item_by_slot(text2num(slot))
|
||||
for(var/vname in edits)
|
||||
I.vv_edit_var(vname,edits[vname])
|
||||
//Apply access
|
||||
var/obj/item/id_slot = H.get_item_by_slot(slot_wear_id)
|
||||
if(id_slot)
|
||||
var/obj/item/card/id/card = id_slot.GetID()
|
||||
if(istype(card))
|
||||
card.access |= stored_access
|
||||
if(update_id_name)
|
||||
card.registered_name = H.real_name
|
||||
card.update_label()
|
||||
|
||||
/datum/outfit/varedit/get_json_data()
|
||||
. = .. ()
|
||||
.["stored_access"] = stored_access
|
||||
.["update_id_name"] = update_id_name
|
||||
var/list/stripped_vv = list()
|
||||
for(var/slot in vv_values)
|
||||
var/list/vedits = vv_values[slot]
|
||||
var/list/stripped_edits = list()
|
||||
for(var/edit in vedits)
|
||||
if(istext(vedits[edit]) || isnum(vedits[edit]) || isnull(vedits[edit]))
|
||||
stripped_edits[edit] = vedits[edit]
|
||||
if(stripped_edits.len)
|
||||
stripped_vv[slot] = stripped_edits
|
||||
.["vv_values"] = stripped_vv
|
||||
|
||||
/datum/outfit/varedit/load_from(list/outfit_data)
|
||||
. = ..()
|
||||
stored_access = outfit_data["stored_access"]
|
||||
vv_values = outfit_data["vv_values"]
|
||||
update_id_name = outfit_data["update_id_name"]
|
||||
Reference in New Issue
Block a user