lava_flan.lua 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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 = -1,
  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 = {
  145. times = {[1] = 1.80, [2] = 0.80, [3] = 0.40},
  146. uses = 40,
  147. maxlevel = 3
  148. }
  149. },
  150. damage_groups = {fleshy = 6, fire = 1},
  151. },
  152. groups = {pickaxe = 1},
  153. light_source = 14
  154. })
  155. minetest.register_craft({
  156. output = "mobs:pick_lava",
  157. recipe = {
  158. {"mobs:lava_orb", "mobs:lava_orb", "mobs:lava_orb"},
  159. {"", "default:obsidian_shard", ""},
  160. {"", "default:obsidian_shard", ""}
  161. }
  162. })
  163. -- Add [toolranks] mod support if found
  164. if minetest.get_modpath("toolranks") then
  165. minetest.override_item("mobs:pick_lava", {
  166. original_description = "Lava Pickaxe",
  167. description = toolranks.create_description("Lava Pickaxe", 0, 1),
  168. after_use = toolranks.new_afteruse})
  169. end
  170. -- obsidian flan
  171. mobs:register_mob("mobs_monster:obsidian_flan", {
  172. type = "monster",
  173. passive = false,
  174. attack_type = "shoot",
  175. shoot_interval = 0.5,
  176. shoot_offset = 1.0,
  177. arrow = "mobs_monster:obsidian_arrow",
  178. reach = 2,
  179. damage = 3,
  180. hp_min = 10,
  181. hp_max = 35,
  182. armor = 30,
  183. visual_size = {x = 0.6, y = 0.6},
  184. collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.8, 0.3},
  185. visual = "mesh",
  186. mesh = "zmobs_lava_flan.x",
  187. textures = {
  188. {"mobs_obsidian_flan.png"},
  189. },
  190. blood_texture = "default_obsidian.png",
  191. makes_footstep_sound = true,
  192. sounds = {
  193. random = "mobs_lavaflan",
  194. -- war_cry = "mobs_lavaflan",
  195. },
  196. walk_velocity = 0.1,
  197. run_velocity = 0.5,
  198. jump = false,
  199. view_range = 10,
  200. floats = 0,
  201. drops = {
  202. {name = "default:obsidian_shard", chance = 1, min = 1, max = 5},
  203. {name = "default:obsidian", chance = 3, min = 0, max = 2},
  204. },
  205. water_damage = 0,
  206. lava_damage = 8,
  207. fire_damage = 0,
  208. light_damage = 0,
  209. animation = {
  210. speed_normal = 15,
  211. speed_run = 15,
  212. stand_start = 0,
  213. stand_end = 8,
  214. walk_start = 10,
  215. walk_end = 18,
  216. run_start = 20,
  217. run_end = 28,
  218. punch_start = 20,
  219. punch_end = 28
  220. }
  221. })
  222. mobs:register_egg("mobs_monster:obsidian_flan", S("Obsidian Flan"),
  223. "default_obsidian.png", 1)
  224. local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
  225. -- mese arrow (weapon)
  226. mobs:register_arrow("mobs_monster:obsidian_arrow", {
  227. visual = "sprite",
  228. -- visual = "wielditem",
  229. visual_size = {x = 0.5, y = 0.5},
  230. textures = {"default_obsidian_shard.png"},
  231. velocity = 6,
  232. -- rotate = 180,
  233. hit_player = function(self, player)
  234. player:punch(self.object, 1.0, {
  235. full_punch_interval = 1.0,
  236. damage_groups = {fleshy = 8},
  237. }, nil)
  238. end,
  239. hit_mob = function(self, player)
  240. player:punch(self.object, 1.0, {
  241. full_punch_interval = 1.0,
  242. damage_groups = {fleshy = 8},
  243. }, nil)
  244. end,
  245. hit_node = function(self, pos, node)
  246. if mobs_griefing == false or minetest.is_protected(pos, "") then
  247. return
  248. end
  249. local texture = "default_dirt.png" --fallback texture
  250. local radius = 1
  251. local def = minetest.registered_nodes[node]
  252. if def then
  253. node = {name = node}
  254. end
  255. if def and def.tiles and def.tiles[1] then
  256. texture = def.tiles[1]
  257. end
  258. -- do not break obsidian or diamond blocks or unbreakable nodes
  259. if (def.groups and def.groups.level and def.groups.level > 1)
  260. or def.groups.unbreakable then
  261. return
  262. end
  263. minetest.add_particlespawner({
  264. amount = 32,
  265. time = 0.1,
  266. minpos = vector.subtract(pos, radius / 2),
  267. maxpos = vector.add(pos, radius / 2),
  268. minvel = {x = -3, y = 0, z = -3},
  269. maxvel = {x = 3, y = 5, z = 3},
  270. minacc = {x = 0, y = -10, z = 0},
  271. maxacc = {x = 0, y = -10, z = 0},
  272. minexptime = 0.8,
  273. maxexptime = 2.0,
  274. minsize = radius * 0.33,
  275. maxsize = radius,
  276. texture = texture,
  277. -- ^ only as fallback for clients without support for `node` parameter
  278. node = node,
  279. collisiondetection = true
  280. })
  281. minetest.set_node(pos, {name = "air"})
  282. local snd = def.sounds and def.sounds.dug or "default_dig_crumbly"
  283. minetest.sound_play(snd, {pos = pos, max_hear_distance = 12, gain = 1.0}, true)
  284. end
  285. })