1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-07-23 18:40:25 +02:00

Compare commits

...

6 Commits

Author SHA1 Message Date
9f46182bb4 remove need for default mod 2021-07-22 09:48:56 +01:00
2535b5636e add support for MarkBu's pathfinder mod 2021-07-22 09:34:21 +01:00
2d014a75c4 tweak "stand" mobs velocity 2021-07-21 19:38:41 +01:00
db3831dccf update api.txt 2021-07-14 15:53:20 +01:00
29b2204f7c add 'mobs_spawn_monster_protected' switch (thanks 0siribix) 2021-07-14 15:43:02 +01:00
7fbfd9d59c fix "stand" mobs fall jitter 2021-07-13 16:56:53 +01:00
7 changed files with 34 additions and 18 deletions

28
api.lua
View File

@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20210614",
version = "20210722",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -56,6 +56,7 @@ local disable_blood = settings:get_bool("mobs_disable_blood")
local mobs_drop_items = settings:get_bool("mobs_drop_items") ~= false
local mobs_griefing = settings:get_bool("mobs_griefing") ~= false
local spawn_protected = settings:get_bool("mobs_spawn_protected") ~= false
local spawn_monster_protected = settings:get_bool("mobs_spawn_monster_protected") ~= false
local remove_far = settings:get_bool("remove_far_mobs") ~= false
local mob_area_spawn = settings:get_bool("mob_area_spawn")
local difficulty = tonumber(settings:get("mob_difficulty")) or 1.0
@ -82,7 +83,7 @@ local aoc_range = tonumber(settings:get("active_block_range")) * 16
-- pathfinding settings
local enable_pathfinding = true
local stuck_timeout = 3 -- how long before stuck mod starts searching
local stuck_path_timeout = 10 -- how long will mob follow path before giving up
local stuck_path_timeout = 5 -- how long will mob follow path before giving up
-- default nodes
local node_fire = "fire:basic_flame"
@ -273,7 +274,9 @@ function mob_class:set_velocity(v)
-- halt mob if it has been ordered to stay
if self.order == "stand" then
self.object:set_velocity({x = 0, y = 0, z = 0})
local vel = self.object:get_velocity() or {y = 0}
self.object:set_velocity({x = 0, y = vel.y, z = 0})
return
end
@ -1651,6 +1654,8 @@ local can_dig_drop = function(pos)
return false
end
local pathfinder_mod = minetest.get_modpath("pathfinder")
-- path finding and smart mob routine by rnd,
-- line_of_sight and other edits by Elkien3
function mob_class:smart_mobs(s, p, dist, dtime)
@ -1779,13 +1784,18 @@ function mob_class:smart_mobs(s, p, dist, dtime)
jumpheight = 1
end
self.path.way = minetest.find_path(s, p1, 16, jumpheight,
dropheight, "Dijkstra")
if pathfinder_mod then
self.path.way = pathfinder.find_path(s, p1, self, dtime)
else
self.path.way = minetest.find_path(s, p1, 16, jumpheight,
dropheight, "Dijkstra")
end
--[[
-- show path using particles
if self.path.way and #self.path.way > 0 then
print("-- path length:" .. tonumber(#self.path.way))
for _,pos in pairs(self.path.way) do
minetest.add_particle({
pos = pos,
@ -3956,8 +3966,10 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light, inter
return
end
-- mobs cannot spawn in protected areas when enabled
if not spawn_protected
-- check if mob can spawn inside protected areas
if (spawn_protected == false
or (spawn_monster_protected == false
and minetest.registered_entities[name].type == "monster"))
and minetest.is_protected(pos, "") then
--print("--- inside protected area", name)
return

View File

@ -699,6 +699,8 @@ External Settings for "minetest.conf"
is false)
'mobs_spawn_protected' if set to false then mobs will not spawn in protected
areas (default is true)
'mobs_spawn_monster_protected' if set to false then monsters will not spawn in
protected areas (default is true)
'remove_far_mobs' if true then untamed mobs that are outside players
visual range will be removed (default is true)
'mobname' can change specific mob chance rate (0 to disable) and

View File

@ -10,7 +10,6 @@ minetest.register_craftitem("mobs:nametag", {
if minetest.get_modpath("dye") and minetest.get_modpath("farming") then
minetest.register_craft({
-- type = "shapeless",
output = "mobs:nametag",
recipe = {{"default:paper", "dye:black", "farming:string"}}
})
@ -149,7 +148,7 @@ minetest.register_craft({
-- make sure we can register fences
if default.register_fence then
if minetest.get_modpath("default") and default.register_fence then
-- mob fence (looks like normal fence but collision is 2 high)
default.register_fence("mobs:fence_wood", {
@ -165,6 +164,7 @@ default.register_fence("mobs:fence_wood", {
}
}
})
end
-- mob fence top (has enlarged collisionbox to stop mobs getting over)
minetest.register_node("mobs:fence_top", {
@ -197,8 +197,6 @@ minetest.register_craft({
}
})
end
-- items that can be used as fuel
minetest.register_craft({
@ -361,9 +359,9 @@ minetest.register_node("mobs:meatblock", {
tiles = {"mobs_meat_top.png", "mobs_meat_bottom.png", "mobs_meat_side.png"},
paramtype2 = "facedir",
groups = {choppy = 1, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_leaves_defaults(),
sounds = default and default.node_sound_leaves_defaults(),
on_place = minetest.rotate_node,
on_use = minetest.item_eat(20),
on_use = minetest.item_eat(20)
})
minetest.register_craft({

View File

@ -1,4 +1,4 @@
default
default?
tnt?
dye?
farming?
@ -7,3 +7,4 @@ intllib?
lucky_block?
cmi?
toolranks?
pathfinder?

View File

@ -1,4 +1,4 @@
name = mobs
depends = default
optional_depends = tnt, dye, farming, invisibility, intllib, lucky_block, cmi, toolranks
depends =
optional_depends = default, tnt, dye, farming, invisibility, intllib, lucky_block, cmi, toolranks, pathfinder
description = Adds a mob api for mods to add animals or monsters etc.

View File

@ -23,7 +23,7 @@ Lucky Blocks: 9
Changelog:
- 1.55 - Add 'peaceful_player' privelage and setting so mobs don't attack specific players (thanks sfence)
- 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.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded.
- 1.52 - Added 'mob_active_limit' in settings to set number of mobs in game,

View File

@ -13,6 +13,9 @@ mobs_griefing (Griefing Mobs) bool true
# If false then Mobs no longer spawn inside player protected areas
mobs_spawn_protected (Spawn Mobs in protected areas) bool true
# If false then Monsters no longer spawn inside player protected areas
mobs_spawn_monster_protected (Spawn Monsters in protected areas) bool true
# If true Mobs will be removed once a map chunk is out of view
remove_far_mobs (Remove far Mobs) bool true