From 1da61d4d27ea78bb4338e7f59fc4f990345a9e17 Mon Sep 17 00:00:00 2001 From: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com> Date: Sun, 16 Jan 2022 12:54:10 -0500 Subject: [PATCH] Adds a cap to Xenobiology Mobs and Allows Sentient Giant Spider prompts to be disabled (#17316) Co-authored-by: dearmochi <1496804+dearmochi@users.noreply.github.com> --- code/__DEFINES/mobs.dm | 3 +++ code/controllers/subsystem/mobs.dm | 4 ++-- code/game/objects/effects/spiders.dm | 18 +++++++++++------- .../simple_animal/hostile/giant_spider.dm | 7 +------ .../mob/living/simple_animal/simple_animal.dm | 4 ++++ code/modules/reagents/chemistry/recipes.dm | 4 +++- .../chemistry/recipes/slime_extracts.dm | 18 +++++++++++++++--- 7 files changed, 39 insertions(+), 19 deletions(-) diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index 32d0287caba..a6665768980 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -184,6 +184,9 @@ #define HOSTILE_SPAWN 1 #define FRIENDLY_SPAWN 2 +///Max amount of living Xenobio mobs allowed at any given time (excluding slimes). +#define MAX_GOLD_CORE_MOBS 45 + #define TINT_IMPAIR 2 //Threshold of tint level to apply weld mask overlay #define TINT_BLIND 3 //Threshold of tint level to obscure vision fully #define EYE_SHINE_THRESHOLD 6 //dark_view threshold past which a humanoid's eyes will 'shine' in the dark. diff --git a/code/controllers/subsystem/mobs.dm b/code/controllers/subsystem/mobs.dm index def8a807853..ebd37383e35 100644 --- a/code/controllers/subsystem/mobs.dm +++ b/code/controllers/subsystem/mobs.dm @@ -9,8 +9,8 @@ SUBSYSTEM_DEF(mobs) var/static/list/clients_by_zlevel[][] var/static/list/dead_players_by_zlevel[][] = list(list()) // Needs to support zlevel 1 here, MaxZChanged only happens when CC is created and new_players can login before that. var/static/list/cubemonkeys = list() - /// The amount of giant spiders that exist in the world. Used for mob capping. - var/giant_spiders = 0 + /// The amount of Xenobiology mobs (and their offspring) that exist in the world. Used for mob capping. Excludes Slimes + var/xenobiology_mobs = 0 /datum/controller/subsystem/mobs/get_metrics() . = ..() diff --git a/code/game/objects/effects/spiders.dm b/code/game/objects/effects/spiders.dm index 7a2880d897e..83c34232fcf 100644 --- a/code/game/objects/effects/spiders.dm +++ b/code/game/objects/effects/spiders.dm @@ -1,6 +1,3 @@ -//generic procs copied from obj/effect/alien -#define SPIDER_SOFT_CAP 30 -#define SPIDER_HARD_CAP 40 /obj/structure/spider name = "web" desc = "it's stringy and sticky" @@ -60,6 +57,8 @@ icon_state = "eggs" var/amount_grown = 0 var/player_spiders = 0 + ///Was this egg laid by a xenobiology mob? Used for mob capping + var/xenobiology_spawned = FALSE var/list/faction = list("spiders") /obj/structure/spider/eggcluster/Initialize(mapload) @@ -69,7 +68,7 @@ START_PROCESSING(SSobj, src) /obj/structure/spider/eggcluster/process() - if(SSmobs.giant_spiders > SPIDER_SOFT_CAP) //eggs gonna chill out until there is less spiders + if(SSmobs.xenobiology_mobs > MAX_GOLD_CORE_MOBS - 10) //eggs gonna chill out until there is less spiders return amount_grown += rand(0, 2) @@ -80,6 +79,7 @@ var/obj/structure/spider/spiderling/S = new /obj/structure/spider/spiderling(loc) S.faction = faction.Copy() S.master_commander = master_commander + S.xenobiology_spawned = xenobiology_spawned if(player_spiders) S.player_spiders = TRUE qdel(src) @@ -98,6 +98,8 @@ var/player_spiders = 0 var/list/faction = list("spiders") var/selecting_player = 0 + ///Is this spiderling created from a xenobiology mob? + var/xenobiology_spawned = FALSE /obj/structure/spider/spiderling/Initialize(mapload) . = ..() @@ -174,19 +176,21 @@ if(isturf(loc)) amount_grown += rand(0,2) if(amount_grown >= 100) - if(SSmobs.giant_spiders > SPIDER_HARD_CAP) + if(SSmobs.xenobiology_mobs > MAX_GOLD_CORE_MOBS && xenobiology_spawned) qdel(src) return if(!grow_as) grow_as = pick(typesof(/mob/living/simple_animal/hostile/poison/giant_spider)) var/mob/living/simple_animal/hostile/poison/giant_spider/S = new grow_as(loc) - SSmobs.giant_spiders++ S.faction = faction.Copy() S.master_commander = master_commander + S.xenobiology_spawned = xenobiology_spawned + if(xenobiology_spawned) + SSmobs.xenobiology_mobs++ if(player_spiders && !selecting_player) selecting_player = 1 spawn() - var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as a giant spider?", ROLE_GSPIDER, TRUE, source = S) + var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as a giant spider?", ROLE_SENTIENT, TRUE, source = S) if(length(candidates) && !QDELETED(S)) var/mob/C = pick(candidates) diff --git a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm index 98dcd8cac6e..38e71362817 100644 --- a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm +++ b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm @@ -56,12 +56,6 @@ for(var/obj/structure/spider/S in range(1, get_turf(src))) return S -/mob/living/simple_animal/hostile/poison/giant_spider/death(gibbed) - . = ..() - if(!.) - return FALSE - SSmobs.giant_spiders-- - //nursemaids - these create webs and eggs /mob/living/simple_animal/hostile/poison/giant_spider/nurse desc = "Furry and black, it makes you shudder to look at it. This one has brilliant green eyes." @@ -263,6 +257,7 @@ var/obj/structure/spider/eggcluster/C = new /obj/structure/spider/eggcluster(src.loc) C.faction = faction.Copy() C.master_commander = master_commander + C.xenobiology_spawned = xenobiology_spawned if(ckey) C.player_spiders = 1 fed-- diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 94918368aa0..8547d1b0f99 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -80,6 +80,8 @@ var/max_offspring = DEFAULT_MAX_OFFSPRING var/buffed = 0 //In the event that you want to have a buffing effect on the mob, but don't want it to stack with other effects, any outside force that applies a buff to a simple mob should at least set this to 1, so we have something to check against + ///Was this mob spawned by xenobiology magic? Used for mobcapping. + var/xenobiology_spawned = FALSE var/gold_core_spawnable = NO_SPAWN //If the mob can be spawned with a gold slime core. HOSTILE_SPAWN are spawned with plasma, FRIENDLY_SPAWN are spawned with blood var/mob/living/carbon/human/master_commander = null //holding var for determining who own/controls a sentient simple animal (for sentience potions). @@ -374,6 +376,8 @@ visible_message("\The [src] [deathmessage]") else if(!del_on_death) visible_message("\The [src] stops moving...") + if(xenobiology_spawned) + SSmobs.xenobiology_mobs-- if(del_on_death) //Prevent infinite loops if the mob Destroy() is overridden in such //a manner as to cause a call to death() again diff --git a/code/modules/reagents/chemistry/recipes.dm b/code/modules/reagents/chemistry/recipes.dm index cb739a65a7b..b76634f1dfb 100644 --- a/code/modules/reagents/chemistry/recipes.dm +++ b/code/modules/reagents/chemistry/recipes.dm @@ -21,7 +21,7 @@ return -/datum/chemical_reaction/proc/chemical_mob_spawn(datum/reagents/holder, amount_to_spawn, reaction_name, mob_class = HOSTILE_SPAWN, mob_faction = "chemicalsummon", random = TRUE) +/datum/chemical_reaction/proc/chemical_mob_spawn(datum/reagents/holder, amount_to_spawn, reaction_name, mob_class = HOSTILE_SPAWN, mob_faction = "chemicalsummon", random = TRUE, gold_core_spawn = FALSE) if(holder && holder.my_atom) var/atom/A = holder.my_atom var/turf/T = get_turf(A) @@ -48,6 +48,8 @@ S = create_random_mob(get_turf(holder.my_atom), mob_class) else S = new mob_class(get_turf(holder.my_atom))//Spawn our specific mob_class + if(gold_core_spawn) //For tracking xenobiology mobs + S.xenobiology_spawned = TRUE S.faction |= mob_faction if(prob(50)) for(var/j = 1, j <= rand(1, 3), j++) diff --git a/code/modules/reagents/chemistry/recipes/slime_extracts.dm b/code/modules/reagents/chemistry/recipes/slime_extracts.dm index fd7a4001aa6..c8ea1ee0bb7 100644 --- a/code/modules/reagents/chemistry/recipes/slime_extracts.dm +++ b/code/modules/reagents/chemistry/recipes/slime_extracts.dm @@ -102,7 +102,11 @@ /datum/chemical_reaction/slimemobspawn/proc/summon_mobs(datum/reagents/holder, turf/T) T.visible_message("The slime extract begins to vibrate violently!") - addtimer(CALLBACK(src, .proc/chemical_mob_spawn, holder, 5, "Gold Slime", HOSTILE_SPAWN), 50) + if(SSmobs.xenobiology_mobs < MAX_GOLD_CORE_MOBS) + addtimer(CALLBACK(src, .proc/chemical_mob_spawn, holder, 5, "Gold Slime", HOSTILE_SPAWN, "chemicalsummon", TRUE, TRUE), 50) + SSmobs.xenobiology_mobs += 5 + else + T.visible_message("The slime extract sputters out, there's too many mobs to make any more!") /datum/chemical_reaction/slimemobspawn/lesser name = "Slime Crit Lesser" @@ -111,7 +115,11 @@ /datum/chemical_reaction/slimemobspawn/lesser/summon_mobs(datum/reagents/holder, turf/T) T.visible_message("The slime extract begins to vibrate violently!") - addtimer(CALLBACK(src, .proc/chemical_mob_spawn, holder, 3, "Lesser Gold Slime", HOSTILE_SPAWN, "neutral"), 50) + if(SSmobs.xenobiology_mobs < MAX_GOLD_CORE_MOBS) + addtimer(CALLBACK(src, .proc/chemical_mob_spawn, holder, 3, "Lesser Gold Slime", HOSTILE_SPAWN, "neutral", TRUE, TRUE), 50) + SSmobs.xenobiology_mobs += 3 + else + T.visible_message("The slime extract sputters out, there's too many mobs to make any more!") /datum/chemical_reaction/slimemobspawn/friendly name = "Slime Crit Friendly" @@ -120,7 +128,11 @@ /datum/chemical_reaction/slimemobspawn/friendly/summon_mobs(datum/reagents/holder, turf/T) T.visible_message("The slime extract begins to vibrate adorably!") - addtimer(CALLBACK(src, .proc/chemical_mob_spawn, holder, 1, "Friendly Gold Slime", FRIENDLY_SPAWN, "neutral"), 50) + if(SSmobs.xenobiology_mobs < MAX_GOLD_CORE_MOBS) + addtimer(CALLBACK(src, .proc/chemical_mob_spawn, holder, 1, "Friendly Gold Slime", FRIENDLY_SPAWN, "neutral", TRUE, TRUE), 50) + SSmobs.xenobiology_mobs += 1 + else + T.visible_message("The slime extract sputters out, there's too many mobs to make any more!") //Silver /datum/chemical_reaction/slimebork