rat.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. mobs:spawn({
  58. name = "mobs_animal:rat",
  59. nodes = {"default:stone"},
  60. min_light = 3,
  61. max_light = 9,
  62. interval = 60,
  63. chance = 8000,
  64. max_height = 0,
  65. -- on_spawn = rat_spawn,
  66. })
  67. mobs:register_egg("mobs_animal:rat", S("Rat"), "mobs_rat_inv.png")
  68. mobs:alias_mob("mobs:rat", "mobs_animal:rat") -- compatibility
  69. -- cooked rat, yummy!
  70. minetest.register_craftitem(":mobs:rat_cooked", {
  71. description = S("Cooked Rat"),
  72. inventory_image = "mobs_cooked_rat.png",
  73. on_use = minetest.item_eat(3),
  74. groups = {food_rat = 1, flammable = 2},
  75. })
  76. minetest.register_craft({
  77. type = "cooking",
  78. output = "mobs:rat_cooked",
  79. recipe = "mobs_animal:rat",
  80. cooktime = 5,
  81. })