Skip to content

Commit

Permalink
farmbeasts now properly mate
Browse files Browse the repository at this point in the history
  • Loading branch information
sayterdarkwynd committed Oct 22, 2024
1 parent 7e0920e commit 5c7ab30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions _FUversioning.config
Original file line number Diff line number Diff line change
Expand Up @@ -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;
------------------
Expand Down
14 changes: 8 additions & 6 deletions scripts/actions/monsters/farmable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5c7ab30

Please sign in to comment.