dungeon_master.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. local S = mobs.intllib
  2. local master_types = {
  3. { nodes = {"nether:rack"},
  4. skins = {"mobs_dungeon_master_nether.png"},
  5. },
  6. { nodes = {"nether:rack_deep"},
  7. skins = {"mobs_dungeon_master_netherdeep.png"},
  8. }
  9. }
  10. -- Dungeon Master by PilzAdam
  11. mobs:register_mob("mobs_monster:dungeon_master", {
  12. type = "monster",
  13. passive = false,
  14. damage = 8,
  15. damage_max = 14,
  16. damage_chance = 80,
  17. attack_type = "dogshoot",
  18. dogshoot_switch = 1,
  19. dogshoot_count_max = 12, -- shoot for 10 seconds
  20. dogshoot_count2_max = 3, -- dogfight for 3 seconds
  21. reach = 3,
  22. shoot_interval = 2.2,
  23. arrow = "mobs_monster:fireball",
  24. shoot_offset = 1,
  25. hp_min = 22,
  26. hp_max = 45,
  27. armor = 60,
  28. collisionbox = {-0.7, -1, -0.7, 0.7, 1.6, 0.7},
  29. visual = "mesh",
  30. mesh = "mobs_dungeon_master.b3d",
  31. textures = {
  32. {"mobs_dungeon_master.png"},
  33. {"mobs_dungeon_master2.png"},
  34. {"mobs_dungeon_master3.png"},
  35. },
  36. makes_footstep_sound = true,
  37. sounds = {
  38. random = "mobs_dungeonmaster",
  39. shoot_attack = "mobs_fireball",
  40. },
  41. walk_velocity = 1,
  42. run_velocity = 3,
  43. jump = true,
  44. view_range = 15,
  45. drops = {
  46. {name = "default:mese_crystal_fragment", chance = 1, min = 0, max = 2},
  47. {name = "mobs:leather", chance = 2, min = 0, max = 2},
  48. {name = "default:mese_crystal", chance = 3, min = 0, max = 2},
  49. {name = "default:diamond", chance = 4, min = 0, max = 1},
  50. {name = "default:diamondblock", chance = 30, min = 0, max = 1},
  51. {name = "commoditymarkget:gold_coins", chance = 10, min = 30, max = 200},
  52. {name = "stations:scroll_teleport", chance = 40, min = 1, max = 1},
  53. {name = "stations:scroll_healing", chance = 50, min = 1, max = 1},
  54. {name = 'maxhp:lifeforce2', chance = 9, min = 0, max = 2}
  55. },
  56. water_damage = 1,
  57. lava_damage = 1,
  58. light_damage = 0,
  59. fear_height = 3,
  60. animation = {
  61. stand_start = 0,
  62. stand_end = 19,
  63. walk_start = 20,
  64. walk_end = 35,
  65. punch_start = 36,
  66. punch_end = 48,
  67. shoot_start = 36,
  68. shoot_end = 48,
  69. speed_normal = 15,
  70. speed_run = 15,
  71. },
  72. -- check surrounding nodes and spawn a specific monster
  73. on_spawn = function(self)
  74. local pos = self.object:get_pos() ; pos.y = pos.y - 1
  75. local tmp
  76. for n = 1, #master_types do
  77. tmp = master_types[n]
  78. if minetest.find_node_near(pos, 1, tmp.nodes) then
  79. self.base_texture = tmp.skins
  80. self.object:set_properties({textures = tmp.skins})
  81. if tmp.drops then
  82. self.drops = tmp.drops
  83. end
  84. return true
  85. end
  86. end
  87. return true -- run only once, false/nil runs every activation
  88. end
  89. })
  90. mobs:spawn({
  91. name = "mobs_monster:dungeon_master",
  92. nodes = {"default:stone", "nether:rack", "caverealms:stone_with_algae", "caverealms:stone_with_lichen", "cavrealms:stone_with_moss", "caverealms:hot_cobble" },
  93. max_light = 5,
  94. chance = 9000,
  95. active_object_count = 4,
  96. max_height = -70,
  97. })
  98. -- fireball (weapon)
  99. mobs:register_arrow("mobs_monster:fireball", {
  100. visual = "sprite",
  101. visual_size = {x = 1, y = 1},
  102. textures = {"mobs_fireball.png"},
  103. collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
  104. velocity = 7,
  105. tail = 1,
  106. tail_texture = "mobs_fireball.png",
  107. tail_size = 10,
  108. glow = 5,
  109. expire = 0.1,
  110. on_activate = function(self, staticdata, dtime_s)
  111. -- make fireball indestructable
  112. self.object:set_armor_groups({immortal = 1, fleshy = 100})
  113. end,
  114. -- if player has a good weapon with 7+ damage it can deflect fireball
  115. on_punch = function(self, hitter, tflp, tool_capabilities, dir)
  116. if hitter and hitter:is_player() and tool_capabilities and dir then
  117. local damage = tool_capabilities.damage_groups and
  118. tool_capabilities.damage_groups.fleshy or 1
  119. local tmp = tflp / (tool_capabilities.full_punch_interval or 1.4)
  120. if damage > 6 and tmp < 4 then
  121. self.object:set_velocity({
  122. x = dir.x * self.velocity,
  123. y = dir.y * self.velocity,
  124. z = dir.z * self.velocity,
  125. })
  126. end
  127. end
  128. end,
  129. -- direct hit, no fire... just plenty of pain
  130. hit_player = function(self, player)
  131. player:punch(self.object, 1.0, {
  132. full_punch_interval = 1.0,
  133. damage_groups = {fleshy = 8},
  134. }, nil)
  135. end,
  136. hit_mob = function(self, player)
  137. player:punch(self.object, 1.0, {
  138. full_punch_interval = 1.0,
  139. damage_groups = {fleshy = 8},
  140. }, nil)
  141. end,
  142. -- node hit
  143. hit_node = function(self, pos, node)
  144. mobs:boom(self, pos, 2)
  145. end
  146. })
  147. minetest.override_item("default:obsidian", {on_blast = function() end})