bunny.lua 4.2 KB

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