rat.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. local S = mobs.intllib
  2. -- Rat by PilzAdam (B3D model by sirrobzeroone)
  3. mobs:register_mob("mobs_animal:rat", {
  4. stepheight = 0.6,
  5. type = "animal",
  6. passive = true,
  7. hp_min = 1,
  8. hp_max = 4,
  9. armor = 200,
  10. collisionbox = {-0.2, -1, -0.2, 0.2, -0.8, 0.2},
  11. visual = "mesh",
  12. mesh = "mobs_rat.b3d",
  13. textures = {
  14. {"mobs_rat.png"},
  15. {"mobs_rat2.png"},
  16. },
  17. makes_footstep_sound = false,
  18. sounds = {
  19. random = "mobs_rat",
  20. },
  21. walk_velocity = 1,
  22. run_velocity = 2,
  23. runaway = true,
  24. jump = true,
  25. water_damage = 0,
  26. lava_damage = 4,
  27. light_damage = 0,
  28. fear_height = 2,
  29. on_rightclick = function(self, clicker)
  30. mobs:capture_mob(self, clicker, 50, 90, 0, true, "mobs_animal:rat")
  31. end,
  32. --[[
  33. do_custom = function(self, dtime)
  34. self.rat_timer = (self.rat_timer or 0) + dtime
  35. if self.rat_timer < 1 then return end -- every 1 second
  36. self.rat_timer = 0
  37. local pos = self.object:get_pos()
  38. print("rat pos", pos.x, pos.y, pos.z, dtime)
  39. return false -- return but skip doing rest of API
  40. end,
  41. ]]
  42. --[[
  43. on_blast = function(obj, damage)
  44. print ("--- damage is", damage)
  45. print ("--- mob is", obj.object:get_luaentity().name)
  46. -- return's do_damage, do_knockback and drops
  47. return false, true, {"default:mese"}
  48. end,
  49. ]]
  50. })
  51. local function rat_spawn(self, pos)
  52. self = self:get_luaentity()
  53. print (self.name, pos.x, pos.y, pos.z)
  54. self.hp_max = 100
  55. self.health = 100
  56. end
  57. if not mobs.custom_spawn_animal then
  58. mobs:spawn({
  59. name = "mobs_animal:rat",
  60. nodes = {"default:stone"},
  61. min_light = 3,
  62. max_light = 9,
  63. interval = 60,
  64. chance = 8000,
  65. max_height = 0,
  66. -- on_spawn = rat_spawn,
  67. })
  68. end
  69. mobs:register_egg("mobs_animal:rat", S("Rat"), "mobs_rat_inv.png")
  70. mobs:alias_mob("mobs:rat", "mobs_animal:rat") -- compatibility
  71. -- cooked rat, yummy!
  72. minetest.register_craftitem(":mobs:rat_cooked", {
  73. description = S("Cooked Rat"),
  74. inventory_image = "mobs_cooked_rat.png",
  75. on_use = minetest.item_eat(3),
  76. groups = {food_rat = 1, flammable = 2}
  77. })
  78. minetest.register_craft({
  79. type = "cooking",
  80. output = "mobs:rat_cooked",
  81. recipe = "mobs_animal:rat",
  82. cooktime = 5
  83. })