init.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. if minetest.get_modpath("mobs") and not mobs.mod and mobs.mod ~= "redo" then
  2. minetest.log("error", "[mobs_fish] mobs redo API not found!")
  3. return
  4. end
  5. local SPRITE_VERSION = false -- set to true to use upright sprites instead of meshes
  6. -- local variables
  7. local l_spawn_in = {
  8. "default:water_source", "default:water_flowing",
  9. "default:river_water_source", "default:river_water_flowing"
  10. }
  11. local l_spawn_near = {
  12. "default:sand","default:dirt","group:seaplants","group:seacoral"
  13. }
  14. local l_spawn_chance = 10000
  15. local l_cc_hand = 25
  16. local l_cc_net = 80
  17. local l_water_level = minetest.settings:get("water_level") - 1
  18. local l_anims = {
  19. speed_normal = 24, speed_run = 24,
  20. stand_start = 1, stand_end = 80,
  21. walk_start = 81, walk_end = 155,
  22. run_start = 81, run_end = 155
  23. }
  24. local l_visual = "mesh"
  25. local l_visual_size = {x=.75, y=.75}
  26. local l_clown_mesh = "animal_clownfish.b3d"
  27. local l_trop_mesh = "fish_blue_white.b3d"
  28. local l_clown_textures = {
  29. {"clownfish.png"},
  30. {"clownfish2.png"}
  31. }
  32. local l_trop_textures = {
  33. {"fish.png"},
  34. {"fish2.png"},
  35. {"fish3.png"}
  36. }
  37. if SPRITE_VERSION then
  38. l_visual = "upright_sprite"
  39. l_visual_size = {x=.5, y=.5}
  40. l_clown_mesh = nil
  41. l_trop_mesh = nil
  42. l_clown_textures = {{"animal_clownfish_clownfish_item.png"}}
  43. l_trop_textures = {{"animal_fish_blue_white_fish_blue_white_item.png"}}
  44. end
  45. -- Clownfish
  46. mobs:register_mob("mobs_fish:clownfish", {
  47. type = "animal",
  48. passive = true,
  49. hp_min = 1,
  50. hp_max = 4,
  51. armor = 100,
  52. collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
  53. rotate = 270,
  54. visual = l_visual,
  55. mesh = l_clown_mesh,
  56. textures = l_clown_textures,
  57. visual_size = l_visual_size,
  58. makes_footstep_sound = false,
  59. stepheight = 0.1,
  60. fly = true,
  61. fly_in = "default:water_source",
  62. fall_speed = 0,
  63. view_range = 8,
  64. water_damage = 0,
  65. lava_damage = 5,
  66. light_damage = 0,
  67. animation = l_anims,
  68. on_rightclick = function(self, clicker)
  69. mobs:capture_mob(self, clicker, l_cc_hand, l_cc_net, 0, true, "mobs_fish:clownfish")
  70. end
  71. })
  72. mobs:spawn({
  73. name = "mobs_fish:clownfish",
  74. nodes = l_spawn_in,
  75. neighbors = l_spawn_near,
  76. min_light = 5,
  77. interval = 30,
  78. chance = l_spawn_chance,
  79. max_height = l_water_level,
  80. active_object_count = 5,
  81. })
  82. mobs:register_egg("mobs_fish:clownfish", "Clownfish",
  83. "animal_clownfish_clownfish_item.png", 0)
  84. -- Tropical fish
  85. mobs:register_mob("mobs_fish:tropical", {
  86. type = "animal",
  87. passive = true,
  88. hp_min = 1,
  89. hp_max = 4,
  90. armor = 100,
  91. collisionbox = {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25},
  92. rotate = 270,
  93. visual = l_visual,
  94. mesh = l_trop_mesh,
  95. textures = l_trop_textures,
  96. visual_size = l_visual_size,
  97. makes_footstep_sound = false,
  98. stepheight = 0.1,
  99. fly = true,
  100. fly_in = "default:water_source",
  101. fall_speed = 0,
  102. view_range = 8,
  103. water_damage = 0,
  104. lava_damage = 5,
  105. light_damage = 0,
  106. animation = l_anims,
  107. on_rightclick = function(self, clicker)
  108. mobs:capture_mob(self, clicker, l_cc_hand, l_cc_net, 0, true, "mobs_fish:tropical")
  109. end
  110. })
  111. mobs:spawn({
  112. name = "mobs_fish:tropical",
  113. nodes = l_spawn_in,
  114. neighbors = l_spawn_near,
  115. min_light = 5,
  116. interval = 30,
  117. chance = l_spawn_chance,
  118. max_height = l_water_level,
  119. active_object_count = 5,
  120. })
  121. mobs:register_egg("mobs_fish:tropical", "Tropical fish",
  122. "animal_fish_blue_white_fish_blue_white_item.png", 0)