forked from epCode/extra_mobs
113 lines
2.8 KiB
Lua
113 lines
2.8 KiB
Lua
|
--MCmobs v0.4
|
||
|
--maikerumine
|
||
|
--made for MC like Survival game
|
||
|
--License for code WTFPL and otherwise stated in readmes
|
||
|
|
||
|
local S = minetest.get_translator("extra_mobs")
|
||
|
local mod_bows = minetest.get_modpath("mcl_bows") ~= nil
|
||
|
|
||
|
--###################
|
||
|
--################### piglin
|
||
|
--###################
|
||
|
|
||
|
local piglin = {
|
||
|
type = "monster",
|
||
|
passive = false,
|
||
|
spawn_class = "hostile",
|
||
|
hp_min = 16,
|
||
|
hp_max = 16,
|
||
|
xp_min = 9,
|
||
|
xp_max = 9,
|
||
|
armor = {fleshy = 90},
|
||
|
damage = 4,
|
||
|
reach = 3,
|
||
|
collisionbox = {-.6, -0.01, -.6, .6, 1.4, .6},
|
||
|
visual = "mesh",
|
||
|
mesh = "extra_mobs_piglin.b3d",
|
||
|
textures = { {
|
||
|
"extra_mobs_piglin.png",
|
||
|
"mcl_bows_crossbow_2.png",
|
||
|
} },
|
||
|
visual_size = {x=1, y=1},
|
||
|
sounds = {
|
||
|
random = "extra_mobs_piglin",
|
||
|
damage = "extra_mobs_piglin_hurt",
|
||
|
distance = 16,
|
||
|
},
|
||
|
jump = true,
|
||
|
makes_footstep_sound = true,
|
||
|
walk_velocity = 4.317,
|
||
|
run_velocity = 5.6121,
|
||
|
drops = {
|
||
|
{name = "mcl_mobsitems:leather",
|
||
|
chance = 1,
|
||
|
min = 0,
|
||
|
max = 1,},
|
||
|
},
|
||
|
drops = {
|
||
|
{name = "mcl_mobitems:porkchop",
|
||
|
chance = 1,
|
||
|
min = 2,
|
||
|
max = 4,},
|
||
|
},
|
||
|
animation = {
|
||
|
stand_speed = 30,
|
||
|
walk_speed = 30,
|
||
|
run_speed = 30,
|
||
|
stand_start = 0,
|
||
|
stand_end = 79,
|
||
|
walk_start = 168,
|
||
|
walk_end = 187,
|
||
|
run_start = 440,
|
||
|
run_end = 459,
|
||
|
},
|
||
|
fear_height = 4,
|
||
|
view_range = 16,
|
||
|
on_spawn = function(self)
|
||
|
self.object:set_bone_position("Wield_Item", vector.new(-1.5,7,1.5), vector.new(170,90,90))
|
||
|
end,
|
||
|
do_custom = function(self)
|
||
|
if self.state ~= "attack" then
|
||
|
self._attacked_by_player = false
|
||
|
end
|
||
|
if self.state == "attack" and self.attack:is_player() then
|
||
|
for i=1, 6 do
|
||
|
local stack = self.attack:get_inventory():get_stack("armor", i)
|
||
|
local item = stack:get_name()
|
||
|
if item == "mcl_armor:chestplate_gold" or item == "mcl_armor:leggings_gold" or item == "mcl_armor:helmet_gold" or item == "mcl_armor:boots_gold" then
|
||
|
if self._attacked_by_player == false then
|
||
|
self.state = "stand"
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end,
|
||
|
do_punch = function(self, hitter)
|
||
|
if hitter:is_player() then
|
||
|
self._attacked_by_player = true
|
||
|
end
|
||
|
end,
|
||
|
attack_type = "dogshoot",
|
||
|
arrow = "mcl_bows:arrow_entity",
|
||
|
shoot_arrow = function(self, pos, dir)
|
||
|
if mod_bows then
|
||
|
-- 2-4 damage per arrow
|
||
|
local dmg = math.max(4, math.random(2, 8))
|
||
|
mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
|
||
|
end
|
||
|
end,
|
||
|
shoot_interval = 1.2,
|
||
|
shoot_offset = 1.5,
|
||
|
dogshoot_switch = 1,
|
||
|
dogshoot_count_max =1.8,
|
||
|
}
|
||
|
|
||
|
mobs:register_mob("extra_mobs:piglin", piglin)
|
||
|
|
||
|
|
||
|
-- Regular spawning in the Nether
|
||
|
mobs:spawn_specific("extra_mobs:piglin", {"mcl_nether:netherrack"}, {"air"}, 0, minetest.LIGHT_MAX+1, 30, 6000, 3, mcl_vars.mg_nether_min, mcl_vars.mg_nether_max)
|
||
|
|
||
|
-- spawn eggs
|
||
|
mobs:register_egg("extra_mobs:piglin", S("piglin"), "extra_mobs_spawn_icon_piglin.png", 0)
|