tree_monster.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. local S = mobs.intllib
  2. local tree_types = {
  3. { nodes = {"ethereal:sakura_leaves", "ethereal:sakura_leaves2"},
  4. skins = {"mobs_tree_monster5.png"},
  5. drops = {
  6. {name = "default:stick", chance = 1, min = 1, max = 3},
  7. {name = "ethereal:sakura_leaves", chance = 1, min = 1, max = 2},
  8. {name = "ethereal:sakura_trunk", chance = 2, min = 1, max = 2},
  9. {name = "ethereal:sakura_tree_sapling", chance = 2, min = 0, max = 2},
  10. }
  11. },
  12. { nodes = {"ethereal:frost_leaves"},
  13. skins = {"mobs_tree_monster3.png"},
  14. drops = {
  15. {name = "default:stick", chance = 1, min = 1, max = 3},
  16. {name = "ethereal:frost_leaves", chance = 1, min = 1, max = 2},
  17. {name = "ethereal:frost_tree", chance = 2, min = 1, max = 2},
  18. {name = "ethereal:crystal_spike", chance = 4, min = 0, max = 2},
  19. }
  20. },
  21. { nodes = {"ethereal:yellowleaves"},
  22. skins = {"mobs_tree_monster4.png"},
  23. drops = {
  24. {name = "default:stick", chance = 1, min = 1, max = 3},
  25. {name = "ethereal:yellowleaves", chance = 1, min = 1, max = 2},
  26. {name = "ethereal:yellow_tree_sapling", chance = 2, min = 0, max = 2},
  27. {name = "ethereal:golden_apple", chance = 3, min = 0, max = 2},
  28. }
  29. },
  30. { nodes = {"default:acacia_bush_leaves"},
  31. skins = {"mobs_tree_monster6.png"},
  32. drops = {
  33. {name = "tnt:gunpowder", chance = 1, min = 0, max = 2},
  34. {name = "default:iron_lump", chance = 5, min = 0, max = 2},
  35. {name = "default:coal_lump", chance = 3, min = 0, max = 3}
  36. },
  37. explode = true
  38. },
  39. }
  40. -- Tree Monster (or Tree Gollum) by PilzAdam
  41. mobs:register_mob("mobs_monster:tree_monster", {
  42. type = "monster",
  43. passive = false,
  44. attack_type = "dogfight",
  45. attack_animals = true,
  46. --specific_attack = {"player", "mobs_animal:chicken"},
  47. reach = 2,
  48. damage = 2,
  49. hp_min = 20,
  50. hp_max = 40,
  51. armor = 100,
  52. collisionbox = {-0.4, -1, -0.4, 0.4, 0.8, 0.4},
  53. visual = "mesh",
  54. mesh = "mobs_tree_monster.b3d",
  55. textures = {
  56. {"mobs_tree_monster.png"},
  57. {"mobs_tree_monster2.png"},
  58. },
  59. blood_texture = "default_wood.png",
  60. makes_footstep_sound = true,
  61. sounds = {
  62. random = "mobs_treemonster",
  63. },
  64. walk_velocity = 1,
  65. run_velocity = 3,
  66. jump = true,
  67. view_range = 15,
  68. drops = {
  69. {name = "default:stick", chance = 1, min = 0, max = 2},
  70. {name = "default:sapling", chance = 2, min = 0, max = 2},
  71. {name = "default:junglesapling", chance = 3, min = 0, max = 2},
  72. {name = "default:apple", chance = 4, min = 1, max = 2},
  73. },
  74. water_damage = 0,
  75. lava_damage = 0,
  76. light_damage = 2,
  77. fall_damage = 0,
  78. immune_to = {
  79. {"default:axe_wood", 0}, -- wooden axe doesnt hurt wooden monster
  80. {"default:axe_stone", 4}, -- axes deal more damage to tree monster
  81. {"default:axe_bronze", 5},
  82. {"default:axe_steel", 5},
  83. {"default:axe_mese", 7},
  84. {"default:axe_diamond", 9},
  85. {"default:sapling", -5}, -- default and jungle saplings heal
  86. {"default:junglesapling", -5},
  87. -- {"all", 0}, -- only weapons on list deal damage
  88. },
  89. animation = {
  90. speed_normal = 15,
  91. speed_run = 15,
  92. stand_start = 0,
  93. stand_end = 24,
  94. walk_start = 25,
  95. walk_end = 47,
  96. run_start = 48,
  97. run_end = 62,
  98. punch_start = 48,
  99. punch_end = 62,
  100. },
  101. -- check surrounding nodes and spawn a specific tree monster
  102. on_spawn = function(self)
  103. local pos = self.object:get_pos() ; pos.y = pos.y - 1
  104. local tmp
  105. for n = 1, #tree_types do
  106. tmp = tree_types[n]
  107. if tmp.explode and math.random(2) == 1 then return true end
  108. if minetest.find_node_near(pos, 1, tmp.nodes) then
  109. self.base_texture = tmp.skins
  110. self.object:set_properties({textures = tmp.skins})
  111. if tmp.drops then
  112. self.drops = tmp.drops
  113. end
  114. if tmp.explode then
  115. self.attack_type = "explode"
  116. self.explosion_radius = 3
  117. self.explosion_timer = 3
  118. self.damage = 21
  119. self.reach = 3
  120. self.fear_height = 4
  121. self.water_damage = 2
  122. self.lava_damage = 15
  123. self.light_damage = 0
  124. self.makes_footstep_sound = false
  125. self.runaway_from = {"mobs_animal:kitten"}
  126. self.sounds = {
  127. attack = "tnt_ignite",
  128. explode = "tnt_explode",
  129. fuse = "tnt_ignite"
  130. }
  131. end
  132. return true
  133. end
  134. end
  135. return true -- run only once, false/nil runs every activation
  136. end
  137. })
  138. if not mobs.custom_spawn_monster then
  139. mobs:spawn({
  140. name = "mobs_monster:tree_monster",
  141. nodes = {"group:leaves"}, --{"default:leaves", "default:jungleleaves"},
  142. max_light = 7,
  143. chance = 7000,
  144. min_height = 0,
  145. day_toggle = false,
  146. })
  147. end
  148. mobs:register_egg("mobs_monster:tree_monster", S("Tree Monster"), "default_tree_top.png", 1)
  149. mobs:alias_mob("mobs:tree_monster", "mobs_monster:tree_monster") -- compatibility