Changed recovery time from breeding and growing up times

This commit is contained in:
tenplus1 2015-03-24 12:12:53 +00:00
parent 14b819f630
commit 43a53e18c1
5 changed files with 73 additions and 64 deletions

View File

@ -29,6 +29,7 @@ This mod contains the following additions:
Changelog:
beta- Npc mob added, kills monsters, attacks player when punched, right click with food to heal or gold lump for drop
1.06- Changed recovery times after breeding, and time taken to grow up (can be sped up by feeding baby animal)
1.05- Added ExeterDad's bunny's which can be picked up and tamed with 4 carrots from farming redo or farming_plus, also shears added to get wool from sheep and lastly Jordach/BSD's kitten
1.04- Added mating for sheep, cows and hogs... feed animals to make horny and hope for a baby which is half size, will grow up quick though :)
1.03- Added mob drop/replace feature so that chickens can drop eggs, cow/sheep can eat grass/wheat etc.

127
api.lua
View File

@ -1,4 +1,4 @@
-- Mobs Api (15th March 2015)
-- Mobs Api (24th March 2015)
mobs = {}
mobs.mod = "redo"
@ -340,75 +340,22 @@ function mobs:register_mob(name, def)
end
end
if self.following and self.following:is_player() and self.following:get_wielded_item():get_name() ~= self.follow then
self.following = nil
self.v_start = false
end
if self.following then
local s = self.object:getpos()
local p
if self.following.is_player and self.following:is_player() then
p = self.following:getpos()
elseif self.following.object then
p = self.following.object:getpos()
end
if p then
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
if dist > self.view_range then
self.following = nil
self.v_start = false
else
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
if p.x > s.x then
yaw = yaw+math.pi
end
self.object:setyaw(yaw)
if dist > 2 then
if not self.v_start then
self.v_start = true
self.set_velocity(self, self.walk_velocity)
else
if self.jump and self.get_velocity(self) <= 1.5 and self.object:getvelocity().y == 0 then
local v = self.object:getvelocity()
v.y = 6
self.object:setvelocity(v)
end
self.set_velocity(self, self.walk_velocity)
end
self:set_animation("walk")
else
self.v_start = false
self.set_velocity(self, 0)
self:set_animation("stand")
end
return
end
end
end
-- horny animal can mate for 40 seconds, afterwards horny animal cannot mate again for 60 seconds
if self.horny == true and self.hornytimer < 100 and self.child == false then
-- horny animal can mate for 40 seconds, afterwards horny animal cannot mate again for 200 seconds
if self.horny == true and self.hornytimer < 240 and self.child == false then
self.hornytimer = self.hornytimer + 1
if self.hornytimer <= 40 then
effect(self.object:getpos(), 4, "heart.png")
end
if self.hornytimer >= 100 then
if self.hornytimer >= 240 then
self.hornytimer = 0
self.horny = false
end
end
-- if animal is child take 120 seconds before growing into adult
-- if animal is child take 240 seconds before growing into adult
if self.child == true then
self.hornytimer = self.hornytimer + 1
if self.hornytimer > 120 then
if self.hornytimer > 240 then
self.child = false
self.hornytimer = 0
self.object:set_properties({
@ -462,6 +409,59 @@ function mobs:register_mob(name, def)
end
end
if self.following and self.following:is_player() and self.following:get_wielded_item():get_name() ~= self.follow then
self.following = nil
self.v_start = false
end
if self.following then
local s = self.object:getpos()
local p
if self.following.is_player and self.following:is_player() then
p = self.following:getpos()
elseif self.following.object then
p = self.following.object:getpos()
end
if p then
local dist = ((p.x-s.x)^2 + (p.y-s.y)^2 + (p.z-s.z)^2)^0.5
if dist > self.view_range then
self.following = nil
self.v_start = false
else
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
if p.x > s.x then
yaw = yaw+math.pi
end
self.object:setyaw(yaw)
if dist > 2 then
if not self.v_start then
self.v_start = true
self.set_velocity(self, self.walk_velocity)
else
if self.jump and self.get_velocity(self) <= 0.5 and self.object:getvelocity().y == 0 then -- 0.5 was 1.5
local v = self.object:getvelocity()
v.y = 6
self.object:setvelocity(v)
end
self.set_velocity(self, self.walk_velocity)
end
self:set_animation("walk")
else
self.v_start = false
self.set_velocity(self, 0)
self:set_animation("stand")
end
return
end
end
end
if self.state == "stand" then
-- randomly turn
if math.random(1, 4) == 1 then
@ -701,14 +701,13 @@ function mobs:register_mob(name, def)
end
end
end
-- quick fix for dog so it doesn't revert back to wolf
if self.type == "monster" and self.tamed == true then
self.type = "npc"
end
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
self.object:remove()
end
-- Internal check to see if player damage is still enabled
damage_enabled = minetest.setting_getbool("enable_damage")
end,
get_staticdata = function(self)

View File

@ -67,6 +67,9 @@ mobs:register_mob("mobs:chicken", {
clicker:set_wielded_item(tool)
end
self.food = (self.food or 0) + 1
if self.child == true then
self.hornytimer = self.hornytimer + 10
end
if self.food >= 8 then
self.food = 0
if self.child == false then self.horny = true end

View File

@ -77,6 +77,9 @@ mobs:register_mob("mobs:cow", {
clicker:set_wielded_item(tool)
end
self.food = (self.food or 0) + 1
if self.child == true then
self.hornytimer = self.hornytimer + 10
end
if self.food >= 8 then
self.food = 0
if self.child == false then self.horny = true end

View File

@ -62,6 +62,9 @@ mobs:register_mob("mobs:sheep", {
clicker:set_wielded_item(item)
end
self.food = (self.food or 0) + 1
if self.child == true then
self.hornytimer = self.hornytimer + 10
end
if self.food >= 8 then
self.food = 0
if self.child == false then self.horny = true end