From b843f7cc5d00b6d571f521e235b5d594108d914f Mon Sep 17 00:00:00 2001 From: Drulikar Date: Wed, 15 May 2024 03:46:37 -0700 Subject: [PATCH] Fix verb to adjust predator slots --- code/game/gamemodes/cm_initialize.dm | 45 +++++++++++++++------------- code/modules/admin/tabs/round_tab.dm | 41 +++++++++++++++++-------- 2 files changed, 52 insertions(+), 34 deletions(-) diff --git a/code/game/gamemodes/cm_initialize.dm b/code/game/gamemodes/cm_initialize.dm index c9c180295b1a..413ed0e20e80 100644 --- a/code/game/gamemodes/cm_initialize.dm +++ b/code/game/gamemodes/cm_initialize.dm @@ -175,43 +175,46 @@ Additional game mode variables. if(pred_candidate) pred_candidate.moveToNullspace() //Nullspace it for garbage collection later. -#define calculate_pred_max (floor(length(GLOB.player_list) / pred_per_players) + pred_additional_max + pred_start_count) - -/datum/game_mode/proc/check_predator_late_join(mob/pred_candidate, show_warning = 1) +/datum/game_mode/proc/calculate_pred_max() + return floor(length(GLOB.player_list) / pred_per_players) + pred_additional_max + pred_start_count +/datum/game_mode/proc/check_predator_late_join(mob/pred_candidate, show_warning = TRUE) if(!pred_candidate.client) return - var/datum/job/J = GLOB.RoleAuthority.roles_by_name[JOB_PREDATOR] + var/datum/job/pred_job = GLOB.RoleAuthority.roles_by_name[JOB_PREDATOR] - if(!J) - if(show_warning) to_chat(pred_candidate, SPAN_WARNING("Something went wrong!")) - return + if(!pred_job) + if(show_warning) + to_chat(pred_candidate, SPAN_WARNING("Something went wrong!")) + return FALSE if(!(pred_candidate?.client.check_whitelist_status(WHITELIST_PREDATOR))) - if(show_warning) to_chat(pred_candidate, SPAN_WARNING("You are not whitelisted! You may apply on the forums to be whitelisted as a predator.")) - return + if(show_warning) + to_chat(pred_candidate, SPAN_WARNING("You are not whitelisted! You may apply on the forums to be whitelisted as a predator.")) + return FALSE if(!(flags_round_type & MODE_PREDATOR)) - if(show_warning) to_chat(pred_candidate, SPAN_WARNING("There is no Hunt this round! Maybe the next one.")) - return + if(show_warning) + to_chat(pred_candidate, SPAN_WARNING("There is no Hunt this round! Maybe the next one.")) + return FALSE if(pred_candidate.ckey in predators) if(show_warning) to_chat(pred_candidate, SPAN_WARNING("You already were a Yautja! Give someone else a chance.")) - return + return FALSE - if(show_warning && tgui_alert(pred_candidate, "Confirm joining the hunt. You will join as \a [lowertext(J.get_whitelist_status(pred_candidate.client))] predator", "Confirmation", list("Yes", "No"), 10 SECONDS) != "Yes") - return - if(J.get_whitelist_status(pred_candidate.client) == WHITELIST_NORMAL) - var/pred_max = calculate_pred_max - if(pred_current_num >= pred_max) - if(show_warning) to_chat(pred_candidate, SPAN_WARNING("Only [pred_max] predators may spawn this round, but Councillors and Ancients do not count.")) - return + if(show_warning && tgui_alert(pred_candidate, "Confirm joining the hunt. You will join as \a [lowertext(pred_job.get_whitelist_status(pred_candidate.client))] predator", "Confirmation", list("Yes", "No"), 10 SECONDS) != "Yes") + return FALSE - return 1 + if(pred_job.get_whitelist_status(pred_candidate.client) == WHITELIST_NORMAL) + var/pred_max = calculate_pred_max() + if(pred_current_num >= pred_max) + if(show_warning) + to_chat(pred_candidate, SPAN_WARNING("Only [pred_max] predators may spawn this round, but Councillors and Ancients do not count.")) + return FALSE -#undef calculate_pred_max + return TRUE /datum/game_mode/proc/transform_predator(mob/pred_candidate) set waitfor = FALSE diff --git a/code/modules/admin/tabs/round_tab.dm b/code/modules/admin/tabs/round_tab.dm index 4a993459e7d1..f6a39ad39022 100644 --- a/code/modules/admin/tabs/round_tab.dm +++ b/code/modules/admin/tabs/round_tab.dm @@ -1,22 +1,37 @@ /client/proc/adjust_predator_round() - set name = "Adjust Predator Round" - set desc = "Adjust the number of predators present in a predator round." + set name = "Adjust Predator Slots" + set desc = "Adjust the extra slots for predators." set category = "Server.Round" - if(admin_holder) - if(!SSticker || !SSticker.mode) - to_chat(src, SPAN_WARNING("The game hasn't started yet!")) - return + if(!admin_holder) + return - var/value = tgui_input_number(src,"How many additional predators can join? Decreasing the value is not recommended. Current predator count: [SSticker.mode.pred_current_num]","Input:", 0, (SSticker.mode.pred_additional_max - SSticker.mode.pred_current_num)) + if(!SSticker?.mode) + to_chat(src, SPAN_WARNING("The game hasn't started yet!")) + return - if(value < SSticker.mode.pred_current_num) - to_chat(src, SPAN_NOTICE("Aborting. Number cannot be lower than the current pred count. (current: [SSticker.mode.pred_current_num], attempted: [value])")) - return + var/cur_extra = SSticker.mode.pred_additional_max + var/cur_count = SSticker.mode.pred_current_num + var/cur_max = SSticker.mode.calculate_pred_max() + var/value = tgui_input_number(src, "How many additional predators can join? Current predator count: [cur_count]/[cur_max] Current setting: [cur_extra]", "Input:", default = cur_extra, min_value = 0, integer_only = TRUE) + + if(isnull(value)) + return + + if(value == cur_extra) + return + + cur_count = SSticker.mode.pred_current_num // values could have changed since asking + cur_max = SSticker.mode.calculate_pred_max() + var/free_extra = max(min(cur_extra, cur_max - cur_count), 0) // how much we could potentionally reduce pred_additional_max + + // If we are reducing the count and that exceeds how much we could reduce it by + if(value < cur_extra && (cur_extra - value) > free_extra) + to_chat(src, SPAN_NOTICE("Aborting. Number cannot result in a max less than current pred count. (current: [cur_count]/[cur_max], current extra: [cur_extra], attempted: [value])")) + return - if(value) - SSticker.mode.pred_additional_max = abs(value) - message_admins("[key_name_admin(usr)] adjusted the additional pred amount to [abs(value)].") + SSticker.mode.pred_additional_max = value + message_admins("[key_name_admin(usr)] adjusted the additional pred amount from [cur_extra] to [value].") /datum/admins/proc/force_predator_round() set name = "Toggle Predator Round"