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

Lobby xeno late join queue information #7261

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
* 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
* * abomination - Whether the potential larva is for an abomination
*/
/proc/get_alien_candidates(datum/hive_status/hive = null, sorted = TRUE, abomination = FALSE)
var/list/candidates = list()
Expand Down
41 changes: 36 additions & 5 deletions code/game/gamemodes/cm_initialize.dm
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,39 @@ Additional game mode variables.
available_xenos[larva_option] = list(hive)

if(!length(available_xenos) || (instant_join && !length(available_xenos_non_ssd)))
if(!xeno_candidate.client?.prefs || !(xeno_candidate.client.prefs.be_special & BE_ALIEN_AFTER_DEATH))
var/is_new_player = isnewplayer(xeno_candidate)
if(!xeno_candidate.client?.prefs || (!(xeno_candidate.client.prefs.be_special & BE_ALIEN_AFTER_DEATH) && !is_new_player))
to_chat(xeno_candidate, SPAN_WARNING("There aren't any available xenomorphs or burrowed larvae. \
You can try getting spawned as a chestburster larva by toggling your Xenomorph candidacy in \
Preferences -> Toggle SpecialRole Candidacy."))
return FALSE
to_chat(xeno_candidate, SPAN_WARNING("There aren't any available xenomorphs or burrowed larvae."))

// If a lobby player is trying to join as xeno, estimate their possible position
if(is_new_player)
var/mob/new_player/candidate_new_player = xeno_candidate
if(candidate_new_player.larva_queue_message_stale_time <= world.time)
// No cached/current lobby message, determine the position
var/list/valid_candidates = get_alien_candidates()
var/candidate_time = candidate_new_player.client.player_details.larva_queue_time
var/position = 1
for(var/mob/dead/observer/current in valid_candidates)
if(current.client.player_details.larva_queue_time >= candidate_time)
break
position++
candidate_new_player.larva_queue_message_stale_time = world.time + 3 MINUTES // spam prevention
candidate_new_player.larva_queue_cached_message = "Your position would be [position]\th in the larva queue if you observed and were elgible to be a xeno. \
The ordering is based on your time of death or the time you joined. When you have been dead long enough and are not inactive, \
you will periodically receive messages where you are in the queue relative to other currently valid xeno candidates. \
Your current position will shift as others change their preferences or go inactive, but your relative position compared to all observers is the same. \
Note: Playing as a facehugger/lesser or in the thunderdome will not alter your time of death. \
This means you won't lose your relative place in queue if you step away, disconnect, play as a facehugger/lesser, or play in the thunderdome."
to_chat(candidate_new_player, SPAN_XENONOTICE(candidate_new_player.larva_queue_cached_message))
return FALSE

if(!isobserver(xeno_candidate))
return FALSE

var/mob/dead/observer/candidate_observer = xeno_candidate

// If an observing mod wants to join as a xeno, disable their larva protection so that they can enter the queue.
Expand All @@ -410,16 +434,23 @@ Additional game mode variables.
return FALSE

// No cache, lets check now then
message_alien_candidates(get_alien_candidates(), dequeued = 0, cache_only = TRUE)
var/list/valid_candidates = get_alien_candidates()
message_alien_candidates(valid_candidates, dequeued = 0, cache_only = TRUE)

// If we aren't in the queue yet, let's teach them about the queue
if(!candidate_observer.larva_queue_cached_message)
candidate_observer.larva_queue_cached_message = "You are currently awaiting assignment in the larva queue. \
var/candidate_time = candidate_observer.client.player_details.larva_queue_time
var/position = 1
for(var/mob/dead/observer/current in valid_candidates)
if(current.client.player_details.larva_queue_time >= candidate_time)
break
position++
candidate_observer.larva_queue_cached_message = "You are currently ineligible to be a larva but would be [position]\th in queue. \
The ordering is based on your time of death or the time you joined. When you have been dead long enough and are not inactive, \
you will periodically receive messages where you are in the queue relative to other currently valid xeno candidates. \
Your current position will shift as others change their preferences or go inactive, but your relative position compared to all observers is the same. \
Note: Playing as a facehugger or in the thunderdome will not alter your time of death. \
This means you won't lose your relative place in queue if you step away, disconnect, play as a facehugger, or play in the thunderdome."
Note: Playing as a facehugger/lesser or in the thunderdome will not alter your time of death. \
This means you won't lose your relative place in queue if you step away, disconnect, play as a facehugger/lesser, or play in the thunderdome."
to_chat(candidate_observer, SPAN_XENONOTICE(candidate_observer.larva_queue_cached_message))
return FALSE

Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/dead/observer/observer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
var/own_orbit_size = 0
var/observer_actions = list(/datum/action/observer_action/join_xeno, /datum/action/observer_action/join_lesser_drone)
var/datum/action/minimap/observer/minimap
///The last message for this player with their larva queue information
var/larva_queue_cached_message
///Used to bypass time of death checks such as when being selected for larva.
var/bypass_time_of_death_checks = FALSE
Expand Down
105 changes: 63 additions & 42 deletions code/modules/mob/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
/mob/new_player
var/ready = FALSE
var/spawning = FALSE//Referenced when you want to delete the new_player later on in the code.
///The last message for this player with their larva queue information
var/larva_queue_cached_message
///The time when the larva_queue_cached_message should be considered stale
var/larva_queue_message_stale_time

invisibility = 101

Expand Down Expand Up @@ -116,45 +120,11 @@
if(!SSticker || SSticker.current_state == GAME_STATE_STARTUP)
to_chat(src, SPAN_WARNING("The game is still setting up, please try again later."))
return
if(alert(src,"Are you sure you wish to observe? When you observe, you will not be able to join as marine. It might also take some time to become a xeno or responder!","Player Setup","Yes","No") == "Yes")
if(!client)
return TRUE
if(!client.prefs?.preview_dummy)
client.prefs.update_preview_icon()
var/mob/dead/observer/observer = new /mob/dead/observer(get_turf(pick(GLOB.latejoin)), client.prefs.preview_dummy)
observer.set_lighting_alpha_from_pref(client)
spawning = TRUE
observer.started_as_observer = TRUE

close_spawn_windows()

var/obj/effect/landmark/observer_start/O = SAFEPICK(GLOB.observer_starts)
if(istype(O))
to_chat(src, SPAN_NOTICE("Now teleporting."))
observer.forceMove(O.loc)
else
to_chat(src, SPAN_DANGER("Could not locate an observer spawn point. Use the Teleport verb to jump to the station map."))
observer.icon = 'icons/mob/humans/species/r_human.dmi'
observer.icon_state = "anglo_example"
observer.alpha = 127

if(client.prefs.be_random_name)
client.prefs.real_name = random_name(client.prefs.gender)
observer.real_name = client.prefs.real_name
observer.name = observer.real_name

mind.transfer_to(observer, TRUE)

if(observer.client)
observer.client.change_view(GLOB.world_view_size)

observer.set_huds_from_prefs()

qdel(src)
if(tgui_alert(src, "Are you sure you wish to observe? When you observe, you will not be able to join as marine. It might also take some time to become a xeno or responder!", "Player Setup", list("Yes", "No")) == "Yes")
attempt_observe()
return TRUE

if("late_join")

if(SSticker.current_state != GAME_STATE_PLAYING || !SSticker.mode)
to_chat(src, SPAN_WARNING("The round is either not ready, or has already finished..."))
return
Expand All @@ -175,10 +145,20 @@
to_chat(src, SPAN_WARNING("The round is either not ready, or has already finished..."))
return

if(alert(src,"Are you sure you want to attempt joining as a xenomorph?","Confirmation","Yes","No") == "Yes" )
if(tgui_alert(src, "Are you sure you want to attempt joining as a xenomorph?", "Confirmation", list("Yes", "No")) == "Yes")
if(!client)
return TRUE
if(SSticker.mode.check_xeno_late_join(src))
var/mob/new_xeno = SSticker.mode.attempt_to_join_as_xeno(src, 0)
if(new_xeno && !istype(new_xeno, /mob/living/carbon/xenomorph/larva))
var/mob/new_xeno = SSticker.mode.attempt_to_join_as_xeno(src, FALSE)
if(!new_xeno)
if(tgui_alert(src, "Do you sure you wish to observe to be a xeno candidate? When you observe, you will not be able to join as marine. It might also take some time to become a xeno or responder!", "Player Setup", list("Yes", "No")) == "Yes")
if(!client)
return TRUE
if(client.prefs && !(client.prefs.be_special & BE_ALIEN_AFTER_DEATH))
client.prefs.be_special |= BE_ALIEN_AFTER_DEATH
to_chat(src, SPAN_BOLDNOTICE("You will now be considered for Xenomorph after unrevivable death events (where possible)."))
attempt_observe()
else if(!istype(new_xeno, /mob/living/carbon/xenomorph/larva))
SSticker.mode.transfer_xeno(src, new_xeno)
close_spawn_windows()

Expand All @@ -187,7 +167,7 @@
to_chat(src, SPAN_WARNING("The round is either not ready, or has already finished..."))
return

if(alert(src,"Are you sure you want to attempt joining as a predator?","Confirmation","Yes","No") == "Yes" )
if(tgui_alert(src, "Are you sure you want to attempt joining as a predator?", "Confirmation", list("Yes", "No")) == "Yes")
if(SSticker.mode.check_predator_late_join(src,0))
close_spawn_windows()
SSticker.mode.attempt_to_join_as_predator(src)
Expand All @@ -202,7 +182,6 @@
ViewHiveLeaders()

if("SelectedJob")

if(!GLOB.enter_allowed)
to_chat(usr, SPAN_WARNING("There is an administrative lock on entering the game! (The dropship likely crashed into the Almayer. This should take at most 20 minutes.)"))
return
Expand Down Expand Up @@ -232,6 +211,48 @@
var/datum/tutorial_menu/menu = new(src)
menu.ui_interact(src)

/mob/new_player/proc/attempt_observe()
if(src != usr)
return
if(!client)
return
if(!SSticker || SSticker.current_state == GAME_STATE_STARTUP)
to_chat(src, SPAN_WARNING("The game is still setting up, please try again later."))
return

if(!client.prefs?.preview_dummy)
client.prefs.update_preview_icon()
var/mob/dead/observer/observer = new /mob/dead/observer(get_turf(pick(GLOB.latejoin)), client.prefs.preview_dummy)
observer.set_lighting_alpha_from_pref(client)
spawning = TRUE
observer.started_as_observer = TRUE

close_spawn_windows()

var/obj/effect/landmark/observer_start/O = SAFEPICK(GLOB.observer_starts)
if(istype(O))
to_chat(src, SPAN_NOTICE("Now teleporting."))
observer.forceMove(O.loc)
else
to_chat(src, SPAN_DANGER("Could not locate an observer spawn point. Use the Teleport verb to jump to the station map."))
observer.icon = 'icons/mob/humans/species/r_human.dmi'
observer.icon_state = "anglo_example"
observer.alpha = 127

if(client.prefs.be_random_name)
client.prefs.real_name = random_name(client.prefs.gender)
observer.real_name = client.prefs.real_name
observer.name = observer.real_name

mind.transfer_to(observer, TRUE)

if(observer.client)
observer.client.change_view(GLOB.world_view_size)

observer.set_huds_from_prefs()

qdel(src)

/mob/new_player/proc/AttemptLateSpawn(rank)
var/datum/job/player_rank = GLOB.RoleAuthority.roles_for_mode[rank]
if (src != usr)
Expand All @@ -243,7 +264,7 @@
to_chat(usr, SPAN_WARNING("There is an administrative lock on entering the game! (The dropship likely crashed into the Almayer. This should take at most 20 minutes.)"))
return
if(!GLOB.RoleAuthority.assign_role(src, player_rank, 1))
to_chat(src, alert("[rank] is not available. Please try another."))
to_chat(src, SPAN_WARNING("[rank] is not available. Please try another."))
return

spawning = TRUE
Expand Down
Loading