From aa4988c8e0c6bb7e0ce5ef3b28b0fa0f1e718a9e Mon Sep 17 00:00:00 2001 From: Drathek <76988376+Drulikar@users.noreply.github.com> Date: Tue, 18 Jul 2023 12:37:06 -0700 Subject: [PATCH] Prevent Banished in Larva Queue and Set Queue Time for Cryoing (#3885) # About the pull request This PR makes it so the larva queue can check if the candidate is currently in the banishment list for a hive. Join as xeno checks this, but xeno candidates (even before the queue) never has. A note of banishment is added to the queue message if join as xeno is used to check queue placement, but otherwise they just simply won't have queue messages until some hive core they aren't banished from ticks. The reason why they personally have a number at all though is because that was a check for all possible xeno hives. If say both the normal hive and greeno hive cores were ticking, there were 10 ghosts total, and 2 were banished from the normal hive, the queue length for the greeno hive would have 10 people, and the queue length for the normal hive would have 8 people, but otherwise the queue is shared. This PR also makes it so entering a cryopod sets your queue time; otherwise any marine that cryos (even if its say two hours in a game) would be basically the front of the queue (the time would still just be their join time). # Explain why it's good for the game Banished players should stay banished until the queen changes her mind or dies. Cryo'd marines also shouldn't get prioritized over people who have been waiting. # Testing Photographs and Procedure
Screenshots & Videos (Message below was also tweaked to also include "Your queue number won't update until there is a hive you aren't banished from.") ![image](https://github.com/cmss13-devs/cmss13/assets/76988376/3664fbe4-4d56-446b-a918-350e77ec1ed9)
# Changelog :cl: Drathek fix: Banished players will no longer be candidates for hives they are banished from. fix: Cryoing will now set your larva queue time so you don't get prioritized over others that have been waiting. admin: Shuttle intoTheSunset will set larva queue time the same as other situations. /:cl: --- code/__HELPERS/game.dm | 19 +++++++++++++++++-- code/game/gamemodes/cm_initialize.dm | 7 +++++++ code/game/machinery/cryopod.dm | 18 ++++++++++-------- .../structures/special/pylon_core.dm | 2 +- .../mob/living/carbon/xenomorph/Embryo.dm | 2 +- .../mob/living/carbon/xenomorph/death.dm | 2 +- code/modules/shuttle/shuttle.dm | 2 +- 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index 0132a31d0b50..cca3edda464e 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -241,8 +241,14 @@ else return get_step(start, EAST) -/// Get a list of observers that can be alien candidates, optionally sorted by larva_queue_time -/proc/get_alien_candidates(sorted = TRUE) +/** + * Get a list of observers that can be alien candidates. + * + * Arguments: + * * hive - The hive we're filling a slot for to check if the player is banished + * * sorted - Whether to sort by larva_queue_time (default TRUE) or leave unsorted + */ +/proc/get_alien_candidates(datum/hive_status/hive = null, sorted = TRUE) var/list/candidates = list() for(var/mob/dead/observer/cur_obs as anything in GLOB.observer_list) @@ -273,6 +279,15 @@ if((cur_obs.client.admin_holder && (cur_obs.client.admin_holder.rights & R_MOD)) && !cur_obs.adminlarva) continue + if(hive) + var/banished = FALSE + for(var/mob_name in hive.banished_ckeys) + if(hive.banished_ckeys[mob_name] == cur_obs.ckey) + banished = TRUE + break + if(banished) + continue + candidates += cur_obs // Optionally sort by larva_queue_time diff --git a/code/game/gamemodes/cm_initialize.dm b/code/game/gamemodes/cm_initialize.dm index b95052de8824..a42ff3f22e59 100644 --- a/code/game/gamemodes/cm_initialize.dm +++ b/code/game/gamemodes/cm_initialize.dm @@ -384,6 +384,13 @@ Additional game mode variables. // No cache, lets check now then message_alien_candidates(get_alien_candidates(), dequeued = 0, cache_only = TRUE) if(candidate_observer.larva_queue_cached_message) + var/datum/hive_status/cur_hive + for(var/hive_num in GLOB.hive_datum) + cur_hive = GLOB.hive_datum[hive_num] + for(var/mob_name in cur_hive.banished_ckeys) + if(cur_hive.banished_ckeys[mob_name] == xeno_candidate.ckey) + candidate_observer.larva_queue_cached_message += "\n" + SPAN_WARNING("NOTE: You are banished from the [cur_hive] and you may not rejoin unless the Queen re-admits you or dies. Your queue number won't update until there is a hive you aren't banished from.") + break to_chat(xeno_candidate, candidate_observer.larva_queue_cached_message) return FALSE diff --git a/code/game/machinery/cryopod.dm b/code/game/machinery/cryopod.dm index ed06c0117f33..9c0a227008c3 100644 --- a/code/game/machinery/cryopod.dm +++ b/code/game/machinery/cryopod.dm @@ -503,23 +503,25 @@ GLOBAL_LIST_INIT(frozen_items, list(SQUAD_MARINE_1 = list(), SQUAD_MARINE_2 = li add_fingerprint(usr) -/obj/structure/machinery/cryopod/proc/go_in_cryopod(mob/M, silent = FALSE) +/obj/structure/machinery/cryopod/proc/go_in_cryopod(mob/mob, silent = FALSE) if(occupant) return - M.forceMove(src) - occupant = M + mob.forceMove(src) + occupant = mob icon_state = "body_scanner_closed" SetLuminosity(2) time_entered = world.time start_processing() if(!silent) - if(M.client) - to_chat(M, SPAN_NOTICE("You feel cool air surround you. You go numb as your senses turn inward.")) - to_chat(M, SPAN_BOLDNOTICE("If you log out or close your client now, your character will permanently removed from the round in 10 minutes. If you ghost, timer will be decreased to 2 minutes.")) + if(mob.client) + to_chat(mob, SPAN_NOTICE("You feel cool air surround you. You go numb as your senses turn inward.")) + to_chat(mob, SPAN_BOLDNOTICE("If you log out or close your client now, your character will permanently removed from the round in 10 minutes. If you ghost, timer will be decreased to 2 minutes.")) + if(!is_admin_level(src.z)) // Set their queue time now because the client has to actually leave to despawn and at that point the client is lost + mob.client.player_details.larva_queue_time = max(mob.client.player_details.larva_queue_time, world.time) var/area/location = get_area(src) - if(M.job != GET_MAPPED_ROLE(JOB_SQUAD_MARINE)) - message_admins("[key_name_admin(M)], [M.job], has entered \a [src] at [location] after playing for [duration2text(world.time - M.life_time_start)].") + if(mob.job != GET_MAPPED_ROLE(JOB_SQUAD_MARINE)) + message_admins("[key_name_admin(mob)], [mob.job], has entered \a [src] at [location] after playing for [duration2text(world.time - mob.life_time_start)].") playsound(src, 'sound/machines/hydraulics_3.ogg', 30) silent_exit = silent diff --git a/code/modules/cm_aliens/structures/special/pylon_core.dm b/code/modules/cm_aliens/structures/special/pylon_core.dm index c38e540efb30..a29b49b7745a 100644 --- a/code/modules/cm_aliens/structures/special/pylon_core.dm +++ b/code/modules/cm_aliens/structures/special/pylon_core.dm @@ -150,7 +150,7 @@ last_larva_time = world.time if(spawning_larva || (last_larva_queue_time + spawn_cooldown * 4) < world.time) last_larva_queue_time = world.time - var/list/players_with_xeno_pref = get_alien_candidates() + var/list/players_with_xeno_pref = get_alien_candidates(linked_hive) if(players_with_xeno_pref && players_with_xeno_pref.len) if(spawning_larva && spawn_burrowed_larva(players_with_xeno_pref[1])) // We were in spawning_larva mode and successfully spawned someone diff --git a/code/modules/mob/living/carbon/xenomorph/Embryo.dm b/code/modules/mob/living/carbon/xenomorph/Embryo.dm index 01f6c1a3c238..3ba42650e49c 100644 --- a/code/modules/mob/living/carbon/xenomorph/Embryo.dm +++ b/code/modules/mob/living/carbon/xenomorph/Embryo.dm @@ -163,7 +163,7 @@ if(!picked) // Get a candidate from observers - var/list/candidates = get_alien_candidates() + var/list/candidates = get_alien_candidates(hive) if(candidates && candidates.len) // If they were facehugged by a player thats still in queue, they get second dibs on the new larva. if(hugger_ckey) diff --git a/code/modules/mob/living/carbon/xenomorph/death.dm b/code/modules/mob/living/carbon/xenomorph/death.dm index e3a69da23262..12c9b3e37c9b 100644 --- a/code/modules/mob/living/carbon/xenomorph/death.dm +++ b/code/modules/mob/living/carbon/xenomorph/death.dm @@ -38,7 +38,7 @@ if(GLOB.hive_datum[hivenumber].stored_larva) GLOB.hive_datum[hivenumber].stored_larva = round(GLOB.hive_datum[hivenumber].stored_larva * 0.5) //Lose half on dead queen - var/list/players_with_xeno_pref = get_alien_candidates() + var/list/players_with_xeno_pref = get_alien_candidates(GLOB.hive_datum[hivenumber]) if(players_with_xeno_pref && istype(GLOB.hive_datum[hivenumber].hive_location, /obj/effect/alien/resin/special/pylon/core)) var/turf/larva_spawn = get_turf(GLOB.hive_datum[hivenumber].hive_location) var/count = 0 diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 6d3465ee8747..983fffeb2634 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -635,7 +635,7 @@ var/mob/dead/observer/obs = mob.ghostize(FALSE) if(obs) obs.timeofdeath = world.time - obs.client?.player_details.larva_queue_time = world.time + obs.client?.player_details.larva_queue_time = max(obs.client.player_details.larva_queue_time, world.time) mob.moveToNullspace() // Now that mobs are stowed, delete the shuttle