larva.lua 4.3 KB

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