Artic fox and tweaks
This commit is contained in:
parent
64931e2f99
commit
912238ccd9
23
fox.lua
23
fox.lua
|
@ -12,19 +12,12 @@ local atan = function(x)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
local S = minetest.get_translator("extra_mobs")
|
||||
|
||||
--###################
|
||||
--################### fox
|
||||
--###################
|
||||
|
||||
local dir_to_pitch = function(dir)
|
||||
local dir2 = vector.normalize(dir)
|
||||
local xz = math.abs(dir.x) + math.abs(dir.z)
|
||||
return -math.atan2(-dir.y, xz)
|
||||
end
|
||||
|
||||
local fox = {
|
||||
type = "monster",
|
||||
passive = false,
|
||||
|
@ -68,6 +61,12 @@ local fox = {
|
|||
lay_end = 34,
|
||||
},
|
||||
runaway = true,
|
||||
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
|
||||
minetest.chat_send_all("true")
|
||||
self.object:set_properties({textures={"extra_mobs_artic_fox.png"}})
|
||||
end
|
||||
end,
|
||||
do_custom = function(self)
|
||||
if self.state ~= "attack" and math.random(1, 5000) == 1 then
|
||||
self.state = "lay"
|
||||
|
@ -79,7 +78,9 @@ local fox = {
|
|||
end)
|
||||
end
|
||||
for _,object in pairs(minetest.get_objects_inside_radius(self.object:get_pos(), 8)) do
|
||||
if object:is_player() and not object:get_player_control().sneak then
|
||||
if not object:is_player() and object:get_luaentity().name == "extra_mobs:fox" and self.state ~= "attack" and math.random(1, 500) == 1 then
|
||||
self.horny = true
|
||||
end
|
||||
local lp = object:get_pos()
|
||||
local s = self.object:get_pos()
|
||||
local vec = {
|
||||
|
@ -87,9 +88,10 @@ local fox = {
|
|||
y = lp.y - s.y,
|
||||
z = lp.z - s.z
|
||||
}
|
||||
if object:is_player() and not object:get_player_control().sneak then
|
||||
self.state = "runaway"
|
||||
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
|
||||
if self.reach > vector.distance(self.object:get_pos(), object:get_pos()) and self.timer > .9 and minetest.is_creative_enabled() == false then
|
||||
self.timer = 0
|
||||
object:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
|
@ -112,5 +114,8 @@ mobs:register_mob("extra_mobs:fox", fox)
|
|||
-- Regular spawning in the Nether
|
||||
mobs:spawn_specific("extra_mobs:fox", {"mcl_core:dirt_with_grass"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500)
|
||||
|
||||
mobs:spawn_specific("extra_mobs:fox", {"mcl_core:dirt_with_grass_snow"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500)
|
||||
mobs:spawn_specific("extra_mobs:artic_fox", {"mcl_core:snow"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, 0, 500)
|
||||
|
||||
-- spawn eggs
|
||||
mobs:register_egg("extra_mobs:fox", S("Fox"), "extra_mobs_spawn_icon_fox.png", 0)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 984 B |
Loading…
Reference in New Issue