-- simple dog to use with animal mobs !!!
-- This is a " kitten " version of the animal mobs, with some minor modifications.
-- sounds : 
-- https://freesound.org/people/ScouseMouseJB/sounds/276267/
-- https://freesound.org/people/TobiasKosmos/sounds/163280/

mobs:register_mob("dog:dog", {
	--nametag = "dog",
	type = "animal",
        --specific_attack = {"mobs_animal:kitten"},
        damage = 3,
	attack_type = "dogfight",
	pathfinding = true,
	--attack_animals = true, -- so it can attack kitten?
	group_attack = true,
	reach = 2,
	passive = false,
	hp_min = 5,
	hp_max = 10,
	armor = 100,
	collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.1, 0.3},
	visual = "mesh",
	visual_size = {x = 0.5, y = 0.5},
	mesh = "dog.b3d",
	rotate = 180,
	textures = {
		{"dog.png"},
		{"dog_black.png"},
		{"dog_yellow.png"},
		{"dog_tabby.png"},
		
	},
	makes_footstep_sound = false,
	sounds = {
		random = "bark",
		death = "yelp",
	},
	walk_velocity = 2,
	walk_chance = 15,
	run_velocity = 3,
	runaway = true,
	jump = true,
	jump_height = 2,
	stepheight = 2,
	fall_damage = 1,
	drops = {
		--{name = "", chance = 1, min = 0, max = 1},
	},
	water_damage = 0,
	lava_damage = 5,
	fear_height = 3,
	animation = {
		speed_normal = 20, -- 42
		--stoodup_start = 0,
		--stoodup_end = 0,
		walk_start = 20,
		walk_end = 40,
		stand_start = 50,
		stand_end = 109,
	},
	follow = {
		"mobs:chicken_raw", 
		"mobs:meat_raw",
		"bonemeal:bone", -- sugestão de Lunovox
		"skullkingsitems:bone", -- Ossos do Forgottenmonsters
		
	},
	view_range = 10,
	runaway = true , 

	on_rightclick = function(self, clicker)

		if mobs:feed_tame(self, clicker, 8, true, true) then return end
		if mobs:protect(self, clicker) then return end
		if mobs:capture_mob(self, clicker, 50, 50, 90, false, nil) then return end

		-- by right-clicking owner can switch between staying and walking
		if self.owner and self.owner == clicker:get_player_name() then

			if self.order ~= "stand" then
				self.order = "stand"
				self.state = "stand"
				self.object:set_velocity({x = 0, y = 0, z = 0})
				mobs:set_animation(self, "stand")
			
			else     
				self.order = ""
				mobs:set_animation(self, "walk")
				
			end
		end
	end,

	
})


local spawn_on = "default:dirt_with_grass"

if minetest.get_modpath("ethereal") then
	spawn_on = "ethereal:grove_dirt"
end

if not mobs.custom_spawn_animal then
mobs:spawn({
	name = "dog:dog",
	nodes = {spawn_on},
	neighbors = {"group:grass"},
	min_light = 14,
	interval = 60,
	chance = 10000, -- 22000
	min_height = 5,
	max_height = 50,
	day_toggle = true,
})
end


mobs:register_egg("dog:dog", "Dog", "dog_egg.png", 1)




