init.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. if minetest.get_modpath("mobs") and not mobs.mod and mobs.mod ~= "redo" then
  2. minetest.log("error", "[mobs_crocs] mobs redo API not found!")
  3. return
  4. end
  5. -- local variables
  6. local l_skins = {
  7. {"croco.png"},
  8. {"croco2.png"}
  9. }
  10. local l_anims = {
  11. speed_normal = 24, speed_run = 24,
  12. stand_start = 0, stand_end = 80,
  13. walk_start = 81, walk_end = 170,
  14. run_start = 81, run_end = 170,
  15. punch_start = 205, punch_end = 220
  16. }
  17. local l_model = "crocodile.x"
  18. local l_sounds = {random = "croco"}
  19. local l_egg_texture = "default_grass.png"
  20. local l_spawn_chance = 60000
  21. -- load settings
  22. local ENABLE_WALKERS = minetest.settings:get_bool("mobs_crocs.enable_walkers", true)
  23. local ENABLE_FLOATERS = minetest.settings:get_bool("mobs_crocs.enable_floaters", true)
  24. local ENABLE_SWIMMERS = minetest.settings:get_bool("mobs_crocs.enable_swimmers", true)
  25. if not ENABLE_WALKERS then
  26. l_spawn_chance = l_spawn_chance - 20000
  27. end
  28. if not ENABLE_FLOATERS then
  29. l_spawn_chance = l_spawn_chance - 20000
  30. end
  31. if not ENABLE_SWIMMERS then
  32. l_spawn_chance = l_spawn_chance - 20000
  33. end
  34. -- no float
  35. if ENABLE_WALKERS then
  36. mobs:register_mob("mobs_crocs:crocodile", {
  37. type = "monster",
  38. attack_type = "dogfight",
  39. damage = 8,
  40. reach = 3,
  41. hp_min = 20,
  42. hp_max = 25,
  43. armor = 200,
  44. collisionbox = {-0.85, -0.30, -0.85, 0.85, .5, 0.85},
  45. drawtype = "front",
  46. visual = "mesh",
  47. mesh = l_model,
  48. textures = l_skins,
  49. visual_size = {x = 4, y = 4},
  50. sounds = l_sounds,
  51. fly = false,
  52. floats = 0,
  53. stepheight = 1,
  54. view_range = 10,
  55. water_damage = 0,
  56. lava_damage = 10,
  57. light_damage = 0,
  58. animation = l_anims,
  59. drops = {
  60. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  61. {name = "mobs:leather", chance = 1, min = 0, max = 2},
  62. },
  63. })
  64. mobs:spawn({
  65. name = "mobs_crocs:crocodile",
  66. nodes = {
  67. "default:dirt_with_grass", "default:dirt",
  68. "default:jungle_grass", "default:sand"
  69. },
  70. neighbors = {
  71. "default:water_flowing", "default:water_source",
  72. "default:papyrus", "dryplants:juncus", "dryplants:reedmace"
  73. },
  74. interval = 30,
  75. chance = l_spawn_chance,
  76. min_height = 0,
  77. max_height = 10,
  78. })
  79. mobs:register_egg("mobs_crocs:crocodile", "Crocodile", l_egg_texture, 1)
  80. end
  81. -- float
  82. if ENABLE_FLOATERS then
  83. mobs:register_mob("mobs_crocs:crocodile_float", {
  84. type = "monster",
  85. attack_type = "dogfight",
  86. damage = 8,
  87. reach = 2,
  88. hp_min = 20,
  89. hp_max = 25,
  90. armor = 200,
  91. collisionbox = {-0.638, -0.23, -0.638, 0.638, .5, 0.638},
  92. drawtype = "front",
  93. visual = "mesh",
  94. mesh = l_model,
  95. textures = l_skins,
  96. visual_size = {x = 3, y = 3},
  97. sounds = l_sounds,
  98. fly = false,
  99. stepheight = 1,
  100. view_range = 10,
  101. water_damage = 0,
  102. lava_damage = 10,
  103. light_damage = 0,
  104. animation = l_anims,
  105. drops = {
  106. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  107. {name = "mobs:leather", chance = 1, min = 0, max = 2},
  108. },
  109. })
  110. mobs:spawn({
  111. name = "mobs_crocs:crocodile_float",
  112. nodes = {"default:water_flowing","default:water_source"},
  113. neighbors = {
  114. "default:dirt_with_grass", "default:jungle_grass", "default:sand",
  115. "default:dirt", "default:papyrus", "group:seaplants",
  116. "dryplants:juncus", "dryplants:reedmace"
  117. },
  118. interval = 30,
  119. chance = l_spawn_chance,
  120. min_height = -3,
  121. max_height = 10,
  122. })
  123. mobs:register_egg("mobs_crocs:crocodile_float", "Crocodile (floater)",
  124. l_egg_texture, 1)
  125. end
  126. -- swim
  127. if ENABLE_SWIMMERS then
  128. mobs:register_mob("mobs_crocs:crocodile_swim", {
  129. type = "monster",
  130. attack_type = "dogfight",
  131. damage = 8,
  132. reach = 1,
  133. hp_min = 20,
  134. hp_max = 25,
  135. armor = 200,
  136. collisionbox = {-0.425, -0.15, -0.425, 0.425, 0.5, 0.425},
  137. drawtype = "front",
  138. visual = "mesh",
  139. mesh = l_model,
  140. textures = l_skins,
  141. visual_size = {x = 2, y = 2},
  142. sounds = l_sounds,
  143. fly = true,
  144. fly_in = "default:water_source",
  145. fall_speed = -1,
  146. floats = 0,
  147. view_range = 10,
  148. water_damage = 0,
  149. lava_damage = 10,
  150. light_damage = 0,
  151. animation = l_anims,
  152. drops = {
  153. {name = "mobs:meat_raw", chance = 1, min = 1, max = 3},
  154. {name = "mobs:leather", chance = 1, min = 0, max = 2},
  155. },
  156. })
  157. mobs:spawn({
  158. name = "mobs_crocs:crocodile_swim",
  159. nodes = {"default:water_flowing","default:water_source"},
  160. neighbors = {"default:sand","default:dirt","group:seaplants"},
  161. interval = 30,
  162. chance = l_spawn_chance,
  163. min_height = -8,
  164. max_height = 10,
  165. })
  166. mobs:register_egg("mobs_crocs:crocodile_swim", "Crocodile (swimmer)",
  167. l_egg_texture, 1)
  168. end