lava_flan.lua 8.1 KB

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