Merge pull request #7288 from unid15/BUGfix_he

Cockroaches no longer spam useless, dead eggs + tiny nerf
This commit is contained in:
clusterfack
2015-12-25 12:00:09 -06:00
4 changed files with 65 additions and 26 deletions

View File

@@ -157,3 +157,6 @@
#define hardcore_mode_on (hardcore_mode)//((ticker) && (ticker.hardcore_mode)) #define hardcore_mode_on (hardcore_mode)//((ticker) && (ticker.hardcore_mode))
#define eligible_for_hardcore_mode(M) (M.ckey && M.client) #define eligible_for_hardcore_mode(M) (M.ckey && M.client)
//Helper macro for eggs, called in process() of all fertilized eggs. If it returns 0, the egg will no longer be able to hatch
#define is_in_valid_nest(egg) (isturf(egg.loc))

View File

@@ -79,9 +79,9 @@
var/obj/item/weapon/reagent_containers/glass/G = O var/obj/item/weapon/reagent_containers/glass/G = O
var/transfered = udder.trans_id_to(G, "milk", rand(5,10)) var/transfered = udder.trans_id_to(G, "milk", rand(5,10))
if(G.reagents.total_volume >= G.volume) if(G.reagents.total_volume >= G.volume)
to_chat(user, "<span class='warning'>[O] is full.</span>") to_chat(user, "<span class='warning'>[O] is full.</span>")
if(!transfered) if(!transfered)
to_chat(user, "<span class='warning'>The udder is dry. Wait a bit longer...</span>") to_chat(user, "<span class='warning'>The udder is dry. Wait a bit longer...</span>")
else else
..() ..()
//cow //cow
@@ -121,9 +121,9 @@
var/obj/item/weapon/reagent_containers/glass/G = O var/obj/item/weapon/reagent_containers/glass/G = O
var/transfered = udder.trans_id_to(G, "milk", rand(5,10)) var/transfered = udder.trans_id_to(G, "milk", rand(5,10))
if(G.reagents.total_volume >= G.volume) if(G.reagents.total_volume >= G.volume)
to_chat(user, "<span class='warning'>[O] is full.</span>") to_chat(user, "<span class='warning'>[O] is full.</span>")
if(!transfered) if(!transfered)
to_chat(user, "<span class='warning'>The udder is dry. Wait a bit longer...</span>") to_chat(user, "<span class='warning'>The udder is dry. Wait a bit longer...</span>")
else else
..() ..()
@@ -146,7 +146,7 @@
"[src] looks at you pleadingly", "[src] looks at you pleadingly",
"[src] looks at you with a resigned expression.", "[src] looks at you with a resigned expression.",
"[src] seems resigned to its fate.") "[src] seems resigned to its fate.")
to_chat(M, pick(responses)) to_chat(M, pick(responses))
else else
..() ..()
@@ -234,9 +234,9 @@
user.drop_item(O) user.drop_item(O)
qdel(O) qdel(O)
eggsleft += rand(1, 4) eggsleft += rand(1, 4)
// to_chat(world, eggsleft) // to_chat(world, eggsleft)
else else
to_chat(user, "<span class='notice'>[name] doesn't seem hungry!</span>") to_chat(user, "<span class='notice'>[name] doesn't seem hungry!</span>")
else if(istype(O, /obj/item/weapon/dnainjector)) else if(istype(O, /obj/item/weapon/dnainjector))
var/obj/item/weapon/dnainjector/I = O var/obj/item/weapon/dnainjector/I = O
I.inject(src, user) I.inject(src, user)
@@ -259,7 +259,7 @@
/obj/item/weapon/reagent_containers/food/snacks/egg/var/amount_grown = 0 /obj/item/weapon/reagent_containers/food/snacks/egg/var/amount_grown = 0
/obj/item/weapon/reagent_containers/food/snacks/egg/process() /obj/item/weapon/reagent_containers/food/snacks/egg/process()
if(isturf(loc)) if(is_in_valid_nest(src)) //_macros.dm
amount_grown += rand(1,2) amount_grown += rand(1,2)
if(amount_grown >= 100) if(amount_grown >= 100)
hatch() hatch()

View File

@@ -18,9 +18,9 @@
maxHealth = 4 maxHealth = 4
health = 4 health = 4
response_help = "pets \the" response_help = "pets"
response_disarm = "pokes \the" response_disarm = "pokes"
response_harm = "stomps on \the" response_harm = "stomps on"
density = 0 density = 0
@@ -48,6 +48,11 @@
var/last_laid_eggs = 0 var/last_laid_eggs = 0
var/const/egg_laying_cooldown = 30 SECONDS
var/const/egg_laying_chance = 75
var/const/max_unhatchable_eggs_in_world = 30
/mob/living/simple_animal/cockroach/New() /mob/living/simple_animal/cockroach/New()
..() ..()
@@ -79,6 +84,8 @@
return ..() return ..()
/mob/living/simple_animal/cockroach/Crossed(mob/living/O) /mob/living/simple_animal/cockroach/Crossed(mob/living/O)
if(!istype(O)) return
if(src.size > O.size - 2) return //Human sized dudes can stomp default-sized cockroaches just fine. For bigger roaches you need bigger dudes if(src.size > O.size - 2) return //Human sized dudes can stomp default-sized cockroaches just fine. For bigger roaches you need bigger dudes
if(flying) return if(flying) return
if(O.a_intent == I_HELP) return //Must be on harm intent to stomp if(O.a_intent == I_HELP) return //Must be on harm intent to stomp
@@ -103,14 +110,14 @@
spawn() spawn()
turns_since_move -= rand(5,20) //Stay here for a while. turns_since_move is set to 0 immediately after this proc, so the spawn() is required. turns_since_move -= rand(5,20) //Stay here for a while. turns_since_move is set to 0 immediately after this proc, so the spawn() is required.
if((last_laid_eggs + 30 SECONDS < world.time)) //Always lay eggs under food if((last_laid_eggs + egg_laying_cooldown < world.time) && prob(egg_laying_chance)) //75% chance of laying eggs under food
sleep(rand(1,5) SECONDS) sleep(rand(1,5) SECONDS)
//And yeah, roaches can lay eggs on their own eggs. This is kinda intended //And yeah, roaches can lay eggs on their own eggs. This is kinda intended
lay_eggs()
if(F && F.reagents) if(F && F.reagents)
F.reagents.add_reagent("toxin", rand(0.2,0.6)) //Add some toxin to the food F.reagents.add_reagent("toxin", rand(0.2,0.6)) //Add some toxin to the food
lay_eggs()
return //Don't do anything after that return //Don't do anything after that
@@ -127,7 +134,7 @@
spawn() spawn()
turns_since_move -= rand(5,20) //Stay here for a while turns_since_move -= rand(5,20) //Stay here for a while
if((last_laid_eggs + 30 SECONDS < world.time) && prob(25)) //25% chance of laying eggs under the trash if((last_laid_eggs + egg_laying_cooldown < world.time) && prob(egg_laying_chance * 0.25)) //Chance of laying eggs under trash is 1/4 of normal
sleep(rand(1,5) SECONDS) sleep(rand(1,5) SECONDS)
lay_eggs() lay_eggs()
@@ -186,9 +193,9 @@
turns_per_move = 1 turns_per_move = 1
response_help = "attempts to pet \the" response_help = "attempts to pet"
response_disarm = "tries to catch \the" response_disarm = "tries to catch"
response_harm = "swats \the" response_harm = "swats"
layer = 4 layer = 4
@@ -211,16 +218,23 @@
if(anim) animate(src, pixel_y = pixel_y - 8, 5, 1, ELASTIC_EASING) if(anim) animate(src, pixel_y = pixel_y - 8, 5, 1, ELASTIC_EASING)
/mob/living/simple_animal/cockroach/proc/lay_eggs() /mob/living/simple_animal/cockroach/proc/lay_eggs()
if((cockroach_egg_amount >= max_unhatchable_eggs_in_world) && (animal_count[src.type] >= ANIMAL_CHILD_CAP)) //If roaches can't breed anymore (too many of them), and there are more than 30 eggs in the world, don't create eggs
last_laid_eggs = world.time
return
var/obj/item/weapon/reagent_containers/food/snacks/roach_eggs/E = new(get_turf(src)) var/obj/item/weapon/reagent_containers/food/snacks/roach_eggs/E = new(get_turf(src))
E.layer = src.layer //If we're hiding, the eggs are hidden too E.layer = src.layer //If we're hiding, the eggs are hidden too
E.pixel_x = src.pixel_x E.pixel_x = src.pixel_x
E.pixel_y = src.pixel_y E.pixel_y = src.pixel_y
if((animal_count[src.type] < ANIMAL_CHILD_CAP) && prob(75)) //Cap of 50 roaches. The chance of eggs actually being fertilized is very big, but in the end there won't be any roaches created over the cap of 50 (since the eggs check for the cap before hatching) if((animal_count[src.type] < ANIMAL_CHILD_CAP))
processing_objects.Add(E) last_laid_eggs = world.time //If the eggs can hatch, cooldown is 30 seconds
E.fertilize()
last_laid_eggs = world.time - (rand(1,15) SECONDS) else
last_laid_eggs = world.time - 60 SECONDS //If roaches can't breed, they lay eggs slower.
/mob/living/simple_animal/cockroach/attackby(obj/item/W, mob/user) /mob/living/simple_animal/cockroach/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/weapon/newspaper)) if(istype(W, /obj/item/weapon/newspaper))

View File

@@ -1,3 +1,5 @@
var/global/cockroach_egg_amount = 0
/obj/item/weapon/reagent_containers/food/snacks/roach_eggs /obj/item/weapon/reagent_containers/food/snacks/roach_eggs
name = "cockroach eggs" name = "cockroach eggs"
desc = "A bunch of tiny, brown eggs, each of them housing a bunch of cockroach larvae." desc = "A bunch of tiny, brown eggs, each of them housing a bunch of cockroach larvae."
@@ -16,20 +18,40 @@
icon_state = "roach_eggs[rand(1,3)]" icon_state = "roach_eggs[rand(1,3)]"
/obj/item/weapon/reagent_containers/food/snacks/roach_eggs/process() cockroach_egg_amount++
if(isturf(loc))
amount_grown += rand(1,3)
if(amount_grown >= 50) /obj/item/weapon/reagent_containers/food/snacks/roach_eggs/process()
if(is_in_valid_nest(src)) //_macros.dm
amount_grown += rand(1,2)
if(amount_grown >= 41)
if(animal_count[/mob/living/simple_animal/cockroach] < ANIMAL_CHILD_CAP) if(animal_count[/mob/living/simple_animal/cockroach] < ANIMAL_CHILD_CAP)
hatch() hatch()
else else
processing_objects.Remove(src) die()
else else
processing_objects.Remove(src) die()
/obj/item/weapon/reagent_containers/food/snacks/roach_eggs/Destroy()
if(amount_grown)
die()
cockroach_egg_amount--
return ..()
/obj/item/weapon/reagent_containers/food/snacks/roach_eggs/proc/hatch() /obj/item/weapon/reagent_containers/food/snacks/roach_eggs/proc/hatch()
new /mob/living/simple_animal/cockroach(get_turf(src)) new /mob/living/simple_animal/cockroach(get_turf(src))
processing_objects.Remove(src) processing_objects.Remove(src)
qdel(src) qdel(src)
/obj/item/weapon/reagent_containers/food/snacks/roach_eggs/proc/fertilize()
processing_objects.Add(src)
amount_grown = 1 //So there's a way of checking if the egg is fertilized without doing processing_objects.Find(src)
/obj/item/weapon/reagent_containers/food/snacks/roach_eggs/proc/die()
processing_objects.Remove(src)
amount_grown = 0