mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-07-17 07:40:23 +02:00
Compare commits
10 Commits
7179dc86e6
...
b9ad166821
Author | SHA1 | Date | |
---|---|---|---|
b9ad166821 | |||
b588452dea | |||
d6bd538a35 | |||
2ca012e30b | |||
c7838e5517 | |||
38232d5ef4 | |||
26cc611ad4 | |||
1a85cf7e2c | |||
06dbdb1c44 | |||
f040ee5bc7 |
122
api.lua
122
api.lua
@ -6,9 +6,9 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20190520",
|
version = "20191116",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- creative check
|
-- creative check
|
||||||
@ -79,11 +79,11 @@ local node_snow = "default:snow"
|
|||||||
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "default:dirt"
|
mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "default:dirt"
|
||||||
|
|
||||||
local mob_class = {
|
local mob_class = {
|
||||||
stepheight = 1.1, -- was 0.6
|
stepheight = 1.1,
|
||||||
fly_in = "air",
|
fly_in = "air",
|
||||||
owner = "",
|
owner = "",
|
||||||
order = "",
|
order = "",
|
||||||
jump_height = 4, -- was 6
|
jump_height = 4,
|
||||||
lifetimer = 180, -- 3 minutes
|
lifetimer = 180, -- 3 minutes
|
||||||
physical = true,
|
physical = true,
|
||||||
collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
|
collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
|
||||||
@ -142,8 +142,9 @@ local mob_class = {
|
|||||||
attack_players = true,
|
attack_players = true,
|
||||||
attack_npcs = true,
|
attack_npcs = true,
|
||||||
facing_fence = false,
|
facing_fence = false,
|
||||||
_cmi_is_mob = true,
|
_cmi_is_mob = true
|
||||||
}
|
}
|
||||||
|
|
||||||
local mob_class_meta = {__index = mob_class}
|
local mob_class_meta = {__index = mob_class}
|
||||||
|
|
||||||
-- play sound
|
-- play sound
|
||||||
@ -232,7 +233,7 @@ function mob_class:set_velocity(v)
|
|||||||
self.object:set_velocity({
|
self.object:set_velocity({
|
||||||
x = (sin(yaw) * -v) + c_x,
|
x = (sin(yaw) * -v) + c_x,
|
||||||
y = self.object:get_velocity().y,
|
y = self.object:get_velocity().y,
|
||||||
z = (cos(yaw) * v) + c_y,
|
z = (cos(yaw) * v) + c_y
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -285,7 +286,7 @@ function mob_class:set_animation(anim, force)
|
|||||||
|
|
||||||
self.animation.current = self.animation.current or ""
|
self.animation.current = self.animation.current or ""
|
||||||
|
|
||||||
-- only set different animation for attacks when using same set
|
-- only use different animation for attacks when using same set
|
||||||
if force ~= true and anim ~= "punch" and anim ~= "shoot"
|
if force ~= true and anim ~= "punch" and anim ~= "shoot"
|
||||||
and string.find(self.animation.current, anim) then
|
and string.find(self.animation.current, anim) then
|
||||||
return
|
return
|
||||||
@ -393,7 +394,6 @@ local line_of_sight = function(self, pos1, pos2, stepsize)
|
|||||||
|
|
||||||
-- New Nodename found
|
-- New Nodename found
|
||||||
nn = minetest.get_node(pos).name
|
nn = minetest.get_node(pos).name
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@ -474,7 +474,7 @@ local ray_line_of_sight = function(self, pos1, pos2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- detect if using minetest 5.0 by searching for permafrost node
|
-- detect if using minetest 5.0 by searching for permafrost node
|
||||||
local is_50 = minetest.registered_nodes["default:permafrost"]
|
local is_50 = nil -- minetest.registered_nodes["default:permafrost"]
|
||||||
|
|
||||||
function mob_class:line_of_sight(pos1, pos2, stepsize)
|
function mob_class:line_of_sight(pos1, pos2, stepsize)
|
||||||
|
|
||||||
@ -528,7 +528,7 @@ function mob_class:flight_check()
|
|||||||
|
|
||||||
local def = minetest.registered_nodes[self.standing_in]
|
local def = minetest.registered_nodes[self.standing_in]
|
||||||
|
|
||||||
if not def then return false end -- nil check
|
if not def then return false end
|
||||||
|
|
||||||
if type(self.fly_in) == "string"
|
if type(self.fly_in) == "string"
|
||||||
and self.standing_in == self.fly_in then
|
and self.standing_in == self.fly_in then
|
||||||
@ -586,11 +586,7 @@ function mob_class:do_stay_near()
|
|||||||
|
|
||||||
local target = nearby_nodes[math.random(1, #nearby_nodes)]
|
local target = nearby_nodes[math.random(1, #nearby_nodes)]
|
||||||
local direction = vector.direction(pos, target)
|
local direction = vector.direction(pos, target)
|
||||||
|
local vec = {x = target.x - pos.x, z = target.z - pos.z}
|
||||||
local vec = {
|
|
||||||
x = target.x - pos.x,
|
|
||||||
z = target.z - pos.z
|
|
||||||
}
|
|
||||||
|
|
||||||
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
|
yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate
|
||||||
|
|
||||||
@ -631,7 +627,7 @@ local effect = function(pos, amount, texture, min_size, max_size, radius, gravit
|
|||||||
minsize = min_size,
|
minsize = min_size,
|
||||||
maxsize = max_size,
|
maxsize = max_size,
|
||||||
texture = texture,
|
texture = texture,
|
||||||
glow = glow,
|
glow = glow
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -664,6 +660,11 @@ end
|
|||||||
-- drop items
|
-- drop items
|
||||||
function mob_class:item_drop()
|
function mob_class:item_drop()
|
||||||
|
|
||||||
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
|
-- check for drops function
|
||||||
|
self.drops = type(self.drops) == "function" and self.drops(pos) or self.drops
|
||||||
|
|
||||||
-- check for nil or no drops
|
-- check for nil or no drops
|
||||||
if not self.drops or #self.drops == 0 then
|
if not self.drops or #self.drops == 0 then
|
||||||
return
|
return
|
||||||
@ -680,7 +681,6 @@ function mob_class:item_drop()
|
|||||||
and self.cause_of_death.puncher:is_player() or nil
|
and self.cause_of_death.puncher:is_player() or nil
|
||||||
|
|
||||||
local obj, item, num
|
local obj, item, num
|
||||||
local pos = self.object:get_pos()
|
|
||||||
|
|
||||||
for n = 1, #self.drops do
|
for n = 1, #self.drops do
|
||||||
|
|
||||||
@ -713,7 +713,7 @@ function mob_class:item_drop()
|
|||||||
obj:set_velocity({
|
obj:set_velocity({
|
||||||
x = random(-10, 10) / 9,
|
x = random(-10, 10) / 9,
|
||||||
y = 6,
|
y = 6,
|
||||||
z = random(-10, 10) / 9,
|
z = random(-10, 10) / 9
|
||||||
})
|
})
|
||||||
|
|
||||||
elseif obj then
|
elseif obj then
|
||||||
@ -842,8 +842,7 @@ function mob_class:is_at_cliff()
|
|||||||
|
|
||||||
if minetest.line_of_sight(
|
if minetest.line_of_sight(
|
||||||
{x = pos.x + dir_x, y = ypos, z = pos.z + dir_z},
|
{x = pos.x + dir_x, y = ypos, z = pos.z + dir_z},
|
||||||
{x = pos.x + dir_x, y = ypos - self.fear_height, z = pos.z + dir_z}
|
{x = pos.x + dir_x, y = ypos - self.fear_height, z = pos.z + dir_z}, 1) then
|
||||||
, 1) then
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -1044,9 +1043,9 @@ function mob_class:do_jump()
|
|||||||
if self.object:get_luaentity() then
|
if self.object:get_luaentity() then
|
||||||
|
|
||||||
self.object:set_acceleration({
|
self.object:set_acceleration({
|
||||||
x = v.x * 2,--1.5,
|
x = v.x * 2,
|
||||||
y = 0,
|
y = 0,
|
||||||
z = v.z * 2,--1.5
|
z = v.z * 2
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end, self, v)
|
end, self, v)
|
||||||
@ -1157,7 +1156,7 @@ function mob_class:breed()
|
|||||||
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,
|
selectionbox = self.base_selbox
|
||||||
})
|
})
|
||||||
|
|
||||||
-- custom function when child grows up
|
-- custom function when child grows up
|
||||||
@ -1272,7 +1271,7 @@ function mob_class:breed()
|
|||||||
textures = textures,
|
textures = textures,
|
||||||
visual_size = {
|
visual_size = {
|
||||||
x = self.base_size.x * .5,
|
x = self.base_size.x * .5,
|
||||||
y = self.base_size.y * .5,
|
y = self.base_size.y * .5
|
||||||
},
|
},
|
||||||
collisionbox = {
|
collisionbox = {
|
||||||
self.base_colbox[1] * .5,
|
self.base_colbox[1] * .5,
|
||||||
@ -1280,7 +1279,7 @@ function mob_class:breed()
|
|||||||
self.base_colbox[3] * .5,
|
self.base_colbox[3] * .5,
|
||||||
self.base_colbox[4] * .5,
|
self.base_colbox[4] * .5,
|
||||||
self.base_colbox[5] * .5,
|
self.base_colbox[5] * .5,
|
||||||
self.base_colbox[6] * .5,
|
self.base_colbox[6] * .5
|
||||||
},
|
},
|
||||||
selectionbox = {
|
selectionbox = {
|
||||||
self.base_selbox[1] * .5,
|
self.base_selbox[1] * .5,
|
||||||
@ -1288,7 +1287,7 @@ function mob_class:breed()
|
|||||||
self.base_selbox[3] * .5,
|
self.base_selbox[3] * .5,
|
||||||
self.base_selbox[4] * .5,
|
self.base_selbox[4] * .5,
|
||||||
self.base_selbox[5] * .5,
|
self.base_selbox[5] * .5,
|
||||||
self.base_selbox[6] * .5,
|
self.base_selbox[6] * .5
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
-- tamed and owned by parents' owner
|
-- tamed and owned by parents' owner
|
||||||
@ -1646,7 +1645,7 @@ local specific_attack = function(list, what)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- general attack function for all mobs ==========
|
-- general attack function for all mobs
|
||||||
function mob_class:general_attack()
|
function mob_class:general_attack()
|
||||||
|
|
||||||
-- return if already attacking, passive or docile during day
|
-- return if already attacking, passive or docile during day
|
||||||
@ -2023,7 +2022,7 @@ function mob_class:do_states(dtime)
|
|||||||
and self.walk_chance ~= 0
|
and self.walk_chance ~= 0
|
||||||
and self.facing_fence ~= true
|
and self.facing_fence ~= true
|
||||||
and random(1, 100) <= self.walk_chance
|
and random(1, 100) <= self.walk_chance
|
||||||
and self:is_at_cliff() == false then
|
and self.at_cliff == false then
|
||||||
|
|
||||||
self:set_velocity(self.walk_velocity)
|
self:set_velocity(self.walk_velocity)
|
||||||
self.state = "walk"
|
self.state = "walk"
|
||||||
@ -2104,10 +2103,8 @@ function mob_class:do_states(dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- stand for great fall in front
|
-- stand for great fall in front
|
||||||
local temp_is_cliff = self:is_at_cliff()
|
|
||||||
|
|
||||||
if self.facing_fence == true
|
if self.facing_fence == true
|
||||||
or temp_is_cliff
|
or self.at_cliff
|
||||||
or random(1, 100) <= self.stand_chance then
|
or random(1, 100) <= self.stand_chance then
|
||||||
|
|
||||||
self:set_velocity(0)
|
self:set_velocity(0)
|
||||||
@ -2133,7 +2130,7 @@ function mob_class:do_states(dtime)
|
|||||||
|
|
||||||
-- stop after 5 seconds or when at cliff
|
-- stop after 5 seconds or when at cliff
|
||||||
if self.runaway_timer > 5
|
if self.runaway_timer > 5
|
||||||
or self:is_at_cliff()
|
or self.at_cliff
|
||||||
or self.order == "stand" then
|
or self.order == "stand" then
|
||||||
self.runaway_timer = 0
|
self.runaway_timer = 0
|
||||||
self:set_velocity(0)
|
self:set_velocity(0)
|
||||||
@ -2235,9 +2232,9 @@ function mob_class:do_states(dtime)
|
|||||||
self.blinktimer = 0
|
self.blinktimer = 0
|
||||||
|
|
||||||
if self.blinkstatus then
|
if self.blinkstatus then
|
||||||
self.object:settexturemod("")
|
self.object:set_texture_mod("")
|
||||||
else
|
else
|
||||||
self.object:settexturemod("^[brighten")
|
self.object:set_texture_mod("^[brighten")
|
||||||
end
|
end
|
||||||
|
|
||||||
self.blinkstatus = not self.blinkstatus
|
self.blinkstatus = not self.blinkstatus
|
||||||
@ -2264,7 +2261,7 @@ function mob_class:do_states(dtime)
|
|||||||
tnt.boom(pos, {
|
tnt.boom(pos, {
|
||||||
radius = node_break_radius,
|
radius = node_break_radius,
|
||||||
damage_radius = entity_damage_radius,
|
damage_radius = entity_damage_radius,
|
||||||
sound = self.sounds.explode,
|
sound = self.sounds.explode
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -2383,7 +2380,7 @@ function mob_class:do_states(dtime)
|
|||||||
self:smart_mobs(s, p, dist, dtime)
|
self:smart_mobs(s, p, dist, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self:is_at_cliff() then
|
if self.at_cliff then
|
||||||
|
|
||||||
self:set_velocity(0)
|
self:set_velocity(0)
|
||||||
self:set_animation("stand")
|
self:set_animation("stand")
|
||||||
@ -2415,13 +2412,7 @@ function mob_class:do_states(dtime)
|
|||||||
if self.timer > 1 then
|
if self.timer > 1 then
|
||||||
|
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
|
self:set_animation("punch")
|
||||||
-- if self.double_melee_attack
|
|
||||||
-- and random(1, 2) == 1 then
|
|
||||||
-- self:set_animation("punch2")
|
|
||||||
-- else
|
|
||||||
self:set_animation("punch")
|
|
||||||
-- end
|
|
||||||
|
|
||||||
local p2 = p
|
local p2 = p
|
||||||
local s2 = s
|
local s2 = s
|
||||||
@ -3128,6 +3119,24 @@ function mob_class:on_step(dtime)
|
|||||||
x = pos.x, y = pos.y + y_level + 0.25, z = pos.z}, "air").name
|
x = pos.x, y = pos.y + y_level + 0.25, z = pos.z}, "air").name
|
||||||
-- print ("standing in " .. self.standing_in)
|
-- print ("standing in " .. self.standing_in)
|
||||||
|
|
||||||
|
-- if standing inside solid block then jump to escape
|
||||||
|
if minetest.registered_nodes[self.standing_in].walkable and
|
||||||
|
minetest.registered_nodes[self.standing_in].drawtype == "normal" then
|
||||||
|
|
||||||
|
self.object:set_velocity({
|
||||||
|
x = 0,
|
||||||
|
y = self.jump_height,
|
||||||
|
z = 0
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check and stop if standing at cliff and fear of heights
|
||||||
|
self.at_cliff = self:is_at_cliff()
|
||||||
|
|
||||||
|
if self.at_cliff then
|
||||||
|
self:set_velocity(0)
|
||||||
|
end
|
||||||
|
|
||||||
-- check for mob expiration (0.25 instead of dtime since were in a timer)
|
-- check for mob expiration (0.25 instead of dtime since were in a timer)
|
||||||
self:mob_expire(pos, 0.25)
|
self:mob_expire(pos, 0.25)
|
||||||
end
|
end
|
||||||
@ -3374,11 +3383,13 @@ end -- END mobs:register_mob function
|
|||||||
|
|
||||||
|
|
||||||
-- count how many mobs of one type are inside an area
|
-- count how many mobs of one type are inside an area
|
||||||
|
-- will also return true for second value if player is inside area
|
||||||
local count_mobs = function(pos, type)
|
local count_mobs = function(pos, type)
|
||||||
|
|
||||||
local total = 0
|
local total = 0
|
||||||
local objs = minetest.get_objects_inside_radius(pos, aoc_range * 2)
|
local objs = minetest.get_objects_inside_radius(pos, aoc_range * 2)
|
||||||
local ent
|
local ent
|
||||||
|
local players
|
||||||
|
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
|
|
||||||
@ -3390,10 +3401,12 @@ local count_mobs = function(pos, type)
|
|||||||
if ent and ent.name and ent.name == type then
|
if ent and ent.name and ent.name == type then
|
||||||
total = total + 1
|
total = total + 1
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
players = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return total
|
return total, players
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -3462,7 +3475,12 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- get total number of this mob in area
|
-- get total number of this mob in area
|
||||||
local num_mob = count_mobs(pos, name)
|
local num_mob, is_pla = count_mobs(pos, name)
|
||||||
|
|
||||||
|
if not is_pla then
|
||||||
|
--print ("--- no players within active area, will not spawn " .. name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if num_mob >= aoc then
|
if num_mob >= aoc then
|
||||||
--print ("--- too many " .. name .. " in area", num_mob .. "/" .. aoc)
|
--print ("--- too many " .. name .. " in area", num_mob .. "/" .. aoc)
|
||||||
@ -3509,7 +3527,7 @@ function mobs:spawn_specific(name, nodes, neighbors, min_light, max_light,
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- only spawn away from player
|
-- only spawn away from player
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 10)
|
local objs = minetest.get_objects_inside_radius(pos, 8)
|
||||||
|
|
||||||
for n = 1, #objs do
|
for n = 1, #objs do
|
||||||
|
|
||||||
@ -3586,8 +3604,7 @@ function mobs:spawn(def)
|
|||||||
def.min_height or -31000,
|
def.min_height or -31000,
|
||||||
def.max_height or 31000,
|
def.max_height or 31000,
|
||||||
def.day_toggle,
|
def.day_toggle,
|
||||||
def.on_spawn
|
def.on_spawn)
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -3647,7 +3664,7 @@ function mobs:register_arrow(name, def)
|
|||||||
collisiondetection = false,
|
collisiondetection = false,
|
||||||
texture = def.tail_texture,
|
texture = def.tail_texture,
|
||||||
size = def.tail_size or 5,
|
size = def.tail_size or 5,
|
||||||
glow = def.glow or 0,
|
glow = def.glow or 0
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -4171,8 +4188,6 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
local tag = self.nametag or ""
|
local tag = self.nametag or ""
|
||||||
|
|
||||||
minetest.show_formspec(name, "mobs_nametag", "size[8,4]"
|
minetest.show_formspec(name, "mobs_nametag", "size[8,4]"
|
||||||
.. default.gui_bg
|
|
||||||
.. default.gui_bg_img
|
|
||||||
.. "field[0.5,1;7.5,0;name;"
|
.. "field[0.5,1;7.5,0;name;"
|
||||||
.. minetest.formspec_escape(S("Enter name:")) .. ";" .. tag .. "]"
|
.. minetest.formspec_escape(S("Enter name:")) .. ";" .. tag .. "]"
|
||||||
.. "button_exit[2.5,3.5;3,1;mob_rename;"
|
.. "button_exit[2.5,3.5;3,1;mob_rename;"
|
||||||
@ -4233,6 +4248,11 @@ end)
|
|||||||
-- compatibility function for old entities to new modpack entities
|
-- compatibility function for old entities to new modpack entities
|
||||||
function mobs:alias_mob(old_name, new_name)
|
function mobs:alias_mob(old_name, new_name)
|
||||||
|
|
||||||
|
-- check old_name entity doesnt already exist
|
||||||
|
if minetest.registered_entities[old_name] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- spawn egg
|
-- spawn egg
|
||||||
minetest.register_alias(old_name, new_name)
|
minetest.register_alias(old_name, new_name)
|
||||||
|
|
||||||
|
15
api.txt
15
api.txt
@ -158,6 +158,11 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
'min' minimum number of items dropped, set to 0 for rare drops.
|
'min' minimum number of items dropped, set to 0 for rare drops.
|
||||||
'max' maximum number of items dropped.
|
'max' maximum number of items dropped.
|
||||||
Note: If weapon has {fire=1} damage group set then cooked items will drop.
|
Note: If weapon has {fire=1} damage group set then cooked items will drop.
|
||||||
|
Note2: A function can now be passed which can also return drops table, e.g.
|
||||||
|
drops = function(pos)
|
||||||
|
-- do something
|
||||||
|
return { {name = "farming:bread"}, {name = "default:dirt", chance = 2} }
|
||||||
|
end
|
||||||
|
|
||||||
'visual' holds the look of the mob you wish to create:
|
'visual' holds the look of the mob you wish to create:
|
||||||
'cube' looks like a normal node
|
'cube' looks like a normal node
|
||||||
@ -624,8 +629,14 @@ 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
|
||||||
mob will spawn e.g.
|
mob will spawn e.g.
|
||||||
|
|
||||||
mobs_animal:sheep_chance 11000
|
mobs_animal:sheep 11000
|
||||||
mobs_monster:sand_monster_chance 100
|
mobs_monster:sand_monster 100
|
||||||
|
|
||||||
|
...you can also change how many of a certain mob appear in an active mapblock by
|
||||||
|
adding a comma and then a new value e.g.
|
||||||
|
|
||||||
|
mobs_animal:cow 8000,4 <-- 4 cows per mapblock at 8000 spawn chance
|
||||||
|
mobs_monster:dirt_monster ,20 <-- 20 dirt monsters per mapblock
|
||||||
|
|
||||||
|
|
||||||
Rideable Horse Example Mob
|
Rideable Horse Example Mob
|
||||||
|
98
crafts.lua
98
crafts.lua
@ -5,14 +5,14 @@ local S = mobs.intllib
|
|||||||
minetest.register_craftitem("mobs:nametag", {
|
minetest.register_craftitem("mobs:nametag", {
|
||||||
description = S("Name Tag"),
|
description = S("Name Tag"),
|
||||||
inventory_image = "mobs_nametag.png",
|
inventory_image = "mobs_nametag.png",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
if minetest.get_modpath("dye") and minetest.get_modpath("farming") then
|
if minetest.get_modpath("dye") and minetest.get_modpath("farming") then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
output = "mobs:nametag",
|
output = "mobs:nametag",
|
||||||
recipe = {"default:paper", "dye:black", "farming:string"},
|
recipe = {"default:paper", "dye:black", "farming:string"}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ end
|
|||||||
minetest.register_craftitem("mobs:leather", {
|
minetest.register_craftitem("mobs:leather", {
|
||||||
description = S("Leather"),
|
description = S("Leather"),
|
||||||
inventory_image = "mobs_leather.png",
|
inventory_image = "mobs_leather.png",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- raw meat
|
-- raw meat
|
||||||
@ -28,7 +28,7 @@ minetest.register_craftitem("mobs:meat_raw", {
|
|||||||
description = S("Raw Meat"),
|
description = S("Raw Meat"),
|
||||||
inventory_image = "mobs_meat_raw.png",
|
inventory_image = "mobs_meat_raw.png",
|
||||||
on_use = minetest.item_eat(3),
|
on_use = minetest.item_eat(3),
|
||||||
groups = {food_meat_raw = 1, flammable = 2},
|
groups = {food_meat_raw = 1, flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- cooked meat
|
-- cooked meat
|
||||||
@ -36,21 +36,21 @@ minetest.register_craftitem("mobs:meat", {
|
|||||||
description = S("Meat"),
|
description = S("Meat"),
|
||||||
inventory_image = "mobs_meat.png",
|
inventory_image = "mobs_meat.png",
|
||||||
on_use = minetest.item_eat(8),
|
on_use = minetest.item_eat(8),
|
||||||
groups = {food_meat = 1, flammable = 2},
|
groups = {food_meat = 1, flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "cooking",
|
type = "cooking",
|
||||||
output = "mobs:meat",
|
output = "mobs:meat",
|
||||||
recipe = "mobs:meat_raw",
|
recipe = "mobs:meat_raw",
|
||||||
cooktime = 5,
|
cooktime = 5
|
||||||
})
|
})
|
||||||
|
|
||||||
-- lasso
|
-- lasso
|
||||||
minetest.register_tool("mobs:lasso", {
|
minetest.register_tool("mobs:lasso", {
|
||||||
description = S("Lasso (right-click animal to put in inventory)"),
|
description = S("Lasso (right-click animal to put in inventory)"),
|
||||||
inventory_image = "mobs_magic_lasso.png",
|
inventory_image = "mobs_magic_lasso.png",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
if minetest.get_modpath("farming") then
|
if minetest.get_modpath("farming") then
|
||||||
@ -59,7 +59,7 @@ if minetest.get_modpath("farming") then
|
|||||||
recipe = {
|
recipe = {
|
||||||
{"farming:string", "", "farming:string"},
|
{"farming:string", "", "farming:string"},
|
||||||
{"", "default:diamond", ""},
|
{"", "default:diamond", ""},
|
||||||
{"farming:string", "", "farming:string"},
|
{"farming:string", "", "farming:string"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -70,7 +70,7 @@ minetest.register_alias("mobs:magic_lasso", "mobs:lasso")
|
|||||||
minetest.register_tool("mobs:net", {
|
minetest.register_tool("mobs:net", {
|
||||||
description = S("Net (right-click animal to put in inventory)"),
|
description = S("Net (right-click animal to put in inventory)"),
|
||||||
inventory_image = "mobs_net.png",
|
inventory_image = "mobs_net.png",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
if minetest.get_modpath("farming") then
|
if minetest.get_modpath("farming") then
|
||||||
@ -79,7 +79,7 @@ if minetest.get_modpath("farming") then
|
|||||||
recipe = {
|
recipe = {
|
||||||
{"group:stick", "", "group:stick"},
|
{"group:stick", "", "group:stick"},
|
||||||
{"group:stick", "", "group:stick"},
|
{"group:stick", "", "group:stick"},
|
||||||
{"farming:string", "group:stick", "farming:string"},
|
{"farming:string", "group:stick", "farming:string"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -88,14 +88,14 @@ end
|
|||||||
minetest.register_tool("mobs:shears", {
|
minetest.register_tool("mobs:shears", {
|
||||||
description = S("Steel Shears (right-click to shear)"),
|
description = S("Steel Shears (right-click to shear)"),
|
||||||
inventory_image = "mobs_shears.png",
|
inventory_image = "mobs_shears.png",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'mobs:shears',
|
output = "mobs:shears",
|
||||||
recipe = {
|
recipe = {
|
||||||
{'', 'default:steel_ingot', ''},
|
{"", "default:steel_ingot", ""},
|
||||||
{'', 'group:stick', 'default:steel_ingot'},
|
{"", "group:stick", "default:steel_ingot"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ minetest.register_craft({
|
|||||||
minetest.register_craftitem("mobs:protector", {
|
minetest.register_craftitem("mobs:protector", {
|
||||||
description = S("Mob Protection Rune"),
|
description = S("Mob Protection Rune"),
|
||||||
inventory_image = "mobs_protector.png",
|
inventory_image = "mobs_protector.png",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -111,7 +111,7 @@ minetest.register_craft({
|
|||||||
recipe = {
|
recipe = {
|
||||||
{"default:stone", "default:stone", "default:stone"},
|
{"default:stone", "default:stone", "default:stone"},
|
||||||
{"default:stone", "default:goldblock", "default:stone"},
|
{"default:stone", "default:goldblock", "default:stone"},
|
||||||
{"default:stone", "default:stone", "default:stone"},
|
{"default:stone", "default:stone", "default:stone"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ minetest.register_craft({
|
|||||||
minetest.register_craftitem("mobs:saddle", {
|
minetest.register_craftitem("mobs:saddle", {
|
||||||
description = S("Saddle"),
|
description = S("Saddle"),
|
||||||
inventory_image = "mobs_saddle.png",
|
inventory_image = "mobs_saddle.png",
|
||||||
groups = {flammable = 2},
|
groups = {flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -127,7 +127,7 @@ minetest.register_craft({
|
|||||||
recipe = {
|
recipe = {
|
||||||
{"mobs:leather", "mobs:leather", "mobs:leather"},
|
{"mobs:leather", "mobs:leather", "mobs:leather"},
|
||||||
{"mobs:leather", "default:steel_ingot", "mobs:leather"},
|
{"mobs:leather", "default:steel_ingot", "mobs:leather"},
|
||||||
{"mobs:leather", "default:steel_ingot", "mobs:leather"},
|
{"mobs:leather", "default:steel_ingot", "mobs:leather"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -142,38 +142,38 @@ default.register_fence("mobs:fence_wood", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{-0.5, -0.5, -0.5, 0.5, 1.9, 0.5},
|
{-0.5, -0.5, -0.5, 0.5, 1.9, 0.5},
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- mob fence top (has enlarged collisionbox to stop mobs getting over)
|
-- mob fence top (has enlarged collisionbox to stop mobs getting over)
|
||||||
minetest.register_node("mobs:fence_top", {
|
minetest.register_node("mobs:fence_top", {
|
||||||
description = S("Mob Fence Top"),
|
description = S("Mob Fence Top"),
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"default_wood.png"},
|
tiles = {"default_wood.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
|
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2},
|
fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2}
|
||||||
},
|
},
|
||||||
collision_box = {
|
collision_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4},
|
fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4}
|
||||||
},
|
},
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4},
|
fixed = {-0.4, -1.5, -0.4, 0.4, 0, 0.4}
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mobs:fence_top 12",
|
output = "mobs:fence_top 12",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:wood", "group:wood", "group:wood"},
|
{"group:wood", "group:wood", "group:wood"},
|
||||||
{"", "default:fence_wood", ""},
|
{"", "default:fence_wood", ""}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -181,43 +181,43 @@ minetest.register_craft({
|
|||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = "mobs:nametag",
|
recipe = "mobs:nametag",
|
||||||
burntime = 3,
|
burntime = 3
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = "mobs:lasso",
|
recipe = "mobs:lasso",
|
||||||
burntime = 7,
|
burntime = 7
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = "mobs:net",
|
recipe = "mobs:net",
|
||||||
burntime = 8,
|
burntime = 8
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = "mobs:leather",
|
recipe = "mobs:leather",
|
||||||
burntime = 4,
|
burntime = 4
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = "mobs:saddle",
|
recipe = "mobs:saddle",
|
||||||
burntime = 7,
|
burntime = 7
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = "mobs:fence_wood",
|
recipe = "mobs:fence_wood",
|
||||||
burntime = 7,
|
burntime = 7
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "fuel",
|
type = "fuel",
|
||||||
recipe = "mobs:fence_top",
|
recipe = "mobs:fence_top",
|
||||||
burntime = 2,
|
burntime = 2
|
||||||
})
|
})
|
||||||
|
|
||||||
-- this tool spawns same mob and adds owner, protected, nametag info
|
-- this tool spawns same mob and adds owner, protected, nametag info
|
||||||
@ -284,7 +284,7 @@ minetest.register_tool(":mobs:mob_reset_stick", {
|
|||||||
.. "button_exit[2.5,3.5;3,1;mob_texture_change;"
|
.. "button_exit[2.5,3.5;3,1;mob_texture_change;"
|
||||||
.. minetest.formspec_escape(S("Change")) .. "]")
|
.. minetest.formspec_escape(S("Change")) .. "]")
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
@ -13,6 +13,6 @@ if minetest.get_modpath("lucky_block") then
|
|||||||
{"dro", {"mobs:protector"}, 1},
|
{"dro", {"mobs:protector"}, 1},
|
||||||
{"dro", {"mobs:fence_wood"}, 10},
|
{"dro", {"mobs:fence_wood"}, 10},
|
||||||
{"dro", {"mobs:fence_top"}, 12},
|
{"dro", {"mobs:fence_top"}, 12},
|
||||||
{"lig"},
|
{"lig"}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -212,7 +212,8 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- fix mob rotation
|
-- fix mob rotation
|
||||||
entity.object:set_yaw(entity.driver:get_look_horizontal() - entity.rotate)
|
local horz = entity.driver:get_look_horizontal() or 0
|
||||||
|
entity.object:set_yaw(horz - entity.rotate)
|
||||||
|
|
||||||
if can_fly then
|
if can_fly then
|
||||||
|
|
||||||
@ -246,7 +247,6 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
acce_y = acce_y + (acce_y * 3) + 1
|
acce_y = acce_y + (acce_y * 3) + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
|||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set moving animation
|
-- set moving animation
|
||||||
if moving_anim then
|
if moving_anim then
|
||||||
mobs:set_animation(entity, moving_anim)
|
mobs:set_animation(entity, moving_anim)
|
||||||
|
@ -23,7 +23,7 @@ Lucky Blocks: 9
|
|||||||
|
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
- 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found (thanks Astrobe)
|
- 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found (thanks Astrobe), dont spawn mobs if world anchor nearby (technic or simple_anchor mods)
|
||||||
- 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07
|
- 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07
|
||||||
- 1.48- Add mobs:set_velocity(self, velocity) global function
|
- 1.48- Add mobs:set_velocity(self, velocity) global function
|
||||||
- 1.47- Mob damage changes, min and max light level for damage added, ignition sources checked for lava damage
|
- 1.47- Mob damage changes, min and max light level for damage added, ignition sources checked for lava damage
|
||||||
|
@ -68,7 +68,7 @@ minetest.register_node("mobs:spawner", {
|
|||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
S("Syntax: “name min_light[0-14] max_light[0-14] max_mobs_in_area[0 to disable] distance[1-20] y_offset[-10 to 10]”"))
|
S("Syntax: “name min_light[0-14] max_light[0-14] max_mobs_in_area[0 to disable] distance[1-20] y_offset[-10 to 10]”"))
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -174,6 +174,5 @@ minetest.register_abm({
|
|||||||
minetest.add_entity(pos2, mob)
|
minetest.add_entity(pos2, mob)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user