You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

332 lines
7.3KB

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