goblins.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. local search_replace2 = function(
  2. self,
  3. search_rate,
  4. search_rate_above,
  5. search_rate_below,
  6. search_offset,
  7. search_offset_above,
  8. search_offset_below,
  9. replace_rate,
  10. replace_what,
  11. replace_with)
  12. if math.random(1, search_rate) == 1 then
  13. local pos = self.object:get_pos() --
  14. local pos1 = self.object:get_pos()
  15. local pos2 = self.object:get_pos()
  16. -- if we are looking, will we look below and by how much?
  17. if math.random(1, search_rate_below) == 1 then
  18. pos1.y = pos1.y - search_offset_below
  19. end
  20. -- if we are looking, will we look above and by how much?
  21. if math.random(1, search_rate_above) == 1 then
  22. pos2.y = pos2.y + search_offset_above
  23. end
  24. pos1.x = pos1.x - search_offset
  25. pos1.z = pos1.z - search_offset
  26. pos2.x = pos2.x + search_offset
  27. pos2.z = pos2.z + search_offset
  28. local nodelist = minetest.find_nodes_in_area(pos1, pos2, replace_what)
  29. if #nodelist > 0 then
  30. for key,value in pairs(nodelist) do
  31. -- ok we see some nodes around us, are we going to replace them?
  32. if math.random(1, replace_rate) == 1 then
  33. minetest.set_node(value, {name = replace_with})
  34. end
  35. minetest.sound_play(self.sounds.replace, {
  36. object = self.object,
  37. max_hear_distance = self.sounds.distance
  38. })
  39. end
  40. end
  41. end
  42. end
  43. local goblin_sounds = {
  44. random = "goblins_goblin_ambient",
  45. warcry = "goblins_goblin_attack",
  46. attack = "goblins_goblin_attack",
  47. damage = "goblins_goblin_damage",
  48. death = "goblins_goblin_death",
  49. distance = 7,
  50. }
  51. mobs:register_mob('fantasy_mobs:goblin', {
  52. description = 'Goblin',
  53. type = 'monster',
  54. passive = false,
  55. damage = 8,
  56. attack_type = 'dogfight',
  57. hp_min = 20,
  58. hp_max = 50,
  59. armor = 100,
  60. collisionbox = {-0.35,-1,-0.35, 0.35,-.1,0.35},
  61. visual = 'mesh',
  62. mesh = 'fantasy_goblin.b3d',
  63. textures = {
  64. {'fantasy_goblin_1.png'},
  65. {'fantasy_goblin_2.png'},
  66. {'fantasy_goblin_3.png'},
  67. {'fantasy_goblin_4.png'},
  68. {'fantasy_goblin_5.png'},
  69. {'fantasy_goblin_6.png'},
  70. {'fantasy_goblin_7.png'},
  71. {'fantasy_goblin_8.png'},
  72. {'fantasy_goblin_9.png'},
  73. {'fantasy_goblin_10.png'},
  74. {'fantasy_goblin_11.png'},
  75. {'fantasy_goblin_12.png'},
  76. },
  77. makes_footstep_sound = true,
  78. sounds = goblin_sounds,
  79. walk_velocity = 2,
  80. run_velocity = 3,
  81. jump = true,
  82. drops = {
  83. {name = 'default:mossycobble', chance = 1, min = 1, max = 3},
  84. {name = 'default:apple', chance = 2, min = 1, max = 2},
  85. {name = 'default:torch', chance = 3, min = 1, max = 10},
  86. {name = 'default:coal_lump', chance = 10, min = 1, max = 15},
  87. {name = 'stations:scroll_anti_fire', chance = 30, min = 1, max = 1},
  88. {name = 'stations:scroll_sulfur_dust', chance = 30, min = 1, max = 1},
  89. {name = 'stations:scroll_gunpowder', chance = 30, min = 1, max = 1},
  90. {name = 'default:diamond', chance = 500, min = 0, max = 20},
  91. {name = 'farming:coffee_beans', chance = 300, min = 0, max = 5},
  92. {name = 'stations:scroll_ash', chance = 1, min = 0, max = 1},
  93. {name = 'epic:reaver', chance = 150, min = 0, max = 1},
  94. {name = 'illuminati:cone_off', chance = 150, min = 0, max = 1},
  95. {name = 'illuminati:core_off', chance = 150, min = 0, max = 1},
  96. },
  97. water_damage = 0,
  98. lava_damage = 2,
  99. light_damage = 0,
  100. follow = {'default:diamond', 'default:apple', 'farming:bread'},
  101. view_range = 10,
  102. animation = {
  103. speed_normal = 30,
  104. speed_run = 30,
  105. stand_start = 0,
  106. stand_end = 79,
  107. walk_start = 168,
  108. walk_end = 187,
  109. run_start = 168,
  110. run_end = 187,
  111. punch_start = 200,
  112. punch_end = 219,
  113. },
  114. replace_what = {'default:torch', 'default:torch_wall', 'default:torch_ceiling'},
  115. do_custom = function(self)
  116. search_replace2(
  117. self,
  118. 10, --search_rate
  119. 1, --search_rate_above
  120. 1, --search_rate_below
  121. 1, --search_offset
  122. 2, --search_offset_above
  123. 1, --search_offset_below
  124. 5, --replace_rate
  125. {'default:torch', 'default:torch_wall', 'default:torch_ceiling'}, --replace_what
  126. 'air') --replace_with
  127. end,
  128. })
  129. mobs:spawn({
  130. name = 'fantasy_mobs:goblin',
  131. nodes = {'default:mossycobble'},
  132. max_light = 13,
  133. min_height = -31000,
  134. max_height = -10,
  135. interval = 30,
  136. chance = 250,
  137. active_object_count = 10,
  138. })