nssm/mobs/mordain.lua

166 lines
2.9 KiB
Lua
Raw Normal View History

2018-08-08 12:56:14 +03:00
mobs:register_mob("nssm:mordain", {
type = "monster",
hp_max = 32,
hp_min = 23,
collisionbox = {-0.5, -0.3, -0.5, 0.5, 2.7, 0.5},
visual = "mesh",
mesh = "mordain.x",
textures = {
{"mordain.png"}
},
visual_size = {x = 3.5, y = 3.5},
2018-08-08 12:56:14 +03:00
makes_footstep_sound = false,
view_range = 30,
fear_height = 4,
walk_velocity = 1,
run_velocity = 3.5,
2018-08-09 13:57:31 +03:00
rotate = 270,
sounds = {
2018-08-08 12:56:14 +03:00
random = "mordain",
},
damage = 6,
jump = true,
drops = {
{name = "nssm:life_energy", chance = 1, min = 1, max = 1},
{name = "nssm:slothful_soul_fragment", chance = 3, min = 1, max = 1},
2018-08-08 12:56:14 +03:00
},
armor = 80,
drawtype = "front",
water_damage = 0,
lava_damage = 1,
-- light_damage = 2,
group_attack = true,
attack_animals = true,
knock_back = 1,
blood_texture = "morparticle.png",
stepheight = 1.1,
2018-08-08 12:56:14 +03:00
attack_type = "dogfight",
animation = {
speed_normal = 15,
speed_run = 20,
stand_start = 10,
stand_end = 90,
walk_start = 100,
walk_end = 140,
run_start = 170,
run_end = 200,
punch_start = 210,
punch_end = 225,
},
2018-08-08 12:56:14 +03:00
custom_attack = function(self)
self.mordain_timer = self.mordain_timer or os.time()
2018-08-08 12:56:14 +03:00
if (os.time() - self.mordain_timer) > 1 then
2018-08-08 12:56:14 +03:00
self.mordain_timer = os.time()
2018-08-08 14:20:07 +03:00
local s = self.object:get_pos()
local p = self.attack:get_pos()
2018-08-08 12:56:14 +03:00
mobs:set_animation(self, "punch")
2018-08-08 12:56:14 +03:00
if minetest.line_of_sight(
{x = p.x, y = p.y + 1.5, z = p.z},
{x = s.x, y = s.y + 1.5, z = s.z}) == true then
2018-08-08 12:56:14 +03:00
-- play attack sound
if self.sounds.attack then
minetest.sound_play(self.sounds.attack, {
object = self.object,
max_hear_distance = self.sounds.distance
})
end
2018-08-08 12:56:14 +03:00
-- punch player
self.attack:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = self.damage}
2018-08-08 12:56:14 +03:00
}, nil)
end
minetest.after(1, function()
2018-08-08 12:56:14 +03:00
local ty = s.y
local flag = 0
local m = 3
local v = {
x = (p.x - s.x) * m,
y = ty,
z = (p.z - s.z) * m
}
2018-08-08 12:56:14 +03:00
local d = {
x = s.x + v.x,
y = ty,
z = s.z + v.z
}
2018-08-08 12:56:14 +03:00
for j = -3,3 do
2018-08-08 12:56:14 +03:00
ty = d.y + j
local current = minetest.get_node({
x = d.x,
y = ty,
z = d.z}).name
local up = minetest.get_node({
x = d.x,
y = ty + 1,
z = d.z}).name
2018-08-08 12:56:14 +03:00
if up == "air" and current ~= "air" then
2018-08-08 12:56:14 +03:00
d.y = d.y + j+1.5
2018-08-08 12:56:14 +03:00
flag = 1
2018-08-08 12:56:14 +03:00
break
end
end
while flag ~= 1 do
d.x = p.x + math.random(-m, m)
d.z = p.z + math.random(-m, m)
2018-08-08 12:56:14 +03:00
d.y = p.y
2018-08-08 12:56:14 +03:00
local dist = dist_pos(d, p)
if dist >= 2 then
2018-08-08 12:56:14 +03:00
for j = -3,3 do
2018-08-08 12:56:14 +03:00
ty = d.y + j
local current = minetest.get_node({
x = d.x,
y = ty,
z = d.z}).name
local up = minetest.get_node({
x = d.x,
y = ty + 1,
z = d.z}).name
2018-08-08 12:56:14 +03:00
if up == "air" and current ~= "air" then
2018-08-08 12:56:14 +03:00
d.y = d.y + j+1.5
2018-08-08 12:56:14 +03:00
flag = 1
2018-08-08 12:56:14 +03:00
break
end
end
end
end
2018-08-08 14:20:07 +03:00
self.object:set_pos(d)
2018-08-08 12:56:14 +03:00
end)
end
end
})