Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Banished in Larva Queue and Set Queue Time for Cryoing #3885

Merged
merged 4 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions code/game/gamemodes/cm_initialize.dm
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,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

Expand Down
18 changes: 10 additions & 8 deletions code/game/machinery/cryopod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion code/modules/cm_aliens/structures/special/pylon_core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/xenomorph/Embryo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/xenomorph/death.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/modules/shuttle/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading