dungeon_master.lua 4.0 KB

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