forked from VoxeLibre/VoxeLibre
Compare commits
5 Commits
master
...
sheep_eat_
Author | SHA1 | Date |
---|---|---|
epCode | d14662ed88 | |
epCode | bbf8d5b15e | |
epCode | 62319868d3 | |
epCode | 7f1bb3b3c8 | |
epCode | c5fb61303f |
|
@ -355,9 +355,11 @@ function mob_class:do_jump()
|
||||||
jump_c_multiplier = v2/self.walk_velocity/2
|
jump_c_multiplier = v2/self.walk_velocity/2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local yaw_dir = minetest.yaw_to_dir(self.object:get_yaw())
|
||||||
|
|
||||||
-- where is front
|
-- where is front
|
||||||
local dir_x = -math.sin(yaw) * (self.collisionbox[4] + 0.5)*jump_c_multiplier+0.6
|
local dir_x = -math.sin(yaw) * (self.collisionbox[4] + 0.5)*jump_c_multiplier+yaw_dir.x
|
||||||
local dir_z = math.cos(yaw) * (self.collisionbox[4] + 0.5)*jump_c_multiplier+0.6
|
local dir_z = math.cos(yaw) * (self.collisionbox[4] + 0.5)*jump_c_multiplier+yaw_dir.z
|
||||||
|
|
||||||
-- what is in front of mob?
|
-- what is in front of mob?
|
||||||
nod = node_ok({
|
nod = node_ok({
|
||||||
|
@ -480,6 +482,7 @@ end
|
||||||
-- find and replace what mob is looking for (grass, wheat etc.)
|
-- find and replace what mob is looking for (grass, wheat etc.)
|
||||||
function mob_class:replace_node(pos)
|
function mob_class:replace_node(pos)
|
||||||
|
|
||||||
|
|
||||||
if not self.replace_rate
|
if not self.replace_rate
|
||||||
or not self.replace_what
|
or not self.replace_what
|
||||||
or self.child == true
|
or self.child == true
|
||||||
|
@ -519,7 +522,20 @@ function mob_class:replace_node(pos)
|
||||||
if on_replace_return ~= false then
|
if on_replace_return ~= false then
|
||||||
|
|
||||||
if mobs_griefing then
|
if mobs_griefing then
|
||||||
minetest.set_node(pos, newnode)
|
self.state = "eat"
|
||||||
|
self:set_animation("eat")
|
||||||
|
self:set_velocity(0)
|
||||||
|
minetest.after(1.3, function()
|
||||||
|
if self and self.object and not self.dead then
|
||||||
|
self.object:set_velocity(vector.new(0,0,0))
|
||||||
|
minetest.set_node(pos, newnode)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
minetest.after(2.5, function()
|
||||||
|
if self and self.object and self.state == 'eat' and not self.dead then
|
||||||
|
self.state = "walk"
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -184,7 +184,7 @@ function mob_class:collision()
|
||||||
end
|
end
|
||||||
|
|
||||||
function mob_class:check_death_and_slow_mob()
|
function mob_class:check_death_and_slow_mob()
|
||||||
local d = 0.85
|
local d = 0.7
|
||||||
local dying = self:check_dying()
|
local dying = self:check_dying()
|
||||||
if dying then d = 0.92 end
|
if dying then d = 0.92 end
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ function mob_class:set_velocity(v)
|
||||||
local vv = self.object:get_velocity()
|
local vv = self.object:get_velocity()
|
||||||
|
|
||||||
if vv and yaw then
|
if vv and yaw then
|
||||||
self.acc = vector.new(((math.sin(yaw) * -v) + c_x) * .27, 0, ((math.cos(yaw) * v) + c_y) * .27)
|
self.acc = vector.new(((math.sin(yaw) * -v) + c_x) * .4, 0, ((math.cos(yaw) * v) + c_y) * .4)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -327,9 +327,9 @@ function mob_class:set_yaw(yaw, delay, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.deg(yaw) > 360 then
|
if math.deg(yaw) > 360 then
|
||||||
yaw=yaw%360
|
yaw=math.rad(math.deg(yaw)%360)
|
||||||
elseif math.deg(yaw) < 0 then
|
elseif math.deg(yaw) < 0 then
|
||||||
yaw=((360*5)-yaw)%360
|
yaw=math.rad(((360*5)-math.deg(yaw))%360)
|
||||||
end
|
end
|
||||||
|
|
||||||
--calculate the shortest way to turn to find our target
|
--calculate the shortest way to turn to find our target
|
||||||
|
@ -353,7 +353,7 @@ function mob_class:set_yaw(yaw, delay, dtime)
|
||||||
ddtime = dtime
|
ddtime = dtime
|
||||||
end
|
end
|
||||||
|
|
||||||
if math.abs(target_shortest_path_nums) > 5 then
|
if math.abs(target_shortest_path_nums) > 10 then
|
||||||
self.object:set_yaw(self.object:get_yaw()+(target_shortest_path*(3.6*ddtime)))
|
self.object:set_yaw(self.object:get_yaw()+(target_shortest_path*(3.6*ddtime)))
|
||||||
if self.acc then
|
if self.acc then
|
||||||
self.acc=vector.rotate_around_axis(self.acc,vector.new(0,1,0), target_shortest_path*(3.6*ddtime))
|
self.acc=vector.rotate_around_axis(self.acc,vector.new(0,1,0), target_shortest_path*(3.6*ddtime))
|
||||||
|
|
Binary file not shown.
|
@ -101,17 +101,19 @@ mcl_mobs.register_mob("mobs_mc:sheep", {
|
||||||
stand_start = 0, stand_end = 0,
|
stand_start = 0, stand_end = 0,
|
||||||
walk_start = 0, walk_end = 40, walk_speed = 30,
|
walk_start = 0, walk_end = 40, walk_speed = 30,
|
||||||
run_start = 0, run_end = 40, run_speed = 40,
|
run_start = 0, run_end = 40, run_speed = 40,
|
||||||
|
eat_start = 40, eat_end = 80, eat_loop = false,
|
||||||
},
|
},
|
||||||
child_animations = {
|
child_animations = {
|
||||||
stand_start = 81, stand_end = 81,
|
stand_start = 81, stand_end = 81,
|
||||||
walk_start = 81, walk_end = 121, walk_speed = 45,
|
walk_start = 81, walk_end = 121, walk_speed = 45,
|
||||||
run_start = 81, run_end = 121, run_speed = 60,
|
run_start = 81, run_end = 121, run_speed = 60,
|
||||||
|
eat_start = 121, eat_start = 161, eat_loop = false,
|
||||||
},
|
},
|
||||||
follow = { "mcl_farming:wheat_item" },
|
follow = { "mcl_farming:wheat_item" },
|
||||||
view_range = 12,
|
view_range = 12,
|
||||||
|
|
||||||
-- Eat grass
|
-- Eat grass
|
||||||
replace_rate = 20,
|
replace_rate = 40,
|
||||||
replace_what = {
|
replace_what = {
|
||||||
{ "mcl_core:dirt_with_grass", "mcl_core:dirt", -1 },
|
{ "mcl_core:dirt_with_grass", "mcl_core:dirt", -1 },
|
||||||
{ "mcl_flowers:tallgrass", "air", 0 },
|
{ "mcl_flowers:tallgrass", "air", 0 },
|
||||||
|
|
Loading…
Reference in New Issue