kitten.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. local S = mobs.intllib
  2. local hairball = minetest.settings:get("mobs_hairball")
  3. -- Kitten by Jordach / BFD
  4. mobs:register_mob("mobs_animal:kitten", {
  5. stepheight = 0.6,
  6. type = "animal",
  7. specific_attack = {"mobs_animal:rat"},
  8. damage = 1,
  9. damage_chance = 25,
  10. attack_type = "dogfight",
  11. attack_animals = true, -- so it can attack rat
  12. attack_players = false,
  13. reach = 1,
  14. passive = false,
  15. hp_min = 5,
  16. hp_max = 10,
  17. armor = 200,
  18. collisionbox = {-0.3, -0.3, -0.3, 0.3, 0.1, 0.3},
  19. visual = "mesh",
  20. visual_size = {x = 0.5, y = 0.5},
  21. mesh = "mobs_kitten.b3d",
  22. textures = {
  23. {"mobs_kitten_striped.png"},
  24. {"mobs_kitten_splotchy.png"},
  25. {"mobs_kitten_ginger.png"},
  26. {"mobs_kitten_sandy.png"},
  27. },
  28. makes_footstep_sound = false,
  29. sounds = {
  30. random = "mobs_kitten",
  31. },
  32. walk_velocity = 0.6,
  33. walk_chance = 15,
  34. run_velocity = 2,
  35. runaway = true,
  36. jump = false,
  37. drops = {
  38. {name = "mobs:meat_raw", chance = 1, min = 1, max = 1},
  39. {name = "farming:string", chance = 1, min = 1, max = 1},
  40. },
  41. water_damage = 1,
  42. lava_damage = 5,
  43. fear_height = 3,
  44. animation = {
  45. speed_normal = 42,
  46. stand_start = 97,
  47. stand_end = 192,
  48. walk_start = 0,
  49. walk_end = 96,
  50. stoodup_start = 0,
  51. stoodup_end = 0,
  52. },
  53. follow = {"mobs_animal:rat", "fishing:fish_raw", "mobs_fish:clownfish", "mobs_fish:tropical"},
  54. view_range = 8,
  55. specific_attack = {'fantasy_mobs:gnome'},
  56. on_rightclick = function(self, clicker)
  57. if mobs:feed_tame(self, clicker, 4, true, true) then return end
  58. if mobs:protect(self, clicker) then return end
  59. if mobs:capture_mob(self, clicker, 50, 50, 90, false, nil) then return end
  60. -- by right-clicking owner can switch between staying and walking
  61. if self.owner and self.owner == clicker:get_player_name() then
  62. if self.order ~= "stand" then
  63. self.order = "stand"
  64. self.state = "stand"
  65. self.object:set_velocity({x = 0, y = 0, z = 0})
  66. mobs:set_animation(self, "stand")
  67. else
  68. self.order = ""
  69. mobs:set_animation(self, "stoodup")
  70. end
  71. end
  72. end,
  73. do_custom = function(self, dtime)
  74. if hairball == "false" then
  75. return
  76. end
  77. self.hairball_timer = (self.hairball_timer or 0) + dtime
  78. if self.hairball_timer < 10 then
  79. return
  80. end
  81. self.hairball_timer = 0
  82. if self.child
  83. or math.random(1, 250) > 1 then
  84. return
  85. end
  86. local pos = self.object:get_pos()
  87. minetest.add_item(pos, "mobs:hairball")
  88. minetest.sound_play("default_dig_snappy", {
  89. pos = pos,
  90. gain = 1.0,
  91. max_hear_distance = 5,
  92. })
  93. end,
  94. })
  95. local spawn_on = "default:dirt_with_grass"
  96. if minetest.get_modpath("ethereal") then
  97. spawn_on = "ethereal:grove_dirt"
  98. end
  99. mobs:spawn({
  100. name = "mobs_animal:kitten",
  101. nodes = {spawn_on},
  102. neighbors = {"group:grass"},
  103. min_light = 14,
  104. interval = 60,
  105. chance = 10000, -- 22000
  106. min_height = 5,
  107. max_height = 50,
  108. day_toggle = true,
  109. })
  110. mobs:register_egg("mobs_animal:kitten", S("Kitten"), "mobs_kitten_inv.png", 0)
  111. mobs:alias_mob("mobs:kitten", "mobs_animal:kitten") -- compatibility
  112. local hairball_items = {
  113. "default:stick", "default:coal_lump", "default:dry_shrub", "flowers:rose",
  114. "mobs_animal:rat", "default:grass_1", "farming:seed_wheat", "dye:green", "",
  115. "farming:seed_cotton", "default:flint", "default:sapling", "dye:white", "",
  116. "default:clay_lump", "default:paper", "default:dry_grass_1", "dye:red", "",
  117. "farming:string", "mobs:chicken_feather", "default:acacia_bush_sapling", "",
  118. "default:bush_sapling", "default:copper_lump", "default:iron_lump", "",
  119. "dye:black", "dye:brown", "default:obsidian_shard", "default:tin_lump"
  120. }
  121. minetest.register_craftitem(":mobs:hairball", {
  122. description = S("Hairball"),
  123. inventory_image = "mobs_hairball.png",
  124. on_use = function(itemstack, user, pointed_thing)
  125. local pos = user:get_pos()
  126. local dir = user:get_look_dir()
  127. local newpos = {x = pos.x + dir.x, y = pos.y + dir.y + 1.5, z = pos.z + dir.z}
  128. local item = hairball_items[math.random(1, #hairball_items)]
  129. if item ~= "" then
  130. minetest.add_item(newpos, {name = item})
  131. end
  132. minetest.sound_play("default_place_node_hard", {
  133. pos = newpos,
  134. gain = 1.0,
  135. max_hear_distance = 5,
  136. })
  137. itemstack:take_item()
  138. return itemstack
  139. end,
  140. })