mobs/npc.lua

71 lines
1.8 KiB
Lua

-- Npc by TenPlus1
mobs:register_mob("mobs:npc", {
-- animal, monster, npc, barbarian
type = "npc",
-- aggressive, deals 1 damage to player/mob when hit
passive = false,
damage = 1,
attack_type = "dogfight",
attacks_monsters = true,
-- health & armor
hp_min = 10, hp_max = 20, armor = 100,
-- textures and model
collisionbox = {-0.35,-1.0,-0.35, 0.35,0.8,0.35},
visual = "mesh",
mesh = "character.b3d",
drawtype = "front",
available_textures = {
total = 1,
texture_1 = {"mobs_npc.png"},
},
visual_size = {x=1, y=1},
-- sounds
makes_footstep_sound = true,
sounds = {},
-- speed and jump
walk_velocity = 1,
run_velocity = 2,
jump = true,
-- drops wood and chance of apples when dead
drops = {
{name = "default:wood",
chance = 1, min = 1, max = 3},
{name = "default:apple",
chance = 2, min = 1, max = 2},
},
-- damaged by
water_damage = 1,
lava_damage = 2,
light_damage = 0,
-- follow diamond
follow = "default:diamond",
view_range = 15,
-- 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 cooked meat will give npc more health
on_rightclick = function(self, clicker)
local item = clicker:get_wielded_item()
if item:get_name() == "mobs:meat" then
if not minetest.setting_getbool("creative_mode") then
item:take_item()
clicker:set_wielded_item(item)
end
local hp = self.object:get_hp() + 4
if hp > self.hp_max then hp = self.hp_max end
self.object:set_hp(hp)
end
end,
})
-- spawning disabled for now
--mobs:register_spawn("mobs:npc", {"default:dirt_with_grass"}, 20, 0, 7000, 1, 31000)
-- register spawn egg
mobs:register_egg("mobs:npc", "Npc", "default_brick.png", 1)