code:
-- Tree Monster (or Tree Gollum) by PilzAdam
-- some sounds seem to be broken this will also affect the scarecrow.
mobs:register_mob("mobs_creatures:tree_monster", {
	type = "monster",
	passive = false,
	attack_type = "dogfight",
	--specific_attack = {"player", "mobs_animal:chicken"},
	reach = 2,
	damage = 2,
	hp_min = 7,
	hp_max = 15,
	armor = 150,
	collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4},
	visual = "mesh",
	mesh = "mobs_creatures_tree_monster.b3d",
	textures = {
		{"mobs_creatures_tree_monster.png"},
		{"mobs_creatures_tree_monster2.png"},
	},
	blood_texture = "default_wood.png",
	makes_footstep_sound = true,
	sounds = {
		random = "mobs_creatures_dirt_man_random",
		attack = "default_dig_snappy",
		damage = "default_dig_choppy",
		death = "default_place_node_hard",
		jump = "default_wood_footstep",
	},
	walk_velocity = 1,
	run_velocity = 3,
	jump = true,
	view_range = 15,
	drops = {
		{name = "default:tree", chance = 1, min = 0, max = 2},
		{name = "default:sapling", chance = 2, min = 0, max = 2},
		{name = "default:apple", chance = 4, min = 1, max = 2},
	},
	water_damage = 0,
	lava_damage = 0,
	light_damage = 2,
	fall_damage = 0,
	immune_to = {
		{"default:axe_wood", 0}, -- wooden axe doesnt hurt wooden monster
		{"default:axe_stone", 4}, -- axes deal more damage to tree monster
		{"default:axe_bronze", 5},
		{"default:axe_steel", 5},
		{"default:axe_mese", 7},
		{"default:axe_diamond", 9},
		{"default:sapling", -5}, -- default and jungle saplings heal
		{"default:junglesapling", -5},
--		{"all", 0}, -- only weapons on list deal damage
	},
	animation = {
		speed_normal = 15,
		speed_run = 15,
		stand_start = 0,
		stand_end = 24,
		walk_start = 25,
		walk_end = 47,
		run_start = 48,
		run_end = 62,
		punch_start = 48,
		punch_end = 62,
	},
})
-- REGISTER SPAWN PARAMETERS
mobs:spawn_specific("mobs_creatures:tree_monster", {"group:leaves"}, {"air"}, 0, 7, 240, 4000, 1, 0, 100, false)

-- REGISTER SPAWN EGG
mobs:register_egg("mobs_creatures:tree_monster", "Tree Monster", "default_tree_top.png", 1)


code:
--###################
--################### TURTLE
--###################
-- from mobs_mc
--turtle moves on land from 0 to 80
--turtle swims 90 to 170
-- drops seagrass
-- TODO, drops, attributions, swim & land walk, coral&sea spawning.
mobs:register_mob("mobs_creatures:turtle", {
	type = "animal",
	passive = true,
	runaway = true,
	stepheight = 1.2,
	hp_min = 30,
	hp_max = 30,
	armor = 100,
	collisionbox = {-0.35, -0.01, -0.35, 0.35, 1, 0.35},
	visual = "mesh",
	mesh = "mobs_creatures_turtle.b3d",
	textures = {
		{"mobs_creatures_turtle.png"},
	},
	visual_size = {x=3, y=3},
	walk_velocity = 0.6,
	run_velocity = 2,
	jump = false,
	fly = true,
	fly_in = "default:water_source",
	animation = {
	        stand_speed = 25,
	        walk_speed = 25,
		run_speed = 50,
		fly_speed = 25,
		stand_start = 0,
	        stand_end = 0,
		walk_start = 0,
	        walk_end = 80,
		run_start = 0,
	        run_end = 80,
		fly_start = 90,
		fly_end = 170,
	},
})
-- Register spawning parameters.
mobs:spawn_specific("mobs_creatures:turtle", {"default:coral_brown", "default:coral_orange","default:coral_cyan","default:coral_green","default:coral_pink", "decorations_sea:seagrass_02", "decorations_sea:seagrass_03", "decorations_sea:seagrass_05", "decorations_sea:seagrass_06", "decorations_sea:coral_plantlike_01", "decorations_sea:coral_plantlike_02", "decorations_sea:coral_plantlike_03", "decorations_sea:coral_plantlike_04", "decorations_sea:coral_plantlike_05"}, {"default:water_flowing","default:water_source", "default:sand"}, 7, 16, 120, 120, 6, -100, -2)

-- Register spawn egg.
mobs:register_egg("mobs_creatures:turtle", "Turtle Spawn Egg", "default_water.png", 1)

repo_name: korkut/MeseCraft

license: mit


code:
-- Water Man by FreeGamers.org
-- A weak creature made of water that spills upon death.

-- Register mob with Mobs API
mobs:register_mob("mobs_creatures:water_man", {
	type = "monster",
	passive = false,
	attack_type = "dogfight",
	reach = 2,
	damage = 4,
	hp_min = 20,
	hp_max = 20,
	armor = 200,
	collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4},
	visual = "mesh",
        mesh = "mobs_character.b3d",
	textures = {
		{"mobs_creatures_water_man.png"},
	},
	blood_texture = "default_water.png",
	makes_footstep_sound = true,
	sounds = {
		random = "mobs_creatures_dirt_golem_random",
		damage = "default_water_footstep",
		attack = "default_water_footstep",
		jump = "default_water_footstep",
		death = "default_water_footstep",
	},
	view_range = 12,
	walk_velocity = 1,
	run_velocity = 3,
	jump = true,
	knock_back = false,
	suffocation = false,
	floats = true,
	water_damage = 0,
	lava_damage = 0,
	light_damage = 0,
	fall_damage = 0,
	fear_height = 4,
        animation = {
                speed_normal = 30,
                speed_run = 30,
                stand_start = 0,
                stand_end = 79,
                walk_start = 168,
                walk_end = 187,
                run_start = 168,
                run_end = 187,
                punch_start = 200,
                punch_end = 219,
        },
    on_die = function(self, pos) -- on die, spawn a blood source.
	if minetest.get_node(pos).name == "air" then
		minetest.set_node(pos, {name = "default:water_source"})
	end
        self.object:remove()
    end,
})

-- Register Spawn Parameters
mobs:spawn_specific("mobs_creatures:water_man", {"default:water_source", "default:water_flowing"}, {"air"}, 0, 7, 600, 5000, 1, -9500, -500)

-- Register Spawn Egg
mobs:register_egg("mobs_creatures:water_man", "Water Man Spawn Egg", "default_water.png", 1)


code:
-- WOLF MOB
--License for code WTFPL and otherwise stated in readmes
mobs:register_mob("mobs_creatures:wolf", {
	type = "animal",
	hp_min = 10,
	hp_max = 10,
	passive = false,
	group_attack = true,
	collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.84, 0.3},
	visual = "mesh",
	mesh = "mobs_creatures_wolf.b3d",
	textures = {
		{"mobs_creatures_wolf.png"},
	},
	visual_size = {x=3, y=3},
	makes_footstep_sound = true,
	sounds = {
		random = "mobs_creatures_wolf_random",
		damage = "mobs_creatures_wolf_pain",
		death = "mobs_creatures_wolf_death",
		attack = "mobs_creatures_wolf_warcry",
		distance = 16,
	},
	pathfinding = 1,
	floats = 1,
	view_range = 16,
	walk_chance = 50,
	walk_velocity = 2,
	run_velocity = 3,
	stepheight = 1.1,
	damage = 4,
	reach = 2,
	attack_type = "dogfight",
	fear_height = 4,
	water_damage = 0,
	lava_damage = 4,
	light_damage = 0,
	follow = {"mobs_creatures:bone", "mobs_creatures:rotten_flesh", "group:food_meat", "group:food_meat_raw", "group:food_chicken", "group:food_chicken_raw", "group:food_fish", "group:food_fish_raw"},
	on_rightclick = function(self, clicker)
		-- Try to tame wolf (intentionally does NOT use mobs:feed_tame)
		local tool = clicker:get_wielded_item()

		local dog, ent
		if tool:get_name() == "mobs_creatures:bone" then

			if not minetest.settings:get_bool("creative_mode") then
				tool:take_item()
				clicker:set_wielded_item(tool)
			end
			-- 1/3 chance of getting tamed
			if PseudoRandom(os.time()*10):next(1, 3) == 1 then
				local yaw = self.object:get_yaw()
				dog = minetest.add_entity(self.object:getpos(), "mobs_creatures:dog")
				dog:set_yaw(yaw)
				ent = dog:get_luaentity()
				ent.owner = clicker:get_player_name()
				self.object:remove()
			end
		end
	end,
	animation = {
		speed_normal = 50,		speed_run = 100,
		stand_start = 40,		stand_end = 45,
		walk_start = 0,		walk_end = 40,
		run_start = 0,		run_end = 40,
	},
	jump = true,
	attacks_monsters = true,
        -- Make the wolf poop.
        do_custom = function(self, dtime)
                self.egg_timer = (self.egg_timer or 0) + dtime
                if self.egg_timer < 10 then
                       return
                end
                self.egg_timer = 0

                if self.child
                or math.random(1, 100) > 1 then
                        return
                end

                local pos = self.object:get_pos()

                minetest.add_item(pos, "mobs_creatures:poop_turd")

                minetest.sound_play("mobs_creatures_common_poop", {
                        pos = pos,
                        gain = 1.0,
                        max_hear_distance = 8,
                })
        end,
})

-- DOG (TAMED WOLF)
mobs:register_mob("mobs_creatures:dog", {
        type = "animal",
        hp_min = 20,
        hp_max = 20,
        passive = true,
        group_attack = true,
        collisionbox = {-0.3, -0.01, -0.3, 0.3, 0.84, 0.3},
        visual = "mesh",
        mesh = "mobs_creatures_wolf.b3d",
	textures = {
		{"mobs_creatures_wolf_tame.png^(mobs_creatures_wolf_collar.png^[colorize:#0000BB:192)"},
        },
        visual_size = {x=3, y=3},
        makes_footstep_sound = true,
        sounds = {
                random = "mobs_creatures_wolf_random",
                damage = "mobs_creatures_wolf_pain",
                death = "mobs_creatures_wolf_death",
                attack = "mobs_creatures_wolf_warcry",
                distance = 16,
        },
        pathfinding = 1,
        floats = 1,
        view_range = 16,
        walk_chance = 50,
        walk_velocity = 2,
        run_velocity = 3,
        stepheight = 1.1,
        damage = 4,
        reach = 2,
        attack_type = "dogfight",
        fear_height = 4,
        water_damage = 0,
        lava_damage = 4,
        light_damage = 0,
        follow = {"mobs_creatures:bone", "mobs_creatures:rotten_flesh", "group:food_meat", "group:food_meat_raw", "group:food_chicken", "group:food_chicken_raw", "group:food_fish", "group:food_fish_raw"},
	owner_loyal = true,
        animation = {
                speed_normal = 50,              speed_run = 100,
                stand_start = 40,               stand_end = 45,
                walk_start = 0,         walk_end = 40,
                run_start = 0,          run_end = 40,
        },
        jump = true,
        attacks_monsters = true,
	on_rightclick = function(self, clicker)
	        local item = clicker:get_wielded_item()

	        if mobs:protect(self, clicker) then
	                return
	        elseif item:get_name() ~= "" and mobs:capture_mob(self, clicker, 0, 2, 80, false, nil) then
	                return
		elseif item:get_name() == "mobs_creatures:bone" then
	                -- Feed to increase health
	                local hp = self.health
	                local hp_add = 5
	                -- Use eatable group to determine health boost
	                local eatable = minetest.get_item_group(item, "eatable")
	                if eatable > 0 then
	                        hp_add = eatable
	                elseif item:get_name() == "mobs_creatures:rotten_flesh" or minetest.get_item_group(item:get_name(), "food_meat_raw") == 1 or minetest.get_item_group(item:get_name(), "food_meat") == 1 or minetest.get_item_group(item:get_name(), "food_chicken") == 1 or minetest.get_item_group(item:get_name(), "food_chicken_raw") == 1 or minetest.get_item_group(item:get_name(), "food_fish_raw") == 1 or minetest.get_item_group(item:get_name(), "food_fish") == 1 then
	                        hp_add = 4
	                else
	                        hp_add = 4
	                end
	                local new_hp = hp + hp_add
	                if new_hp > self.hp_max then
	                        new_hp = self.hp_max
	                end
	                if not minetest.settings:get_bool("creative_mode") then
	                        item:take_item()
	                        clicker:set_wielded_item(item)
	                end
	                self.health = new_hp
	                return
--	        elseif minetest.get_item_group(item:get_name(), "dye") == 1 then
--	                -- Dye (if possible)
--	                for group, _ in pairs(colors) do
--	                        -- Check if color is supported
--	                        if minetest.get_item_group(item:get_name(), group) == 1 then
--	                                -- Dye collar
--	                                local tex = get_dog_textures(group)
--	                                if tex then
--	                                        self.base_texture = tex
--	                                        self.object:set_properties({
--	                                                textures = self.base_texture
--	                                        })
--	                                        if not minetest.settings:get_bool("creative_mode") then
--	                                                item:take_item()
--	                                                clicker:set_wielded_item(item)
--	                                        end
--	                                        break
--	                                end
--	                        end
--	                end
		        else
	                -- Toggle sitting order

	                if not self.owner or self.owner == "" then
	                        -- Huh? This wolf has no owner? Let's fix this! This should never happen.
	                        self.owner = clicker:get_player_name()
	                end

	                if not self.order or self.order == "" or self.order == "sit" then
	                        self.order = "roam"
	                        self.walk_chance = 50
	                        self.jump = true
	                else
	                        -- TODO: Add sitting model
	                        self.order = "sit"
	                        self.walk_chance = 0
	                        self.jump = false
	                end
	        end
	end,
        -- Make the poopy puppy poop.
        do_custom = function(self, dtime)
                self.egg_timer = (self.egg_timer or 0) + dtime
                if self.egg_timer < 10 then
                       return
                end
                self.egg_timer = 0

                if self.child
                or math.random(1, 100) > 1 then
                        return
                end

                local pos = self.object:get_pos()

                minetest.add_item(pos, "mobs_creatures:poop_turd")

                minetest.sound_play("mobs_creatures_common_poop", {
                        pos = pos,
                        gain = 1.0,
                        max_hear_distance = 8,
                })
        end,

	-- follow function
	function(dist, teleport_check_interval)
	return function(self, dtime)
		-- No teleportation if no owner or if sitting
		if not self.owner or self.order == "sit" then
			return
		end
		if not teleport_check_interval then
			teleport_check_interval = 2
		end
		if not dist then
			dist = 8
		end
		if self._teleport_timer == nil then
			self._teleport_timer = teleport_check_interval
			return
		end
		self._teleport_timer = self._teleport_timer - dtime
		if self._teleport_timer <= 0 then
			self._teleport_timer = teleport_check_interval
			local mob_pos = self.object:getpos()
			local owner = minetest.get_player_by_name(self.owner)
			if not owner then
				-- No owner found, no teleportation
				return
			end
			local owner_pos = owner:getpos()
			local dist_from_owner = vector.distance(owner_pos, mob_pos)
			if dist_from_owner > dist then
				-- Check for nodes below air in a 5×1×5 area around the owner position
				local check_offsets = table.copy(offsets)
				-- Attempt to place mob near player. Must be placed on walkable node below a non-walkable one. Place inside that air node.
				while #check_offsets > 0 do
					local r = pr:next(1, #check_offsets)
					local telepos = vector.add(owner_pos, check_offsets[r])
					local telepos_below = {x=telepos.x, y=telepos.y-1, z=telepos.z}
					table.remove(check_offsets, r)
					-- Long story short, spawn on a platform
					if minetest.registered_nodes[minetest.get_node(telepos).name].walkable == false and
							minetest.registered_nodes[minetest.get_node(telepos_below).name].walkable == true then
						-- Correct position found! Let's teleport.
						self.object:setpos(telepos)
						return
					end
				end
			end
		end
	end
end,

})

-- Collar colors for dog.
--local colors = {
--	["color_black"] = "#000000",
--	["color_blue"] = "#0000BB",
--	["color_brown"] = "#663300", -- brown
--	["color_cyan"] = "#01FFD8",
--	["color_dark_green"] = "#005B00",
--	["color_grey"] = "#C0C0C0",
--	["color_darkgrey"] = "#303030",
--	["color_green"] = "#00FF01",
--	["color_magenta"] = "#FF05BB", -- magenta
--	["color_orange"] = "#FF8401",
--	["color_pink"] = "#FF65B5", -- pink
--	["color_red"] = "#FF0000",
--	["color_violet"] = "#5000CC",
--	["color_white"] = "#FFFFFF",
--	["color_yellow"] = "#FFFF00",
--}
--local get_dog_textures = function(color)
--	if colors[color] then
--		return {"mobs_creatures_wolf_tame.png^(mobs_creatures_wolf_collar.png^[colorize:"..colors[color]..":192)"}
--	else
--		return nil
--	end
--end

-- Tamed wolf texture + red collar
--dog.textures = get_dog_textures("color_red")

-- Register Spawn Parameters
mobs:spawn_specific("mobs_creatures:wolf", {"default:dirt_with_grass", "default:dirt_with_rainforest_litter", "default:dirt", "default:dirt_with_snow", "default:snow", "default:snowblock", "ethereal:prairie_dirt"}, {"air"}, 1, 8, 240, 6000, 2, 3, 100)

-- Register Spawn Egg
mobs:register_egg("mobs_creatures:wolf", "Wolf Spawn Egg", "wool_white.png", 1)


code:
mobs:register_mob('mobs_creatures:zombie', {
	type = "monster",
	passive = false,
	attack_type = "dogfight",
	reach = 2,
	damage = 8,
	hp_min = 20,
	hp_max = 30,
	armor = 100,
	knock_back = true,
        collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
        visual = "mesh",
        mesh = "mobs_character.b3d",
        textures = {
                {"mobs_creatures_zombie.png"},
        },
	blood_texture = "mobs_blood.png",
	makes_footstep_sound = true,
	sounds = {
		random ="mobs_creatures_zombie_random",
		warcry = "mobs_creatures_zombie_warcry",
		attack = "mobs_creatures_zombie_attack",
		damage = "mobs_creatures_zombie_damage",
		death = "mobs_creatures_zombie_death",
	},
	walk_velocity = 1,
	run_velocity = 2.75,
	jump = true,
	floats = true,
	suffocation = true,
	view_range = 16,
	drops = {
	{name = "mobs_creatures:rotten_flesh", chance = 1, min = 0, max = 1},
	{name = "mobs_creatures:bone", chance = 2, min = 0, max = 1},
	},
	lava_damage = 5,
	water_damage = 2,
	light_damage = 5,
	fall_damage = 2,
        animation = {
                speed_normal = 30,
                speed_run = 30,
                stand_start = 0,
                stand_end = 79,
                walk_start = 168,
                walk_end = 187,
                run_start = 168,
                run_end = 187,
                punch_start = 200,
                punch_end = 219,
        },
})

--Spawn Functions
mobs:spawn_specific("mobs_creatures:zombie", {"default:dirt_with_grass","default:dirt","default:stone"}, {"air"}, 0, 7, 60, 2000, 4, -500 ,100)

--Spawn Eggs
mobs:register_egg("mobs_creatures:zombie", "Zombie Spawn Egg", "wool_red.png", 1)


code:
--Space Zombie
mobs:register_mob('mobs_creatures:space_zombie', {
	type = "monster",
	passive = false,
	attack_type = "dogfight",
	reach = 2,
	damage = 6,
	hp_min = 15,
	hp_max = 20,
	armor = 115,
	knock_back = true,
        collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
        visual = "mesh",
        mesh = "mobs_character.b3d",
        textures = {
                {"mobs_creatures_zombie_space.png"},
        },
	blood_texture = "mobs_blood.png",
	makes_footstep_sound = true,
	sounds = {
		random ="mobs_creatures_zombie_random",
		warcry = "mobs_creatures_zombie_warcry",
		attack = "mobs_creatures_zombie_attack",
		damage = "mobs_creatures_zombie_damage",
		death = "mobs_creatures_zombie_death",
	},
	walk_velocity = 1,
	run_velocity = 3,
	jump = true,
	floats = true,
	suffocation = false,
	view_range = 16,
	drops = {
	{name = "mobs_creatures:rotten_flesh", chance = 5, min = 0, max = 1}
	},
	lava_damage = 5,
	water_damage = 2,
	light_damage = 0,
	fall_damage = 2,
        animation = {
                speed_normal = 30,
                speed_run = 30,
                stand_start = 0,
                stand_end = 79,
                walk_start = 168,
                walk_end = 187,
                run_start = 168,
                run_end = 187,
                punch_start = 200,
                punch_end = 219,
        },
})

--Spawn Functions
mobs:spawn_specific("mobs_creatures:space_zombie", {"default:gravel"}, {"vacuum:vacuum"}, 0, 15, 480, 1000, 2, 3000, 3500)

--Spawn Eggs
mobs:register_egg("mobs_creatures:space_zombie", "Space Zombie Spawn Egg", "wool_red.png", 1)


code:
name = mobs_creatures
description = Mob pack meant to bring higher quality mobs to Minetest
author = FreeGamers
depends = mobs
optional_depends = hbhunger, signs


code:
local S = mobs.intllib

-- Igor by TenPlus1

mobs.igor_drops = {
	"vessels:glass_bottle", "mobs:meat_raw", "default:sword_steel",
	"farming:bread", "mesecraft_bucket:bucket_water"
}

mobs:register_mob("mobs_npc:igor", {
	type = "npc",
	passive = false,
	damage = 5,
	attack_type = "dogfight",
	owner_loyal = true,
	pathfinding = true,
	reach = 2,
	attacks_monsters = true,
	hp_min = 20,
	hp_max = 30,
	armor = 100,
	collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
	visual = "mesh",
	mesh = "mobs_character.b3d",
	textures = {
		{"mobs_igor.png"}, -- skin by ruby32199
		{"mobs_igor2.png"},
		{"mobs_igor3.png"},
		{"mobs_igor4.png"},
		{"mobs_igor5.png"},
		{"mobs_igor6.png"},
		{"mobs_igor7.png"},
		{"mobs_igor8.png"},
	},
	makes_footstep_sound = true,
	sounds = {},
	walk_velocity = 1,
	run_velocity = 2,
	stepheight = 1.1,
	fear_height = 2,
	jump = true,
	drops = {
		{name = "mobs:meat_raw", chance = 1, min = 1, max = 2},
		{name = "default:gold_lump", chance = 3, min = 1, max = 1},
	},
	water_damage = 1,
	lava_damage = 3,
	light_damage = 0,
	follow = {"mobs:meat_raw", "default:diamond"},
	view_range = 15,
	owner = "",
	order = "follow",
	-- model animation
	animation = {
		speed_normal = 30,
		speed_run = 30,
		stand_start = 0,
		stand_end = 79,
		walk_start = 168,
		walk_end = 187,
		run_start = 168,
		run_end = 187,
		punch_start = 200,
		punch_end = 219,
	},
	-- right clicking with raw meat will give Igor more health
	on_rightclick = function(self, clicker)

		-- feed to heal npc
		if mobs:feed_tame(self, clicker, 8, false, true) then return end
		if mobs:protect(self, clicker) then return end
		if mobs:capture_mob(self, clicker, nil, 5, 80, false, nil) then return end

		local item = clicker:get_wielded_item()
		local name = clicker:get_player_name()

		-- right clicking with gold lump drops random item from mobs.npc_drops
		if item:get_name() == "default:gold_lump" then

			if not mobs.is_creative(name) then
				item:take_item()
				clicker:set_wielded_item(item)
			end

			local pos = self.object:get_pos()

			pos.y = pos.y + 0.5

			local drops = self.igor_drops or mobs.igor_drops

			minetest.add_item(pos, {
				name = drops[math.random(1, #drops)]
			})

			minetest.chat_send_player(name, S("NPC dropped you an item for gold!"))

			return
		end

		-- if owner switch between follow and stand
		if self.owner and self.owner == name then

			if self.order == "follow" then
				self.order = "stand"
				minetest.chat_send_player(name, S("NPC stands still."))
			else
				self.order = "follow"
				minetest.chat_send_player(name, S("NPC will follow you."))
			end
		end
	end,
})
-- register spawn egg
mobs:register_egg("mobs_npc:igor", S("Igor"), "mobs_meat_raw.png", 1)

-- compatibility
mobs:alias_mob("mobs:igor", "mobs_npc:igor")


code:
local path = minetest.get_modpath("mobs_npc")

-- NPC
dofile(path .. "/npc.lua") -- TenPlus1
dofile(path .. "/trader.lua")
dofile(path .. "/igor.lua")

-- Print mod status in log
print ("[MOD] Mobs Redo 'NPCs' loaded")


code:
# German Translation for mobs_npc mod
# Deutsche Übersetzung der mobs_npc Mod
# last update: 2016/June/10
# Author: Xanthin

#init.lua
[MOD] Mobs Redo 'NPCs' loaded = [MOD] Mobs Redo 'NPCs' geladen

#npc.lua
NPC dropped you an item for gold! = NSC ließ dir für Gold einen Gegenstand fallen!
NPC stands still. = NSC bleibt stehen.
NPC will follow you. = NSC wird dir folgen.
Npc = Nsc

#trader.lua
Trader @1 = Händler @1
[NPC] <Trader @1 > Hello, @2, have a look at my wares. = [NSC] <Händler @1 > Hallo, @2, wirf einen Blick auf meine Waren.
Trader @1's stock: = Händler @1s Warenlager
Selection = Auswahl
Price = Preis
Payment = Bezahlung
Bought items = Ware
Trader = Händler


code:
# Malay translations of mobs_npc mod
# using template from 2016/June/10, translated on 2018/February/05

#init.lua
[MOD] Mobs Redo 'NPCs' loaded = [MODS] Mobs Redo 'NPCs' telah dimuatkan

#npc.lua
NPC dropped you an item for gold! = NPC jatuhkan item untuk anda apabila dibayar dengan emas!
NPC stands still. = NPC berdiri diam.
NPC will follow you. = NPC akan mengikut anda.
Npc = Npc

#trader.lua
Trader @1 = Pedagang @1
[NPC] <Trader @1 > Hello, @2, have a look at my wares. = [NPC] <Pedagang @1 > Helo @2, lihatlah barangan saya.
Trader @1's stock: = Stok pedagang @1:
Selection = Pilihan
Price = Harga
Payment = Bayaran
Bought items = Item dibeli
Trader = Pedagang


code:
# Template for translations of mobs_npc mod
# last update: 2016/June/10

#init.lua
[MOD] Mobs Redo 'NPCs' loaded =

#npc.lua
NPC dropped you an item for gold! =
NPC stands still. =
NPC will follow you. =
Npc =

#trader.lua
Trader @1 =
[NPC] <Trader @1 > Hello, @2, have a look at my wares. =
Trader @1's stock: =
Selection =
Price =
Payment =
Bought items =
Trader =


code:
name = mobs_npc
author = TenPlus1
title = Mobs NPC
description = Adds simple NPC and Trader.
depends = default, mobs
optional_depends = intllib, lucky_block


code:
local S = mobs.intllib

-- Npc by TenPlus1

mobs.npc_drops = {
	"default:pick_steel", "mobs:meat", "default:sword_steel",
	"default:shovel_steel", "farming:bread", "mesecraft_bucket:bucket_water"
}

mobs:register_mob("mobs_npc:npc", {
	type = "npc",
	passive = false,
	damage = 3,
	attack_type = "dogfight",
	attacks_monsters = true,
	attack_npcs = false,
	owner_loyal = true,
	pathfinding = true,
	hp_min = 10,
	hp_max = 20,
	armor = 100,
	collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
	visual = "mesh",
	mesh = "mobs_character.b3d",
	drawtype = "front",
	textures = {
		{"mobs_npc.png"},
		{"mobs_npc2.png"}, -- female by nuttmeg20
	},
	child_texture = {
		{"mobs_npc_baby.png"}, -- derpy baby by AmirDerAssassine
	},
	makes_footstep_sound = true,
	sounds = {},
	walk_velocity = 2,
	run_velocity = 3,
	jump = true,
	drops = {
		{name = "default:wood", chance = 1, min = 1, max = 3},
		{name = "default:apple", chance = 2, min = 1, max = 2},
		{name = "default:axe_stone", chance = 5, min = 1, max = 1},
	},
	water_damage = 0,
	lava_damage = 2,
	light_damage = 0,
	follow = {"farming:bread", "mobs:meat", "default:diamond"},
	view_range = 15,
	owner = "",
	order = "follow",
	fear_height = 3,
	animation = {
		speed_normal = 30,
		speed_run = 30,
		stand_start = 0,
		stand_end = 79,
		walk_start = 168,
		walk_end = 187,
		run_start = 168,
		run_end = 187,
		punch_start = 200,
		punch_end = 219,
	},
	on_rightclick = function(self, clicker)

		-- feed to heal npc
		if mobs:feed_tame(self, clicker, 8, true, true) then return end

		-- capture npc with net or lasso
		if mobs:capture_mob(self, clicker, nil, 5, 80, false, nil) then return end

		-- protect npc with mobs:protector
		if mobs:protect(self, clicker) then return end

		local item = clicker:get_wielded_item()
		local name = clicker:get_player_name()

		-- right clicking with gold lump drops random item from mobs.npc_drops
		if item:get_name() == "default:gold_lump" then

			if not mobs.is_creative(name) then
				item:take_item()
				clicker:set_wielded_item(item)
			end

			local pos = self.object:get_pos()

			pos.y = pos.y + 0.5

			local drops = self.npc_drops or mobs.npc_drops

			minetest.add_item(pos, {
				name = drops[math.random(1, #drops)]
			})

			minetest.chat_send_player(name, S("NPC dropped you an item for gold!"))

			return
		end

		-- by right-clicking owner can switch npc between follow and stand
		if self.owner and self.owner == name then

			if self.order == "follow" then
				self.order = "stand"

				minetest.chat_send_player(name, S("NPC stands still."))
			else
				self.order = "follow"

				minetest.chat_send_player(name, S("NPC will follow you."))
			end
		end

	end,
})

mobs:spawn({
	name = "mobs_npc:npc",
	nodes = {"default:brick"},
	neighbors = {"default:grass_3"},
	min_light = 10,
	chance = 10000,
	active_object_count = 1,
	min_height = 0,
	day_toggle = true,
})

mobs:register_egg("mobs_npc:npc", S("Npc"), "default_brick.png", 1)

-- compatibility
mobs:alias_mob("mobs:npc", "mobs_npc:npc")


code:
NPC MOBS

NPC

- While NPC's don't actually spawn in the world just yet, they do have a spawn egg available to drop him/her into the world and wander around defending himself if attacked.  It will also he will help you attack any monsters in the area and will follow you if you hold a diamond. Right-clicking the NPC with a gold lump will make him drop steel tools or food, right-clicking with an empty hand orders the NPC to stay or follow if owned.

Trader

- Traders are new and still being tested but can be placed into the world using a spawn egg. Right-clicking on a trader opens his shop and allows you to buy his wares inside.  If provoked a trader will attack a player or monster.

Note: self.npc_drops and self.igor_drops are used for random item list when trading for gold and may be changed within the mob itself, if not found the global mobs.npc_drops and mobs.igor_drops are used instead for a default list.

Lucky Blocks: 4


code:
-- edited this version to not have nametags on the HUD.

local S = mobs.intllib

-- define table containing names for use and shop items for sale

mobs.human = {

	names = {
		"Bob", "Duncan", "Bill", "Tom", "James", "Ian", "Lenny",
		"Dylan", "Ethan"
	},

	items = {
		--{item for sale, price, chance of appearing in trader's inventory}
		{"default:apple 10", "default:gold_ingot 2", 10},
		{"farming:bread 10", "default:gold_ingot 4", 5},
		{"default:clay 10", "default:gold_ingot 2", 12},
		{"default:brick 10", "default:gold_ingot 4", 17},
		{"default:glass 10", "default:gold_ingot 4", 17},
		{"default:obsidian 10", "default:gold_ingot 15", 50},
		{"default:diamond 1", "default:gold_ingot 5", 40},
		{"farming:wheat 10", "default:gold_ingot 2", 17},
		{"default:tree 5", "default:gold_ingot 4", 20},
		{"default:stone 10", "default:gold_ingot 8", 17},
		{"default:desert_stone 10", "default:gold_ingot 8", 27},
		{"default:sapling 1", "default:gold_ingot 1", 7},
		{"default:pick_steel 1", "default:gold_ingot 2", 7},
		{"default:sword_steel 1", "default:gold_ingot 2", 17},
		{"default:shovel_steel 1", "default:gold_ingot 1", 17},
		{"default:cactus 2", "default:gold_ingot 2", 40},
		{"default:papyrus 2", "default:gold_ingot 2", 40},
		{"default:mese_crystal_fragment 1", "default:dirt_with_grass 10", 90},
		{"default:mese_crystal_fragment 1", "default:gold_ingot 5", 90},
	}
}

mobs.lunar_human = {

	names = { "Neil", "Yuri", "Buzz", "Alan", "James" },
	items = {
                --{item for sale, price, chance of appearing in trader's inventory}
		{"vacuum:air_bottle 10", "default:gold_ingot 1", 4},
		{"vacuum:airpump 1", "default:gold_ingot 4", 4},
		{"spacesuit:chestplate 1", "default:gold_ingot 4", 4},
		{"spacesuit:helmet 1", "default:gold_ingot 2", 4},
		{"spacesuit:pants 1", "default:gold_ingot 2", 4},
		{"spacesuit:boots 1", "default:gold_ingot 2", 4},
		{"farming:tomato 12", "default:gold_ingot 1", 4},
		{"farming:potato 12", "default:gold_ingot 1", 4},
		{"drinks:jbo_tomato 6", "default:gold_ingot 1", 4},
		}
	}

-- Trader ( same as NPC but with right-click shop )

mobs:register_mob("mobs_npc:trader", {
	type = "npc",
	passive = false,
	damage = 3,
	attack_type = "dogfight",
	attacks_monsters = true,
	attack_animals = false,
	attack_npcs = false,
	pathfinding = false,
	hp_min = 10,
	hp_max = 20,
	armor = 100,
	collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
	visual = "mesh",
	mesh = "mobs_character.b3d",
	textures = {
		{"mobs_trader.png"}, -- by Frerin
		{"mobs_trader2.png"},
		{"mobs_trader3.png"},
	},
	makes_footstep_sound = true,
	sounds = {},
	walk_velocity = 2,
	run_velocity = 3,
	jump = false,
	drops = {},
	water_damage = 0,
	lava_damage = 4,
	light_damage = 0,
	follow = {"default:diamond"},
	view_range = 15,
	owner = "",
	order = "stand",
	fear_height = 3,
	animation = {
		speed_normal = 30,
		speed_run = 30,
		stand_start = 0,
		stand_end = 79,
		walk_start = 168,
		walk_end = 187,
		run_start = 168,
		run_end = 187,
		punch_start = 200,
		punch_end = 219,
	},
	on_rightclick = function(self, clicker)
		mobs_trader(self, clicker, entity, mobs.human)
	end,
})

--This code comes almost exclusively from the trader and inventory of mobf, by Sapier.
--The copyright notice below is from mobf:
-------------------------------------------------------------------------------
-- Mob Framework Mod by Sapier
--
-- You may copy, use, modify or do nearly anything except removing this
-- copyright notice.
-- And of course you are NOT allow to pretend you have written it.
--
--! @file inventory.lua
--! @brief component containing mob inventory related functions
--! @copyright Sapier
--! @author Sapier
--! @date 2013-01-02
--
--! @defgroup Inventory Inventory subcomponent
--! @brief Component handling mob inventory
--! @ingroup framework_int
--! @{
--
-- Contact sapier a t gmx net
-------------------------------------------------------------------------------

-- This code has been heavily modified by isaiah658.
-- Trades are saved in entity metadata so they always stay the same after
-- initially being chosen.  Also the formspec uses item image buttons instead of
-- inventory slots.

function mobs.add_goods(self, entity, race)

	local trade_index = 1
	local trades_already_added = {}
	local trader_pool_size = 10
	local item_pool_size = #race.items -- get number of items on list

	self.trades = {}

	if item_pool_size < trader_pool_size then
		trader_pool_size = item_pool_size
	end

	for i = 1, trader_pool_size do

		-- If there are more trades than the amount being added, they are
		-- randomly selected.  If they are equal, there is no reason to randomly
		-- select them
		local random_trade = nil

		if item_pool_size == trader_pool_size then
			random_trade = i
		else
			while random_trade == nil do

				local num = math.random(item_pool_size)

				if trades_already_added[num] == nil then
					trades_already_added[num] = true
					random_trade = num
				end
			end
		end

		if math.random(0, 100) > race.items[random_trade][3] then

			self.trades[trade_index] = {
				race.items[random_trade][1],
				race.items[random_trade][2]}

			trade_index = trade_index + 1
		end
	end
end

function mobs_trader(self, clicker, entity, race)

	if not self.id then
		self.id = (math.random(1, 1000) * math.random(1, 10000))
			.. self.name .. (math.random(1, 1000) ^ 2)
	end

	if not self.game_name then

		self.game_name = tostring(race.names[math.random(1, #race.names)])
		self.nametag = S("Trader @1", self.game_name)

	end

	if self.trades == nil then
		mobs.add_goods(self, entity, race)
	end

	local player = clicker:get_player_name()

	minetest.chat_send_player(player,
		S("[NPC] <Trader @1> Hello, @2, have a look at my wares.",
		self.game_name, player))

	-- Make formspec trade list
	local formspec_trade_list = ""
	local x, y

	for i = 1, 10 do

		if self.trades[i] and self.trades[i] ~= "" then

			if i < 6 then
				x = 0.5
				y = i - 0.5
			else
				x = 4.5
				y = i - 5.5
			end

			formspec_trade_list = formspec_trade_list
			.. "item_image_button[".. x ..",".. y ..";1,1;"
				.. self.trades[i][2] .. ";prices#".. i .."#".. self.id ..";]"
			.. "item_image_button[".. x + 2 ..",".. y ..";1,1;"
				.. self.trades[i][1] .. ";goods#".. i .."#".. self.id ..";]"
			.. "image[".. x + 1 ..",".. y ..";1,1;gui_arrow_blank.png]"
		end
	end

	minetest.show_formspec(player, "mobs_npc:trade", "size[8,10]"
		.. default.gui_bg_img
		.. default.gui_slots
		.. "label[0.5,-0.1;" .. S("Trader @1's stock:", self.game_name) .. "]"
		.. formspec_trade_list
		.. "list[current_player;main;0,6;8,4;]"
	)
end

minetest.register_on_player_receive_fields(function(player, formname, fields)

	if formname ~= "mobs_npc:trade" then return end

	if fields then

		local trade = ""

		for k, v in pairs(fields) do
			trade = tostring(k)
		end

		local id = trade:split("#")[3]
		local self = nil

		if id ~= nil then

			for k, v in pairs(minetest.luaentities) do

				if v.object and v.id and v.id == id then
					self = v
					break
				end
			end
		end

		if self ~= nil then

			local trade_number = tonumber(trade:split("#")[2])

			if trade_number ~= nil and self.trades[trade_number] ~= nil then

				local price = self.trades[trade_number][2]
				local goods = self.trades[trade_number][1]
				local inv = player:get_inventory()

				if inv:contains_item("main", price) then

					inv:remove_item("main", price)

					local leftover = inv:add_item("main", goods)

					if leftover:get_count() > 0 then

						-- drop item(s) in front of player
						local droppos = player:get_pos()
						local dir = player:get_look_dir()

						droppos.x = droppos.x + dir.x
						droppos.z = droppos.z + dir.z

						minetest.add_item(droppos, leftover)
					end
				end
			end
		end
	end
end)

mobs:register_egg("mobs_npc:trader", S("Trader"), "default_sandstone.png", 1)

-- compatibility
mobs:alias_mob("mobs:trader", "mobs_npc:trader")