Skip to content

Commit

Permalink
Icewalkers and ghosts can now tell who joined and who left the Icemoo…
Browse files Browse the repository at this point in the history
…n Dweller hole (#1062)

* Lets icewalkers and ghosts tell who joined and who left their hole spawner in the round via examining it twice

* Fixes a missing argument in examine()

* Apply suggestions from code review

Co-authored-by: Bloop <[email protected]>

* Update modular_nova/modules/primitive_catgirls/code/spawner.dm

* Fixes the leave and log cache print logic

---------

Co-authored-by: Bloop <[email protected]>
Co-authored-by: SomeRandomOwl <[email protected]>
  • Loading branch information
3 people authored and StealsThePRs committed Feb 26, 2024
1 parent 7926972 commit 3e6e644
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion modular_nova/modules/primitive_catgirls/code/spawner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
uses = 12
deletes_on_zero_uses_left = FALSE

/// The list of real names of those that have gone back into the hole.
/// Should get modified automatically by `create()` and `put_back_in()`.
var/list/went_back_to_sleep = list()
/// The cached string to display for additional info on who joined and who left.
/// Nulled every time someone joins or leaves to ensure it gets re-generated.
var/join_and_leave_log_cache = null
/// The minimum time someone needs to be SSD before they can be put back in
var/ssd_time = 30 MINUTES

Expand All @@ -39,23 +45,77 @@
team = null
return ..()

/obj/effect/mob_spawn/ghost_role/human/primitive_catgirl/examine()
/obj/effect/mob_spawn/ghost_role/human/primitive_catgirl/examine(mob/user)
. = ..()

if(uses)
. += span_notice("You can see <b>[uses]</b> figures sound asleep down there.")
else
. += span_notice("It looks pretty empty.")

if(isprimitivedemihuman(user) || isobserver(user))
. += span_notice("<i>You could examine it more thoroughly...</i>")

return .


/obj/effect/mob_spawn/ghost_role/human/primitive_catgirl/examine_more(mob/user)
. = ..()

if(!isprimitivedemihuman(user) && !isobserver(user))
return

. += get_joined_and_left_log()


/**
* Returns the `join_and_leave_log_cache` string if it already exists, otherwise
* generates and returns it.
*/
/obj/effect/mob_spawn/ghost_role/human/primitive_catgirl/proc/get_joined_and_left_log()
if(join_and_leave_log_cache)
return join_and_leave_log_cache

var/list/joined_player_names = list()

for(var/datum/mind/joined_mind in team.members)
joined_player_names += joined_mind.name

if(!length(joined_player_names) && !length(went_back_to_sleep))
join_and_leave_log_cache = span_notice("Everyone still seems to be sleeping peacefully in the hole.")
return join_and_leave_log_cache

var/nobody_joined = !length(joined_player_names)
var/nobody_returned = !length(went_back_to_sleep)
var/should_add_newline = !nobody_returned && !nobody_joined // if we have both missing kin and kin who went back to sleep, add a newline

join_and_leave_log_cache = span_notice( \
"[nobody_joined ? "" : "You smell that the following kin are missing from the hole:\n\
<b>[joined_player_names.Join("</b>, <b>")]</b>"]\
[should_add_newline ? "\n\n" : ""]\
[nobody_returned ? "" : "You catch the scent of the following kin having recently went back to sleep:\n\
<b>[went_back_to_sleep.Join("</b>, <b>")]</b>"]" \
)

return join_and_leave_log_cache


/obj/effect/mob_spawn/ghost_role/human/primitive_catgirl/allow_spawn(mob/user, silent = FALSE)
if(!(user.key in team.players_spawned)) // One spawn per person
return TRUE
if(!silent)
to_chat(user, span_warning("It'd be weird if there were multiple of you in that cave, wouldn't it?"))
return FALSE


/obj/effect/mob_spawn/ghost_role/human/primitive_catgirl/create(mob/mob_possessor, newname)
. = ..()

// We remove their name from there if they come back.
went_back_to_sleep -= newname
join_and_leave_log_cache = null


// This stuff is put on equip because it turns out /special sometimes just don't get called because Nova
/obj/effect/mob_spawn/ghost_role/human/primitive_catgirl/equip(mob/living/carbon/human/spawned_human)
. = ..()
Expand Down Expand Up @@ -153,6 +213,8 @@
// or whatever.
team.players_spawned -= (target.key)
team.remove_member(target.mind)
went_back_to_sleep += target.real_name
join_and_leave_log_cache = null

for(var/list/record in GLOB.ghost_records)
if(record["name"] == target.real_name)
Expand Down

0 comments on commit 3e6e644

Please sign in to comment.