Merge pull request 'Adds some mob jockey support' (#2752) from mob_jockey into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2752
Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
cora 2022-10-11 09:30:29 +00:00
commit 1b6df20c0c
5 changed files with 43 additions and 3 deletions

View File

@ -467,6 +467,10 @@ local set_animation = function(self, anim, fixed_frame)
return return
end end
if self.jockey then
anim = "jockey"
end
if flight_check(self) and self.fly and anim == "walk" then anim = "fly" end if flight_check(self) and self.fly and anim == "walk" then anim = "fly" end
self._current_animation = self._current_animation or "" self._current_animation = self._current_animation or ""
@ -3459,6 +3463,11 @@ end
local mob_detach_child = function(self, child) local mob_detach_child = function(self, child)
if self.detach_child then
if self.detach_child(self, child) then
return
end
end
if self.driver == child then if self.driver == child then
self.driver = nil self.driver = nil
end end
@ -3807,6 +3816,9 @@ local mob_step = function(self, dtime)
_locked_object_eye_height = self._locked_object:get_properties().eye_height _locked_object_eye_height = self._locked_object:get_properties().eye_height
end end
local self_rot = self.object:get_rotation() local self_rot = self.object:get_rotation()
if self.object:get_attach() then
self_rot = self.object:get_attach():get_rotation()
end
local player_pos = self._locked_object:get_pos() 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 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_yaw = math.deg(-(-(self_rot.y)-(-minetest.dir_to_yaw(direction_player))))+self.head_yaw_offset
@ -4094,6 +4106,7 @@ minetest.register_entity(name, {
on_die = def.on_die, on_die = def.on_die,
spawn_small_alternative = def.spawn_small_alternative, spawn_small_alternative = def.spawn_small_alternative,
do_custom = def.do_custom, do_custom = def.do_custom,
detach_child = def.detach_child,
jump_height = def.jump_height or 4, -- was 6 jump_height = def.jump_height or 4, -- was 6
rotate = math.rad(def.rotate or 0), -- 0=front, 90=side, 180=back, 270=side2 rotate = math.rad(def.rotate or 0), -- 0=front, 90=side, 180=back, 270=side2
lifetimer = def.lifetimer or 57.73, lifetimer = def.lifetimer or 57.73,

View File

@ -34,7 +34,6 @@ local skeleton = {
"mcl_bows_bow_0.png", -- bow "mcl_bows_bow_0.png", -- bow
"mobs_mc_skeleton.png", -- skeleton "mobs_mc_skeleton.png", -- skeleton
} }, } },
visual_size = {x=1, y=1},
makes_footstep_sound = true, makes_footstep_sound = true,
textures = { textures = {
{ {
@ -81,11 +80,27 @@ local skeleton = {
run_speed = 30, run_speed = 30,
shoot_start = 70, shoot_start = 70,
shoot_end = 90, shoot_end = 90,
jockey_start = 172,
jockey_end = 172,
die_start = 160, die_start = 160,
die_end = 170, die_end = 170,
die_speed = 15, die_speed = 15,
die_loop = false, die_loop = false,
}, },
jock = "mobs_mc:spider",
on_spawn = function(self)
self.jockey = false
if math.random(100) == 1 then -- 1% like from MCwiki
self.jockey = true
local jock = minetest.add_entity(self.object:get_pos(), "mobs_mc:spider")
jock:get_luaentity().docile_by_day = false
self.object:set_attach(jock, "", vector.new(0,0,0), vector.new(0,0,0))
end
return true
end,
on_detach=function(self, parent)
self.jockey = false
end,
ignited_by_sunlight = true, ignited_by_sunlight = true,
view_range = 16, view_range = 16,
fear_height = 4, fear_height = 4,
@ -93,6 +108,9 @@ local skeleton = {
arrow = "mcl_bows:arrow_entity", arrow = "mcl_bows:arrow_entity",
shoot_arrow = function(self, pos, dir) shoot_arrow = function(self, pos, dir)
if mod_bows then if mod_bows then
if self.attack then
self.object:set_yaw(minetest.dir_to_yaw(vector.direction(self.object:get_pos(), self.attack:get_pos())))
end
-- 2-4 damage per arrow -- 2-4 damage per arrow
local dmg = math.max(4, math.random(2, 8)) local dmg = math.max(4, math.random(2, 8))
mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg) mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)

View File

@ -14,7 +14,7 @@ local S = minetest.get_translator("mobs_mc")
minetest.register_entity("mobs_mc:spider_eyes", { minetest.register_entity("mobs_mc:spider_eyes", {
visual = "mesh", visual = "mesh",
mesh = "mobs_mc_spider.b3d", mesh = "mobs_mc_spider.b3d",
visual_size = {x=1.01, y=1.01}, visual_size = {x=1.01/3, y=1.01/3},
textures = { textures = {
"mobs_mc_spider_eyes.png", "mobs_mc_spider_eyes.png",
}, },
@ -44,6 +44,7 @@ local spider = {
xp_max = 5, xp_max = 5,
armor = {fleshy = 100, arthropod = 100}, armor = {fleshy = 100, arthropod = 100},
on_spawn = function(self) on_spawn = function(self)
self.object:set_properties({visual_size={x=1,y=1}})
local spider_eyes=false local spider_eyes=false
for n = 1, #self.object:get_children() do for n = 1, #self.object:get_children() do
local obj = self.object:get_children()[n] local obj = self.object:get_children()[n]
@ -55,6 +56,14 @@ 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,
on_die=function(self)
if self.object:get_children() and self.object:get_children()[1] then
self.object:get_children()[1]:set_detach()
end
end,
detach_child=function(self, child)
child:get_luaentity().jockey = false
end,
head_swivel = "Head_Control", head_swivel = "Head_Control",
bone_eye_height = 1, bone_eye_height = 1,
curiosity = 10, curiosity = 10,
@ -65,7 +74,7 @@ local spider = {
textures = { textures = {
{"mobs_mc_spider.png"}, {"mobs_mc_spider.png"},
}, },
visual_size = {x=3, y=3}, visual_size = {x=1, y=1},
makes_footstep_sound = false, makes_footstep_sound = false,
sounds = { sounds = {
random = "mobs_mc_spider_random", random = "mobs_mc_spider_random",