Add api and following mobs as starers: cow, chicken, creeper, pig, sheep, skellys. spider, villager, villager_zombie, wolf
This commit is contained in:
parent
8893241ae9
commit
1a6698abda
|
@ -61,6 +61,13 @@ if minetest.settings:get_bool("only_peaceful_mobs", false) then
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function dir_to_pitch(dir)
|
||||||
|
--local dir2 = vector.normalize(dir)
|
||||||
|
local xz = math.abs(dir.x) + math.abs(dir.z)
|
||||||
|
return -math.atan2(-dir.y, xz)
|
||||||
|
end
|
||||||
|
|
||||||
-- pathfinding settings
|
-- pathfinding settings
|
||||||
local enable_pathfinding = true
|
local enable_pathfinding = true
|
||||||
local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching
|
local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching
|
||||||
|
@ -3706,6 +3713,60 @@ local mob_step = function(self, dtime)
|
||||||
|
|
||||||
-- end rotation
|
-- end rotation
|
||||||
|
|
||||||
|
if self.head_swivel and type(self.head_swivel) == "string" then
|
||||||
|
local oldp,oldr = self.object:get_bone_position(self.head_swivel)
|
||||||
|
|
||||||
|
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 10)) do
|
||||||
|
if obj:is_player() and not self.attack then
|
||||||
|
if not self._locked_object then
|
||||||
|
if math.random(50/self.curiosity) == 1 then
|
||||||
|
self._locked_object = obj
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if math.random(200*self.curiosity) == 1 then
|
||||||
|
self._locked_object = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.attack then
|
||||||
|
self._locked_object = self.attack
|
||||||
|
end
|
||||||
|
|
||||||
|
if self._locked_object and (self._locked_object:is_player() or self._locked_object:get_luaentity()) and self._locked_object:get_hp() > 0 then
|
||||||
|
local _locked_object_eye_height = 1.5
|
||||||
|
if self._locked_object:is_player() then
|
||||||
|
_locked_object_eye_height = self._locked_object:get_properties().eye_height
|
||||||
|
end
|
||||||
|
local self_rot = self.object:get_rotation()
|
||||||
|
local player_pos = self._locked_object:get_pos()
|
||||||
|
local direction_player = vector.direction(vector.add(self.object:get_pos(), vector.new(0, self.head_eye_height*.7, 0)), vector.add(player_pos, vector.new(0, _locked_object_eye_height, 0)))
|
||||||
|
local mob_yaw = math.deg(-(-(self_rot.y)-(-minetest.dir_to_yaw(direction_player))))--+self.head_yaw_offset
|
||||||
|
local mob_pitch = math.deg(-dir_to_pitch(direction_player))
|
||||||
|
if (mob_yaw < -60 or mob_yaw > 60) and not (self.attack and self.type == "monster") then
|
||||||
|
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.multiply(oldr, 0.9))
|
||||||
|
elseif self.attack and self.type == "monster" then
|
||||||
|
if self.head_yaw == "y" then
|
||||||
|
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.new(mob_pitch, mob_yaw, 0))
|
||||||
|
elseif self.head_yaw == "z" then
|
||||||
|
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.new(mob_pitch, 0, -mob_yaw))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if self.head_yaw == "y" then
|
||||||
|
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.new(((mob_pitch-oldr.x)*.3)+oldr.x, ((mob_yaw-oldr.y)*.3)+oldr.y, 0))
|
||||||
|
elseif self.head_yaw == "z" then
|
||||||
|
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.new(((mob_pitch-oldr.x)*.3)+oldr.x, 0, -(((mob_yaw-oldr.y)*.3)+oldr.y)*3))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif not self._locked_object and math.abs(oldr.y) > 3 and math.abs(oldr.x) < 3 then
|
||||||
|
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.multiply(oldr, 0.9))
|
||||||
|
else
|
||||||
|
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,self.horrizonatal_head_height), vector.new(0,0,0))
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- run custom function (defined in mob lua file)
|
-- run custom function (defined in mob lua file)
|
||||||
if self.do_custom then
|
if self.do_custom then
|
||||||
|
|
||||||
|
@ -3946,6 +4007,13 @@ end
|
||||||
minetest.register_entity(name, {
|
minetest.register_entity(name, {
|
||||||
|
|
||||||
use_texture_alpha = def.use_texture_alpha,
|
use_texture_alpha = def.use_texture_alpha,
|
||||||
|
head_swivel = def.head_swivel or nil, -- bool to activate this function
|
||||||
|
head_yaw_offset = def.head_yaw_offset or 0, -- for wonkey model bones
|
||||||
|
bone_eye_height = def.bone_eye_height or 1.4, -- head bone offset
|
||||||
|
head_eye_height = def.head_eye_height or def.bone_eye_height or 0, -- how hight aproximatly the mobs head is fromm the ground to tell the mob how high to look up at the player
|
||||||
|
curiosity = def.curiosity or 1, -- how often mob will look at player on idle
|
||||||
|
head_yaw = def.head_yaw or "y", -- axis to rotate head on
|
||||||
|
horrizonatal_head_height = def.horrizonatal_head_height or 0,
|
||||||
stepheight = def.stepheight or 0.6,
|
stepheight = def.stepheight or 0.6,
|
||||||
name = name,
|
name = name,
|
||||||
description = def.description,
|
description = def.description,
|
||||||
|
|
|
@ -20,6 +20,12 @@ mcl_mobs:register_mob("mobs_mc:chicken", {
|
||||||
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.69, 0.2},
|
collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.69, 0.2},
|
||||||
runaway = true,
|
runaway = true,
|
||||||
floats = 1,
|
floats = 1,
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 1.8,
|
||||||
|
head_eye_height = 1.5,
|
||||||
|
curiosity = 10,
|
||||||
|
head_yaw="z",
|
||||||
|
visual_size = {x=3,y=3},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_chicken.b3d",
|
mesh = "mobs_mc_chicken.b3d",
|
||||||
textures = {
|
textures = {
|
||||||
|
|
|
@ -17,6 +17,12 @@ local cow_def = {
|
||||||
"mobs_mc_cow.png",
|
"mobs_mc_cow.png",
|
||||||
"blank.png",
|
"blank.png",
|
||||||
}, },
|
}, },
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 3.4,
|
||||||
|
head_eye_height = 1.1,
|
||||||
|
horrizonatal_head_height=-.7,
|
||||||
|
curiosity = 2,
|
||||||
|
head_yaw="z",
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
drops = {
|
drops = {
|
||||||
|
|
|
@ -21,6 +21,9 @@ mcl_mobs:register_mob("mobs_mc:creeper", {
|
||||||
pathfinding = 1,
|
pathfinding = 1,
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_creeper.b3d",
|
mesh = "mobs_mc_creeper.b3d",
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 2.35,
|
||||||
|
curiosity = 2,
|
||||||
textures = {
|
textures = {
|
||||||
{"mobs_mc_creeper.png",
|
{"mobs_mc_creeper.png",
|
||||||
"mobs_mc_empty.png"},
|
"mobs_mc_empty.png"},
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -18,6 +18,12 @@ mcl_mobs:register_mob("mobs_mc:pig", {
|
||||||
"mobs_mc_pig.png", -- base
|
"mobs_mc_pig.png", -- base
|
||||||
"blank.png", -- saddle
|
"blank.png", -- saddle
|
||||||
}},
|
}},
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 2.9,
|
||||||
|
head_eye_height = 0.8,
|
||||||
|
horrizonatal_head_height=-.4,
|
||||||
|
curiosity = 3,
|
||||||
|
head_yaw="z",
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
walk_velocity = 1,
|
walk_velocity = 1,
|
||||||
run_velocity = 3,
|
run_velocity = 3,
|
||||||
|
|
|
@ -61,7 +61,12 @@ mcl_mobs:register_mob("mobs_mc:sheep", {
|
||||||
xp_min = 1,
|
xp_min = 1,
|
||||||
xp_max = 3,
|
xp_max = 3,
|
||||||
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.29, 0.45},
|
collisionbox = {-0.45, -0.01, -0.45, 0.45, 1.29, 0.45},
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 3.3,
|
||||||
|
head_eye_height = 1.1,
|
||||||
|
horrizonatal_head_height=-.7,
|
||||||
|
curiosity = 6,
|
||||||
|
head_yaw="z",
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_sheepfur.b3d",
|
mesh = "mobs_mc_sheepfur.b3d",
|
||||||
textures = { sheep_texture("unicolor_white") },
|
textures = { sheep_texture("unicolor_white") },
|
||||||
|
|
|
@ -25,6 +25,9 @@ local skeleton = {
|
||||||
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.98, 0.3},
|
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.98, 0.3},
|
||||||
pathfinding = 1,
|
pathfinding = 1,
|
||||||
group_attack = true,
|
group_attack = true,
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 2.35,
|
||||||
|
curiosity = .1,
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_skeleton.b3d",
|
mesh = "mobs_mc_skeleton.b3d",
|
||||||
textures = { {
|
textures = { {
|
||||||
|
|
|
@ -55,6 +55,10 @@ local spider = {
|
||||||
minetest.add_entity(self.object:get_pos(), "mobs_mc:spider_eyes"):set_attach(self.object, "body.head", vector.new(0,-0.98,2), vector.new(90,180,180))
|
minetest.add_entity(self.object:get_pos(), "mobs_mc:spider_eyes"):set_attach(self.object, "body.head", vector.new(0,-0.98,2), vector.new(90,180,180))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 1,
|
||||||
|
curiosity = 10,
|
||||||
|
head_yaw="z",
|
||||||
collisionbox = {-0.7, -0.01, -0.7, 0.7, 0.89, 0.7},
|
collisionbox = {-0.7, -0.01, -0.7, 0.7, 0.89, 0.7},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_spider.b3d",
|
mesh = "mobs_mc_spider.b3d",
|
||||||
|
|
|
@ -1235,6 +1235,9 @@ mcl_mobs:register_mob("mobs_mc:villager", {
|
||||||
spawn_class = "passive",
|
spawn_class = "passive",
|
||||||
hp_min = 20,
|
hp_min = 20,
|
||||||
hp_max = 20,
|
hp_max = 20,
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 2.35,
|
||||||
|
curiosity = 10,
|
||||||
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3},
|
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_villager.b3d",
|
mesh = "mobs_mc_villager.b3d",
|
||||||
|
|
|
@ -39,13 +39,16 @@ mcl_mobs:register_mob("mobs_mc:villager_zombie", {
|
||||||
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3},
|
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3},
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "mobs_mc_villager_zombie.b3d",
|
mesh = "mobs_mc_villager_zombie.b3d",
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 2.35,
|
||||||
|
curiosity = 2,
|
||||||
textures = {
|
textures = {
|
||||||
{"mobs_mc_empty.png", "mobs_mc_zombie_butcher.png", "mobs_mc_empty.png"},
|
{"mobs_mc_zombie_butcher.png"},
|
||||||
{"mobs_mc_empty.png", "mobs_mc_zombie_farmer.png", "mobs_mc_empty.png"},
|
{"mobs_mc_zombie_farmer.png"},
|
||||||
{"mobs_mc_empty.png", "mobs_mc_zombie_librarian.png", "mobs_mc_empty.png"},
|
{"mobs_mc_zombie_librarian.png"},
|
||||||
{"mobs_mc_empty.png", "mobs_mc_zombie_priest.png", "mobs_mc_empty.png"},
|
{"mobs_mc_zombie_priest.png"},
|
||||||
{"mobs_mc_empty.png", "mobs_mc_zombie_smith.png", "mobs_mc_empty.png"},
|
{"mobs_mc_zombie_smith.png"},
|
||||||
{"mobs_mc_empty.png", "mobs_mc_zombie_villager.png", "mobs_mc_empty.png"},
|
{"mobs_mc_zombie_villager.png"},
|
||||||
},
|
},
|
||||||
visual_size = {x=2.75, y=2.75},
|
visual_size = {x=2.75, y=2.75},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
|
|
|
@ -26,6 +26,12 @@ local wolf = {
|
||||||
{"mobs_mc_wolf.png"},
|
{"mobs_mc_wolf.png"},
|
||||||
},
|
},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
|
head_swivel = "Head_Control",
|
||||||
|
bone_eye_height = 1.2,
|
||||||
|
head_eye_height = 1.1,
|
||||||
|
horrizonatal_head_height=0,
|
||||||
|
curiosity = 10,
|
||||||
|
head_yaw="z",
|
||||||
sounds = {
|
sounds = {
|
||||||
attack = "mobs_mc_wolf_bark",
|
attack = "mobs_mc_wolf_bark",
|
||||||
war_cry = "mobs_mc_wolf_growl",
|
war_cry = "mobs_mc_wolf_growl",
|
||||||
|
|
|
@ -60,9 +60,8 @@ local zombie = {
|
||||||
mesh = "mobs_mc_zombie.b3d",
|
mesh = "mobs_mc_zombie.b3d",
|
||||||
textures = {
|
textures = {
|
||||||
{
|
{
|
||||||
"mobs_mc_empty.png", -- armor
|
|
||||||
"mobs_mc_zombie.png", -- texture
|
"mobs_mc_zombie.png", -- texture
|
||||||
"mobs_mc_empty.png", -- wielded_item
|
"mobs_mc_empty.png", -- armor
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
|
@ -127,9 +126,8 @@ local husk = table.copy(zombie)
|
||||||
husk.description = S("Husk")
|
husk.description = S("Husk")
|
||||||
husk.textures = {
|
husk.textures = {
|
||||||
{
|
{
|
||||||
"mobs_mc_empty.png", -- armor
|
|
||||||
"mobs_mc_husk.png", -- texture
|
"mobs_mc_husk.png", -- texture
|
||||||
"mobs_mc_empty.png", -- wielded_item
|
"mobs_mc_empty.png", -- armor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
husk.ignited_by_sunlight = false
|
husk.ignited_by_sunlight = false
|
||||||
|
@ -144,7 +142,6 @@ mcl_mobs:register_mob("mobs_mc:husk", husk)
|
||||||
local baby_husk = table.copy(baby_zombie)
|
local baby_husk = table.copy(baby_zombie)
|
||||||
baby_husk.description = S("Baby Husk")
|
baby_husk.description = S("Baby Husk")
|
||||||
baby_husk.textures = {{
|
baby_husk.textures = {{
|
||||||
"mobs_mc_empty.png", -- armor
|
|
||||||
"mobs_mc_husk.png", -- texture
|
"mobs_mc_husk.png", -- texture
|
||||||
"mobs_mc_empty.png", -- wielded_item
|
"mobs_mc_empty.png", -- wielded_item
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in New Issue