lava_flan.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. local S = mobs.intllib
  2. -- Lava Flan by Zeg9 (additional textures by JurajVajda)
  3. mobs:register_mob("mobs_monster:lava_flan", {
  4. type = "monster",
  5. passive = false,
  6. attack_type = "dogfight",
  7. reach = 2,
  8. damage = 3,
  9. hp_min = 10,
  10. hp_max = 35,
  11. armor = 80,
  12. collisionbox = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5},
  13. visual = "mesh",
  14. mesh = "zmobs_lava_flan.x",
  15. textures = {
  16. {"zmobs_lava_flan.png"},
  17. {"zmobs_lava_flan2.png"},
  18. {"zmobs_lava_flan3.png"},
  19. },
  20. blood_texture = "fire_basic_flame.png",
  21. makes_footstep_sound = false,
  22. sounds = {
  23. random = "mobs_lavaflan",
  24. war_cry = "mobs_lavaflan",
  25. },
  26. walk_velocity = 0.5,
  27. run_velocity = 2,
  28. jump = true,
  29. view_range = 10,
  30. floats = 1,
  31. drops = {
  32. {name = "mobs:lava_orb", chance = 15, min = 1, max = 1},
  33. },
  34. water_damage = 8,
  35. lava_damage = 0,
  36. light_damage = 0,
  37. immune_to = {
  38. {"mobs:pick_lava", -2}, -- lava pick heals 2 health
  39. },
  40. animation = {
  41. speed_normal = 15,
  42. speed_run = 15,
  43. stand_start = 0,
  44. stand_end = 8,
  45. walk_start = 10,
  46. walk_end = 18,
  47. run_start = 20,
  48. run_end = 28,
  49. punch_start = 20,
  50. punch_end = 28,
  51. },
  52. on_die = function(self, pos)
  53. if minetest.get_node(pos).name == "air" then
  54. minetest.set_node(pos, {name = "fire:basic_flame"})
  55. end
  56. self.object:remove()
  57. minetest.add_particlespawner({
  58. amount = 20,
  59. time = 0.25,
  60. minpos = pos,
  61. maxpos = pos,
  62. minvel = {x = -2, y = -2, z = -2},
  63. maxvel = {x = 2, y = 2, z = 2},
  64. minacc = {x = 0, y = -10, z = 0},
  65. maxacc = {x = 0, y = -10, z = 0},
  66. minexptime = 0.1,
  67. maxexptime = 1,
  68. minsize = 1.0,
  69. maxsize = 2.0,
  70. texture = "fire_basic_flame.png",
  71. })
  72. end,
  73. glow = 10,
  74. })
  75. mobs:spawn({
  76. name = "mobs_monster:lava_flan",
  77. nodes = {"default:lava_source"},
  78. chance = 1500,
  79. active_object_count = 1,
  80. max_height = 0,
  81. })
  82. mobs:register_egg("mobs_monster:lava_flan", S("Lava Flan"), "default_lava.png", 1)
  83. mobs:alias_mob("mobs:lava_flan", "mobs_monster:lava_flan") -- compatibility
  84. -- lava orb
  85. minetest.register_craftitem(":mobs:lava_orb", {
  86. description = S("Lava orb"),
  87. inventory_image = "zmobs_lava_orb.png",
  88. })
  89. minetest.register_alias("zmobs:lava_orb", "mobs:lava_orb")
  90. minetest.register_craft({
  91. type = "fuel",
  92. recipe = "mobs:lava_orb",
  93. burntime = 80,
  94. })
  95. -- Lava Pick (digs and smelts at same time)
  96. local old_handle_node_drops = minetest.handle_node_drops
  97. function minetest.handle_node_drops(pos, drops, digger)
  98. -- are we holding Lava Pick?
  99. if digger:get_wielded_item():get_name() ~= ("mobs:pick_lava") then
  100. return old_handle_node_drops(pos, drops, digger)
  101. end
  102. -- reset new smelted drops
  103. local hot_drops = {}
  104. -- loop through current node drops
  105. for _, drop in pairs(drops) do
  106. -- get cooked output of current drops
  107. local stack = ItemStack(drop)
  108. local output = minetest.get_craft_result({
  109. method = "cooking",
  110. width = 1,
  111. items = {drop}
  112. })
  113. -- if we have cooked result then add to new list
  114. if output
  115. and output.item
  116. and not output.item:is_empty() then
  117. table.insert(hot_drops,
  118. ItemStack({
  119. name = output.item:get_name(),
  120. count = output.item:to_table().count,
  121. })
  122. )
  123. else -- if not then return normal drops
  124. table.insert(hot_drops, stack)
  125. end
  126. end
  127. return old_handle_node_drops(pos, hot_drops, digger)
  128. end
  129. minetest.register_tool(":mobs:pick_lava", {
  130. description = S("Lava Pickaxe"),
  131. inventory_image = "mobs_pick_lava.png",
  132. tool_capabilities = {
  133. full_punch_interval = 0.4,
  134. max_drop_level=3,
  135. groupcaps={
  136. cracky = {times={[1]=1.80, [2]=0.80, [3]=0.40}, uses=40, maxlevel=3},
  137. },
  138. damage_groups = {fleshy = 6, fire = 1},
  139. },
  140. groups = {pickaxe = 1}
  141. })
  142. minetest.register_craft({
  143. output = "mobs:pick_lava",
  144. recipe = {
  145. {"mobs:lava_orb", "mobs:lava_orb", "mobs:lava_orb"},
  146. {"", "default:obsidian_shard", ""},
  147. {"", "default:obsidian_shard", ""},
  148. }
  149. })
  150. -- Add [toolranks] mod support if found
  151. if minetest.get_modpath("toolranks") then
  152. minetest.override_item("mobs:pick_lava", {
  153. original_description = "Lava Pickaxe",
  154. description = toolranks.create_description("Lava Pickaxe", 0, 1),
  155. after_use = toolranks.new_afteruse})
  156. end