diff --git a/code/controllers/subsystem/mobs.dm b/code/controllers/subsystem/mobs.dm
index c0837ec76b..b88e3c711c 100644
--- a/code/controllers/subsystem/mobs.dm
+++ b/code/controllers/subsystem/mobs.dm
@@ -6,6 +6,8 @@ SUBSYSTEM_DEF(mobs)
var/list/currentrun = list()
var/static/list/clients_by_zlevel[][]
+ var/static/list/cubemonkeys = list()
+ var/cubemonkeycap = 20
/datum/controller/subsystem/mobs/stat_entry()
..("P:[GLOB.mob_living_list.len]")
diff --git a/code/modules/food_and_drinks/food/snacks_meat.dm b/code/modules/food_and_drinks/food/snacks_meat.dm
index cbe93f7003..8affd79e52 100644
--- a/code/modules/food_and_drinks/food/snacks_meat.dm
+++ b/code/modules/food_and_drinks/food/snacks_meat.dm
@@ -185,10 +185,13 @@
foodtype = MEAT | SUGAR
/obj/item/reagent_containers/food/snacks/monkeycube/proc/Expand()
- visible_message("[src] expands!")
var/mob/spammer = get_mob_by_key(fingerprintslast)
- var/mob/living/carbon/monkey/bananas = new(drop_location())
- bananas.log_message("Spawned via [src] at [COORD(src)], Last attached mob: [key_name(spammer)].", INDIVIDUAL_ATTACK_LOG)
+ var/mob/living/carbon/monkey/bananas = new(drop_location(), TRUE, spammer)
+ if (!QDELETED(bananas))
+ visible_message("[src] expands!")
+ bananas.log_message("Spawned via [src] at [COORD(src)], Last attached mob: [key_name(spammer)].", INDIVIDUAL_ATTACK_LOG)
+ else if (!spammer) // Visible message in case there are no fingerprints
+ visible_message("[src] fails to expand!")
qdel(src)
/obj/item/reagent_containers/food/snacks/enchiladas
@@ -286,4 +289,4 @@
name = "double rat-kebab"
icon_state = "doubleratkebab"
tastes = list("rat meat" = 2, "metal" = 1)
- bonus_reagents = list("nutriment" = 6, "vitamin" = 2)
\ No newline at end of file
+ bonus_reagents = list("nutriment" = 6, "vitamin" = 2)
diff --git a/code/modules/mob/living/carbon/monkey/monkey.dm b/code/modules/mob/living/carbon/monkey/monkey.dm
index 77bae8b91d..7713be5e4b 100644
--- a/code/modules/mob/living/carbon/monkey/monkey.dm
+++ b/code/modules/mob/living/carbon/monkey/monkey.dm
@@ -16,7 +16,7 @@
-/mob/living/carbon/monkey/Initialize()
+/mob/living/carbon/monkey/Initialize(mapload, cubespawned=FALSE, mob/spawner)
verbs += /mob/living/proc/mob_sleep
verbs += /mob/living/proc/lay_down
@@ -31,9 +31,20 @@
. = ..()
+ if (cubespawned)
+ if (LAZYLEN(SSmobs.cubemonkeys) > SSmobs.cubemonkeycap)
+ if (spawner)
+ to_chat(spawner, "Bluespace harmonics prevent the spawning of more than [SSmobs.cubemonkeycap] monkeys on the station at one time!")
+ return INITIALIZE_HINT_QDEL
+ SSmobs.cubemonkeys += src
+
create_dna(src)
dna.initialize_dna(random_blood_type())
+/mob/living/carbon/monkey/Destroy()
+ SSmobs.cubemonkeys -= src
+ return ..()
+
/mob/living/carbon/monkey/create_internal_organs()
internal_organs += new /obj/item/organ/appendix
internal_organs += new /obj/item/organ/lungs
diff --git a/code/modules/research/xenobiology/xenobio_camera.dm b/code/modules/research/xenobiology/xenobio_camera.dm
index b4b626dab2..cfd32150fa 100644
--- a/code/modules/research/xenobiology/xenobio_camera.dm
+++ b/code/modules/research/xenobiology/xenobio_camera.dm
@@ -168,10 +168,11 @@
if(GLOB.cameranet.checkTurfVis(remote_eye.loc))
if(X.monkeys >= 1)
- var/mob/living/carbon/monkey/food = new /mob/living/carbon/monkey(remote_eye.loc)
- food.LAssailant = C
- X.monkeys --
- to_chat(owner, "[X] now has [X.monkeys] monkeys left.")
+ var/mob/living/carbon/monkey/food = new /mob/living/carbon/monkey(remote_eye.loc, TRUE, owner)
+ if (!QDELETED(food))
+ food.LAssailant = C
+ X.monkeys --
+ to_chat(owner, "[X] now has [X.monkeys] monkeys left.")
else
to_chat(owner, "Target is not near a camera. Cannot proceed.")