mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-29 14:01:07 +01:00
Update Mobs Redo
This commit is contained in:
parent
a818995d2a
commit
a89b9e9c45
4 changed files with 77 additions and 50 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
mobs = {}
|
mobs = {}
|
||||||
mobs.mod = "redo"
|
mobs.mod = "redo"
|
||||||
mobs.version = "20171018"
|
mobs.version = "20180104"
|
||||||
|
|
||||||
|
|
||||||
-- Intllib
|
-- Intllib
|
||||||
|
@ -61,6 +61,7 @@ local remove_far = minetest.settings:get_bool("remove_far_mobs")
|
||||||
local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0
|
local difficulty = tonumber(minetest.settings:get("mob_difficulty")) or 1.0
|
||||||
local show_health = false
|
local show_health = false
|
||||||
local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99)
|
local max_per_block = tonumber(minetest.settings:get("max_objects_per_block") or 99)
|
||||||
|
local mob_chance_multiplier = tonumber(minetest.settings:get("mob_chance_multiplier") or 1)
|
||||||
|
|
||||||
-- Peaceful mode message so players will know there are no monsters
|
-- Peaceful mode message so players will know there are no monsters
|
||||||
if peaceful_only then
|
if peaceful_only then
|
||||||
|
@ -88,6 +89,7 @@ local node_snowblock = "mcl_core:snowblock"
|
||||||
local node_snow = "mcl_core:snow"
|
local node_snow = "mcl_core:snow"
|
||||||
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dirt"
|
||||||
|
|
||||||
|
|
||||||
-- play sound
|
-- play sound
|
||||||
local mob_sound = function(self, sound)
|
local mob_sound = function(self, sound)
|
||||||
|
|
||||||
|
@ -425,7 +427,8 @@ local check_for_death = function(self, cause, cmi_cause)
|
||||||
self.nametag2 = self.nametag or ""
|
self.nametag2 = self.nametag or ""
|
||||||
end
|
end
|
||||||
|
|
||||||
if show_health then
|
if show_health
|
||||||
|
and (cmi_cause and cmi_cause.type == "punch") then
|
||||||
|
|
||||||
self.htimer = 2
|
self.htimer = 2
|
||||||
self.nametag = "♥ " .. self.health .. " / " .. self.hp_max
|
self.nametag = "♥ " .. self.health .. " / " .. self.hp_max
|
||||||
|
@ -828,6 +831,7 @@ local breed = function(self)
|
||||||
mesh = self.base_mesh,
|
mesh = self.base_mesh,
|
||||||
visual_size = self.base_size,
|
visual_size = self.base_size,
|
||||||
collisionbox = self.base_colbox,
|
collisionbox = self.base_colbox,
|
||||||
|
selectionbox = self.base_selbox,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- custom function when child grows up
|
-- custom function when child grows up
|
||||||
|
@ -948,6 +952,14 @@ local breed = function(self)
|
||||||
self.base_colbox[5] * .5,
|
self.base_colbox[5] * .5,
|
||||||
self.base_colbox[6] * .5,
|
self.base_colbox[6] * .5,
|
||||||
},
|
},
|
||||||
|
selectionbox = {
|
||||||
|
self.base_selbox[1] * .5,
|
||||||
|
self.base_selbox[2] * .5,
|
||||||
|
self.base_selbox[3] * .5,
|
||||||
|
self.base_selbox[4] * .5,
|
||||||
|
self.base_selbox[5] * .5,
|
||||||
|
self.base_selbox[6] * .5,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
-- tamed and owned by parents' owner
|
-- tamed and owned by parents' owner
|
||||||
ent2.child = true
|
ent2.child = true
|
||||||
|
@ -1078,10 +1090,10 @@ local smart_mobs = function(self, s, p, dist, dtime)
|
||||||
p1.y = floor(p1.y + 0.5)
|
p1.y = floor(p1.y + 0.5)
|
||||||
p1.z = floor(p1.z + 0.5)
|
p1.z = floor(p1.z + 0.5)
|
||||||
|
|
||||||
local dropheight = 10
|
local dropheight = 6
|
||||||
if self.fear_height ~= 0 then dropheight = self.fear_height end
|
if self.fear_height ~= 0 then dropheight = self.fear_height end
|
||||||
|
|
||||||
-- self.path.way = minetest.find_path(s, p1, 16, 2, 6, "Dijkstra") -- "A*_noprefetch"
|
-- self.path.way = minetest.find_path(s, p1, 16, 2, 6, "Dijkstra")
|
||||||
self.path.way = minetest.find_path(s, p1, 16, self.stepheight, dropheight, "A*_noprefetch")
|
self.path.way = minetest.find_path(s, p1, 16, self.stepheight, dropheight, "A*_noprefetch")
|
||||||
|
|
||||||
-- attempt to unstick mob that is "daydreaming"
|
-- attempt to unstick mob that is "daydreaming"
|
||||||
|
@ -2423,6 +2435,7 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
self.base_mesh = def.mesh
|
self.base_mesh = def.mesh
|
||||||
self.base_size = self.visual_size
|
self.base_size = self.visual_size
|
||||||
self.base_colbox = self.collisionbox
|
self.base_colbox = self.collisionbox
|
||||||
|
self.base_selbox = self.selectionbox
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set texture, model and size
|
-- set texture, model and size
|
||||||
|
@ -2430,6 +2443,7 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
local mesh = self.base_mesh
|
local mesh = self.base_mesh
|
||||||
local vis_size = self.base_size
|
local vis_size = self.base_size
|
||||||
local colbox = self.base_colbox
|
local colbox = self.base_colbox
|
||||||
|
local selbox = self.base_selbox
|
||||||
|
|
||||||
-- specific texture if gotten
|
-- specific texture if gotten
|
||||||
if self.gotten == true
|
if self.gotten == true
|
||||||
|
@ -2463,6 +2477,14 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
self.base_colbox[5] * .5,
|
self.base_colbox[5] * .5,
|
||||||
self.base_colbox[6] * .5
|
self.base_colbox[6] * .5
|
||||||
}
|
}
|
||||||
|
selbox = {
|
||||||
|
self.base_selbox[1] * .5,
|
||||||
|
self.base_selbox[2] * .5,
|
||||||
|
self.base_selbox[3] * .5,
|
||||||
|
self.base_selbox[4] * .5,
|
||||||
|
self.base_selbox[5] * .5,
|
||||||
|
self.base_selbox[6] * .5
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.health == 0 then
|
if self.health == 0 then
|
||||||
|
@ -2485,6 +2507,7 @@ local mob_activate = function(self, staticdata, def, dtime)
|
||||||
self.textures = textures
|
self.textures = textures
|
||||||
self.mesh = mesh
|
self.mesh = mesh
|
||||||
self.collisionbox = colbox
|
self.collisionbox = colbox
|
||||||
|
self.selectionbox = selbox
|
||||||
self.visual_size = vis_size
|
self.visual_size = vis_size
|
||||||
self.standing_in = ""
|
self.standing_in = ""
|
||||||
|
|
||||||
|
@ -2674,6 +2697,7 @@ minetest.register_entity(name, {
|
||||||
hp_max = max(1, (def.hp_max or 10) * difficulty),
|
hp_max = max(1, (def.hp_max or 10) * difficulty),
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = def.collisionbox,
|
collisionbox = def.collisionbox,
|
||||||
|
selectionbox = def.selectionbox or def.collisionbox,
|
||||||
visual = def.visual,
|
visual = def.visual,
|
||||||
visual_size = def.visual_size or {x = 1, y = 1},
|
visual_size = def.visual_size or {x = 1, y = 1},
|
||||||
mesh = def.mesh,
|
mesh = def.mesh,
|
||||||
|
@ -2832,13 +2856,14 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
nodenames = nodes,
|
nodenames = nodes,
|
||||||
neighbors = neighbors,
|
neighbors = neighbors,
|
||||||
interval = interval,
|
interval = interval,
|
||||||
chance = chance,
|
chance = max(1, (chance * mob_chance_multiplier)),
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
|
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
|
||||||
-- is mob actually registered?
|
-- is mob actually registered?
|
||||||
if not mobs.spawning_mobs[name] then
|
if not mobs.spawning_mobs[name]
|
||||||
|
or not minetest.registered_entities[name] then
|
||||||
--print ("--- mob doesn't exist", name)
|
--print ("--- mob doesn't exist", name)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -2907,23 +2932,22 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- are we spawning inside solid nodes?
|
-- do we have enough height clearance to spawn mob?
|
||||||
if minetest.registered_nodes[node_ok(pos).name].walkable == true then
|
local ent = minetest.registered_entities[name]
|
||||||
--print ("--- feet in block", name, node_ok(pos).name)
|
local height = max(0, math.ceil(ent.collisionbox[5] - ent.collisionbox[2]) - 1)
|
||||||
|
|
||||||
|
for n = 0, height do
|
||||||
|
|
||||||
|
local pos2 = {x = pos.x, y = pos.y + n, z = pos.z}
|
||||||
|
|
||||||
|
if minetest.registered_nodes[node_ok(pos2).name].walkable == true then
|
||||||
|
--print ("--- inside block", name, node_ok(pos2).name)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
pos.y = pos.y + 1
|
|
||||||
|
|
||||||
if minetest.registered_nodes[node_ok(pos).name].walkable == true then
|
|
||||||
--print ("--- head in block", name, node_ok(pos).name)
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- spawn mob half block higher than ground
|
-- spawn mob half block higher than ground
|
||||||
pos.y = pos.y - 0.5
|
pos.y = pos.y + 0.5
|
||||||
|
|
||||||
if minetest.registered_entities[name] then
|
|
||||||
|
|
||||||
local mob = minetest.add_entity(pos, name)
|
local mob = minetest.add_entity(pos, name)
|
||||||
--[[
|
--[[
|
||||||
|
@ -2937,10 +2961,6 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
||||||
|
|
||||||
on_spawn(ent, pos)
|
on_spawn(ent, pos)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
minetest.log("warning", string.format("[mobs] %s failed to spawn at %s",
|
|
||||||
name, minetest.pos_to_string(pos)))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
MOB API (18th October 2017)
|
MOB API
|
||||||
|
|
||||||
The mob api is a function that can be called on by other mods to add new animals or monsters into minetest.
|
The mob api is a function that can be called on by other mods to add new animals or monsters into minetest.
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ The mob api is a function that can be called on by other mods to add new animals
|
||||||
'mobname' can change specific mob chance rate (0 to disable) and spawn number e.g. mobs_animal:cow = 1000,5
|
'mobname' can change specific mob chance rate (0 to disable) and spawn number e.g. mobs_animal:cow = 1000,5
|
||||||
'mob_difficulty' sets difficulty level (health and hit damage multiplied by this number), defaults to 1.0.
|
'mob_difficulty' sets difficulty level (health and hit damage multiplied by this number), defaults to 1.0.
|
||||||
'mob_show_health' if false then punching mob will not show health status (true by default)
|
'mob_show_health' if false then punching mob will not show health status (true by default)
|
||||||
|
'mob_chance_multiplier' multiplies chance of all mobs spawning and can be set to 0.5 to have mobs spawn more or 2.0 to spawn less. e.g. 1 in 7000 * 0.5 = 1 in 3500 so better odds of spawning.
|
||||||
|
|
||||||
mobs:register_mob(name, definition)
|
mobs:register_mob(name, definition)
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ This functions registers a new mob as a Minetest entity.
|
||||||
'nametag' string containing name of mob to display above entity
|
'nametag' string containing name of mob to display above entity
|
||||||
'physical' same is in minetest.register_entity()
|
'physical' same is in minetest.register_entity()
|
||||||
'collisionbox' same is in minetest.register_entity()
|
'collisionbox' same is in minetest.register_entity()
|
||||||
|
'selectionbox' same is in minetest.register_entity()
|
||||||
'visual' same is in minetest.register_entity()
|
'visual' same is in minetest.register_entity()
|
||||||
'visual_size' same is in minetest.register_entity()
|
'visual_size' same is in minetest.register_entity()
|
||||||
'textures' same is in minetest.register_entity()
|
'textures' same is in minetest.register_entity()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
Mobs Redo API (last updated 18th Oct 2017)
|
Mobs Redo API
|
||||||
==========================================
|
=============
|
||||||
|
|
||||||
Welcome to the world of mobs in minetest and hopefully an easy guide to defining
|
Welcome to the world of mobs in minetest and hopefully an easy guide to defining
|
||||||
your own mobs and having them appear in your worlds.
|
your own mobs and having them appear in your worlds.
|
||||||
|
@ -140,8 +140,9 @@ functions needed for the mob to work properly which contains the following:
|
||||||
'wielditem' how it looks when player holds it in hand.
|
'wielditem' how it looks when player holds it in hand.
|
||||||
'mesh' uses separate object file to define mob.
|
'mesh' uses separate object file to define mob.
|
||||||
'visual_size' has the size of the mob, defaults to {x = 1, y = 1}
|
'visual_size' has the size of the mob, defaults to {x = 1, y = 1}
|
||||||
'collision_box' has the box in which mob can be interacted with e.g.
|
'collision_box' has the box in which mob can be interacted with the
|
||||||
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
world e.g. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
|
||||||
|
'selection_box' has the box in which player can interact with mob
|
||||||
'textures' holds a table list of textures to be used for mob, or you
|
'textures' holds a table list of textures to be used for mob, or you
|
||||||
could use multiple lists inside another table for random
|
could use multiple lists inside another table for random
|
||||||
selection e.g. { {"texture1.png"}, {"texture2.png"} }
|
selection e.g. { {"texture1.png"}, {"texture2.png"} }
|
||||||
|
@ -546,6 +547,10 @@ External Settings for "minetest.conf"
|
||||||
multiplied by this number), defaults to 1.0.
|
multiplied by this number), defaults to 1.0.
|
||||||
'mob_show_health' if false then punching mob will not show health status
|
'mob_show_health' if false then punching mob will not show health status
|
||||||
(true by default)
|
(true by default)
|
||||||
|
'mob_chance_multiplier' multiplies chance of all mobs spawning and can be set
|
||||||
|
to 0.5 to have mobs spawn more or 2.0 to spawn less.
|
||||||
|
e.g. 1 in 7000 * 0.5 = 1 in 3500 so better odds of
|
||||||
|
spawning.
|
||||||
|
|
||||||
Players can override the spawn chance for each mob registered by adding a line
|
Players can override the spawn chance for each mob registered by adding a line
|
||||||
to their minetest.conf file with a new value, the lower the value the more each
|
to their minetest.conf file with a new value, the lower the value the more each
|
||||||
|
|
|
@ -7,7 +7,7 @@ if minetest.get_modpath("lucky_block") then
|
||||||
{"dro", {"mobs:nametag"}, 1},
|
{"dro", {"mobs:nametag"}, 1},
|
||||||
{"dro", {"mobs:leather"}, 5},
|
{"dro", {"mobs:leather"}, 5},
|
||||||
{"dro", {"mobs:net"}, 1},
|
{"dro", {"mobs:net"}, 1},
|
||||||
{"dro", {"mobs:magic_lasso"}, 1},
|
{"dro", {"mobs:lasso"}, 1},
|
||||||
{"dro", {"mobs:shears"}, 1},
|
{"dro", {"mobs:shears"}, 1},
|
||||||
{"dro", {"mobs:protector"}, 1},
|
{"dro", {"mobs:protector"}, 1},
|
||||||
{"lig"},
|
{"lig"},
|
||||||
|
|
Loading…
Reference in a new issue