lava_flan.lua 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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. fire_damage = 0,
  37. light_damage = 0,
  38. immune_to = {
  39. {"mobs:pick_lava", -2}, -- lava pick heals 2 health
  40. },
  41. fly_in = {"default:lava_source", "default:lava_flowing"},
  42. animation = {
  43. speed_normal = 15,
  44. speed_run = 15,
  45. stand_start = 0,
  46. stand_end = 8,
  47. walk_start = 10,
  48. walk_end = 18,
  49. run_start = 20,
  50. run_end = 28,
  51. punch_start = 20,
  52. punch_end = 28,
  53. },
  54. on_die = function(self, pos)
  55. local cod = self.cause_of_death or {}
  56. local def = cod.node and minetest.registered_nodes[cod.node]
  57. if def and def.groups and def.groups.water then
  58. pos.y = pos.y + 1
  59. mobs:effect(pos, 40, "tnt_smoke.png", 3, 5, 2, 0.5, nil, false)
  60. minetest.sound_play("fire_extinguish_flame",
  61. {pos = pos, max_hear_distance = 12, gain = 1.5}, true)
  62. self.object:remove()
  63. if math.random(4) == 1 then
  64. mobs:add_mob(pos, {
  65. name = "mobs_monster:obsidian_flan",
  66. })
  67. end
  68. else
  69. if minetest.get_node(pos).name == "air" then
  70. minetest.set_node(pos, {name = "fire:basic_flame"})
  71. end
  72. mobs:effect(pos, 40, "fire_basic_flame.png", 2, 3, 2, 5, 10, nil)
  73. self.object:remove()
  74. end
  75. end,
  76. glow = 10,
  77. })
  78. if not mobs.custom_spawn_monster then
  79. mobs:spawn({
  80. name = "mobs_monster:lava_flan",
  81. nodes = {"default:lava_source"},
  82. chance = 1500,
  83. active_object_count = 1,
  84. max_height = 0,
  85. })
  86. end
  87. mobs:register_egg("mobs_monster:lava_flan", S("Lava Flan"), "default_lava.png", 1)
  88. mobs:alias_mob("mobs:lava_flan", "mobs_monster:lava_flan") -- compatibility
  89. -- lava orb
  90. minetest.register_craftitem(":mobs:lava_orb", {
  91. description = S("Lava orb"),
  92. inventory_image = "zmobs_lava_orb.png",
  93. light_source = 14,
  94. })
  95. minetest.register_alias("zmobs:lava_orb", "mobs:lava_orb")
  96. minetest.register_craft({
  97. type = "fuel",
  98. recipe = "mobs:lava_orb",
  99. burntime = 80,
  100. })
  101. -- Lava Pick (digs and smelts at same time)
  102. local old_handle_node_drops = minetest.handle_node_drops
  103. function minetest.handle_node_drops(pos, drops, digger)
  104. -- does player exist?
  105. if not digger then return end
  106. -- are we holding Lava Pick?
  107. if digger:get_wielded_item():get_name() ~= ("mobs:pick_lava") then
  108. return old_handle_node_drops(pos, drops, digger)
  109. end
  110. -- reset new smelted drops
  111. local hot_drops = {}
  112. -- loop through current node drops
  113. for _, drop in pairs(drops) do
  114. -- get cooked output of current drops
  115. local stack = ItemStack(drop)
  116. local output = minetest.get_craft_result({
  117. method = "cooking",
  118. width = 1,
  119. items = {drop}
  120. })
  121. -- if we have cooked result then add to new list
  122. if output
  123. and output.item
  124. and not output.item:is_empty() then
  125. table.insert(hot_drops,
  126. ItemStack({
  127. name = output.item:get_name(),
  128. count = output.item:to_table().count,
  129. })
  130. )
  131. else -- if not then return normal drops
  132. table.insert(hot_drops, stack)
  133. end
  134. end
  135. return old_handle_node_drops(pos, hot_drops, digger)
  136. end
  137. minetest.register_tool(":mobs:pick_lava", {
  138. description = S("Lava Pickaxe"),
  139. inventory_image = "mobs_pick_lava.png",
  140. tool_capabilities = {
  141. full_punch_interval = 0.4,
  142. max_drop_level=3,
  143. groupcaps={
  144. cracky = {times={[1]=1.80, [2]=0.80, [3]=0.40}, uses=40, maxlevel=3},
  145. },
  146. damage_groups = {fleshy = 6, fire = 1},
  147. },
  148. groups = {pickaxe = 1},
  149. light_source = 14
  150. })
  151. minetest.register_craft({
  152. output = "mobs:pick_lava",
  153. recipe = {
  154. {"mobs:lava_orb", "mobs:lava_orb", "mobs:lava_orb"},
  155. {"", "default:obsidian_shard", ""},
  156. {"", "default:obsidian_shard", ""},
  157. }
  158. })
  159. -- Add [toolranks] mod support if found
  160. if minetest.get_modpath("toolranks") then
  161. minetest.override_item("mobs:pick_lava", {
  162. original_description = "Lava Pickaxe",
  163. description = toolranks.create_description("Lava Pickaxe", 0, 1),
  164. after_use = toolranks.new_afteruse})
  165. end
  166. -- obsidian flan
  167. mobs:register_mob("mobs_monster:obsidian_flan", {
  168. type = "monster",
  169. passive = false,
  170. attack_type = "shoot",
  171. shoot_interval = 0.5,
  172. shoot_offset = 1.0,
  173. arrow = "mobs_monster:obsidian_arrow",
  174. reach = 2,
  175. damage = 3,
  176. hp_min = 10,
  177. hp_max = 35,
  178. armor = 30,
  179. visual_size = {x = 0.6, y = 0.6},
  180. collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.8, 0.3},
  181. visual = "mesh",
  182. mesh = "zmobs_lava_flan.x",
  183. textures = {
  184. {"mobs_obsidian_flan.png"},
  185. },
  186. blood_texture = "default_obsidian.png",
  187. makes_footstep_sound = true,
  188. sounds = {
  189. random = "mobs_lavaflan",
  190. -- war_cry = "mobs_lavaflan",
  191. },
  192. walk_velocity = 0.1,
  193. run_velocity = 0.5,
  194. jump = false,
  195. view_range = 10,
  196. floats = 0,
  197. drops = {
  198. {name = "default:obsidian_shard", chance = 1, min = 1, max = 5},
  199. {name = "default:obsidian", chance = 3, min = 0, max = 2},
  200. },
  201. water_damage = 0,
  202. lava_damage = 8,
  203. fire_damage = 0,
  204. light_damage = 0,
  205. animation = {
  206. speed_normal = 15,
  207. speed_run = 15,
  208. stand_start = 0,
  209. stand_end = 8,
  210. walk_start = 10,
  211. walk_end = 18,
  212. run_start = 20,
  213. run_end = 28,
  214. punch_start = 20,
  215. punch_end = 28,
  216. }
  217. })
  218. mobs:register_egg("mobs_monster:obsidian_flan", S("Obsidian Flan"),
  219. "default_obsidian.png", 1)
  220. local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
  221. -- mese arrow (weapon)
  222. mobs:register_arrow("mobs_monster:obsidian_arrow", {
  223. visual = "sprite",
  224. -- visual = "wielditem",
  225. visual_size = {x = 0.5, y = 0.5},
  226. textures = {"default_obsidian_shard.png"},
  227. velocity = 6,
  228. -- rotate = 180,
  229. hit_player = function(self, player)
  230. player:punch(self.object, 1.0, {
  231. full_punch_interval = 1.0,
  232. damage_groups = {fleshy = 8},
  233. }, nil)
  234. end,
  235. hit_mob = function(self, player)
  236. player:punch(self.object, 1.0, {
  237. full_punch_interval = 1.0,
  238. damage_groups = {fleshy = 8},
  239. }, nil)
  240. end,
  241. hit_node = function(self, pos, node)
  242. if mobs_griefing == false or minetest.is_protected(pos, "") then
  243. return
  244. end
  245. local texture = "default_dirt.png" --fallback texture
  246. local radius = 1
  247. local def = minetest.registered_nodes[node]
  248. if def then
  249. node = { name = node }
  250. end
  251. if def and def.tiles and def.tiles[1] then
  252. texture = def.tiles[1]
  253. end
  254. -- do not break obsidian or diamond blocks or unbreakable nodes
  255. if (def.groups and def.groups.level and def.groups.level > 1)
  256. or def.groups.unbreakable then
  257. return
  258. end
  259. minetest.add_particlespawner({
  260. amount = 32,
  261. time = 0.1,
  262. minpos = vector.subtract(pos, radius / 2),
  263. maxpos = vector.add(pos, radius / 2),
  264. minvel = {x = -3, y = 0, z = -3},
  265. maxvel = {x = 3, y = 5, z = 3},
  266. minacc = {x = 0, y = -10, z = 0},
  267. maxacc = {x = 0, y = -10, z = 0},
  268. minexptime = 0.8,
  269. maxexptime = 2.0,
  270. minsize = radius * 0.33,
  271. maxsize = radius,
  272. texture = texture,
  273. -- ^ only as fallback for clients without support for `node` parameter
  274. node = node,
  275. collisiondetection = true,
  276. })
  277. minetest.set_node(pos, {name = "air"})
  278. local snd = def.sounds and def.sounds.dug or "default_dig_crumbly"
  279. minetest.sound_play(snd, {pos = pos, max_hear_distance = 12, gain = 1.0}, true)
  280. end
  281. })