mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-07-22 10:00:28 +02:00
Compare commits
5 Commits
9f46182bb4
...
26ec61ee29
Author | SHA1 | Date | |
---|---|---|---|
26ec61ee29 | |||
a8ca00dc56 | |||
4c80a55c04 | |||
deee28fc59 | |||
ab44080ff8 |
74
api.lua
74
api.lua
@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20210722",
|
version = "20210920",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -160,6 +160,7 @@ local mob_class = {
|
|||||||
attack_players = true,
|
attack_players = true,
|
||||||
attack_npcs = true,
|
attack_npcs = true,
|
||||||
facing_fence = false,
|
facing_fence = false,
|
||||||
|
_breed_countdown = nil,
|
||||||
_cmi_is_mob = true
|
_cmi_is_mob = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,6 +723,13 @@ function mobs:effect(pos, amount, texture, min_size, max_size,
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Thanks Wuzzy for the following editable settings
|
||||||
|
|
||||||
|
local HORNY_TIME = 30
|
||||||
|
local HORNY_AGAIN_TIME = 60 * 5 -- 5 minutes
|
||||||
|
local CHILD_GROW_TIME = 60 * 20 -- 20 minutes
|
||||||
|
|
||||||
|
|
||||||
-- update nametag colour
|
-- update nametag colour
|
||||||
function mob_class:update_tag()
|
function mob_class:update_tag()
|
||||||
|
|
||||||
@ -740,9 +748,25 @@ function mob_class:update_tag()
|
|||||||
col = "#FF0000"
|
col = "#FF0000"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- build infotext
|
local text = ""
|
||||||
|
|
||||||
|
if self.horny == true then
|
||||||
|
|
||||||
|
text = "\nLoving: " .. (self.hornytimer - (HORNY_TIME + HORNY_AGAIN_TIME))
|
||||||
|
|
||||||
|
elseif self.child == true then
|
||||||
|
|
||||||
|
text = "\nGrowing: " .. (self.hornytimer - CHILD_GROW_TIME)
|
||||||
|
|
||||||
|
elseif self._breed_countdown then
|
||||||
|
|
||||||
|
text = "\nBreeding: " .. self._breed_countdown
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
self.infotext = "Health: " .. self.health .. " / " .. self.hp_max
|
self.infotext = "Health: " .. self.health .. " / " .. self.hp_max
|
||||||
.. "\n" .. "Owner: " .. self.owner
|
.. "\n" .. "Owner: " .. self.owner
|
||||||
|
.. text
|
||||||
|
|
||||||
-- set changes
|
-- set changes
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
@ -1358,10 +1382,6 @@ function mob_class:follow_holding(clicker)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Thanks Wuzzy for the following editable settings
|
|
||||||
local HORNY_TIME = 30
|
|
||||||
local HORNY_AGAIN_TIME = 60 * 5 -- 5 minutes
|
|
||||||
local CHILD_GROW_TIME = 60 * 20 -- 20 minutes
|
|
||||||
|
|
||||||
-- find two animals of same type and breed if nearby and horny
|
-- find two animals of same type and breed if nearby and horny
|
||||||
function mob_class:breed()
|
function mob_class:breed()
|
||||||
@ -1414,6 +1434,8 @@ function mob_class:breed()
|
|||||||
self.hornytimer = 0
|
self.hornytimer = 0
|
||||||
self.horny = false
|
self.horny = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:update_tag()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- find another same animal who is also horny and mate if nearby
|
-- find another same animal who is also horny and mate if nearby
|
||||||
@ -1469,6 +1491,8 @@ function mob_class:breed()
|
|||||||
self.hornytimer = HORNY_TIME + 1
|
self.hornytimer = HORNY_TIME + 1
|
||||||
ent.hornytimer = HORNY_TIME + 1
|
ent.hornytimer = HORNY_TIME + 1
|
||||||
|
|
||||||
|
self:update_tag()
|
||||||
|
|
||||||
-- have we reached active mob limit
|
-- have we reached active mob limit
|
||||||
if active_limit > 0 and active_mobs >= active_limit then
|
if active_limit > 0 and active_mobs >= active_limit then
|
||||||
minetest.chat_send_player(self.owner,
|
minetest.chat_send_player(self.owner,
|
||||||
@ -2703,6 +2727,12 @@ function mob_class:do_states(dtime)
|
|||||||
local obj = minetest.add_entity(p, self.arrow)
|
local obj = minetest.add_entity(p, self.arrow)
|
||||||
local ent = obj:get_luaentity()
|
local ent = obj:get_luaentity()
|
||||||
local amount = (vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) ^ 0.5
|
local amount = (vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) ^ 0.5
|
||||||
|
|
||||||
|
-- check for custom override for arrow
|
||||||
|
if self.arrow_override then
|
||||||
|
self.arrow_override(ent)
|
||||||
|
end
|
||||||
|
|
||||||
local v = ent.velocity or 1 -- or set to default
|
local v = ent.velocity or 1 -- or set to default
|
||||||
|
|
||||||
ent.switch = 1
|
ent.switch = 1
|
||||||
@ -3263,7 +3293,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
|||||||
self.object:set_texture_mod(self.texture_mods)
|
self.object:set_texture_mod(self.texture_mods)
|
||||||
|
|
||||||
-- set 5.x flag to remove monsters when map area unloaded
|
-- set 5.x flag to remove monsters when map area unloaded
|
||||||
if remove_far and self.type == "monster" then
|
if remove_far and self.type == "monster" and not self.tamed then
|
||||||
self.static_save = false
|
self.static_save = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3573,6 +3603,7 @@ minetest.register_entity(name, setmetatable({
|
|||||||
armor = def.armor,
|
armor = def.armor,
|
||||||
on_rightclick = def.on_rightclick,
|
on_rightclick = def.on_rightclick,
|
||||||
arrow = def.arrow,
|
arrow = def.arrow,
|
||||||
|
arrow_override = def.arrow_override,
|
||||||
shoot_interval = def.shoot_interval,
|
shoot_interval = def.shoot_interval,
|
||||||
sounds = def.sounds,
|
sounds = def.sounds,
|
||||||
animation = def.animation,
|
animation = def.animation,
|
||||||
@ -4443,7 +4474,7 @@ end
|
|||||||
function mobs:capture_mob(self, clicker, chance_hand, chance_net,
|
function mobs:capture_mob(self, clicker, chance_hand, chance_net,
|
||||||
chance_lasso, force_take, replacewith)
|
chance_lasso, force_take, replacewith)
|
||||||
|
|
||||||
if self.child
|
if not self --self.child
|
||||||
or not clicker:is_player()
|
or not clicker:is_player()
|
||||||
or not clicker:get_inventory() then
|
or not clicker:get_inventory() then
|
||||||
return false
|
return false
|
||||||
@ -4660,25 +4691,25 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
|
|
||||||
self.object:set_hp(self.health)
|
self.object:set_hp(self.health)
|
||||||
|
|
||||||
self:update_tag()
|
|
||||||
|
|
||||||
-- make children grow quicker
|
-- make children grow quicker
|
||||||
if self.child == true then
|
if self.child == true then
|
||||||
|
|
||||||
-- self.hornytimer = self.hornytimer + 20
|
-- self.hornytimer = self.hornytimer + 20
|
||||||
-- deduct 10% of the time to adulthood
|
-- deduct 10% of the time to adulthood
|
||||||
self.hornytimer = self.hornytimer + (
|
self.hornytimer = math.floor(self.hornytimer + (
|
||||||
(CHILD_GROW_TIME - self.hornytimer) * 0.1)
|
(CHILD_GROW_TIME - self.hornytimer) * 0.1))
|
||||||
--print ("====", self.hornytimer)
|
--print ("====", self.hornytimer)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- feed and tame
|
-- feed and tame
|
||||||
self.food = (self.food or 0) + 1
|
self.food = (self.food or 0) + 1
|
||||||
|
self._breed_countdown = feed_count - self.food
|
||||||
|
|
||||||
if self.food >= feed_count then
|
if self.food >= feed_count then
|
||||||
|
|
||||||
self.food = 0
|
self.food = 0
|
||||||
|
self._breed_countdown = nil
|
||||||
|
|
||||||
if breed and self.hornytimer == 0 then
|
if breed and self.hornytimer == 0 then
|
||||||
self.horny = true
|
self.horny = true
|
||||||
@ -4693,6 +4724,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.tamed = true
|
self.tamed = true
|
||||||
|
self.static_save = true
|
||||||
|
|
||||||
if not self.owner or self.owner == "" then
|
if not self.owner or self.owner == "" then
|
||||||
self.owner = clicker:get_player_name()
|
self.owner = clicker:get_player_name()
|
||||||
@ -4703,6 +4735,8 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
self:mob_sound(self.sounds.random)
|
self:mob_sound(self.sounds.random)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:update_tag()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -4732,6 +4766,22 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- if mob follows items and user right clicks while holding sneak it shows info
|
||||||
|
if self.follow then
|
||||||
|
|
||||||
|
if clicker:get_player_control().sneak then
|
||||||
|
|
||||||
|
if type(self.follow) == "string" then
|
||||||
|
self.follow = {self.follow}
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.chat_send_player(clicker:get_player_name(),
|
||||||
|
S("@1 follows:\n- @2",
|
||||||
|
self.name:split(":")[2],
|
||||||
|
table.concat(self.follow, "\n- ")))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
2
api.txt
2
api.txt
@ -123,6 +123,8 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
continue chasing.
|
continue chasing.
|
||||||
'arrow' holds the pre-defined arrow object to shoot when
|
'arrow' holds the pre-defined arrow object to shoot when
|
||||||
attacking.
|
attacking.
|
||||||
|
'arrow_override' function that allows tweaking of arrow entity from
|
||||||
|
inside mob definition (self) passed to function.
|
||||||
'dogshoot_switch' allows switching between attack types by using timers
|
'dogshoot_switch' allows switching between attack types by using timers
|
||||||
(1 for shoot, 2 for dogfight)
|
(1 for shoot, 2 for dogfight)
|
||||||
'dogshoot_count_max' contains how many seconds before switching from
|
'dogshoot_count_max' contains how many seconds before switching from
|
||||||
|
@ -23,6 +23,7 @@ Lucky Blocks: 9
|
|||||||
|
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
- 1.56 - Added arrow_override function to mob definition to tweak arrow entity settings, tamed monsters no longer despawn when outside loaded map area.
|
||||||
- 1.55 - Add 'peaceful_player' privelage and setting so mobs don't attack specific players (thanks sfence), add support for MarkBu's pathfinder mod, remove need for default mod
|
- 1.55 - Add 'peaceful_player' privelage and setting so mobs don't attack specific players (thanks sfence), add support for MarkBu's pathfinder mod, remove need for default mod
|
||||||
- 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks, on_flop added, air_damage added.
|
- 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks, on_flop added, air_damage added.
|
||||||
- 1.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded.
|
- 1.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded.
|
||||||
|
Reference in New Issue
Block a user