diff --git a/code/modules/events/spider_terror.dm b/code/modules/events/spider_terror.dm index c6f5b52e6e25..51f71526d24a 100644 --- a/code/modules/events/spider_terror.dm +++ b/code/modules/events/spider_terror.dm @@ -1,28 +1,13 @@ -#define TS_POINTS_GREEN 9 -#define TS_POINTS_WHITE 17 -#define TS_POINTS_PRINCESS 19 -#define TS_POINTS_PRINCE 30 -#define TS_POINTS_QUEEN 42 - -#define TERROR_GREEN /mob/living/simple_animal/hostile/poison/terror_spider/green -#define TERROR_WHITE /mob/living/simple_animal/hostile/poison/terror_spider/prince -#define TERROR_PRINCESS /mob/living/simple_animal/hostile/poison/terror_spider/queen/princess -#define TERROR_PRINCE /mob/living/simple_animal/hostile/poison/terror_spider/prince -#define TERROR_QUEEN /mob/living/simple_animal/hostile/poison/terror_spider/queen +#define TS_HIGHPOP_TRIGGER 80 /datum/event/spider_terror announceWhen = 240 - var/poulation_factor = 1.5 // higher - lesser spawnpoints - var/spawncount = 0 // amount of spawned spiders - var/spawnpoints = TS_POINTS_GREEN // weihgt points + var/spawncount = 1 var/successSpawn = FALSE //So we don't make a command report if nothing gets spawned. - //lists for mathcing spiders and their weights - var/list/spider_types = list("TERROR_GREEN" = TERROR_GREEN, "TERROR_WHITE" = TERROR_WHITE, "TERROR_PRINCESS" = TERROR_PRINCESS, "TERROR_PRINCE" = TERROR_PRINCE, "TERROR_QUEEN" = TERROR_QUEEN) - var/list/spider_costs = list("TERROR_GREEN" = TS_POINTS_GREEN, "TERROR_WHITE" = TS_POINTS_WHITE, "TERROR_PRINCESS" = TS_POINTS_PRINCESS, "TERROR_PRINCE" = TS_POINTS_PRINCE, "TERROR_QUEEN" = TS_POINTS_QUEEN) - var/list/spider_counts = list("TERROR_GREEN" = 0, "TERROR_WHITE" = 0, "TERROR_PRINCESS" = 0, "TERROR_PRINCE" = 0, "TERROR_QUEEN" = 0) /datum/event/spider_terror/setup() announceWhen = rand(announceWhen, announceWhen + 30) + spawncount = 1 /datum/event/spider_terror/announce(false_alarm) if(successSpawn || false_alarm) @@ -35,83 +20,52 @@ INVOKE_ASYNC(src, PROC_REF(wrappedstart)) /datum/event/spider_terror/proc/wrappedstart() - var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as a terror spider?", null, TRUE, source = /mob/living/simple_animal/hostile/poison/terror_spider) // questionable - var/max_spiders = length(candidates) - log_debug("where is [max_spiders] candidates") - spawnpoints += round(length(GLOB.clients) / poulation_factor) // server population sensevity - log_debug("where is [spawnpoints] available spawnpoints") - spawn_terror_spiders(count_spawn_spiders(max_spiders), candidates) - SSevents.biohazards_this_round += 1 - -/datum/event/spider_terror/proc/count_spawn_spiders(max_spiders) - while(spawnpoints >= TS_POINTS_GREEN && spawncount < max_spiders) - var/chosen_spider_id = pick(spider_costs) // random spider type choose - var/cost = spider_costs[chosen_spider_id] - - if(spawnpoints - cost >= 0) - spider_counts[chosen_spider_id] += 1 - spawnpoints -= cost - spawncount += 1 - log_debug("spider adde into pool: [chosen_spider_id]") - log_debug("where is [spawnpoints] available spawnpoints now") - - if(spawnpoints >= TS_POINTS_GREEN) - continue - - else - break // lack of points break - - if(spawncount >= max_spiders) - - break // over candidates limit break - log_debug("spider list is done: [spider_counts]") - log_debug("selected [spawncount] spider(s)") - return spider_counts - -/datum/event/spider_terror/proc/spawn_terror_spiders(list/spider_counts, candidates) - log_debug("begin spiders spawning") + var/spider_type + var/infestation_type + if((length(GLOB.clients)) < TS_HIGHPOP_TRIGGER) + infestation_type = pick(TS_INFESTATION_GREEN_SPIDER, TS_INFESTATION_PRINCE_SPIDER, TS_INFESTATION_WHITE_SPIDER, TS_INFESTATION_PRINCESS_SPIDER) + else + infestation_type = pick(TS_INFESTATION_PRINCE_SPIDER, TS_INFESTATION_WHITE_SPIDER, TS_INFESTATION_PRINCESS_SPIDER, TS_INFESTATION_QUEEN_SPIDER) + switch(infestation_type) + if(TS_INFESTATION_GREEN_SPIDER) + // Weakest, only used during lowpop. + spider_type = /mob/living/simple_animal/hostile/poison/terror_spider/green + spawncount = 5 + if(TS_INFESTATION_PRINCE_SPIDER) + // Fairly weak. Dangerous in single combat but has little staying power. Always gets whittled down. + spider_type = /mob/living/simple_animal/hostile/poison/terror_spider/prince + spawncount = 1 + if(TS_INFESTATION_WHITE_SPIDER) + // Variable. Depends how many they infect. + spider_type = /mob/living/simple_animal/hostile/poison/terror_spider/white + spawncount = 2 + if(TS_INFESTATION_PRINCESS_SPIDER) + // Pretty strong. + spider_type = /mob/living/simple_animal/hostile/poison/terror_spider/queen/princess + spawncount = 3 + if(TS_INFESTATION_QUEEN_SPIDER) + // Strongest, only used during highpop. + spider_type = /mob/living/simple_animal/hostile/poison/terror_spider/queen + spawncount = 1 + var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as a terror spider?", null, TRUE, source = spider_type) + if(length(candidates) < spawncount) + message_admins("Warning: not enough players volunteered to be terrors. Could only spawn [length(candidates)] out of [spawncount]!") var/list/vents = get_valid_vent_spawns(exclude_mobs_nearby = TRUE) if(!length(vents)) message_admins("Warning: No suitable vents detected for spawning terrors. Force picking from station vents regardless of state!") vents = get_valid_vent_spawns(unwelded_only = FALSE, min_network_size = 0) - - log_debug("where is awailible [length(vents)] vents") - while(spawncount && length(vents) && length(candidates)) - for(var/spider_id in spider_counts) - var/spider_type = spider_types[spider_id] - var/spider_count = spider_counts[spider_id] - - while(spider_count > 0 && length(candidates)) - var/obj/vent = pick_n_take(vents) - var/mob/living/simple_animal/hostile/poison/terror_spider/S = new spider_type(vent.loc) - var/mob/M = pick_n_take(candidates) - S.key = M.key - dust_if_respawnable(M) - S.forceMove(vent) - S.add_ventcrawl(vent) - SEND_SOUND(S, sound('sound/ambience/antag/terrorspider.ogg')) - S.give_intro_text() - spawncount-- - successSpawn = TRUE - - spider_count -- - - if(spawncount <= 0) - break - - spider_counts[spider_type] = 0 - - log_and_message_admins("spiders spawned successfully") - -#undef TS_POINTS_GREEN -#undef TS_POINTS_WHITE -#undef TS_POINTS_PRINCESS -#undef TS_POINTS_PRINCE -#undef TS_POINTS_QUEEN - -#undef TERROR_GREEN -#undef TERROR_WHITE -#undef TERROR_PRINCESS -#undef TERROR_PRINCE -#undef TERROR_QUEEN + var/obj/vent = pick_n_take(vents) + var/mob/living/simple_animal/hostile/poison/terror_spider/S = new spider_type(vent.loc) + var/mob/M = pick_n_take(candidates) + S.key = M.key + dust_if_respawnable(M) + S.forceMove(vent) + S.add_ventcrawl(vent) + SEND_SOUND(S, sound('sound/ambience/antag/terrorspider.ogg')) + S.give_intro_text() + spawncount-- + successSpawn = TRUE + SSevents.biohazards_this_round += infestation_type + +#undef TS_HIGHPOP_TRIGGER diff --git a/modular_ss220/events/_events.dme b/modular_ss220/events/_events.dme index f2d0c0781a56..f7491fa48fb4 100644 --- a/modular_ss220/events/_events.dme +++ b/modular_ss220/events/_events.dme @@ -4,3 +4,4 @@ #include "code/headcrabs.dm" #include "code/infestation_extended.dm" #include "code/christmas.dm" +#include "code/spider_terror.dm" diff --git a/modular_ss220/events/code/spider_terror.dm b/modular_ss220/events/code/spider_terror.dm new file mode 100644 index 000000000000..c6f5b52e6e25 --- /dev/null +++ b/modular_ss220/events/code/spider_terror.dm @@ -0,0 +1,117 @@ +#define TS_POINTS_GREEN 9 +#define TS_POINTS_WHITE 17 +#define TS_POINTS_PRINCESS 19 +#define TS_POINTS_PRINCE 30 +#define TS_POINTS_QUEEN 42 + +#define TERROR_GREEN /mob/living/simple_animal/hostile/poison/terror_spider/green +#define TERROR_WHITE /mob/living/simple_animal/hostile/poison/terror_spider/prince +#define TERROR_PRINCESS /mob/living/simple_animal/hostile/poison/terror_spider/queen/princess +#define TERROR_PRINCE /mob/living/simple_animal/hostile/poison/terror_spider/prince +#define TERROR_QUEEN /mob/living/simple_animal/hostile/poison/terror_spider/queen + +/datum/event/spider_terror + announceWhen = 240 + var/poulation_factor = 1.5 // higher - lesser spawnpoints + var/spawncount = 0 // amount of spawned spiders + var/spawnpoints = TS_POINTS_GREEN // weihgt points + var/successSpawn = FALSE //So we don't make a command report if nothing gets spawned. + //lists for mathcing spiders and their weights + var/list/spider_types = list("TERROR_GREEN" = TERROR_GREEN, "TERROR_WHITE" = TERROR_WHITE, "TERROR_PRINCESS" = TERROR_PRINCESS, "TERROR_PRINCE" = TERROR_PRINCE, "TERROR_QUEEN" = TERROR_QUEEN) + var/list/spider_costs = list("TERROR_GREEN" = TS_POINTS_GREEN, "TERROR_WHITE" = TS_POINTS_WHITE, "TERROR_PRINCESS" = TS_POINTS_PRINCESS, "TERROR_PRINCE" = TS_POINTS_PRINCE, "TERROR_QUEEN" = TS_POINTS_QUEEN) + var/list/spider_counts = list("TERROR_GREEN" = 0, "TERROR_WHITE" = 0, "TERROR_PRINCESS" = 0, "TERROR_PRINCE" = 0, "TERROR_QUEEN" = 0) + +/datum/event/spider_terror/setup() + announceWhen = rand(announceWhen, announceWhen + 30) + +/datum/event/spider_terror/announce(false_alarm) + if(successSpawn || false_alarm) + GLOB.major_announcement.Announce("Confirmed outbreak of level 3-S biohazard aboard [station_name()]. All personnel must contain the outbreak.", "Biohazard Alert", 'sound/effects/siren-spooky.ogg', new_sound2 = 'sound/AI/outbreak3.ogg') + else + log_and_message_admins("Warning: Could not spawn any mobs for event Terror Spiders") + +/datum/event/spider_terror/start() + // It is necessary to wrap this to avoid the event triggering repeatedly. + INVOKE_ASYNC(src, PROC_REF(wrappedstart)) + +/datum/event/spider_terror/proc/wrappedstart() + var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as a terror spider?", null, TRUE, source = /mob/living/simple_animal/hostile/poison/terror_spider) // questionable + var/max_spiders = length(candidates) + log_debug("where is [max_spiders] candidates") + spawnpoints += round(length(GLOB.clients) / poulation_factor) // server population sensevity + log_debug("where is [spawnpoints] available spawnpoints") + spawn_terror_spiders(count_spawn_spiders(max_spiders), candidates) + SSevents.biohazards_this_round += 1 + +/datum/event/spider_terror/proc/count_spawn_spiders(max_spiders) + while(spawnpoints >= TS_POINTS_GREEN && spawncount < max_spiders) + var/chosen_spider_id = pick(spider_costs) // random spider type choose + var/cost = spider_costs[chosen_spider_id] + + if(spawnpoints - cost >= 0) + spider_counts[chosen_spider_id] += 1 + spawnpoints -= cost + spawncount += 1 + log_debug("spider adde into pool: [chosen_spider_id]") + log_debug("where is [spawnpoints] available spawnpoints now") + + if(spawnpoints >= TS_POINTS_GREEN) + continue + + else + break // lack of points break + + if(spawncount >= max_spiders) + + break // over candidates limit break + log_debug("spider list is done: [spider_counts]") + log_debug("selected [spawncount] spider(s)") + return spider_counts + +/datum/event/spider_terror/proc/spawn_terror_spiders(list/spider_counts, candidates) + log_debug("begin spiders spawning") + var/list/vents = get_valid_vent_spawns(exclude_mobs_nearby = TRUE) + if(!length(vents)) + message_admins("Warning: No suitable vents detected for spawning terrors. Force picking from station vents regardless of state!") + vents = get_valid_vent_spawns(unwelded_only = FALSE, min_network_size = 0) + + log_debug("where is awailible [length(vents)] vents") + + while(spawncount && length(vents) && length(candidates)) + for(var/spider_id in spider_counts) + var/spider_type = spider_types[spider_id] + var/spider_count = spider_counts[spider_id] + + while(spider_count > 0 && length(candidates)) + var/obj/vent = pick_n_take(vents) + var/mob/living/simple_animal/hostile/poison/terror_spider/S = new spider_type(vent.loc) + var/mob/M = pick_n_take(candidates) + S.key = M.key + dust_if_respawnable(M) + S.forceMove(vent) + S.add_ventcrawl(vent) + SEND_SOUND(S, sound('sound/ambience/antag/terrorspider.ogg')) + S.give_intro_text() + spawncount-- + successSpawn = TRUE + + spider_count -- + + if(spawncount <= 0) + break + + spider_counts[spider_type] = 0 + + log_and_message_admins("spiders spawned successfully") + +#undef TS_POINTS_GREEN +#undef TS_POINTS_WHITE +#undef TS_POINTS_PRINCESS +#undef TS_POINTS_PRINCE +#undef TS_POINTS_QUEEN + +#undef TERROR_GREEN +#undef TERROR_WHITE +#undef TERROR_PRINCESS +#undef TERROR_PRINCE +#undef TERROR_QUEEN