Rework how mail envelopes are generated. (#32322)

* Rework how mail envelopes are generated.

* Add newline to departments_defines.dm

* Apply suggestion from CRUNCH review.

Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com>
Signed-off-by: Alan <alfalfascout@users.noreply.github.com>

---------

Signed-off-by: Alan <alfalfascout@users.noreply.github.com>
Co-authored-by: CRUNCH <143041327+CRUNCH-Borg@users.noreply.github.com>
This commit is contained in:
Alan
2026-07-24 19:34:36 +00:00
committed by GitHub
co-authored by CRUNCH
parent f742e427cd
commit 991e53368f
3 changed files with 43 additions and 20 deletions
+9 -9
View File
@@ -78,7 +78,7 @@
/obj/item/toy/figure/crew/hos,
/obj/item/toy/figure/crew/secofficer,
/obj/item/storage/box/scratch_cards)
job_list = list("Head of Security", "Security Officer", "Detective", "Warden")
job_list = DEP_MAIL_LIST_SECURITY
/obj/item/envelope/science
icon_state = "mail_sci"
@@ -96,7 +96,7 @@
/obj/item/toy/figure/crew/roboticist,
/obj/item/toy/figure/crew/scientist,
/obj/item/storage/box/scratch_cards)
job_list = list("Research Director", "Roboticist", "Geneticist", "Scientist")
job_list = DEP_MAIL_LIST_SCIENCE
/obj/item/envelope/supply
icon_state = "mail_sup"
@@ -113,7 +113,7 @@
/obj/item/toy/figure/crew/qm,
/obj/item/toy/figure/crew/miner,
/obj/item/storage/box/scratch_cards)
job_list = list("Quartermaster", "Cargo Technician", "Shaft Miner", "Explorer")
job_list = DEP_MAIL_LIST_SUPPLY
/obj/item/envelope/medical
icon_state = "mail_med"
@@ -132,7 +132,7 @@
/obj/item/toy/figure/crew/md,
/obj/item/toy/figure/crew/virologist,
/obj/item/storage/box/scratch_cards)
job_list = list("Chief Medical Officer", "Medical Doctor", "Coroner", "Chemist", "Virologist", "Psychiatrist", "Paramedic")
job_list = DEP_MAIL_LIST_MEDICAL
/obj/item/envelope/engineering
icon_state = "mail_eng"
@@ -148,7 +148,7 @@
/obj/item/toy/figure/crew/ce,
/obj/item/toy/figure/crew/engineer,
/obj/item/storage/box/scratch_cards)
job_list = list("Chief Engineer", "Station Engineer", "Life Support Specialist")
job_list = DEP_MAIL_LIST_ENGINEERING
/obj/item/envelope/bread
icon_state = "mail_serv"
@@ -166,7 +166,7 @@
/obj/item/toy/figure/crew/janitor,
/obj/item/toy/figure/crew/librarian,
/obj/item/storage/box/scratch_cards)
job_list = list("Bartender", "Chef", "Botanist", "Janitor", "Librarian")
job_list = DEP_MAIL_LIST_BREAD
/obj/item/envelope/circuses
icon_state = "mail_serv"
@@ -183,7 +183,7 @@
/obj/item/toy/figure/crew/chaplain,
/obj/item/toy/figure/crew/mime,
/obj/item/storage/box/scratch_cards)
job_list = list("Clown", "Mime", "Head of Personnel", "Chaplain")
job_list = DEP_MAIL_LIST_SERVICE
/obj/item/envelope/command
@@ -200,7 +200,7 @@
/obj/item/toy/figure/crew/iaa,
/obj/item/toy/figure/crew/dsquad,
/obj/item/storage/box/scratch_cards)
job_list = list("Captain", "Magistrate", "Nanotrasen Representative", "Blueshield", "Internal Affairs Agent", "Nanotrasen Career Trainer")
job_list = DEP_MAIL_LIST_COMMAND
/obj/item/envelope/misc
possible_contents = list(/obj/item/clothing/under/misc/assistantformal,
@@ -215,7 +215,7 @@
/obj/item/toy/figure/owl,
/obj/item/toy/figure/griffin,
/obj/item/storage/box/scratch_cards)
job_list = list("Assistant")
job_list = DEP_MAIL_LIST_MISC
/*//////////////////////\/
@@ -617,20 +617,33 @@
icon_closed = "mailsealed"
material_drop = /obj/item/stack/sheet/plastic
material_drop_amount = 4
var/list/possible_contents = list(/obj/item/envelope/security,
/obj/item/envelope/science,
/obj/item/envelope/supply,
/obj/item/envelope/medical,
/obj/item/envelope/engineering,
/obj/item/envelope/bread,
/obj/item/envelope/circuses,
/obj/item/envelope/command,
/obj/item/envelope/misc)
var/list/possible_contents = list(/obj/item/envelope/security = DEP_MAIL_LIST_SECURITY,
/obj/item/envelope/science = DEP_MAIL_LIST_SCIENCE,
/obj/item/envelope/supply = DEP_MAIL_LIST_SUPPLY,
/obj/item/envelope/medical = DEP_MAIL_LIST_MEDICAL,
/obj/item/envelope/engineering = DEP_MAIL_LIST_ENGINEERING,
/obj/item/envelope/bread = DEP_MAIL_LIST_BREAD,
/obj/item/envelope/circuses = DEP_MAIL_LIST_SERVICE,
/obj/item/envelope/command = DEP_MAIL_LIST_COMMAND,
/obj/item/envelope/misc = DEP_MAIL_LIST_MISC)
/obj/structure/closet/crate/mail/populate_contents()
. = ..()
for(var/i in 1 to rand(5, 10))
var/item = pick(possible_contents)
var/list/narrowed_contents = possible_contents.Copy()
for(var/envelope_type in narrowed_contents)
var/found = FALSE
for(var/datum/mind/recipient in SSticker.minds)
var/turf/recipient_turf = get_turf(recipient.current)
if(recipient.offstation_role || !ishuman(recipient.current) || is_admin_level(recipient_turf.z))
continue
if(recipient.assigned_role in narrowed_contents[envelope_type])
found = TRUE
break
if(!found)
narrowed_contents -= envelope_type
for(var/i in 1 to (ceil(length(GLOB.crew_list) / 20) + rand(1, 5))) // Scale number of letters with number of crew.
var/item = pick(narrowed_contents)
new item(src)
/obj/structure/closet/crate/tape/populate_contents()