secrets.sec 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. -- Note: file is not secret. Contents intentionally revealed.
  2. -- Despawn oerkki. Note: despawn effect must appear the same as the teleport
  3. -- effect. Players should not be able to tell the difference.
  4. local function despawn(self)
  5. local pos = self.object:get_pos()
  6. ambiance.sound_play("nether_portal_usual", pos, 1.0, 20)
  7. preload_tp.spawn_particles(pos)
  8. self.mkrm = true
  9. end
  10. -- Teleport to somewhere nearby.
  11. local function teleport(self)
  12. -- The oerkki teleports some distance away.
  13. local pos = self.object:get_pos()
  14. p = vector.round(pos)
  15. p.x = p.x + math.random(-70, 70)
  16. p.z = p.z + math.random(-70, 70)
  17. p.y = p.y + math.random(-15, 15)
  18. local minp = vector.add(p, {x=-10, y=-10, z=-10})
  19. local maxp = vector.add(p, {x=10, y=10, z=10})
  20. local targets = hb4.find_walkable_in_area_under_unwalkable(minp, maxp)
  21. if #targets == 0 then
  22. return
  23. end
  24. local target = targets[math.random(1, #targets)]
  25. self.object:set_pos(target)
  26. -- Play sound/particle effect.
  27. ambiance.sound_play("nether_portal_usual", pos, 1.0, 20)
  28. preload_tp.spawn_particles(pos)
  29. -- A 2/3 chance Oerkki heals.
  30. if math.random(1, 3) > 1 then
  31. self.health = math.random(self.hp_min, self.hp_max)
  32. end
  33. -- Stop any current activity.
  34. self.attack = nil
  35. mobs.transition_state(self, "")
  36. end
  37. -- The oerkki teleports to a location the player has recently been.
  38. local function prevpos(self)
  39. local pos = self.object:get_pos()
  40. -- We can assume the nearest player to us is the right one.
  41. local pref = hb4.nearest_player(pos)
  42. if not pref then
  43. return
  44. end
  45. local pname = pref:get_player_name()
  46. local positions = ap.get_position_list(pname)
  47. if #positions == 0 then
  48. return
  49. end
  50. local data = positions[math.random(1, #positions)]
  51. local target = data.pos
  52. self.object:set_pos(target)
  53. -- Play sound/particle effect.
  54. ambiance.sound_play("nether_portal_usual", pos, 1.0, 20)
  55. preload_tp.spawn_particles(pos)
  56. -- A 1/3 chance Oerkki heals.
  57. if math.random(1, 3) > 2 then
  58. self.health = math.random(self.hp_min, self.hp_max)
  59. end
  60. -- Stop any current activity.
  61. self.attack = nil
  62. mobs.transition_state(self, "")
  63. end
  64. -- The oerkki goes to harass someone else.
  65. local function harass(self)
  66. local pos = self.object:get_pos()
  67. -- Find a random player.
  68. local players = minetest.get_connected_players()
  69. if #players == 0 then
  70. return
  71. end
  72. local pref = players[math.random(1, #players)]
  73. local p = vector.round(pref:get_pos())
  74. -- Don't harass players in the city or in their bases.
  75. if city_block:in_city(p) or minetest.test_protection(p, "") then
  76. return
  77. end
  78. p.x = p.x + math.random(-10, 10)
  79. p.z = p.z + math.random(-10, 10)
  80. p.y = p.y + math.random(-15, 15)
  81. local minp = vector.add(p, {x=-5, y=-5, z=-5})
  82. local maxp = vector.add(p, {x=5, y=5, z=5})
  83. local targets = hb4.find_walkable_in_area_under_unwalkable(minp, maxp)
  84. if #targets == 0 then
  85. return
  86. end
  87. local target = targets[math.random(1, #targets)]
  88. self.object:set_pos(target)
  89. -- Play sound/particle effect.
  90. ambiance.sound_play("nether_portal_usual", pos, 1.0, 20)
  91. preload_tp.spawn_particles(pos)
  92. -- A 2/3 chance Oerkki heals.
  93. if math.random(1, 3) > 1 then
  94. self.health = math.random(self.hp_min, self.hp_max)
  95. end
  96. -- Stop any current activity.
  97. self.attack = nil
  98. mobs.transition_state(self, "")
  99. end
  100. -- The oerkki calls for reinforcements.
  101. local function reinforce(self)
  102. local pos = self.object:get_pos()
  103. -- We can assume the nearest player to us is the right one.
  104. local pref = hb4.nearest_player(pos)
  105. if not pref then
  106. return
  107. end
  108. local p = vector.round(pref:get_pos())
  109. local minp = vector.add(p, {x=-5, y=-5, z=-5})
  110. local maxp = vector.add(p, {x=5, y=5, z=5})
  111. local targets = hb4.find_walkable_in_area_under_unwalkable(minp, maxp)
  112. if #targets == 0 then
  113. return
  114. end
  115. local t1 = targets[math.random(1, #targets)]
  116. local t2 = targets[math.random(1, #targets)]
  117. local t3 = targets[math.random(1, #targets)]
  118. -- Play sound/particle effect.
  119. ambiance.sound_play("teleport", pos, 1.0, 20)
  120. preload_tp.spawn_particles(pos)
  121. minetest.add_entity(t1, "griefer:griefer")
  122. minetest.add_entity(t2, "griefer:griefer")
  123. -- Small chance of a 3rd oerkki.
  124. if math.random(1, 3) == 1 then
  125. minetest.add_entity(t3, "griefer:griefer")
  126. end
  127. -- A small chance the elite oerkki despawns.
  128. if math.random(1, 6) == 1 then
  129. despawn(self)
  130. end
  131. -- A 1/3 chance Oerkki heals.
  132. if math.random(1, 3) > 2 then
  133. self.health = math.random(self.hp_min, self.hp_max)
  134. end
  135. end
  136. -- The oerkki sets up an ambush.
  137. local function ambush(self)
  138. local pos = self.object:get_pos()
  139. local pref = hb4.nearest_player(pos)
  140. if not pref then
  141. return
  142. end
  143. local pname = pref:get_player_name()
  144. -- Cloak oerkki (actually we just remove it and spawn a new one later).
  145. cloaking.particle_effect(pos)
  146. self.mkrm = true
  147. local function spawn()
  148. local player = minetest.get_player_by_name(pname)
  149. if not player then
  150. return
  151. end
  152. local p = vector.round(player:get_pos())
  153. local minp = vector.add(p, {x=-5, y=-5, z=-5})
  154. local maxp = vector.add(p, {x=5, y=5, z=5})
  155. local targets = hb4.find_walkable_in_area_under_unwalkable(minp, maxp)
  156. if #targets == 0 then
  157. return
  158. end
  159. local target = targets[math.random(1, #targets)]
  160. -- Oerkki decloaks.
  161. minetest.add_entity(target, "griefer:elite_griefer")
  162. cloaking.particle_effect(target)
  163. end
  164. -- The oerkki reappears some time later.
  165. minetest.after(math.random(30, 360), spawn)
  166. end
  167. -- To be called externally.
  168. function griefer.stupid_oerkki_trick(self)
  169. -- Choose action based on dice. Note: the ranges should not overlap,
  170. -- otherwise chance percentages will be in conflict.
  171. local dice = math.random(1, 100)
  172. -- 20% chance the oerkki teleports somewhere else.
  173. if dice >= 80 and dice <= 100 then
  174. teleport(self)
  175. return
  176. end
  177. -- 10% chance the oerkki despawns.
  178. if dice >= 70 and dice <= 80 then
  179. despawn(self)
  180. return
  181. end
  182. -- 5% chance the oerkki teleports to somewhere the player previously was.
  183. if dice >= 65 and dice <= 70 then
  184. prevpos(self)
  185. return
  186. end
  187. -- 15% chance the oerkki goes to harass someone else.
  188. if dice >= 50 and dice <= 65 then
  189. harass(self)
  190. return
  191. end
  192. -- 10% chance the oerkki calls for reinforcements.
  193. if dice >= 40 and dice <= 50 then
  194. reinforce(self)
  195. return
  196. end
  197. -- 10% chance the oerkki sets up an ambush.
  198. if dice >= 30 and dice <= 40 then
  199. ambush(self)
  200. return
  201. end
  202. end