goblins.lua 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. damage_max = 12,
  57. damage_chance = 95,
  58. attack_type = 'dogfight',
  59. hp_min = 20,
  60. hp_max = 50,
  61. armor = 100,
  62. collisionbox = {-0.35,-1,-0.35, 0.35,-.1,0.35},
  63. visual = 'mesh',
  64. mesh = 'fantasy_goblin.b3d',
  65. textures = {
  66. {'fantasy_goblin_1.png'},
  67. {'fantasy_goblin_2.png'},
  68. {'fantasy_goblin_3.png'},
  69. {'fantasy_goblin_4.png'},
  70. {'fantasy_goblin_5.png'},
  71. {'fantasy_goblin_6.png'},
  72. {'fantasy_goblin_7.png'},
  73. {'fantasy_goblin_8.png'},
  74. {'fantasy_goblin_9.png'},
  75. {'fantasy_goblin_10.png'},
  76. {'fantasy_goblin_11.png'},
  77. {'fantasy_goblin_12.png'},
  78. },
  79. makes_footstep_sound = true,
  80. sounds = goblin_sounds,
  81. walk_velocity = 2,
  82. run_velocity = 3,
  83. jump = true,
  84. drops = {
  85. {name = 'default:mossycobble', chance = 1, min = 1, max = 3},
  86. {name = 'default:apple', chance = 2, min = 1, max = 2},
  87. {name = 'default:torch', chance = 3, min = 1, max = 10},
  88. {name = 'default:coal_lump', chance = 10, min = 1, max = 15},
  89. {name = 'stations:scroll_anti_fire', chance = 30, min = 1, max = 1},
  90. {name = 'stations:scroll_sulfur_dust', chance = 30, min = 1, max = 1},
  91. {name = 'stations:scroll_gunpowder', chance = 30, min = 1, max = 1},
  92. {name = 'default:diamond', chance = 500, min = 0, max = 20},
  93. {name = 'farming:coffee_beans', chance = 300, min = 0, max = 5},
  94. {name = 'stations:scroll_ash', chance = 1, min = 0, max = 1},
  95. {name = 'epic:reaver', chance = 150, min = 0, max = 1},
  96. {name = 'illuminati:cone_off', chance = 150, min = 0, max = 1},
  97. {name = 'illuminati:core_off', chance = 150, min = 0, max = 1},
  98. {name = 'fantasy_mobs:goblin_sketch', chance = 10, min = 1, max = 1},
  99. },
  100. water_damage = 0,
  101. lava_damage = 2,
  102. light_damage = 0,
  103. follow = {'default:diamond', 'default:apple', 'farming:bread'},
  104. view_range = 10,
  105. animation = {
  106. speed_normal = 30,
  107. speed_run = 30,
  108. stand_start = 0,
  109. stand_end = 79,
  110. walk_start = 168,
  111. walk_end = 187,
  112. run_start = 168,
  113. run_end = 187,
  114. punch_start = 200,
  115. punch_end = 219,
  116. },
  117. replace_what = {'default:torch', 'default:torch_wall', 'default:torch_ceiling'},
  118. do_custom = function(self)
  119. search_replace2(
  120. self,
  121. 10, --search_rate
  122. 1, --search_rate_above
  123. 1, --search_rate_below
  124. 1, --search_offset
  125. 2, --search_offset_above
  126. 1, --search_offset_below
  127. 5, --replace_rate
  128. {'default:torch', 'default:torch_wall', 'default:torch_ceiling'}, --replace_what
  129. 'air') --replace_with
  130. end,
  131. })
  132. mobs:spawn({
  133. name = 'fantasy_mobs:goblin',
  134. nodes = {'default:mossycobble'},
  135. max_light = 13,
  136. min_height = -31000,
  137. max_height = -10,
  138. interval = 30,
  139. chance = 250,
  140. active_object_count = 10,
  141. })