Files
Bubberstation/code/modules/events/nightmare.dm
SkyratBot c86fdad6ad [MIRROR] Fixes nightmares not spawning [MDB IGNORE] (#8563)
* Fixes nightmares not spawning (#61821)

Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>

* Fixes nightmares not spawning

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Ghom <42542238+Ghommie@ users.noreply.github.com>
2021-10-02 23:05:57 +01:00

45 lines
1.4 KiB
Plaintext

/datum/round_event_control/nightmare
name = "Spawn Nightmare"
typepath = /datum/round_event/ghost_role/nightmare
max_occurrences = 1
min_players = 20
dynamic_should_hijack = TRUE
/datum/round_event/ghost_role/nightmare
minimum_required = 1
role_name = "nightmare"
fakeable = FALSE
/datum/round_event/ghost_role/nightmare/spawn_role()
var/list/candidates = get_candidates(ROLE_ALIEN, ROLE_NIGHTMARE)
if(!candidates.len)
return NOT_ENOUGH_PLAYERS
var/mob/dead/selected = pick(candidates)
var/datum/mind/player_mind = new /datum/mind(selected.key)
player_mind.active = TRUE
var/list/spawn_locs = list()
for(var/X in GLOB.xeno_spawn)
var/turf/T = X
var/light_amount = T.get_lumcount()
if(light_amount < SHADOW_SPECIES_LIGHT_THRESHOLD)
spawn_locs += T
if(!spawn_locs.len)
message_admins("No valid spawn locations found, aborting...")
return MAP_ERROR
var/mob/living/carbon/human/S = new ((pick(spawn_locs)))
player_mind.transfer_to(S)
player_mind.set_assigned_role(SSjob.GetJobType(/datum/job/nightmare))
player_mind.special_role = ROLE_NIGHTMARE
player_mind.add_antag_datum(/datum/antagonist/nightmare)
S.set_species(/datum/species/shadow/nightmare)
playsound(S, 'sound/magic/ethereal_exit.ogg', 50, TRUE, -1)
message_admins("[ADMIN_LOOKUPFLW(S)] has been made into a Nightmare by an event.")
log_game("[key_name(S)] was spawned as a Nightmare by an event.")
spawned_mobs += S
return SUCCESSFUL_SPAWN