1
0
Fork 0

Make Zombie model and head rotation work

This commit is contained in:
epCode 2022-06-07 13:59:08 -07:00
parent 36ddec9812
commit b991bb5291
4 changed files with 25 additions and 10 deletions

View File

@ -3656,26 +3656,33 @@ local mob_step = function(self, dtime)
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() then
if obj:is_player() and not self.attack then
if not self._locked_object then
if math.random(50) == 1 then
if math.random(50/self.curiosity) == 1 then
self._locked_object = obj
end
else
if math.random(200) == 1 then
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 then
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.bone_eye_height*.7, 0)), vector.add(player_pos, vector.new(0, self._locked_object:get_properties().eye_height, 0)))
local mob_yaw = math.deg(-(-self.object:get_rotation().y-(-minetest.dir_to_yaw(direction_player))))
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 then
if (mob_yaw < -60 or mob_yaw > 60) and not self.attack then
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,0), vector.multiply(oldr, 0.9))
elseif self.attack then
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,0), vector.new(mob_pitch, mob_yaw, 0))
else
self.object:set_bone_position(self.head_swivel, vector.new(0,self.bone_eye_height,0), vector.new(((mob_pitch-oldr.x)*.3)+oldr.x, ((mob_yaw-oldr.y)*.3)+oldr.y, 0))
end
@ -3926,8 +3933,10 @@ end
minetest.register_entity(name, {
use_texture_alpha = def.use_texture_alpha,
head_swivel = def.head_swivel or nil,
bone_eye_height = def.bone_eye_height or 1.4,
head_swivel = def.head_swivel or nil, -- name of head bone
head_yaw_offset = def.head_yaw_offset or 0, -- name of head bone
bone_eye_height = def.bone_eye_height or 1.4, -- mob eye height
curiosity = def.curiosity or 1, -- factor for staqring at players
stepheight = def.stepheight or 0.6,
name = name,
description = def.description,

View File

@ -1221,6 +1221,7 @@ mcl_mobs:register_mob("mobs_mc:villager", {
--EXPERIMENTAL
head_swivel = "Head_Control",
bone_eye_height = 2.35,
curiosity = 10,
-------------------------------
visual_size = {x=2.75, y=2.75},
makes_footstep_sound = true,

View File

@ -60,11 +60,16 @@ local zombie = {
mesh = "mobs_mc_zombie.b3d",
textures = {
{
"mobs_mc_empty.png", -- armor
"mobs_mc_zombie.png", -- texture
"mobs_mc_empty.png", -- wielded_item
"mobs_mc_zombie.png", -- skin
"mcl_armor_chestplate_diamond.png", -- armor
"mobs_mc_empty.png", -- wielded item
}
},
--EXPERIMENTAL
head_swivel = "Head_Control",
bone_eye_height = 2.35,
curiosity = .1,
-------------------------------
visual_size = {x=3, y=3},
makes_footstep_sound = true,
sounds = {