bunny.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. self.runaway = false
  70. return
  71. end
  72. end,
  73. on_spawn = function(self)
  74. local pos = self.object:get_pos() ; pos.y = pos.y - 1
  75. -- white snowy bunny
  76. if minetest.find_node_near(pos, 1,
  77. {"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
  78. self.base_texture = {"mobs_bunny_white.png"}
  79. self.object:set_properties({textures = self.base_texture})
  80. -- brown desert bunny
  81. elseif minetest.find_node_near(pos, 1,
  82. {"default:desert_sand", "default:desert_stone"}) then
  83. self.base_texture = {"mobs_bunny_brown.png"}
  84. self.object:set_properties({textures = self.base_texture})
  85. -- grey stone bunny
  86. elseif minetest.find_node_near(pos, 1,
  87. {"default:stone", "default:gravel"}) then
  88. self.base_texture = {"mobs_bunny_grey.png"}
  89. self.object:set_properties({textures = self.base_texture})
  90. end
  91. return true -- run only once, false/nil runs every activation
  92. end,
  93. attack_type = "dogfight",
  94. damage = 5,
  95. })
  96. local spawn_on = "default:dirt_with_grass"
  97. if minetest.get_modpath("ethereal") then
  98. spawn_on = "ethereal:prairie_dirt"
  99. end
  100. mobs:spawn({
  101. name = "mobs_animal:bunny",
  102. nodes = {spawn_on},
  103. neighbors = {"group:grass"},
  104. min_light = 14,
  105. interval = 60,
  106. chance = 8000, -- 15000
  107. min_height = 5,
  108. max_height = 200,
  109. day_toggle = true,
  110. })
  111. mobs:register_egg("mobs_animal:bunny", S("Bunny"), "mobs_bunny_inv.png", 0)
  112. mobs:alias_mob("mobs:bunny", "mobs_animal:bunny") -- compatibility
  113. -- raw rabbit
  114. minetest.register_craftitem(":mobs:rabbit_raw", {
  115. description = S("Raw Rabbit"),
  116. inventory_image = "mobs_rabbit_raw.png",
  117. on_use = minetest.item_eat(3),
  118. groups = {food_meat_raw = 1, food_rabbit_raw = 1, flammable = 2},
  119. })
  120. -- cooked rabbit
  121. minetest.register_craftitem(":mobs:rabbit_cooked", {
  122. description = S("Cooked Rabbit"),
  123. inventory_image = "mobs_rabbit_cooked.png",
  124. on_use = minetest.item_eat(5),
  125. groups = {food_meat = 1, food_rabbit = 1, flammable = 2},
  126. })
  127. minetest.register_craft({
  128. type = "cooking",
  129. output = "mobs:rabbit_cooked",
  130. recipe = "mobs:rabbit_raw",
  131. cooktime = 5,
  132. })
  133. -- rabbit hide
  134. minetest.register_craftitem(":mobs:rabbit_hide", {
  135. description = S("Rabbit Hide"),
  136. inventory_image = "mobs_rabbit_hide.png",
  137. groups = {flammable = 2},
  138. })
  139. minetest.register_craft({
  140. type = "fuel",
  141. recipe = "mobs:rabbit_hide",
  142. burntime = 2,
  143. })
  144. minetest.register_craft({
  145. output = "mobs:leather",
  146. type = "shapeless",
  147. recipe = {
  148. "mobs:rabbit_hide", "mobs:rabbit_hide",
  149. "mobs:rabbit_hide", "mobs:rabbit_hide"
  150. }
  151. })