Mobs: Separate taming level and horny level
This commit is contained in:
parent
9a0dbcb04d
commit
ff1be9a95b
@ -233,9 +233,10 @@ These fields are available:
|
|||||||
### Status
|
### Status
|
||||||
|
|
||||||
* `_tamed`: `true` if mob is tame
|
* `_tamed`: `true` if mob is tame
|
||||||
* `_tb_level`: tame/breed level. Starts at 0 and increases for any food given, used to trigger taming/breeding
|
* `_tame_level`: tame level. Starts at 0 and increases for any food given, used to trigger taming
|
||||||
|
* `_horny_level`: 'horny' level. Starts at 0 and increases for any food given to an adult, used to trigger horny mode
|
||||||
* `_child`: `true` if mob is a child
|
* `_child`: `true` if mob is a child
|
||||||
* `_horny`: `true` if mob is “horny”. If another horny mob is nearby, they will mate and spawn a child
|
* `_horny`: `true` if mob is “horny”. If another horny mob is nearby, they will mate and spawn a child soon
|
||||||
* `_pregnant`: `true` if mob is pregnant and about to spawn a child
|
* `_pregnant`: `true` if mob is pregnant and about to spawn a child
|
||||||
|
|
||||||
### Damage
|
### Damage
|
||||||
|
@ -2,7 +2,8 @@ local DEFAULT_ADD_CHILD_GROW_TIMER = 20
|
|||||||
|
|
||||||
-- Entity variables to persist:
|
-- Entity variables to persist:
|
||||||
rp_mobs.add_persisted_entity_vars({
|
rp_mobs.add_persisted_entity_vars({
|
||||||
"_tb_level", -- tame/breed level. Increases when a mob was fed; used to trigger taming and breeding
|
"_tame_level", -- Tame level. Increases when a mob was fed; used to trigger taming
|
||||||
|
"_horny_level", -- Horny level. Increases when an adult mob was fed; used to trigger breeding
|
||||||
"_tamed", -- true if mob is tame
|
"_tamed", -- true if mob is tame
|
||||||
})
|
})
|
||||||
--[[ NOT persisted variables:
|
--[[ NOT persisted variables:
|
||||||
@ -10,8 +11,12 @@ rp_mobs.add_persisted_entity_vars({
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
local feed_handling = function(mob, feeder_name, food_points, food_till_tamed, can_breed, add_child_grow_timer) -- Check if a mob is fed
|
local feed_handling = function(mob, feeder_name, food_points, food_till_tamed, food_till_horny, add_child_grow_timer) -- Check if a mob is fed
|
||||||
mob._tb_level = (mob._tb_level or 0) + food_points
|
-- Increase tame and horny level
|
||||||
|
mob._tame_level = (mob._tame_level or 0) + food_points
|
||||||
|
if not mob._child and not mob._horny then
|
||||||
|
mob._horny_level = (mob._horny_level or 0) + food_points
|
||||||
|
end
|
||||||
|
|
||||||
-- Remember name of feeder for achievements
|
-- Remember name of feeder for achievements
|
||||||
if feeder_name then
|
if feeder_name then
|
||||||
@ -25,12 +30,8 @@ local feed_handling = function(mob, feeder_name, food_points, food_till_tamed, c
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Tame mob if threshold was reached
|
-- Tame mob if threshold was reached
|
||||||
if food_till_tamed and mob._tb_level >= food_till_tamed then
|
if food_till_tamed and mob._tame_level >= food_till_tamed then
|
||||||
mob._tb_level = 0
|
mob._tame_level = 0
|
||||||
|
|
||||||
if can_breed and mob._horny_timer == 0 then
|
|
||||||
rp_mobs.make_horny(mob, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
if (not mob._tamed) and feeder_name ~= nil then
|
if (not mob._tamed) and feeder_name ~= nil then
|
||||||
mob._tamed = true
|
mob._tamed = true
|
||||||
@ -41,18 +42,25 @@ local feed_handling = function(mob, feeder_name, food_points, food_till_tamed, c
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Make mob horny if threshold was reached
|
||||||
|
if food_till_horny and mob._horny_level >= food_till_horny and mob._horny_timer == 0 and not mob._child and not mob._horny then
|
||||||
|
mob._horny_level = 0
|
||||||
|
|
||||||
|
rp_mobs.make_horny(mob, true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Let a player feed a mob with their wielded item and optionally tame it and make it horny
|
-- Let a player feed a mob with their wielded item and optionally tame it and make it horny
|
||||||
-- * mob: The mob that is fed
|
-- * mob: The mob that is fed
|
||||||
-- * feeder: Player who feeds the mob
|
-- * feeder: Player who feeds the mob
|
||||||
-- * allowed_foods: List of allowed food items
|
-- * allowed_foods: List of allowed food items
|
||||||
-- * food_till_tamed: How many food points the mob needs until it is tamed
|
-- * food_till_tamed: How many food points the mob needs until it is tamed (nil = no taming)
|
||||||
-- * can_breed: true if feeding may cause this mob to become horny, false otherwise
|
-- * food_till_horny: How many food points the mob needs until it becomes horny (nil = no horny)
|
||||||
-- * add_child_growth_timer: (optional) By how many seconds the child growth timer is increased (default: 20)
|
-- * add_child_growth_timer: (optional) By how many seconds the child growth timer is increased (default: 20)
|
||||||
-- * effect: (optional) true to show particle effects, false otherwise (default: true)
|
-- * effect: (optional) true to show particle effects, false otherwise (default: true)
|
||||||
-- * eat_sound: (optional) Name of sound to play for the mob eating (default: "mobs_eat")
|
-- * eat_sound: (optional) Name of sound to play for the mob eating (default: "mobs_eat")
|
||||||
rp_mobs.feed_tame_breed = function(mob, feeder, allowed_foods, food_till_tamed, can_breed, add_child_grow_timer, effect, eat_sound)
|
rp_mobs.feed_tame_breed = function(mob, feeder, allowed_foods, food_till_tamed, food_till_horny, add_child_grow_timer, effect, eat_sound)
|
||||||
if not rp_mobs.is_alive(mob) then
|
if not rp_mobs.is_alive(mob) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -126,7 +134,7 @@ rp_mobs.feed_tame_breed = function(mob, feeder, allowed_foods, food_till_tamed,
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
feed_handling(mob, feeder_name, food_points, food_till_tamed, can_breed, add_child_grow_timer)
|
feed_handling(mob, feeder_name, food_points, food_till_tamed, food_till_horny, add_child_grow_timer)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
|
@ -95,7 +95,7 @@ rp_mobs.register_mob("rp_mobs_mobs:boar", {
|
|||||||
rp_mobs.handle_breeding(self, dtime)
|
rp_mobs.handle_breeding(self, dtime)
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
rp_mobs.feed_tame_breed(self, clicker, FOOD, 8, true)
|
rp_mobs.feed_tame_breed(self, clicker, FOOD, 8, 8)
|
||||||
rp_mobs.call_on_capture(self, clicker)
|
rp_mobs.call_on_capture(self, clicker)
|
||||||
end,
|
end,
|
||||||
_on_capture = function(self, capturer)
|
_on_capture = function(self, capturer)
|
||||||
|
@ -184,7 +184,7 @@ rp_mobs.register_mob("rp_mobs_mobs:sheep", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Are we feeding?
|
-- Are we feeding?
|
||||||
if rp_mobs.feed_tame_breed(self, clicker, FOOD, 8, true) then
|
if rp_mobs.feed_tame_breed(self, clicker, FOOD, 8, 8) then
|
||||||
-- Update wool status if shorn
|
-- Update wool status if shorn
|
||||||
if not self._custom_state.shorn then
|
if not self._custom_state.shorn then
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
|
@ -88,7 +88,7 @@ rp_mobs.register_mob("rp_mobs_mobs:skunk", {
|
|||||||
rp_mobs.handle_breeding(self, dtime)
|
rp_mobs.handle_breeding(self, dtime)
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
rp_mobs.feed_tame_breed(self, clicker, FOOD, 6, true)
|
rp_mobs.feed_tame_breed(self, clicker, FOOD, 6, 6)
|
||||||
rp_mobs.call_on_capture(self, clicker)
|
rp_mobs.call_on_capture(self, clicker)
|
||||||
end,
|
end,
|
||||||
_on_capture = function(self, capturer)
|
_on_capture = function(self, capturer)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user