forked from MineClone5/MineClone5
Merge pull request 'fox_fixes' (#368) from SumianVoice/MineClone5_c:fox_fixes into master
Reviewed-on: MineClone5/MineClone5#368
This commit is contained in:
commit
ec00351041
|
@ -21,9 +21,11 @@ local S = minetest.get_translator("extra_mobs")
|
||||||
local followitem = "mcl_farming:sweet_berry"
|
local followitem = "mcl_farming:sweet_berry"
|
||||||
|
|
||||||
local fox = {
|
local fox = {
|
||||||
type = "monster",
|
type = "animal",
|
||||||
passive = false,
|
passive = false,
|
||||||
spawn_class = "hostile",
|
spawn_class = "hostile",
|
||||||
|
skittish = true,
|
||||||
|
runaway = true,
|
||||||
hp_min = 10,
|
hp_min = 10,
|
||||||
hp_max = 10,
|
hp_max = 10,
|
||||||
xp_min = 1,
|
xp_min = 1,
|
||||||
|
@ -32,9 +34,20 @@ local fox = {
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
damage = 2,
|
damage = 2,
|
||||||
reach = 1.5,
|
reach = 1.5,
|
||||||
|
jump = true,
|
||||||
|
makes_footstep_sound = true,
|
||||||
|
walk_velocity = 3,
|
||||||
|
run_velocity = 6,
|
||||||
|
follow_velocity = 2,
|
||||||
|
follow = followitem,
|
||||||
|
pathfinding = 1,
|
||||||
|
fear_height = 4,
|
||||||
|
view_range = 16,
|
||||||
collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.84, 0.3},
|
collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.84, 0.3},
|
||||||
|
specific_attack = { "mobs_mc:chicken", "extra_mobs:cod", "extra_mobs:salmon" },
|
||||||
visual = "mesh",
|
visual = "mesh",
|
||||||
mesh = "extra_mobs_fox.b3d",
|
mesh = "extra_mobs_fox.b3d",
|
||||||
|
rotate = 270,
|
||||||
textures = { {
|
textures = { {
|
||||||
"extra_mobs_fox.png",
|
"extra_mobs_fox.png",
|
||||||
"extra_mobs_trans.png",
|
"extra_mobs_trans.png",
|
||||||
|
@ -42,10 +55,6 @@ local fox = {
|
||||||
visual_size = {x=3, y=3},
|
visual_size = {x=3, y=3},
|
||||||
sounds = {
|
sounds = {
|
||||||
},
|
},
|
||||||
jump = true,
|
|
||||||
makes_footstep_sound = true,
|
|
||||||
walk_velocity = 3,
|
|
||||||
run_velocity = 6,
|
|
||||||
drops = {
|
drops = {
|
||||||
},
|
},
|
||||||
animation = {
|
animation = {
|
||||||
|
@ -63,9 +72,9 @@ local fox = {
|
||||||
lay_start = 34,
|
lay_start = 34,
|
||||||
lay_end = 34,
|
lay_end = 34,
|
||||||
},
|
},
|
||||||
runaway = true,
|
|
||||||
on_spawn = function(self)
|
on_spawn = function(self)
|
||||||
if minetest.find_node_near(self.object:get_pos(), 4, "mcl_core:snow") ~= nil or minetest.find_node_near(self.object:get_pos(), 4, "mcl_core:dirt_with_grass_snow") ~= nil then
|
if minetest.find_node_near(self.object:get_pos(), 4, "mcl_core:snow") ~= nil
|
||||||
|
or minetest.find_node_near(self.object:get_pos(), 4, "mcl_core:dirt_with_grass_snow") ~= nil then
|
||||||
self.object:set_properties({textures={"extra_mobs_artic_fox.png", "extra_mobs_trans.png"}})
|
self.object:set_properties({textures={"extra_mobs_artic_fox.png", "extra_mobs_trans.png"}})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -83,7 +92,11 @@ local fox = {
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
for _,object in pairs(minetest.get_objects_inside_radius(self.object:get_pos(), 8)) do
|
for _,object in pairs(minetest.get_objects_inside_radius(self.object:get_pos(), 8)) do
|
||||||
if object and not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "extra_mobs:fox" and self.state ~= "attack" and math.random(1, 500) == 1 then
|
if object
|
||||||
|
and not object:is_player()
|
||||||
|
and object:get_luaentity()
|
||||||
|
and object:get_luaentity().name == "extra_mobs:fox"
|
||||||
|
and self.state ~= "attack" and math.random(1, 500) == 1 then
|
||||||
self.horny = true
|
self.horny = true
|
||||||
end
|
end
|
||||||
local lp = object:get_pos()
|
local lp = object:get_pos()
|
||||||
|
@ -93,26 +106,37 @@ local fox = {
|
||||||
y = lp.y - s.y,
|
y = lp.y - s.y,
|
||||||
z = lp.z - s.z
|
z = lp.z - s.z
|
||||||
}
|
}
|
||||||
if object and object:is_player() and not object:get_player_control().sneak or not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "mobs_mc:wolf" then
|
-- scare logic
|
||||||
|
if (object
|
||||||
|
and object:is_player()
|
||||||
|
and not object:get_player_control().sneak)
|
||||||
|
or (not object:is_player()
|
||||||
|
and object:get_luaentity()
|
||||||
|
and object:get_luaentity().name == "mobs_mc:wolf") then
|
||||||
|
-- don't keep setting it once it's set
|
||||||
|
if not self.state == "runaway" then
|
||||||
self.state = "runaway"
|
self.state = "runaway"
|
||||||
self.object:set_rotation({x=0,y=(atan(vec.z / vec.x) + 3 * pi / 2) - self.rotate,z=0})
|
self.object:set_rotation({x=0,y=(atan(vec.z / vec.x) + 3 * pi / 2) - self.rotate,z=0})
|
||||||
if self.reach > vector.distance(self.object:get_pos(), object:get_pos()) and self.timer > .9 then
|
end
|
||||||
|
-- if it is within a distance of the player or wolf
|
||||||
|
if 6 > vector.distance(self.object:get_pos(), object:get_pos()) then
|
||||||
|
self.timer = self.timer + 1
|
||||||
|
-- have some time before getting scared
|
||||||
|
if self.timer > 6 then
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
object:punch(self.object, 1.0, {
|
-- punch the fox for the player, but don't do any damage
|
||||||
full_punch_interval = 1.0,
|
self.object:punch(object, 0, {
|
||||||
damage_groups = {fleshy = self.damage}
|
full_punch_interval = 0,
|
||||||
|
damage_groups = {fleshy = 0}
|
||||||
}, nil)
|
}, nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
do_punch = function(self)
|
do_punch = function(self)
|
||||||
self.state = "runaway"
|
self.state = "runaway"
|
||||||
end,
|
end,
|
||||||
follow = followitem,
|
|
||||||
fear_height = 4,
|
|
||||||
view_range = 16,
|
|
||||||
specific_attack = { "mobs_mc:chicken", "extra_mobs:cod", "extra_mobs:salmon" },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mobs:register_mob("extra_mobs:fox", fox)
|
mobs:register_mob("extra_mobs:fox", fox)
|
||||||
|
|
Loading…
Reference in New Issue