From 5c552abe6edc76ab50294b736afee07a4ce0defd Mon Sep 17 00:00:00 2001 From: Dip Date: Fri, 2 Oct 2020 21:33:03 -0300 Subject: [PATCH] Ghost_Role_Eligibility Updates & LL Mob Spawn Updates --- code/__HELPERS/game.dm | 5 +- .../datums/elements/ghost_role_eligibility.dm | 68 +++++++++---------- code/game/area/areas.dm | 5 ++ code/game/area/areas/mining.dm | 2 + .../dynamic/dynamic_rulesets_midround.dm | 3 +- .../turfs/simulated/floor/plating/asteroid.dm | 13 ++-- code/modules/admin/topic.dm | 5 +- code/modules/mob/mob.dm | 5 +- 8 files changed, 57 insertions(+), 49 deletions(-) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index cc7f5d5d..8ef1c3f3 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -442,8 +442,7 @@ candidates -= M /proc/pollGhostCandidates(Question, jobbanType, datum/game_mode/gametypeCheck, be_special_flag = 0, poll_time = 300, ignore_category = null, flashwindow = TRUE) - var/datum/element/ghost_role_eligibility/eligibility = SSdcs.GetElement(/datum/element/ghost_role_eligibility) - var/list/candidates = eligibility.get_all_ghost_role_eligible() + var/list/candidates = get_all_ghost_role_eligible() return pollCandidates(Question, jobbanType, gametypeCheck, be_special_flag, poll_time, ignore_category, flashwindow, candidates) /proc/pollCandidates(Question, jobbanType, datum/game_mode/gametypeCheck, be_special_flag = 0, poll_time = 300, ignore_category = null, flashwindow = TRUE, list/group = null) @@ -453,7 +452,7 @@ var/list/result = list() for(var/m in group) var/mob/M = m - if(!M.key || !M.client || (ignore_category && GLOB.poll_ignore[ignore_category] && M.ckey in GLOB.poll_ignore[ignore_category])) + if(!M.key || !M.client || (ignore_category && GLOB.poll_ignore[ignore_category] && (M.ckey in GLOB.poll_ignore[ignore_category]))) continue if(be_special_flag) if(!(M.client.prefs) || !(be_special_flag in M.client.prefs.be_special)) diff --git a/code/datums/elements/ghost_role_eligibility.dm b/code/datums/elements/ghost_role_eligibility.dm index e57aaddd..4e7884ef 100644 --- a/code/datums/elements/ghost_role_eligibility.dm +++ b/code/datums/elements/ghost_role_eligibility.dm @@ -1,56 +1,54 @@ -/datum/element/ghost_role_eligibility - element_flags = ELEMENT_DETACH - var/list/timeouts = list() - var/list/mob/eligible_mobs = list() +GLOBAL_LIST_EMPTY(ghost_eligible_mobs) -/datum/element/ghost_role_eligibility/Attach(datum/target,penalize = FALSE) +GLOBAL_LIST_EMPTY(client_ghost_timeouts) + +/datum/element/ghost_role_eligibility + element_flags = ELEMENT_DETACH | ELEMENT_BESPOKE + id_arg_index = 2 + var/penalizing = FALSE + var/free_ghost = FALSE + +/datum/element/ghost_role_eligibility/Attach(datum/target,free_ghosting = FALSE, penalize_on_ghost = FALSE) . = ..() if(!ismob(target)) return ELEMENT_INCOMPATIBLE + penalizing = penalize_on_ghost + free_ghost = free_ghosting var/mob/M = target - if(!(M in eligible_mobs)) - eligible_mobs += M - if(penalize) //penalizing them from making a ghost role / midround antag comeback right away. - var/penalty = CONFIG_GET(number/suicide_reenter_round_timer) MINUTES - var/roundstart_quit_limit = CONFIG_GET(number/roundstart_suicide_time_limit) MINUTES - if(world.time < roundstart_quit_limit) //add up the time difference to their antag rolling penalty if they quit before half a (ingame) hour even passed. - penalty += roundstart_quit_limit - world.time - if(penalty) - penalty += world.realtime - if(penalty - SSshuttle.realtimeofstart > SSshuttle.auto_call + SSshuttle.emergencyCallTime + SSshuttle.emergencyDockTime + SSshuttle.emergencyEscapeTime) - penalty = CANT_REENTER_ROUND - if(!(M.ckey in timeouts)) - timeouts += M.ckey - timeouts[M.ckey] = 0 - else if(timeouts[M.ckey] == CANT_REENTER_ROUND) - return - timeouts[M.ckey] = max(timeouts[M.ckey],penalty) + if(!(M in GLOB.ghost_eligible_mobs)) + GLOB.ghost_eligible_mobs += M + RegisterSignal(M, COMSIG_MOB_GHOSTIZE, .proc/get_ghost_flags) /datum/element/ghost_role_eligibility/Detach(mob/M) . = ..() - if(M in eligible_mobs) - eligible_mobs -= M + if(M in GLOB.ghost_eligible_mobs) + GLOB.ghost_eligible_mobs -= M + UnregisterSignal(M, COMSIG_MOB_GHOSTIZE) -/datum/element/ghost_role_eligibility/proc/get_all_ghost_role_eligible(silent = FALSE) +/proc/get_all_ghost_role_eligible(silent = FALSE) var/list/candidates = list() - for(var/m in eligible_mobs) + for(var/m in GLOB.ghost_eligible_mobs) var/mob/M = m if(M.can_reenter_round(TRUE)) candidates += M return candidates /mob/proc/can_reenter_round(silent = FALSE) - var/datum/element/ghost_role_eligibility/eli = SSdcs.GetElement(/datum/element/ghost_role_eligibility) - return eli.can_reenter_round(src,silent) - -/datum/element/ghost_role_eligibility/proc/can_reenter_round(var/mob/M,silent = FALSE) - if(!(M in eligible_mobs)) + if(!(src in GLOB.ghost_eligible_mobs)) return FALSE - if(!(M.ckey in timeouts)) + if(!(ckey in GLOB.client_ghost_timeouts)) return TRUE - var/timeout = timeouts[M.ckey] + var/timeout = GLOB.client_ghost_timeouts[ckey] if(timeout != CANT_REENTER_ROUND && timeout <= world.realtime) return TRUE - if(!silent && M.client) - to_chat(M, "You are unable to reenter the round[timeout != CANT_REENTER_ROUND ? " yet. Your ghost role blacklist will expire in [DisplayTimeText(timeout - world.realtime)]" : ""].") + if(!silent && client) + to_chat(src, "You are unable to reenter the round[timeout != CANT_REENTER_ROUND ? " yet. Your ghost role blacklist will expire in [DisplayTimeText(timeout - world.realtime)]" : ""].") return FALSE + +/datum/element/ghost_role_eligibility/proc/get_ghost_flags() + . = 0 + if(!penalizing) + . |= COMPONENT_DO_NOT_PENALIZE_GHOSTING + if(free_ghost) + . |= COMPONENT_FREE_GHOSTING + return . diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index dfbb5981..2e5d87d3 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -18,6 +18,11 @@ var/clockwork_warp_allowed = TRUE // Can servants warp into this area from Reebe? var/clockwork_warp_fail = "The structure there is too dense for warping to pierce. (This is normal in high-security areas.)" + /// if mobs can be spawned by natural random generation + var/mob_spawn_allowed = FALSE + /// If megafauna can be spawned by natural random generation + var/megafauna_spawn_allowed = FALSE + var/fire = null var/atmos = TRUE var/atmosalm = FALSE diff --git a/code/game/area/areas/mining.dm b/code/game/area/areas/mining.dm index 2ca9167b..6497ca54 100644 --- a/code/game/area/areas/mining.dm +++ b/code/game/area/areas/mining.dm @@ -114,9 +114,11 @@ /area/lavaland/surface/outdoors/unexplored //monsters and ruins spawn here icon_state = "unexplored" + mob_spawn_allowed = TRUE /area/lavaland/surface/outdoors/unexplored/danger //megafauna will also spawn here icon_state = "danger" + megafauna_spawn_allowed = TRUE /area/lavaland/surface/outdoors/explored name = "Lavaland Labor Camp" diff --git a/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm b/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm index 7bcd6c8a..0d242e93 100644 --- a/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm +++ b/code/game/gamemodes/dynamic/dynamic_rulesets_midround.dm @@ -36,8 +36,7 @@ living_players = trim_list(mode.current_players[CURRENT_LIVING_PLAYERS]) living_antags = trim_list(mode.current_players[CURRENT_LIVING_ANTAGS]) list_observers = trim_list(mode.current_players[CURRENT_OBSERVERS]) - var/datum/element/ghost_role_eligibility/eligibility = SSdcs.GetElement(/datum/element/ghost_role_eligibility) - ghost_eligible = trim_list(eligibility.get_all_ghost_role_eligible()) + ghost_eligible = trim_list(get_all_ghost_role_eligible()) /datum/dynamic_ruleset/midround/proc/trim_list(list/L = list()) var/list/trimmed_list = L.Copy() diff --git a/code/game/turfs/simulated/floor/plating/asteroid.dm b/code/game/turfs/simulated/floor/plating/asteroid.dm index d9966ee5..4dc9b168 100644 --- a/code/game/turfs/simulated/floor/plating/asteroid.dm +++ b/code/game/turfs/simulated/floor/plating/asteroid.dm @@ -259,12 +259,17 @@ T.ChangeTurf(turf_type, null, CHANGETURF_IGNORE_AIR) /turf/open/floor/plating/asteroid/airless/cave/proc/SpawnMonster(turf/T) + if(!isarea(loc)) + return + var/area/A = loc if(prob(30)) - if(istype(loc, /area/mine/explored) || !istype(loc, /area/lavaland/surface/outdoors/unexplored)) + if(!A.mob_spawn_allowed) return var/randumb = pickweight(mob_spawn_list) + if(!randumb) + return while(randumb == SPAWN_MEGAFAUNA) - if(istype(loc, /area/lavaland/surface/outdoors/unexplored/danger)) //this is danger. it's boss time. + if(A.megafauna_spawn_allowed && megafauna_spawn_list && megafauna_spawn_list.len) //this is danger. it's boss time. var/maybe_boss = pickweight(megafauna_spawn_list) if(megafauna_spawn_list[maybe_boss]) randumb = maybe_boss @@ -282,7 +287,7 @@ return //prevents tendrils spawning in each other's collapse range new randumb(T) - return + return TRUE #undef SPAWN_MEGAFAUNA #undef SPAWN_BUBBLEGUM @@ -351,4 +356,4 @@ /turf/open/floor/plating/asteroid/snow/atmosphere initial_gas_mix = "o2=22;n2=82;TEMP=180" - planetary_atmos = FALSE \ No newline at end of file + planetary_atmos = FALSE diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index d2a39a0c..47de043c 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1737,9 +1737,8 @@ var/mob/M = locate(href_list["makeeligible"]) if(!ismob(M)) to_chat(usr, "this can only be used on instances of type /mob.") - var/datum/element/ghost_role_eligibility/eli = SSdcs.GetElement(/datum/element/ghost_role_eligibility) - if(M.ckey in eli.timeouts) - eli.timeouts -= M.ckey + if(M.ckey in GLOB.client_ghost_timeouts) + GLOB.client_ghost_timeouts -= M.ckey else if(href_list["sendtoprison"]) if(!check_rights(R_ADMIN)) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index c7ce6577..f8f94d3f 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -319,8 +319,9 @@ face_atom(A) var/list/result = A.examine(src) - to_chat(src, result.Join("\n")) - SEND_SIGNAL(src, COMSIG_MOB_EXAMINATE, A) + if(result != null) + to_chat(src, result.Join("\n")) + SEND_SIGNAL(src, COMSIG_MOB_EXAMINATE, A) //same as above //note: ghosts can point, this is intended