From 6c2d43ec5acf8ce9339439ce7bc6a6c8a6984e5e Mon Sep 17 00:00:00 2001 From: Charlie Nolan Date: Tue, 10 Sep 2024 15:42:26 -0700 Subject: [PATCH] Re-weighted secondary goals. (#26586) --- code/game/gamemodes/game_mode.dm | 1 + code/modules/admin/topic.dm | 2 +- .../secondary/bar/random_bulk_drink.dm | 2 +- .../secondary/bar/variety_drinks.dm | 2 +- .../secondary/botany/kudzu_goal.dm | 2 +- .../kitchen/random_bulk_condiment.dm | 2 +- .../secondary/kitchen/random_bulk_food.dm | 2 +- .../secondary/kitchen/variety_food.dm | 2 +- .../secondary/medical/random_bulk_medicine.dm | 2 +- .../secondary/medical/variety_medicine.dm | 2 +- .../secondary/science/random_bulk_chemical.dm | 2 +- .../secondary/science/random_ripley.dm | 2 +- .../secondary/science/variety_chemicals.dm | 2 +- .../station_goals/secondary/secondary_goal.dm | 39 +++++++++++++------ 14 files changed, 40 insertions(+), 24 deletions(-) diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index 56735afd7f4..1bbc3599ee6 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -40,6 +40,7 @@ var/list/blob_overminds = list() var/list/datum/station_goal/station_goals = list() // A list of all station goals for this game mode + var/list/secondary_goal_grab_bags = null // Once initialized, contains an associative list of department_name -> list(secondary_goal_type). When a goal is requested, a type will be pulled out of the department's grab bag. When the bag is empty, it will be refilled from the list of all goals in that department, with the amount of each set to the type's weight, max 10. var/list/datum/station_goal/secondary/secondary_goals = list() // A list of all secondary goals issued /// Each item in this list can only be rolled once on average. diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 00757650a39..34d5d48c9fb 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -3379,7 +3379,7 @@ if(T == /datum/station_goal/secondary) continue var/datum/station_goal/secondary/SG = T - if(initial(SG.abstract)) + if(initial(SG.weight) < 1) type_choices -= SG var/picked = pick_closest_path(FALSE, make_types_fancy(type_choices), skip_filter = TRUE) if(!picked) diff --git a/code/modules/station_goals/secondary/bar/random_bulk_drink.dm b/code/modules/station_goals/secondary/bar/random_bulk_drink.dm index 016e9e74b3b..6c65bb527ca 100644 --- a/code/modules/station_goals/secondary/bar/random_bulk_drink.dm +++ b/code/modules/station_goals/secondary/bar/random_bulk_drink.dm @@ -1,7 +1,7 @@ /datum/station_goal/secondary/random_bulk_reagent/bar name = "Random Bulk Drink" department = "Bar" - abstract = FALSE + weight = 9 /datum/station_goal/secondary/random_bulk_reagent/bar/randomize_params() ..() diff --git a/code/modules/station_goals/secondary/bar/variety_drinks.dm b/code/modules/station_goals/secondary/bar/variety_drinks.dm index fe11f919de3..778d1055282 100644 --- a/code/modules/station_goals/secondary/bar/variety_drinks.dm +++ b/code/modules/station_goals/secondary/bar/variety_drinks.dm @@ -3,7 +3,7 @@ progress_type = /datum/secondary_goal_progress/variety_reagent department = "Bar" generic_name_plural = "alcoholic drinks" - abstract = FALSE + weight = 1 /datum/station_goal/secondary/variety_reagent/bar/randomize_params() ..() diff --git a/code/modules/station_goals/secondary/botany/kudzu_goal.dm b/code/modules/station_goals/secondary/botany/kudzu_goal.dm index d77445775a1..2a002dc568a 100644 --- a/code/modules/station_goals/secondary/botany/kudzu_goal.dm +++ b/code/modules/station_goals/secondary/botany/kudzu_goal.dm @@ -2,7 +2,7 @@ name = "Random Kudzu" department = "Hydroponics" progress_type = /datum/secondary_goal_progress/random_kudzu - abstract = FALSE + weight = 1 var/list/traits = list() var/amount = 5 diff --git a/code/modules/station_goals/secondary/kitchen/random_bulk_condiment.dm b/code/modules/station_goals/secondary/kitchen/random_bulk_condiment.dm index a92d3fae94b..6f930cc2b48 100644 --- a/code/modules/station_goals/secondary/kitchen/random_bulk_condiment.dm +++ b/code/modules/station_goals/secondary/kitchen/random_bulk_condiment.dm @@ -1,7 +1,7 @@ /datum/station_goal/secondary/random_bulk_reagent/kitchen name = "Random Bulk Condiment" department = "Kitchen" - abstract = FALSE + weight = 1 /datum/station_goal/secondary/random_bulk_reagent/kitchen/randomize_params() ..() diff --git a/code/modules/station_goals/secondary/kitchen/random_bulk_food.dm b/code/modules/station_goals/secondary/kitchen/random_bulk_food.dm index 65141215e62..6b5c7497555 100644 --- a/code/modules/station_goals/secondary/kitchen/random_bulk_food.dm +++ b/code/modules/station_goals/secondary/kitchen/random_bulk_food.dm @@ -2,7 +2,7 @@ name = "Random Bulk Food" department = "Kitchen" progress_type = /datum/secondary_goal_progress/random_bulk_food - abstract = FALSE + weight = 8 var/obj/item/food/food_type var/amount var/reward diff --git a/code/modules/station_goals/secondary/kitchen/variety_food.dm b/code/modules/station_goals/secondary/kitchen/variety_food.dm index 66144ba2477..32c32380587 100644 --- a/code/modules/station_goals/secondary/kitchen/variety_food.dm +++ b/code/modules/station_goals/secondary/kitchen/variety_food.dm @@ -2,7 +2,7 @@ name = "Variety of Food" progress_type = /datum/secondary_goal_progress/variety_food department = "Kitchen" - abstract = FALSE + weight = 1 /// How many different types of food are needed. var/different_types = 10 /// How many of each food type are needed. diff --git a/code/modules/station_goals/secondary/medical/random_bulk_medicine.dm b/code/modules/station_goals/secondary/medical/random_bulk_medicine.dm index 640e25d631a..cee6cdb3f3e 100644 --- a/code/modules/station_goals/secondary/medical/random_bulk_medicine.dm +++ b/code/modules/station_goals/secondary/medical/random_bulk_medicine.dm @@ -1,7 +1,7 @@ /datum/station_goal/secondary/random_bulk_reagent/medchem name = "Random Bulk Medicine" department = "Chemistry" - abstract = FALSE + weight = 9 /datum/station_goal/secondary/random_bulk_reagent/medchem/randomize_params() ..() diff --git a/code/modules/station_goals/secondary/medical/variety_medicine.dm b/code/modules/station_goals/secondary/medical/variety_medicine.dm index 6618374912e..37f3543bdb7 100644 --- a/code/modules/station_goals/secondary/medical/variety_medicine.dm +++ b/code/modules/station_goals/secondary/medical/variety_medicine.dm @@ -3,7 +3,7 @@ progress_type = /datum/secondary_goal_progress/variety_reagent department = "Chemistry" generic_name_plural = "medicines" - abstract = FALSE + weight = 1 /datum/station_goal/secondary/variety_reagent/medchem/randomize_params() ..() diff --git a/code/modules/station_goals/secondary/science/random_bulk_chemical.dm b/code/modules/station_goals/secondary/science/random_bulk_chemical.dm index ce20898ed20..1f1f58bc39e 100644 --- a/code/modules/station_goals/secondary/science/random_bulk_chemical.dm +++ b/code/modules/station_goals/secondary/science/random_bulk_chemical.dm @@ -1,7 +1,7 @@ /datum/station_goal/secondary/random_bulk_reagent/scichem name = "Random Bulk Chemical" department = "Science" - abstract = FALSE + weight = 9 /datum/station_goal/secondary/random_bulk_reagent/scichem/randomize_params() ..() diff --git a/code/modules/station_goals/secondary/science/random_ripley.dm b/code/modules/station_goals/secondary/science/random_ripley.dm index 3486ea8b3ee..ce3e6a678da 100644 --- a/code/modules/station_goals/secondary/science/random_ripley.dm +++ b/code/modules/station_goals/secondary/science/random_ripley.dm @@ -3,7 +3,7 @@ department = "Robotics" progress_type = /datum/secondary_goal_progress/random_ripley should_send_crate = FALSE - abstract = FALSE + weight = 1 var/list/modules = list() var/static/list/general_modules = list( /obj/item/mecha_parts/mecha_equipment/repair_droid, diff --git a/code/modules/station_goals/secondary/science/variety_chemicals.dm b/code/modules/station_goals/secondary/science/variety_chemicals.dm index 68080f0641e..de3a1bfdd01 100644 --- a/code/modules/station_goals/secondary/science/variety_chemicals.dm +++ b/code/modules/station_goals/secondary/science/variety_chemicals.dm @@ -4,7 +4,7 @@ different_types = 5 department = "Science" generic_name_plural = "chemicals" - abstract = FALSE + weight = 1 /datum/station_goal/secondary/variety_reagent/scichem/randomize_params() ..() diff --git a/code/modules/station_goals/secondary/secondary_goal.dm b/code/modules/station_goals/secondary/secondary_goal.dm index aad6a1bcdb8..a9643bcee3f 100644 --- a/code/modules/station_goals/secondary/secondary_goal.dm +++ b/code/modules/station_goals/secondary/secondary_goal.dm @@ -17,8 +17,8 @@ var/datum/secondary_goal_progress/progress /// Tracker that manages the goal progress, permanent and temporary. var/datum/secondary_goal_tracker/tracker - /// Abstract goals can't be used directly. - var/abstract = TRUE + /// The goal weight of a secondary goal type defines how many copies of it are in the grab bag that new secondary goals are pulled from. When the bag is empty, it gets refilled with the same number of each secondary goal type. Max 10. + weight = 0 /datum/station_goal/secondary/proc/Initialize(requester_name_in, requester_account) SHOULD_CALL_PARENT(TRUE) @@ -53,23 +53,38 @@ if(department != "Bridge") send_requests_console_message(message_parts, "Central Command", "Bridge", "Stamped with the Central Command rubber stamp.", "Verified by A.L.I.C.E (CentCom AI)", RQ_NORMALPRIORITY) -/proc/generate_secondary_goal(department, requester = null, mob/user = null) - var/list/possible = list() - var/list/departments = list() +/proc/init_secondary_goal_grab_bags() + SSticker.mode.secondary_goal_grab_bags = list() for(var/T in subtypesof(/datum/station_goal/secondary)) var/datum/station_goal/secondary/G = T - if(!initial(G.abstract) && !departments[initial(G.department)]) - departments[initial(G.department)] = TRUE - if(initial(G.department) != department || initial(G.abstract)) + if(initial(G.weight) < 1) continue - possible += G + var/department = initial(G.department) + if(isnull(SSticker.mode.secondary_goal_grab_bags[department])) + SSticker.mode.secondary_goal_grab_bags[department] = list() + for(var/i in 1 to min(10, initial(G.weight))) + SSticker.mode.secondary_goal_grab_bags[department] += G - if(!length(possible)) +/proc/generate_secondary_goal(department, requester = null, mob/user = null) + if(isnull(SSticker.mode.secondary_goal_grab_bags)) + init_secondary_goal_grab_bags() + + var/list/possible = SSticker.mode.secondary_goal_grab_bags[department] + + if(isnull(possible)) if(user) - to_chat(user, "No goals available for [department]. Goals are currently available for [english_list(departments)].") + to_chat(user, "No goals available for [department]. Goals are currently available for [english_list(SSticker.mode.secondary_goal_grab_bags)].") return - var/datum/station_goal/secondary/picked = pick(possible) + if(length(possible) == 0) + for(var/T in subtypesof(/datum/station_goal/secondary)) + var/datum/station_goal/secondary/G = T + if(initial(G.weight) < 1 || initial(G.department) != department) + continue + for(var/i in 1 to min(10, initial(G.weight))) + possible += G + + var/datum/station_goal/secondary/picked = pick_n_take(possible) var/datum/station_goal/secondary/built = new picked var/requester_name = null