From 5c7ab30812c7e2cff729f04381cca5cbe26b765d Mon Sep 17 00:00:00 2001 From: sayterdarkwynd Date: Tue, 22 Oct 2024 14:55:45 -0400 Subject: [PATCH] farmbeasts now properly mate --- _FUversioning.config | 2 ++ scripts/actions/monsters/farmable.lua | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/_FUversioning.config b/_FUversioning.config index 055d9d4eab8..2db38d872ef 100644 --- a/_FUversioning.config +++ b/_FUversioning.config @@ -14,6 +14,8 @@ * the Armory can now sort by rarity * added additional notices and microtutorials to the Science Outpost * changed the beam-in point for the Science Outpost to the teleporter position instead of the lower Coffee Dock +* Troughs give a radiomessage when first picked up +* Farm animals now properly mate to produce offspring. Their hunger level directly influences this chance. ^cyan;6.4.6^reset; ------------------ diff --git a/scripts/actions/monsters/farmable.lua b/scripts/actions/monsters/farmable.lua index 70f67644e2d..c6b7c6e252d 100644 --- a/scripts/actions/monsters/farmable.lua +++ b/scripts/actions/monsters/farmable.lua @@ -186,7 +186,7 @@ end function removeFood(args) storage.food = math.max((storage.food or 100) - 0.277777778/config.getParameter('hungerTime',20),0) - storage.mateTimer = math.max((storage.mateTimer or 60) - 0.277777778/config.getParameter('mateTimer',60),0) + storage.mateTimer = math.max((storage.mateTimer or 120) - 5/config.getParameter('mateTimer',120),0) self.timerPoop = (self.timerPoop or 90) - 1 if self.timerPoop <= 0 and storage.food >= 50 then @@ -243,14 +243,16 @@ function displayHappiness() end end +-- Fed livestock breed more often. Breeding removes most of their current food. They must be ready to mate, 70% happy, and beat the difficulty class of the roll function checkMate() - self.randChance = math.random(100) * (1 - storage.food/1000) --current happiness level determines breeding chances + self.d20 = math.random(20) + (storage.happiness/10) --roll a d20. Happiness increases value of roll, increasing likelihood of success by up to 50% self.eggType = config.getParameter("eggType") - if self.eggType then - -- Fed livestock breed more often. Breeding removes most of their current food. - if (storage.mateTimer <= 0) and (self.randChance == 0) and (self.canMate) and (storage.happiness >= 70) then + --is egg, and the d20 roll exceeds or equals the difficulty (19) + if (self.eggType) and (self.d20 >= 19) then + --creature is full enough, the wait timer is up, and the creature is currently capable of mating (has eaten at least once) + if (storage.mateTimer <= 0) and (self.canMate) and (storage.food >= 45) then + storage.mateTimer = 120 - (storage.food/5) world.spawnItem( self.eggType, mcontroller.position(), 1 ) - storage.mateTimer = 60 - (storage.food/5) world.spawnProjectile("fu_egglay",mcontroller.position(), entity.id(), {0, 20}, false, configBombDrop) animator.playSound("harvest") storage.food = storage.food - 45