From b1f80461f6d79ebb77bdf6eab3936dcf03548e4a Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 28 Jan 2024 07:54:26 +0300 Subject: [PATCH 01/11] tweak: terror spiders spawn refactor --- code/modules/events/spider_terror.dm | 138 ++++++++++++++++++--------- 1 file changed, 91 insertions(+), 47 deletions(-) diff --git a/code/modules/events/spider_terror.dm b/code/modules/events/spider_terror.dm index 51f71526d24a..719729786119 100644 --- a/code/modules/events/spider_terror.dm +++ b/code/modules/events/spider_terror.dm @@ -1,13 +1,28 @@ -#define TS_HIGHPOP_TRIGGER 80 +#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/spawncount = 1 + var/spawncount = 0 + var/spawnpoints = 9 var/successSpawn = FALSE //So we don't make a command report if nothing gets spawned. + 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) @@ -20,52 +35,81 @@ INVOKE_ASYNC(src, PROC_REF(wrappedstart)) /datum/event/spider_terror/proc/wrappedstart() - 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/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) / 1.5) // 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("where is [spawnpoints] available spawnpoints") + + 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)) - 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 + log_debug("list inspection started") + 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) + log_debug("type is set: [spider_type]") + 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 + log_debug("key set") + 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 -- + + spider_counts[spider_type] = 0 + + +#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 From 8898c14bafeefacf0d7b6505e79b68264f5d8b25 Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 28 Jan 2024 08:15:05 +0300 Subject: [PATCH 02/11] cleanup --- code/modules/events/spider_terror.dm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/code/modules/events/spider_terror.dm b/code/modules/events/spider_terror.dm index 719729786119..e466b88cc0c6 100644 --- a/code/modules/events/spider_terror.dm +++ b/code/modules/events/spider_terror.dm @@ -10,13 +10,13 @@ #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/spawncount = 0 - var/spawnpoints = 9 + var/poulation_factor = 1.5 // higher - lesser spawnpoints + var/spawncount = 0 // amount of spawned spiders + var/spawnpoints = 9 // 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) @@ -38,7 +38,7 @@ 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) / 1.5) // server population sensevity + 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 @@ -52,7 +52,8 @@ spider_counts[chosen_spider_id] += 1 spawnpoints -= cost spawncount += 1 - log_debug("where is [spawnpoints] available spawnpoints") + log_debug("spider adde into pool: [chosen_spider_id]") + log_debug("where is [spawnpoints] available spawnpoints now") if(spawnpoints >= TS_POINTS_GREEN) continue @@ -77,18 +78,15 @@ log_debug("where is awailible [length(vents)] vents") while(spawncount && length(vents) && length(candidates)) - log_debug("list inspection started") 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) - log_debug("type is set: [spider_type]") 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 - log_debug("key set") dust_if_respawnable(M) S.forceMove(vent) S.add_ventcrawl(vent) @@ -99,8 +97,12 @@ 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 From 406dcecc5f8e95cbb8ccdba6b94777b54fcccc25 Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 28 Jan 2024 15:58:47 +0300 Subject: [PATCH 03/11] pupu --- code/modules/events/spider_terror.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/events/spider_terror.dm b/code/modules/events/spider_terror.dm index e466b88cc0c6..c6f5b52e6e25 100644 --- a/code/modules/events/spider_terror.dm +++ b/code/modules/events/spider_terror.dm @@ -14,7 +14,7 @@ announceWhen = 240 var/poulation_factor = 1.5 // higher - lesser spawnpoints var/spawncount = 0 // amount of spawned spiders - var/spawnpoints = 9 // weihgt points + 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) From f2e9771f1f1c1c99d3a226d609c37f98a8092305 Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 28 Jan 2024 16:29:33 +0300 Subject: [PATCH 04/11] now is modular --- code/modules/events/spider_terror.dm | 140 +++++++-------------- modular_ss220/events/_events.dme | 1 + modular_ss220/events/code/spider_terror.dm | 117 +++++++++++++++++ 3 files changed, 165 insertions(+), 93 deletions(-) create mode 100644 modular_ss220/events/code/spider_terror.dm 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 From ba48b87c378e5dce351d92ad0eb2651ba0c82061 Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 28 Jan 2024 16:38:33 +0300 Subject: [PATCH 05/11] wrong code --- modular_ss220/events/code/spider_terror.dm | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/modular_ss220/events/code/spider_terror.dm b/modular_ss220/events/code/spider_terror.dm index c6f5b52e6e25..eddece9e97d5 100644 --- a/modular_ss220/events/code/spider_terror.dm +++ b/modular_ss220/events/code/spider_terror.dm @@ -13,28 +13,18 @@ /datum/event/spider_terror announceWhen = 240 var/poulation_factor = 1.5 // higher - lesser spawnpoints - var/spawncount = 0 // amount of spawned spiders + 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)) + INVOKE_ASYNC(src, PROC_REF(wrappedstart_new)) -/datum/event/spider_terror/proc/wrappedstart() +/datum/event/spider_terror/proc/wrappedstart_new() 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") @@ -76,12 +66,12 @@ vents = get_valid_vent_spawns(unwelded_only = FALSE, min_network_size = 0) log_debug("where is awailible [length(vents)] vents") - + log_debug("spawncount is: [spawncount] 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] - + log_debug("entering inner while cycle") 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) From 6698d031a036a800a6bba6ed65a87401f8eafa80 Mon Sep 17 00:00:00 2001 From: Peter Date: Sun, 28 Jan 2024 20:03:15 +0300 Subject: [PATCH 06/11] fixed modular --- modular_ss220/events/code/spider_terror.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modular_ss220/events/code/spider_terror.dm b/modular_ss220/events/code/spider_terror.dm index eddece9e97d5..fd5b56117875 100644 --- a/modular_ss220/events/code/spider_terror.dm +++ b/modular_ss220/events/code/spider_terror.dm @@ -21,6 +21,7 @@ var/list/spider_counts = list("TERROR_GREEN" = 0, "TERROR_WHITE" = 0, "TERROR_PRINCESS" = 0, "TERROR_PRINCE" = 0, "TERROR_QUEEN" = 0) /datum/event/spider_terror/start() + spawncount = 0 // yeah, still not 0 // It is necessary to wrap this to avoid the event triggering repeatedly. INVOKE_ASYNC(src, PROC_REF(wrappedstart_new)) @@ -42,7 +43,7 @@ spider_counts[chosen_spider_id] += 1 spawnpoints -= cost spawncount += 1 - log_debug("spider adde into pool: [chosen_spider_id]") + log_debug("spider added into pool: [chosen_spider_id]") log_debug("where is [spawnpoints] available spawnpoints now") if(spawnpoints >= TS_POINTS_GREEN) @@ -54,7 +55,6 @@ 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 From 0f5481e47f445969c292b939b04833b649f76632 Mon Sep 17 00:00:00 2001 From: Fullonibus <38350888+Fullonibus@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:42:20 +0300 Subject: [PATCH 07/11] Update modular_ss220/events/code/spider_terror.dm Co-authored-by: Mikhail Dzianishchyts --- modular_ss220/events/code/spider_terror.dm | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/modular_ss220/events/code/spider_terror.dm b/modular_ss220/events/code/spider_terror.dm index fd5b56117875..0f5055955224 100644 --- a/modular_ss220/events/code/spider_terror.dm +++ b/modular_ss220/events/code/spider_terror.dm @@ -46,15 +46,9 @@ log_debug("spider added 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 + if(spawnpoints < TS_POINTS_GREEN || spawncount >= max_spiders) + break + log_debug("selected [spawncount] spider(s)") return spider_counts From 2dd048cc4674405ec96faaef23090ddc1de898a6 Mon Sep 17 00:00:00 2001 From: Fullonibus <38350888+Fullonibus@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:42:30 +0300 Subject: [PATCH 08/11] Update modular_ss220/events/code/spider_terror.dm Co-authored-by: Mikhail Dzianishchyts --- modular_ss220/events/code/spider_terror.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modular_ss220/events/code/spider_terror.dm b/modular_ss220/events/code/spider_terror.dm index 0f5055955224..5b274b2ec8f1 100644 --- a/modular_ss220/events/code/spider_terror.dm +++ b/modular_ss220/events/code/spider_terror.dm @@ -79,7 +79,7 @@ spawncount-- successSpawn = TRUE - spider_count -- + spider_count-- if(spawncount <= 0) break From 49b2a220560ef59bfe26ad86481a2e5e2667927c Mon Sep 17 00:00:00 2001 From: Fullonibus <38350888+Fullonibus@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:42:37 +0300 Subject: [PATCH 09/11] Update modular_ss220/events/code/spider_terror.dm Co-authored-by: Mikhail Dzianishchyts --- modular_ss220/events/code/spider_terror.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modular_ss220/events/code/spider_terror.dm b/modular_ss220/events/code/spider_terror.dm index 5b274b2ec8f1..8cbf619e6a45 100644 --- a/modular_ss220/events/code/spider_terror.dm +++ b/modular_ss220/events/code/spider_terror.dm @@ -29,7 +29,7 @@ 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 + spawnpoints += round(population_factor * length(GLOB.clients)) // server population sensitivity log_debug("where is [spawnpoints] available spawnpoints") spawn_terror_spiders(count_spawn_spiders(max_spiders), candidates) SSevents.biohazards_this_round += 1 From 8d9d535e3fdf8b3ea7125e73f3d5a4354c370eb3 Mon Sep 17 00:00:00 2001 From: Fullonibus <38350888+Fullonibus@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:43:12 +0300 Subject: [PATCH 10/11] Update modular_ss220/events/code/spider_terror.dm Co-authored-by: Mikhail Dzianishchyts --- modular_ss220/events/code/spider_terror.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modular_ss220/events/code/spider_terror.dm b/modular_ss220/events/code/spider_terror.dm index 8cbf619e6a45..32f8dcf635ff 100644 --- a/modular_ss220/events/code/spider_terror.dm +++ b/modular_ss220/events/code/spider_terror.dm @@ -12,10 +12,10 @@ /datum/event/spider_terror announceWhen = 240 - var/poulation_factor = 1.5 // higher - lesser spawnpoints + var/population_factor = 0.7 // higher - more spawnpoints spawncount = 0 // amount of spawned spiders - var/spawnpoints = TS_POINTS_GREEN // weihgt points - //lists for mathcing spiders and their weights + var/spawnpoints = TS_POINTS_GREEN // weight points + /// lists for matching 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) From d17ff9b8716bac4e8c74ecff12259590160cf794 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 26 Feb 2024 20:24:01 +0300 Subject: [PATCH 11/11] de-defined type list --- modular_ss220/events/code/spider_terror.dm | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/modular_ss220/events/code/spider_terror.dm b/modular_ss220/events/code/spider_terror.dm index 32f8dcf635ff..689c735dc18b 100644 --- a/modular_ss220/events/code/spider_terror.dm +++ b/modular_ss220/events/code/spider_terror.dm @@ -4,11 +4,6 @@ #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 @@ -16,9 +11,30 @@ spawncount = 0 // amount of spawned spiders var/spawnpoints = TS_POINTS_GREEN // weight points /// lists for matching 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) + + var/list/spider_types = list( + "TERROR_GREEN" = /mob/living/simple_animal/hostile/poison/terror_spider/green, + "TERROR_WHITE" = /mob/living/simple_animal/hostile/poison/terror_spider/white, + "TERROR_PRINCESS" = /mob/living/simple_animal/hostile/poison/terror_spider/queen/princess, + "TERROR_PRINCE" = /mob/living/simple_animal/hostile/poison/terror_spider/prince, + "TERROR_QUEEN" = /mob/living/simple_animal/hostile/poison/terror_spider/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/start() spawncount = 0 // yeah, still not 0 @@ -48,7 +64,7 @@ if(spawnpoints < TS_POINTS_GREEN || spawncount >= max_spiders) break - + log_debug("selected [spawncount] spider(s)") return spider_counts @@ -93,9 +109,3 @@ #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