larva.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. mobs:register_mob('fantasy_mobs:larva', {
  2. description = 'Larva',
  3. type = 'monster',
  4. damage = 30,
  5. attack_type = 'dogfight',
  6. hp_min = 40,
  7. hp_max = 100,
  8. armor = 75,
  9. collisionbox = {-.35,-.05,-.35,.35,.3,.35},
  10. visual = 'mesh',
  11. mesh = 'fantasy_larva.b3d',
  12. textures = {
  13. {'fantasy_larva.png'},
  14. },
  15. visual_size = {x = 10, y = 10},
  16. walk_velocity = 1,
  17. run_velocity = 3,
  18. water_damage = 0,
  19. lava_damage = 10,
  20. view_range = 5,
  21. reach = 2,
  22. replace_rate = 1,
  23. replace_what = {
  24. {'default:obsidian', 'fantasy_mobs:larva_egg', 0},
  25. },
  26. drops = {
  27. {name = 'fantasy_mobs:larva_egg', chance = 100, min = 0, max = 1},
  28. },
  29. runaway_from = {'fantasy_mobs:larva_pet'},
  30. animation = {
  31. walk_start = 1,
  32. walk_end = 59,
  33. punch_start = 61,
  34. punch_end = 100,
  35. },
  36. })
  37. mobs:register_mob('fantasy_mobs:larva_pet', {
  38. description = 'Larva pet',
  39. type = 'npc',
  40. passive = false,
  41. attack_type = 'dogfight',
  42. owner_loyal = true,
  43. pathfinding = true,
  44. damage = 7,
  45. hp_min = 20,
  46. hp_max = 60,
  47. armor = 75,
  48. collisionbox = {-.35,-.05,-.35,.35,.3,.35},
  49. visual = 'mesh',
  50. mesh = 'fantasy_larva.b3d',
  51. textures = {
  52. {'fantasy_larva.png'},
  53. },
  54. visual_size = {x = 10, y = 10},
  55. walk_velocity = 1,
  56. run_velocity = 3,
  57. water_damage = 0,
  58. lava_damage = 10,
  59. light_damage = 1,
  60. view_range = 5,
  61. fear_height = 2,
  62. follow = 'default:obsidian_shard',
  63. owner = '',
  64. order = 'follow',
  65. reach = 2,
  66. animation = {
  67. walk_start = 1,
  68. walk_end = 59,
  69. punch_start = 61,
  70. punch_end = 100,
  71. },
  72. on_spawn = function(self)
  73. local pos = self.object:get_pos()
  74. local objs = minetest.get_objects_inside_radius(pos, 4)
  75. for _, obj in pairs(objs) do
  76. if obj:is_player() then
  77. local owner = obj:get_player_name()
  78. self.owner = owner
  79. minetest.chat_send_player(owner, "Eww, a nether larva think you're its parent, gross.")
  80. end
  81. end
  82. return true
  83. end,
  84. on_rightclick = function(self, clicker)
  85. local name = clicker:get_player_name()
  86. if mobs:feed_tame(self, clicker, 10, false, true) then
  87. return
  88. end
  89. if self.owner and self.owner == name then
  90. if self.order == 'follow' then
  91. self.order = 'stand'
  92. minetest.chat_send_player(name, ('Larva holding ground.'))
  93. else
  94. self.order = 'follow'
  95. minetest.chat_send_player(name, ('Larva following you.'))
  96. end
  97. mobs:capture_mob(self, clicker, 20, 0, 100, false, nil)
  98. end
  99. end,
  100. })
  101. mobs:spawn({
  102. name = 'fantasy_mobs:larva',
  103. nodes = {'nether:rack'},
  104. min_height = -31000,
  105. max_height = -5000,
  106. interval = 31,
  107. chance = 2000,
  108. active_object_count = 15,
  109. })
  110. minetest.register_node('fantasy_mobs:larva_egg', {
  111. description = 'Larva egg',
  112. drawtype = 'mesh',
  113. mesh = 'fantasy_mobs_larva_egg.obj',
  114. tiles = {'fantasy_larva.png'},
  115. paramtype = 'light',
  116. groups = {oddly_breakable_by_hand=1},
  117. selection_box = {
  118. type = 'fixed',
  119. fixed = {-.2, -.5, -.2, .2, -.1, .2}, -- Right, Bottom, Back, Left, Top, Front
  120. },
  121. collision_box = {
  122. type = 'fixed',
  123. fixed = {-.2, -.5, -.2, .2, -.1, .2}, -- Right, Bottom, Back, Left, Top, Front
  124. },
  125. on_construct = function(pos)
  126. local fpos, num = minetest.find_nodes_in_area(
  127. {x = pos.x+2, y = pos.y, z = pos.z+2},
  128. {x = pos.x-2, y = pos.y-1, z = pos.z-2},
  129. 'nether:sand')
  130. if #fpos >= 9 then
  131. if pos.y > 0 then
  132. local timer = minetest.get_node_timer(pos)
  133. timer:start(300)
  134. end
  135. end
  136. end,
  137. on_timer = function(pos)
  138. minetest.add_entity(pos, 'fantasy_mobs:larva_pet')
  139. minetest.remove_node(pos)
  140. end,
  141. })
  142. mobs:register_egg('fantasy_mobs:larva_pet', 'Nether Larva', 'fantasy_mobs_larva_pet.png', 0, true)