bunny.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. local S = mobs.intllib
  2. -- Bunny by ExeterDad
  3. mobs:register_mob("mobs_animal:bunny", {
  4. stepheight = 0.6,
  5. type = "animal",
  6. passive = true,
  7. reach = 1,
  8. hp_min = 1,
  9. hp_max = 4,
  10. armor = 200,
  11. collisionbox = {-0.268, -0.5, -0.268, 0.268, 0.167, 0.268},
  12. visual = "mesh",
  13. mesh = "mobs_bunny.b3d",
  14. drawtype = "front",
  15. textures = {
  16. {"mobs_bunny_grey.png"},
  17. {"mobs_bunny_brown.png"},
  18. {"mobs_bunny_white.png"},
  19. },
  20. sounds = {},
  21. makes_footstep_sound = false,
  22. walk_velocity = 1,
  23. run_velocity = 2,
  24. runaway = true,
  25. runaway_from = {"mobs_animal:pumba", "player"},
  26. jump = true,
  27. jump_height = 6,
  28. drops = {
  29. {name = "mobs:rabbit_raw", chance = 1, min = 1, max = 1},
  30. {name = "mobs:rabbit_hide", chance = 1, min = 0, max = 1},
  31. },
  32. water_damage = 1,
  33. lava_damage = 4,
  34. light_damage = 0,
  35. fear_height = 2,
  36. animation = {
  37. speed_normal = 15,
  38. stand_start = 1,
  39. stand_end = 15,
  40. walk_start = 16,
  41. walk_end = 24,
  42. punch_start = 16,
  43. punch_end = 24,
  44. },
  45. follow = {"farming:carrot", "farming_plus:carrot_item", "default:grass_1"},
  46. view_range = 8,
  47. replace_rate = 10,
  48. replace_what = {"farming:carrot_7", "farming:carrot_8", "farming_plus:carrot"},
  49. replace_with = "air",
  50. on_rightclick = function(self, clicker)
  51. -- feed or tame
  52. if mobs:feed_tame(self, clicker, 4, true, true) then return end
  53. if mobs:protect(self, clicker) then return end
  54. if mobs:capture_mob(self, clicker, 30, 50, 80, false, nil) then return end
  55. -- Monty Python tribute
  56. local item = clicker:get_wielded_item()
  57. if item:get_name() == "mobs:lava_orb" then
  58. if not mobs.is_creative(clicker:get_player_name()) then
  59. item:take_item()
  60. clicker:set_wielded_item(item)
  61. end
  62. self.object:set_properties({
  63. textures = {"mobs_bunny_evil.png"},
  64. })
  65. self.type = "monster"
  66. self.health = 20
  67. self.passive = false
  68. return
  69. end
  70. end,
  71. on_spawn = function(self)
  72. local pos = self.object:get_pos() ; pos.y = pos.y - 1
  73. -- white snowy bunny
  74. if minetest.find_node_near(pos, 1,
  75. {"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
  76. self.base_texture = {"mobs_bunny_white.png"}
  77. self.object:set_properties({textures = self.base_texture})
  78. -- brown desert bunny
  79. elseif minetest.find_node_near(pos, 1,
  80. {"default:desert_sand", "default:desert_stone"}) then
  81. self.base_texture = {"mobs_bunny_brown.png"}
  82. self.object:set_properties({textures = self.base_texture})
  83. -- grey stone bunny
  84. elseif minetest.find_node_near(pos, 1,
  85. {"default:stone", "default:gravel"}) then
  86. self.base_texture = {"mobs_bunny_grey.png"}
  87. self.object:set_properties({textures = self.base_texture})
  88. end
  89. return true -- run only once, false/nil runs every activation
  90. end,
  91. attack_type = "dogfight",
  92. damage = 5,
  93. })
  94. local spawn_on = "default:dirt_with_grass"
  95. if minetest.get_modpath("ethereal") then
  96. spawn_on = "ethereal:prairie_dirt"
  97. end
  98. mobs:spawn({
  99. name = "mobs_animal:bunny",
  100. nodes = {spawn_on},
  101. neighbors = {"group:grass"},
  102. min_light = 14,
  103. interval = 60,
  104. chance = 8000, -- 15000
  105. min_height = 5,
  106. max_height = 200,
  107. day_toggle = true,
  108. })
  109. mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0)
  110. mobs:alias_mob("mobs:bunny", "mobs_animal:bunny") -- compatibility
  111. -- raw rabbit
  112. minetest.register_craftitem(":mobs:rabbit_raw", {
  113. description = S("Raw Rabbit"),
  114. inventory_image = "mobs_rabbit_raw.png",
  115. on_use = minetest.item_eat(3),
  116. groups = {food_meat_raw = 1, food_rabbit_raw = 1, flammable = 2},
  117. })
  118. -- cooked rabbit
  119. minetest.register_craftitem(":mobs:rabbit_cooked", {
  120. description = S("Cooked Rabbit"),
  121. inventory_image = "mobs_rabbit_cooked.png",
  122. on_use = minetest.item_eat(5),
  123. groups = {food_meat = 1, food_rabbit = 1, flammable = 2},
  124. })
  125. minetest.register_craft({
  126. type = "cooking",
  127. output = "mobs:rabbit_cooked",
  128. recipe = "mobs:rabbit_raw",
  129. cooktime = 5,
  130. })
  131. -- rabbit hide
  132. minetest.register_craftitem(":mobs:rabbit_hide", {
  133. description = S("Rabbit Hide"),
  134. inventory_image = "mobs_rabbit_hide.png",
  135. groups = {flammable = 2},
  136. })
  137. minetest.register_craft({
  138. type = "fuel",
  139. recipe = "mobs:rabbit_hide",
  140. burntime = 2,
  141. })
  142. minetest.register_craft({
  143. output = "mobs:leather",
  144. type = "shapeless",
  145. recipe = {
  146. "mobs:rabbit_hide", "mobs:rabbit_hide",
  147. "mobs:rabbit_hide", "mobs:rabbit_hide"
  148. }
  149. })