Skip to content

Commit

Permalink
Переосмысление Family Heirloom квирка (BlueMoon-Labs#657)
Browse files Browse the repository at this point in the history
* Создание преференса под family heirloom в лодауте

* Фикс кнопочек

* Основной функционал лодаутных реликвий

* Особая строчка в экзамайне для реликвий

* Фикс ситуации с clear_loadout()

* Изменил определения того, выбрана ли уже реликвия

* Ошибочка вышла.

---------

Co-authored-by: Марк <[email protected]>
Co-authored-by: Марк <[email protected]>
  • Loading branch information
3 people authored Jan 13, 2024
1 parent b40bdd6 commit 318d7f8
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 37 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/_flags/item_flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#define ITEM_CAN_PARRY (1<<12)
/// This item can be used in the directional blocking system. Only a basic check used to determine if we should proceed with directional block handling at all.
#define ITEM_CAN_BLOCK (1<<13)
/// Является ли данный предмет семейной ценностью (family heirloom)
#define FAMILY_HEIRLOOM (1<<14) // BLUEMOON ADD - выбор вещей из лодаута как family heirloom

// Flags for the clothing_flags var on /obj/item/clothing

Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/loadout.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#define LOADOUT_COLOR "loadout_color"
#define LOADOUT_CUSTOM_NAME "loadout_custom_name"
#define LOADOUT_CUSTOM_DESCRIPTION "loadout_custom_description"
#define LOADOUT_IS_HEIRLOOM "loadout_is_heirloom" // BLUEMOON ADD - выбор вещей из лодаута как family heirloom

//loadout item flags
#define LOADOUT_CAN_NAME (1<<0) //renaming items
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/bitfields.dm
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ DEFINE_BITFIELD(item_flags, list(
"NO_MAT_REDEMPTION" = NO_MAT_REDEMPTION,
"NO_PIXEL_RANDOM_DROP" = NO_PIXEL_RANDOM_DROP,
"SLOWS_WHILE_IN_HAND" = SLOWS_WHILE_IN_HAND,
"FAMILY_HEIRLOOM" = FAMILY_HEIRLOOM // BLUEMOON ADD - выбор вещей из лодаута как family heirloom
))

DEFINE_BITFIELD(material_flags, list(
Expand Down
17 changes: 16 additions & 1 deletion code/controllers/subsystem/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,10 @@ SUBSYSTEM_DEF(job)
if(!the_mob)
the_mob = M // cause this doesn't get assigned if player is a latejoiner
var/list/chosen_gear = the_mob.client.prefs.loadout_data["SAVE_[the_mob.client.prefs.loadout_slot]"]
var/heirloomer = FALSE
var/list/my_quirks = the_mob.client.prefs.all_quirks.Copy()
if("Семейная реликвия" in my_quirks)
heirloomer = TRUE
if(the_mob.client && the_mob.client.prefs && (chosen_gear && chosen_gear.len))
if(!ishuman(M))//no silicons allowed
return
Expand All @@ -740,6 +744,10 @@ SUBSYSTEM_DEF(job)
if(G.handle_post_equip)
permitted = FALSE
if(!permitted)
// BLUEMOON ADD START - выбор вещей из лодаута как family heirloom
if(i[LOADOUT_IS_HEIRLOOM] && heirloomer)
to_chat(M, "<span class='warning'>Вы не смогли взять с собой свой любимый предмет, [G.name], из-за ограничений вашей профессии или других проблем, но у вас была и другая семейная ценность, поэтому вы прихватили её!</span>")
// BLUEMOON END
continue
var/obj/item/I = new G.path
if(I)
Expand Down Expand Up @@ -784,6 +792,14 @@ SUBSYSTEM_DEF(job)
I.forceMove(get_turf(M)) // If everything fails, just put it on the floor under the mob.
else
qdel(I)
// BLUEMOON ADD START - выбор вещей из лодаута как family heirloom
if(i[LOADOUT_IS_HEIRLOOM] && !QDELETED(I) && heirloomer)
I.item_flags |= FAMILY_HEIRLOOM
if(!i[LOADOUT_CUSTOM_NAME])
var/list/family_name = splittext(M.real_name, " ")
I.name = "\improper [family_name[family_name.len]] family [I.name]"
// BLUEMOON END


/datum/controller/subsystem/job/proc/post_equip_loadout(mob/dead/new_player/N, mob/living/M, bypass_prereqs = FALSE, can_drop = TRUE)
var/mob/the_mob = N
Expand Down Expand Up @@ -852,7 +868,6 @@ SUBSYSTEM_DEF(job)
I.forceMove(get_turf(M)) // If everything fails, just put it on the floor under the mob.
else
qdel(I)

/datum/controller/subsystem/job/proc/FreeRole(rank)
if(!rank)
return
Expand Down
76 changes: 43 additions & 33 deletions code/datums/traits/negative.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
medical_record_text = "Пациент демонстрирует неестественную привязанность к семейной реликвии."
var/obj/item/heirloom
var/where
var/loadout_heirloom = FALSE // BLUEMOON EDIT - выбор вещей из лодаута как family heirloom
processing_quirk = TRUE

GLOBAL_LIST_EMPTY(family_heirlooms)
Expand All @@ -47,43 +48,52 @@ GLOBAL_LIST_EMPTY(family_heirlooms)
// Define holder and type
var/mob/living/carbon/human/human_holder = quirk_holder
var/obj/item/heirloom_type

// The quirk holder's species - we have a 50% chance, if we have a species with a set heirloom, to choose a species heirloom.
var/datum/species/holder_species = human_holder.dna?.species
if(holder_species && LAZYLEN(holder_species.family_heirlooms) && prob(50))
heirloom_type = pick(holder_species.family_heirlooms)
else
// Our quirk holder's job
var/datum/job/holder_job = SSjob.GetJob(human_holder.last_mind?.assigned_role)
if(holder_job && LAZYLEN(holder_job.family_heirlooms))
heirloom_type = pick(holder_job.family_heirlooms)

// If we didn't find an heirloom somehow, throw them a generic one
if(!heirloom_type)
heirloom_type = pick(/obj/item/toy/cards/deck, /obj/item/lighter, /obj/item/dice/d20)

// Create the heirloom item
heirloom = new heirloom_type(get_turf(quirk_holder))

// BLUEMOON EDIT START - выбор вещей из лодаута как family heirloom
for (var/obj/item/item in quirk_holder.GetAllContents())
if(item.item_flags & FAMILY_HEIRLOOM)
loadout_heirloom = TRUE
heirloom = item
if(!loadout_heirloom)
// The quirk holder's species - we have a 50% chance, if we have a species with a set heirloom, to choose a species heirloom.
var/datum/species/holder_species = human_holder.dna?.species
if(holder_species && LAZYLEN(holder_species.family_heirlooms) && prob(50))
heirloom_type = pick(holder_species.family_heirlooms)
else
// Our quirk holder's job
var/datum/job/holder_job = SSjob.GetJob(human_holder.last_mind?.assigned_role)
if(holder_job && LAZYLEN(holder_job.family_heirlooms))
heirloom_type = pick(holder_job.family_heirlooms)

// If we didn't find an heirloom somehow, throw them a generic one
if(!heirloom_type)
heirloom_type = pick(/obj/item/toy/cards/deck, /obj/item/lighter, /obj/item/dice/d20)
// Create the heirloom item
heirloom = new heirloom_type(get_turf(quirk_holder))
heirloom.item_flags |= FAMILY_HEIRLOOM
// Determine and assign item location
var/list/slots = list(
"В левом кармане" = ITEM_SLOT_LPOCKET,
"В правом кармане" = ITEM_SLOT_RPOCKET,
"В рюкзаке" = ITEM_SLOT_BACKPACK
)
where = human_holder.equip_in_one_of_slots(heirloom, slots, FALSE) || "под ногами"
// BLUEMOON EDIT END
// Add to global list
GLOB.family_heirlooms += heirloom

// Determine and assign item location
var/list/slots = list(
"В левом кармане" = ITEM_SLOT_LPOCKET,
"В правом кармане" = ITEM_SLOT_RPOCKET,
"В рюкзаке" = ITEM_SLOT_BACKPACK
)
where = human_holder.equip_in_one_of_slots(heirloom, slots, FALSE) || "под ногами"

/datum/quirk/family_heirloom/post_add()
if(where == "В рюкзаке")
var/mob/living/carbon/human/H = quirk_holder
SEND_SIGNAL(H.back, COMSIG_TRY_STORAGE_SHOW, H)

to_chat(quirk_holder, "<span class='boldnotice'>[where] находится [heirloom.name], передающаяся из поколения в поколение. Береги её!</span>")
var/list/family_name = splittext(quirk_holder.real_name, " ")
heirloom.name = "\improper [family_name[family_name.len]] family [heirloom.name]"
// BLUEMOON EDIT START - выбор вещей из лодаута как family heirloom
if(!loadout_heirloom)
if(where == "В рюкзаке")
var/mob/living/carbon/human/H = quirk_holder
SEND_SIGNAL(H.back, COMSIG_TRY_STORAGE_SHOW, H)

to_chat(quirk_holder, "<span class='boldnotice'>[where] находится [heirloom.name], передающаяся из поколения в поколение. Береги её!</span>")
var/list/family_name = splittext(quirk_holder.real_name, " ")
heirloom.name = "\improper [family_name[family_name.len]] family [heirloom.name]"
else
to_chat(quirk_holder, "<span class='boldnotice'>Ты прихватил с собой свою любимую вещь, [heirloom.name]. Береги её!</span>")
// BLUEMOON EDIT END

/datum/quirk/family_heirloom/on_process()
// Ignore for dead holder
Expand Down
16 changes: 16 additions & 0 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,22 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
var/datum/block_parry_data/data = return_block_parry_datum(block_parry_data)
. += "[src] has the capacity to be used to block and/or parry. <a href='?src=[REF(data)];name=[name];block=[item_flags & ITEM_CAN_BLOCK];parry=[item_flags & ITEM_CAN_PARRY];render=1'>\[Show Stats\]</a>"

// BLUEMOON ADD START - выбор вещей из лодаута как family heirloom
if(item_flags & FAMILY_HEIRLOOM)
var/my_heirloom = FALSE
if(istype(user, /mob/living))
var/mob/living/examiner = user
for(var/datum/quirk/Q in examiner.roundstart_quirks)
if(istype(Q, /datum/quirk/family_heirloom))
var/datum/quirk/family_heirloom/heirloom_quirk = Q
if(src == heirloom_quirk.heirloom)
my_heirloom = TRUE // МОЯ ПРЕЛЕСТЬ!
if(my_heirloom)
. += "<span class='boldnotice'>[src] - это моя реликвия! Нужно её беречь!</span>"
else
. += "<span class='notice'>[src] выглядит очень ухоженно. Видимо, этот предмет кому-то ценен...</span>"
// BLUEMOON ADD END

if(!user.research_scanner)
return

Expand Down
39 changes: 37 additions & 2 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,16 @@ GLOBAL_LIST_EMPTY(preferences_datums)
extra_loadout_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_rename=1;loadout_gear_name=[html_encode(gear.name)];'>Name</a> [loadout_item[LOADOUT_CUSTOM_NAME] ? loadout_item[LOADOUT_CUSTOM_NAME] : "N/A"]"
if(gear.loadout_flags & LOADOUT_CAN_DESCRIPTION)
extra_loadout_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_redescribe=1;loadout_gear_name=[html_encode(gear.name)];'>Description</a>"
else
extra_loadout_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_addheirloom=1;loadout_gear_name=[html_encode(gear.name)];'>Select as Heirloom</a><BR>"
// BLUEMOON ADD START - выбор вещей из лодаута как family heirloom
if(loadout_item[LOADOUT_IS_HEIRLOOM])
extra_loadout_data += "<BR><a class='linkOn' href='?_src_=prefs;preference=gear;loadout_removeheirloom=1;loadout_gear_name=[html_encode(gear.name)];'>Select as Heirloom</a><BR>"
else
extra_loadout_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_addheirloom=1;loadout_gear_name=[html_encode(gear.name)];'>Select as Heirloom</a><BR>"
if(ispath(gear.path, /obj/item/clothing/neck/petcollar)) //"name tag" sounds better for me, but in petcollar code "tagname" is used so let it be.
extra_loadout_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_tagname=1;loadout_gear_name=[html_encode(gear.name)];'>Name tag</a> [loadout_item["loadout_custom_tagname"] ? loadout_item["loadout_custom_tagname"] : "Name tag is visible for everyone looking at wearer."]"
// BLUEMOON ADD END
else if((gear_points - gear.cost) < 0)
class_link = "style='white-space:normal;' class='linkOff'"
else if(donoritem)
Expand All @@ -1363,8 +1371,9 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += gear.restricted_roles.Join(";")
dat += "</font>"
if(!istype(gear, /datum/gear/unlockable))
var/is_heirloom_string = loadout_item ? (loadout_item[LOADOUT_IS_HEIRLOOM] ? "<br><br><center><b>Ваша семейная реликвия!</b></center>" : "") : "" // BLUEMOON EDIT - выбор вещей из лодаута как family heirloom
// the below line essentially means "if the loadout item is picked by the user and has a custom description, give it the custom description, otherwise give it the default description"
dat += "</td><td><font size=2><i>[loadout_item ? (loadout_item[LOADOUT_CUSTOM_DESCRIPTION] ? loadout_item[LOADOUT_CUSTOM_DESCRIPTION] : gear.description) : gear.description]</i></font></td></tr>"
dat += "</td><td><font size=2><i>[loadout_item ? (loadout_item[LOADOUT_CUSTOM_DESCRIPTION] ? loadout_item[LOADOUT_CUSTOM_DESCRIPTION] : gear.description) : gear.description]</i> [is_heirloom_string]</font></td></tr>" // BLUEMOON EDIT - выбор вещей из лодаута как family heirloom
else
//we add the user's progress to the description assuming they have progress
var/datum/gear/unlockable/unlockable = gear
Expand Down Expand Up @@ -4173,6 +4182,11 @@ GLOBAL_LIST_EMPTY(preferences_datums)
return
var/toggle = text2num(href_list["toggle_gear"])
if(!toggle && has_loadout_gear(loadout_slot, "[G.type]"))//toggling off and the item effectively is in chosen gear)
var/gear = has_loadout_gear(loadout_slot, "[G.type]")
// BLUEMOON EDIT START - выбор вещей из лодаута как family heirloom
if (gear[LOADOUT_IS_HEIRLOOM])
gear[LOADOUT_IS_HEIRLOOM] = FALSE
// BLUEMOON EDIT END - выбор вещей из лодаута как family heirloom
remove_gear_from_loadout(loadout_slot, "[G.type]")
else if(toggle && !(has_loadout_gear(loadout_slot, "[G.type]")))
if(!is_loadout_slot_available(G.category))
Expand Down Expand Up @@ -4204,7 +4218,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
sanitize_current_slot.Remove(list(entry))
break

if(href_list["loadout_color"] || href_list["loadout_color_polychromic"] || href_list["loadout_color_HSV"] || href_list["loadout_rename"] || href_list["loadout_redescribe"] || href_list["loadout_tagname"])
if(href_list["loadout_color"] || href_list["loadout_color_polychromic"] || href_list["loadout_color_HSV"] || href_list["loadout_rename"] || href_list["loadout_redescribe"] || href_list["loadout_addheirloom"] || href_list["loadout_removeheirloom"] || href_list["loadout_tagname"])

//if the gear doesn't exist, or they don't have it, ignore the request
var/name = html_decode(href_list["loadout_gear_name"])
var/datum/gear/G = GLOB.loadout_items[gear_category][gear_subcategory][name]
Expand Down Expand Up @@ -4262,6 +4277,17 @@ GLOBAL_LIST_EMPTY(preferences_datums)
var/new_description = stripped_input(user, "Enter new description for item. Maximum 500 characters.", "Loadout Item Redescribing", null, 500)
if(new_description)
user_gear[LOADOUT_CUSTOM_DESCRIPTION] = new_description
// BLUEMOON ADD START - выбор вещей из лодаута как family heirloom
if(href_list["loadout_addheirloom"])
// Выбран ли какой-либо другой предмет как семейная реликвия, и если да, то какой?
var/existing = find_gear_with_property(loadout_slot, LOADOUT_IS_HEIRLOOM, TRUE)
if(!existing)
user_gear[LOADOUT_IS_HEIRLOOM] = TRUE
else
to_chat(user, "<font color='red'>У вас уже выбрана ваша семейная реликвия!</font>")
if(href_list["loadout_removeheirloom"])
user_gear[LOADOUT_IS_HEIRLOOM] = FALSE
// BLUEMOON ADD END

//for collars with tagnames
if(href_list["loadout_tagname"])
Expand Down Expand Up @@ -4517,6 +4543,15 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(L[slot] < DEFAULT_SLOT_AMT)
return TRUE

// BLUEMOON ADD START - выбор вещей из лодаута как семейной реликвии
///Searching for loadout item which `property` ([LOADOUT_ITEM], [LOADOUT_COLOR], etc) equals to `value`; returns this items, or FALSE if no gear matched conditions
/datum/preferences/proc/find_gear_with_property(save_slot, property, value)
var/list/gear_list = loadout_data["SAVE_[save_slot]"]
for(var/loadout_gear in gear_list)
if(loadout_gear[property] == value)
return loadout_gear
return FALSE

/datum/preferences/proc/has_loadout_gear(save_slot, gear_type)
var/list/gear_list = loadout_data["SAVE_[save_slot]"]
for(var/loadout_gear in gear_list)
Expand Down
1 change: 0 additions & 1 deletion code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
loadout_data = safe_json_decode(S["loadout"])
else
loadout_data = list()

//try to fix any outdated data if necessary
//preference updating will handle saving the updated data for us.
if(needs_update >= 0)
Expand Down
6 changes: 6 additions & 0 deletions modular_splurt/code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,12 @@
extra_loadout_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_rename=1;loadout_gear_name=[html_encode(gear.name)];'>Name</a> [loadout_item[LOADOUT_CUSTOM_NAME] ? loadout_item[LOADOUT_CUSTOM_NAME] : "N/A"]"
if(gear.loadout_flags & LOADOUT_CAN_DESCRIPTION)
extra_loadout_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_redescribe=1;loadout_gear_name=[html_encode(gear.name)];'>Description</a>"
else
extra_loadout_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_addheirloom=1;loadout_gear_name=[html_encode(gear.name)];'>Select as Heirloom</a><BR>"
// BLUEMOON ADD START - выбор вещей из лодаута как family heirloom
if(loadout_item[LOADOUT_IS_HEIRLOOM])
extra_loadout_data += "<BR><a class='linkOn' href='?_src_=prefs;preference=gear;loadout_removeheirloom=1;loadout_gear_name=[html_encode(gear.name)];'>Select as Heirloom</a><BR>"
// BLUEMOON ADD END
else if((gear_points - gear.cost) < 0)
class_link = "style='white-space:normal;' class='linkOff'"
else if(donoritem)
Expand Down

0 comments on commit 318d7f8

Please sign in to comment.