mordain.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. mobs:register_mob("nssm:mordain", {
  2. type = "monster",
  3. hp_max = 32,
  4. hp_min = 23,
  5. collisionbox = {-0.5, -0.3, -0.5, 0.5, 2.7, 0.5},
  6. visual = "mesh",
  7. mesh = "mordain.x",
  8. textures = {
  9. {"mordain.png"}
  10. },
  11. visual_size = {x = 3.5, y = 3.5},
  12. makes_footstep_sound = false,
  13. view_range = 30,
  14. fear_height = 4,
  15. walk_velocity = 1,
  16. run_velocity = 3.5,
  17. rotate = 270,
  18. sounds = {
  19. random = "mordain",
  20. },
  21. damage = 6,
  22. jump = true,
  23. drops = {
  24. {name = "nssm:life_energy", chance = 1, min = 1, max = 1},
  25. {name = "nssm:slothful_soul_fragment", chance = 3, min = 1, max = 1},
  26. },
  27. armor = 80,
  28. drawtype = "front",
  29. water_damage = 0,
  30. lava_damage = 1,
  31. fire_damage = 1,
  32. -- light_damage = 2,
  33. group_attack = true,
  34. attack_animals = true,
  35. knock_back = 1,
  36. blood_texture = "morparticle.png",
  37. stepheight = 1.1,
  38. attack_type = "dogfight",
  39. animation = {
  40. speed_normal = 15,
  41. speed_run = 20,
  42. stand_start = 10,
  43. stand_end = 90,
  44. walk_start = 100,
  45. walk_end = 140,
  46. run_start = 170,
  47. run_end = 200,
  48. punch_start = 210,
  49. punch_end = 225,
  50. },
  51. custom_attack = function(self)
  52. self.mordain_timer = self.mordain_timer or os.time()
  53. if (os.time() - self.mordain_timer) > 1 then
  54. self.mordain_timer = os.time()
  55. local s = self.object:get_pos()
  56. local p = self.attack:get_pos()
  57. mobs:set_animation(self, "punch")
  58. if minetest.line_of_sight(
  59. {x = p.x, y = p.y + 1.5, z = p.z},
  60. {x = s.x, y = s.y + 1.5, z = s.z}) == true then
  61. -- play attack sound
  62. if self.sounds.attack then
  63. minetest.sound_play(self.sounds.attack, {
  64. object = self.object,
  65. max_hear_distance = self.sounds.distance
  66. })
  67. end
  68. -- punch player
  69. self.attack:punch(self.object, 1.0, {
  70. full_punch_interval = 1.0,
  71. damage_groups = {fleshy = self.damage}
  72. }, nil)
  73. end
  74. minetest.after(1, function()
  75. local ty = s.y
  76. local flag = 0
  77. local m = 3
  78. local v = {
  79. x = (p.x - s.x) * m,
  80. y = ty,
  81. z = (p.z - s.z) * m
  82. }
  83. local d = {
  84. x = s.x + v.x,
  85. y = ty,
  86. z = s.z + v.z
  87. }
  88. for j = -3,3 do
  89. ty = d.y + j
  90. local current = minetest.get_node({
  91. x = d.x,
  92. y = ty,
  93. z = d.z}).name
  94. local up = minetest.get_node({
  95. x = d.x,
  96. y = ty + 1,
  97. z = d.z}).name
  98. if up == "air" and current ~= "air" then
  99. d.y = d.y + j+1.5
  100. flag = 1
  101. break
  102. end
  103. end
  104. while flag ~= 1 do
  105. d.x = p.x + math.random(-m, m)
  106. d.z = p.z + math.random(-m, m)
  107. d.y = p.y
  108. local dist = dist_pos(d, p)
  109. if dist >= 2 then
  110. for j = -3,3 do
  111. ty = d.y + j
  112. local current = minetest.get_node({
  113. x = d.x,
  114. y = ty,
  115. z = d.z}).name
  116. local up = minetest.get_node({
  117. x = d.x,
  118. y = ty + 1,
  119. z = d.z}).name
  120. if up == "air" and current ~= "air" then
  121. d.y = d.y + j+1.5
  122. flag = 1
  123. break
  124. end
  125. end
  126. end
  127. end
  128. self.object:set_pos(d)
  129. end)
  130. end
  131. end
  132. })