tree_monster.lua 4.8 KB

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