lava_flan.lua 7.8 KB

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