init.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. if minetest.get_modpath("mobs") and not mobs.mod and mobs.mod ~= "redo" then
  2. minetest.log("error", "[mobs_sharks] mobs redo API not found!")
  3. return
  4. end
  5. -- local variables
  6. local l_colors = {
  7. "#604000:175", --brown
  8. "#ffffff:150", --white
  9. "#404040:150", --dark_grey
  10. "#a0a0a0:150" --grey
  11. }
  12. local l_skins = {
  13. {
  14. "(shark_first.png^[colorize:" .. l_colors[3]
  15. .. ")^(shark_second.png^[colorize:" .. l_colors[4]
  16. .. ")^shark_third.png"
  17. },
  18. {
  19. "(shark_first.png^[colorize:" .. l_colors[1]
  20. .. ")^(shark_second.png^[colorize:" .. l_colors[2]
  21. ..")^shark_third.png"
  22. },
  23. {
  24. "(shark_first.png^[colorize:" .. l_colors[4]
  25. .. ")^(shark_second.png^[colorize:" .. l_colors[2]
  26. .. ")^shark_third.png"
  27. }
  28. }
  29. local l_anims = {
  30. speed_normal = 24, speed_run = 24,
  31. stand_start = 1, stand_end = 80,
  32. walk_start = 80, walk_end = 160,
  33. run_start = 80, run_end = 160
  34. }
  35. local l_model = "mob_shark.b3d"
  36. local l_egg_texture = "mob_shark_shark_item.png"
  37. local l_spawn_in = {"default:water_flowing","default:water_source"}
  38. local l_spawn_near = {
  39. "default:water_flowing", "default:water_source",
  40. "seawrecks:woodship", "seawrecks:uboot"
  41. }
  42. local l_spawn_chance = 60000
  43. -- load settings
  44. dofile(minetest.get_modpath("mobs_sharks").."/SETTINGS.txt")
  45. if not ENABLE_SHARK_LARGE then
  46. l_spawn_chance = l_spawn_chance - 20000
  47. end
  48. if not ENABLE_SHARK_MEDIUM then
  49. l_spawn_chance = l_spawn_chance - 20000
  50. end
  51. if not ENABLE_SHARK_SMALL then
  52. l_spawn_chance = l_spawn_chance - 20000
  53. end
  54. -- large
  55. if ENABLE_SHARK_LARGE then
  56. mobs:register_mob("mobs_sharks:shark_lg", {
  57. type = "monster",
  58. attack_type = "dogfight",
  59. damage = 10,
  60. reach = 3,
  61. hp_min = 20,
  62. hp_max = 25,
  63. armor = 150,
  64. collisionbox = {-0.75, -0.5, -0.75, 0.75, 0.5, 0.75},
  65. visual = "mesh",
  66. mesh = l_model,
  67. textures = l_skins,
  68. makes_footstep_sound = false,
  69. walk_velocity = 4,
  70. run_velocity = 6,
  71. fly = true,
  72. fly_in = "default:water_source",
  73. fall_speed = 0,
  74. rotate = 270,
  75. view_range = 10,
  76. water_damage = 0,
  77. lava_damage = 10,
  78. light_damage = 0,
  79. animation = l_anims,
  80. jump = false,
  81. stepheight = 0.1,
  82. drops = {
  83. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  84. },
  85. })
  86. mobs:spawn({
  87. name = "mobs_sharks:shark_lg",
  88. nodes = l_spawn_in,
  89. neighbors = l_spawn_near,
  90. interval = 30,
  91. chance = l_spawn_chance,
  92. max_height = 0,
  93. })
  94. mobs:register_egg("mobs_sharks:shark_lg", "Shark (large)", l_egg_texture, 0)
  95. end
  96. -- medium
  97. if ENABLE_SHARK_MEDIUM then
  98. mobs:register_mob("mobs_sharks:shark_md", {
  99. type = "monster",
  100. attack_type = "dogfight",
  101. damage = 8,
  102. reach = 2,
  103. hp_min = 15,
  104. hp_max = 20,
  105. armor = 125,
  106. collisionbox = {-0.57, -0.38, -0.57, 0.57, 0.38, 0.57},
  107. visual = "mesh",
  108. visual_size = {x = 0.75, y = 0.75},
  109. mesh = l_model,
  110. textures = l_skins,
  111. makes_footstep_sound = false,
  112. walk_velocity = 2,
  113. run_velocity = 4,
  114. fly = true,
  115. fly_in = "default:water_source",
  116. fall_speed = -1,
  117. rotate = 270,
  118. view_range = 10,
  119. water_damage = 0,
  120. lava_damage = 10,
  121. light_damage = 0,
  122. animation = l_anims,
  123. jump = false,
  124. stepheight = 0.1,
  125. drops = {
  126. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  127. },
  128. })
  129. mobs:spawn({
  130. name = "mobs_sharks:shark_md",
  131. nodes = l_spawn_in,
  132. neighbors = l_spawn_near,
  133. interval = 30,
  134. chance = l_spawn_chance,
  135. max_height = 0,
  136. })
  137. mobs:register_egg("mobs_sharks:shark_md", "Shark (medium)", l_egg_texture, 0)
  138. end
  139. -- small
  140. if ENABLE_SHARK_SMALL then
  141. mobs:register_mob("mobs_sharks:shark_sm", {
  142. type = "monster",
  143. attack_type = "dogfight",
  144. damage = 6,
  145. reach = 1,
  146. hp_min = 10,
  147. hp_max = 15,
  148. armor = 100,
  149. collisionbox = {-0.38, -0.25, -0.38, 0.38, 0.25, 0.38},
  150. visual = "mesh",
  151. visual_size = {x = 0.5, y = 0.5},
  152. mesh = l_model,
  153. textures = l_skins,
  154. makes_footstep_sound = false,
  155. walk_velocity = 2,
  156. run_velocity = 4,
  157. fly = true,
  158. fly_in = "default:water_source",
  159. fall_speed = -1,
  160. rotate = 270,
  161. view_range = 10,
  162. water_damage = 0,
  163. lava_damage = 10,
  164. light_damage = 0,
  165. animation = l_anims,
  166. jump = false,
  167. stepheight = 0.1,
  168. drops = {
  169. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  170. },
  171. })
  172. mobs:spawn({
  173. name = "mobs_sharks:shark_sm",
  174. nodes = l_spawn_in,
  175. neighbors = l_spawn_near,
  176. interval = 30,
  177. chance = l_spawn_chance,
  178. max_height = 0,
  179. })
  180. mobs:register_egg("mobs_sharks:shark_sm", "Shark (small)", l_egg_texture, 0)
  181. end