darts.lua 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. local function duck_explosion(pos)
  2. if minetest.is_protected(pos, "") then
  3. return
  4. end
  5. pos.y = pos.y + 1
  6. minetest.add_particlespawner({
  7. amount = 10,
  8. time = 0.2,
  9. minpos = {x=pos.x-1, y=pos.y-1, z=pos.z-1},
  10. maxpos = {x=pos.x+1, y=pos.y+4, z=pos.z+1},
  11. minvel = {x=0, y=0, z=0},
  12. maxvel = {x=1, y=1, z=1},
  13. minacc = {x=-0.5,y=5,z=-0.5},
  14. maxacc = {x=0.5,y=5,z=0.5},
  15. minexptime = 1,
  16. maxexptime = 3,
  17. minsize = 4,
  18. maxsize = 6,
  19. collisiondetection = false,
  20. vertical = false,
  21. texture = "duck_egg_fragments.png",
  22. })
  23. core.after(0.4, function()
  24. for dx = -1, 1 do
  25. pos = {x = pos.x + dx, y = pos.y, z = pos.z + dx}
  26. minetest.add_particlespawner({
  27. amount = 100,
  28. time = 0.2,
  29. minpos = {x=pos.x-1, y=pos.y-1, z=pos.z-1},
  30. maxpos = {x=pos.x+1, y=pos.y+4, z=pos.z+1},
  31. minvel = {x=0, y=0, z=0},
  32. maxvel = {x=1, y=5, z=1},
  33. minacc = {x=-0.5,y=5,z=-0.5},
  34. maxacc = {x=0.5,y=5,z=0.5},
  35. minexptime = 1,
  36. maxexptime = 3,
  37. minsize = 2,
  38. maxsize = 4,
  39. collisiondetection = false,
  40. vertical = false,
  41. texture = "tnt_smoke.png",
  42. })
  43. minetest.add_entity(pos, "nssm:duck")
  44. end
  45. end)
  46. end
  47. -- arrow (duck_arrow)
  48. mobs:register_arrow("nssm:duck_father", {
  49. visual = "sprite",
  50. visual_size = {x = 1, y = 1},
  51. textures = {"duck_egg.png"},
  52. velocity = 8,
  53. -- direct hit
  54. hit_player = function(self, player)
  55. local pos = self.object:get_pos()
  56. duck_explosion(pos)
  57. end,
  58. hit_mob = function(self, player)
  59. local pos = self.object:get_pos()
  60. duck_explosion(pos)
  61. end,
  62. hit_node = function(self, pos, node)
  63. duck_explosion(pos)
  64. end,
  65. })
  66. local function ice_explosion(pos)
  67. for i = pos.x - math.random(0, 1), pos.x + math.random(0, 1), 1 do
  68. for j = pos.y - 1, pos.y + 4, 1 do
  69. for k = pos.z-math.random(0, 1), pos.z + math.random(0, 1), 1 do
  70. local p = {x = i, y = j, z = k}
  71. local n = minetest.get_node(p).name
  72. if minetest.get_item_group(n, "unbreakable") == 1
  73. or minetest.is_protected(p, "")
  74. or (n == "bones:bones" and not nssm:affectbones(self)) then
  75. else
  76. minetest.set_node({x = i, y = j, z = k}, {name = "default:ice"})
  77. end
  78. end
  79. end
  80. end
  81. end
  82. -- snow_arrow
  83. mobs:register_arrow("nssm:snow_arrow", {
  84. visual = "sprite",
  85. visual_size = {x = 1, y = 1},
  86. textures = {"transparent.png"},
  87. velocity =20,
  88. -- direct hit
  89. hit_player = function(self, player)
  90. local pos = self.object:get_pos()
  91. ice_explosion(pos)
  92. end,
  93. hit_mob = function(self, player)
  94. local pos = self.object:get_pos()
  95. ice_explosion(pos)
  96. end,
  97. hit_node = function(self, pos, node)
  98. ice_explosion(pos)
  99. end,
  100. })
  101. -- arrow manticore
  102. mobs:register_arrow("nssm:spine", {
  103. visual = "sprite",
  104. visual_size = {x = 1, y = 1},
  105. textures = {"manticore_spine_flying.png"},
  106. velocity = 10,
  107. -- direct hit
  108. hit_player = function(self, player)
  109. player:punch(self.object, 1.0, {
  110. full_punch_interval = 1.0,
  111. damage_groups = {fleshy = 2},
  112. }, nil)
  113. end,
  114. hit_mob = function(self, player)
  115. player:punch(self.object, 1.0, {
  116. full_punch_interval = 1.0,
  117. damage_groups = {fleshy = 2},
  118. }, nil)
  119. end,
  120. hit_node = function(self, pos, node)
  121. end
  122. })
  123. --morbat arrow
  124. mobs:register_arrow("nssm:morarrow", {
  125. visual = "sprite",
  126. visual_size = {x=0.5, y=0.5},
  127. textures = {"morarrow.png"},
  128. velocity= 13,
  129. hit_player = function(self, player)
  130. player:punch(self.object, 1.0, {
  131. full_punch_interval = 1.0,
  132. damage_groups = {fleshy = 3},
  133. }, nil)
  134. end,
  135. hit_node = function(self, pos, node)
  136. end
  137. })
  138. local function explosion_web(pos)
  139. pos.y = round(pos.y)
  140. if minetest.is_protected(pos, "") then
  141. return
  142. end
  143. for i = pos.x - 1, pos.x + 1, 1 do
  144. for j = pos.y - 3, pos.y, 1 do
  145. for k = pos.z - 1, pos.z + 1, 1 do
  146. local p = {x = i, y = j, z = k}
  147. local k = {x = i, y = j + 1, z = k}
  148. local current = minetest.get_node(p).name
  149. local ontop = minetest.get_node(k).name
  150. if (current ~= "air") and
  151. (current ~= "nssm:web") and
  152. (ontop == "air") and not
  153. minetest.is_protected(p,"") and not
  154. minetest.is_protected(k,"") then
  155. minetest.set_node(k, {name="nssm:web"})
  156. end
  157. end
  158. end
  159. end
  160. end
  161. -- web arrow
  162. mobs:register_arrow("nssm:webball", {
  163. visual = "sprite",
  164. visual_size = {x = 1, y = 1},
  165. textures = {"web_ball.png"},
  166. velocity = 8,
  167. -- direct hit
  168. hit_player = function(self, player)
  169. local p = player:get_pos()
  170. explosion_web(p)
  171. end,
  172. hit_mob = function(self, player)
  173. player:punch(self.object, 1.0, {
  174. full_punch_interval = 1.0,
  175. damage_groups = {fleshy = 1},
  176. }, nil)
  177. end,
  178. hit_node = function(self, pos, node)
  179. explosion_web(pos)
  180. end
  181. })
  182. function explosion_thickweb(pos)
  183. pos.y = round(pos.y)
  184. if minetest.is_protected(pos, "") then
  185. return
  186. end
  187. for i = pos.x + 0, pos.x + 0, 1 do
  188. for j = pos.y - 2, pos.y, 1 do
  189. for k = pos.z + 0, pos.z + 0, 1 do
  190. local p = {x = i, y = j, z = k}
  191. local k = {x = i, y = j + 1, z = k}
  192. local current = minetest.get_node(p).name
  193. local ontop = minetest.get_node(k).name
  194. if (current ~= "air") and
  195. (current ~= "nssm:thick_web") and
  196. (ontop == "air") and not
  197. minetest.is_protected(p,"") and not
  198. minetest.is_protected(k,"") then
  199. minetest.set_node(k, {name="nssm:thick_web"})
  200. end
  201. end
  202. end
  203. end
  204. end
  205. -- thick_web arrow
  206. mobs:register_arrow("nssm:thickwebball", {
  207. visual = "sprite",
  208. visual_size = {x = 2, y = 2},
  209. textures = {"thick_web_ball.png"},
  210. velocity = 8,
  211. -- direct hit
  212. hit_player = function(self, player)
  213. local p = player:get_pos()
  214. explosion_thickweb(p)
  215. end,
  216. hit_mob = function(self, player)
  217. player:punch(self.object, 1.0, {
  218. full_punch_interval = 1.0,
  219. damage_groups = {fleshy = 6},
  220. }, nil)
  221. end,
  222. hit_node = function(self, pos, node)
  223. explosion_thickweb(pos)
  224. end
  225. })
  226. -- arrow=>phoenix arrow
  227. mobs:register_arrow("nssm:phoenix_arrow", {
  228. visual = "sprite",
  229. visual_size = {x = 1, y = 1},
  230. textures = {"transparent.png"},
  231. velocity = 8,
  232. -- direct hit
  233. hit_player = function(self, player)
  234. end,
  235. on_step = function(self, dtime)
  236. local pos = self.object:get_pos()
  237. if minetest.is_protected(pos, "") then
  238. return
  239. end
  240. local n = minetest.get_node(pos).name
  241. if self.timer == 0 then
  242. self.timer = os.time()
  243. end
  244. if os.time() - self.timer > 5 or minetest.is_protected(pos, "")
  245. or ((n ~= "air") and (n ~= "nssm:phoenix_fire")) then
  246. self.object:remove()
  247. end
  248. if math.random(1, 2) == 2 then
  249. minetest.set_node(pos, {name = "nssm:phoenix_fire"})
  250. end
  251. if math.random(1, 6) == 1 then
  252. local p = {
  253. x = pos.x + math.random(-1, 1),
  254. y = pos.y + math.random(-1, 1),
  255. z = pos.z + math.random(-1, 1)
  256. }
  257. local n = minetest.get_node(p).name
  258. if n == "air" then
  259. minetest.set_node(p, {name = "nssm:phoenix_fire"})
  260. end
  261. end
  262. end,
  263. })
  264. function gas_explosion(pos)
  265. if minetest.is_protected(pos, "") then
  266. return
  267. end
  268. for dx = -2, 2 do
  269. for dy = -1, 4 do
  270. for dz = -2, 2 do
  271. local p = {x = pos.x + dx, y = pos.y + dy, z = pos.z + dz}
  272. if minetest.is_protected(p, "") then
  273. return
  274. end
  275. local n = minetest.get_node(p).name
  276. if n == "air" then
  277. minetest.set_node(p, {name = "nssm:venomous_gas"})
  278. end
  279. end
  280. end
  281. end
  282. end
  283. mobs:register_arrow("nssm:super_gas", {
  284. visual = "sprite",
  285. visual_size = {x = 1, y = 1},
  286. textures = {"tnt_smoke.png^[colorize:green:170"},
  287. velocity = 8,
  288. -- direct hit
  289. hit_player = function(self, player)
  290. local p = player:get_pos()
  291. gas_explosion(p)
  292. end,
  293. hit_node = function(self, pos, node)
  294. gas_explosion(pos)
  295. end
  296. })
  297. mobs:register_arrow("nssm:roar_of_the_dragon", {
  298. visual = "sprite",
  299. visual_size = {x = 1, y = 1},
  300. textures = {"transparent.png"},
  301. velocity = 10,
  302. on_step = function(self, dtime)
  303. local pos = self.object:get_pos()
  304. local n = minetest.get_node(pos).name
  305. if self.timer == 0 then
  306. self.timer = os.time()
  307. end
  308. if os.time() - self.timer > 8 or minetest.is_protected(pos, "") then
  309. self.object:remove()
  310. end
  311. local objects = minetest.get_objects_inside_radius(pos, 1)
  312. for _,obj in ipairs(objects) do
  313. local name = obj:get_entity_name()
  314. if name ~= "nssm:roar_of_the_dragon"
  315. and name ~= "nssm:mese_dragon" then
  316. obj:set_hp(obj:get_hp() - 0.05)
  317. if obj:get_hp() <= 0 then
  318. if (not obj:is_player())
  319. and name ~= self.object:get_luaentity().name then
  320. obj:remove()
  321. end
  322. end
  323. end
  324. end
  325. minetest.set_node(pos, {name = "air"})
  326. if math.random(1, 2) == 1 then
  327. local p = {
  328. x = pos.x + math.random(-1, 1),
  329. y = pos.y + math.random(-1, 1),
  330. z = pos.z + math.random(-1, 1)
  331. }
  332. if not minetest.is_protected(p, "") then
  333. minetest.set_node(p, {name = "air"})
  334. end
  335. end
  336. end
  337. })
  338. mobs:register_arrow("nssm:lava_arrow", {
  339. visual = "sprite",
  340. visual_size = {x = 1, y = 1},
  341. textures = {"transparent.png"},
  342. velocity = 10,
  343. -- direct hit
  344. hit_player = function(self, player)
  345. local pos = self.object:get_pos()
  346. if minetest.is_protected(pos, "") then
  347. return
  348. end
  349. for dy = -1, 6, 1 do
  350. for dx = -1, 1, 2 do
  351. for dz = -1, 1, 2 do
  352. local p = {x = pos.x + dx, y = pos.y + dy, z = pos.z + dz}
  353. local n = minetest.get_node(p).name
  354. if n ~= "default:lava_flowing"
  355. and not minetest.is_protected(p, "") then
  356. minetest.set_node(p, {name = "default:lava_flowing"})
  357. end
  358. end
  359. end
  360. end
  361. end,
  362. hit_node = function(self, pos, node)
  363. end
  364. })