nssm_weapons.lua 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255
  1. --Parameters used by some weapons
  2. local default_dir = {x = 1, y = 1, z = 1}
  3. --Function used to shoot:
  4. local function weapons_shot(itemstack, placer, pointed_thing, velocity, name)
  5. local dir = placer:get_look_dir();
  6. local playerpos = placer:get_pos();
  7. local obj = minetest.add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+0+dir.z}, "nssm:"..name)
  8. local vec = {x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}
  9. obj:set_velocity(vec)
  10. return itemstack
  11. end
  12. local function hit(pos, self)
  13. local node = node_ok(pos).name
  14. self.hit_node(self, pos, node)
  15. self.object:remove()
  16. return
  17. end
  18. local function activate_balls(pos)
  19. local radius = 50
  20. local objects = minetest.get_objects_inside_radius(pos, radius)
  21. for _,obj in ipairs(objects) do
  22. if (obj:get_luaentity() and obj:get_luaentity().name == "nssm:hellzone_grenade") then
  23. obj:get_luaentity().move = 1
  24. end
  25. end
  26. end
  27. local function search_on_step2(
  28. self,
  29. dtime, --used to count time
  30. max_time, --after this amount of time the entity is removec
  31. radius, --radius in which look for entities to follow
  32. vel) --velocity of the projectile
  33. local pos = self.object:get_pos()
  34. --Disappear after a certain time
  35. if self.life_time == 0 then
  36. self.life_time = os.time()
  37. end
  38. if os.time() - self.life_time > max_time then
  39. self.object:remove()
  40. return
  41. end
  42. --Look for an entity to follow
  43. local objects = minetest.get_objects_inside_radius(pos, radius)
  44. local min_dist = 100
  45. local obj_min = nil
  46. local obj_p = nil
  47. local vec_min = nil
  48. for _,obj in ipairs(objects) do
  49. if (obj:is_player()) then
  50. elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item" and obj:get_luaentity().name ~= self.object:get_luaentity().name) then
  51. obj_p = obj:get_pos()
  52. local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
  53. local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
  54. if (dist<min_dist) then
  55. min_dist = dist
  56. obj_min = obj
  57. vec_min = vec
  58. end
  59. end
  60. end
  61. --Found an entity to follow:
  62. if obj_min ~= nil then
  63. local new_vel = {x=0, y=0, z=0}
  64. local dir = 0
  65. local max_diff = 0
  66. if (max_diff<math.abs(vec_min.x)) then
  67. dir = 1
  68. max_diff = math.abs(vec_min.x)
  69. end
  70. if (max_diff<math.abs(vec_min.y)) then
  71. dir = 2
  72. max_diff = math.abs(vec_min.y)
  73. end
  74. if (max_diff<math.abs(vec_min.z)) then
  75. dir = 3
  76. max_diff = math.abs(vec_min.z)
  77. end
  78. vec_min.x = (vec_min.x/max_diff)*vel
  79. vec_min.y = (vec_min.y/max_diff)*vel
  80. vec_min.z = (vec_min.z/max_diff)*vel
  81. obj_p = obj_min:get_pos()
  82. if min_dist <=8 and self.move==0 then
  83. self.object:set_velocity({x=0, y=0, z=0})
  84. --hit(pos,self)
  85. elseif min_dist<=1 and self.move==1 then
  86. hit(pos,self)
  87. else
  88. self.object:set_velocity(vec_min)
  89. end
  90. end
  91. local n = minetest.get_node(pos).name
  92. if n ~= "air" and n ~= "default:water_source" and n ~= "default:water_flowing" then
  93. hit(pos,self)
  94. end
  95. end
  96. --on_step function able to follow the mobs
  97. local function search_on_step(
  98. self,
  99. dtime, --used to count time
  100. max_time, --after this amount of time the entity is removec
  101. radius, --radius in which look for entities to follow
  102. vel) --velocity of the projectile
  103. local pos = self.object:get_pos()
  104. --Disappear after a certain time
  105. if self.life_time == 0 then
  106. self.life_time = os.time()
  107. end
  108. if os.time() - self.life_time > max_time then
  109. self.object:remove()
  110. return
  111. end
  112. --Look for an entity to follow
  113. local objects = minetest.get_objects_inside_radius(pos, radius)
  114. local min_dist = 100
  115. local obj_min = nil
  116. local obj_p = nil
  117. local vec_min = nil
  118. for _,obj in ipairs(objects) do
  119. if (obj:is_player()) then
  120. elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item" and obj:get_luaentity().name ~= self.object:get_luaentity().name) then
  121. obj_p = obj:get_pos()
  122. local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
  123. local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
  124. if (dist<min_dist) then
  125. min_dist = dist
  126. obj_min = obj
  127. vec_min = vec
  128. end
  129. end
  130. end
  131. --Found an entity to follow:
  132. if obj_min ~= nil then
  133. local new_vel = {x=0, y=0, z=0}
  134. local dir = 0
  135. local max_diff = 0
  136. if (max_diff<math.abs(vec_min.x)) then
  137. dir = 1
  138. max_diff = math.abs(vec_min.x)
  139. end
  140. if (max_diff<math.abs(vec_min.y)) then
  141. dir = 2
  142. max_diff = math.abs(vec_min.y)
  143. end
  144. if (max_diff<math.abs(vec_min.z)) then
  145. dir = 3
  146. max_diff = math.abs(vec_min.z)
  147. end
  148. vec_min.x = (vec_min.x/max_diff)*vel
  149. vec_min.y = (vec_min.y/max_diff)*vel
  150. vec_min.z = (vec_min.z/max_diff)*vel
  151. obj_p = obj_min:get_pos()
  152. if min_dist < 1 then
  153. local node = node_ok(pos).name
  154. self.hit_node(self, pos, node)
  155. self.object:remove()
  156. return
  157. else
  158. self.object:set_velocity(vec_min)
  159. end
  160. end
  161. local n = minetest.get_node(pos).name
  162. if n ~= "air" and n ~= "default:water_source" and n ~= "default:water_flowing" then
  163. local node = node_ok(pos).name
  164. self.hit_node(self, pos, node)
  165. self.object:remove()
  166. return
  167. end
  168. end
  169. local function default_on_step(
  170. self,
  171. dtime, --used to count time
  172. max_time, --after this amount of time the entity is removec
  173. damage, --damage dealt to the entity around
  174. dir, --vector to specify directions in which remove blocks
  175. radius, --radius of blocks removed aroind the projectile
  176. not_transparent, --name of a block or of a group: when the projectile hit one of these blocks the function hit_node is called
  177. vel) --velocity of the projectile
  178. local pos = self.object:get_pos()
  179. if self.life_time == 0 then
  180. self.life_time = os.time()
  181. end
  182. if os.time() - self.life_time > max_time then
  183. local node = node_ok(pos).name
  184. self.hit_node(self, pos, node)
  185. self.object:remove()
  186. return
  187. end
  188. self.timer = self.timer + dtime
  189. --minetest.chat_send_all("Timer: "..self.timer)
  190. --while going around it damages entities
  191. local objects = minetest.get_objects_inside_radius(pos, 2)
  192. if self.timer > 0.1 then
  193. self.timer = 0
  194. for _,obj in ipairs(objects) do
  195. if obj:get_luaentity() then
  196. if obj and obj:get_luaentity()
  197. and obj:get_luaentity().name ~= self.object:get_luaentity().name
  198. and obj:get_luaentity().name ~= "__builtin:item" then
  199. if obj:is_player() then
  200. obj:set_hp(obj:get_hp()-damage)
  201. elseif obj:get_luaentity().health then
  202. obj:get_luaentity().health = obj:get_luaentity().health - damage
  203. --minetest.chat_send_all("Danneggiato: "..obj:get_luaentity_name().." Vita: "..obj:get_luaentity().health)
  204. -- check_for_death(obj:get_luaentity())
  205. end
  206. end
  207. end
  208. end
  209. end
  210. local n = minetest.get_node(pos).name
  211. if n==not_transparent or minetest.get_item_group(n, not_transparent)==1 then
  212. local node = node_ok(pos).name
  213. self.hit_node(self, pos, node)
  214. self.object:remove()
  215. return
  216. else
  217. local vec = self.object:get_velocity()
  218. local c=vel/10
  219. --calculate how many blocks around need to be removed
  220. local max = 0
  221. local posmax = 0
  222. if max<math.abs(vec.x) then
  223. max = math.abs(vec.x)
  224. posmax = 1
  225. end
  226. if max<math.abs(vec.y) then
  227. max = math.abs(vec.y)
  228. posmax = 2
  229. end
  230. if max<math.abs(vec.z) then
  231. max = math.abs(vec.z)
  232. posmax = 3
  233. end
  234. local i = radius
  235. local j = radius
  236. local k = radius
  237. if dir.x == 0 then
  238. i = 0
  239. end
  240. if dir.y == 0 then
  241. j = 0
  242. end
  243. if dir.z == 0 then
  244. k = 0
  245. end
  246. if posmax==1 then
  247. i = 0
  248. end
  249. if posmax==2 then
  250. j = 0
  251. end
  252. if posmax==3 then
  253. k = 0
  254. end
  255. for dx = -i,i do
  256. for dy= -j,j do
  257. for dz = -k,k do
  258. local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  259. if not minetest.is_protected(p, "") or not minetest.get_item_group(n, "unbreakable") == 1 then
  260. minetest.remove_node(p)
  261. end
  262. end
  263. end
  264. end
  265. end
  266. end
  267. --[[
  268. Function to register new weapons: parameters:
  269. - name of the weapon
  270. - on_step function (written by you or taken from the standard one above)
  271. - hit_node function
  272. - description of the weapon
  273. - the velocity of the projectile
  274. - one material to be used in the receipt
  275. ]]
  276. local function nssm_register_weapon(name, def)
  277. minetest.register_entity("nssm:"..name, {
  278. textures = {name..".png"},
  279. on_step = function(self, dtime)
  280. def.on_step(self, dtime)
  281. end,
  282. hit_node = function(self, pos, node)
  283. def.hit_node(self, pos, node)
  284. end,
  285. move = def.move,
  286. life_time = 0,
  287. timer = 0,
  288. custom_timer = 0,
  289. })
  290. minetest.register_craftitem("nssm:"..name.."_hand", {
  291. description = def.description,
  292. inventory_image = name.."_hand.png",
  293. on_use = function(itemstack, placer, pointed_thing)
  294. weapons_shot(itemstack, placer, pointed_thing, def.velocity, name)
  295. itemstack:take_item()
  296. return itemstack
  297. end,
  298. on_drop = def.on_drop or function(itemstack, user, pointed_thing)
  299. end,
  300. })
  301. minetest.register_craft({
  302. output = 'nssm:'..name.."_hand 23",
  303. recipe = {
  304. {'nssm:great_energy_globe', 'nssm:great_energy_globe', 'nssm:great_energy_globe'},
  305. {'nssm:great_energy_globe', def.material, 'nssm:great_energy_globe'},
  306. {'nssm:great_energy_globe', 'nssm:great_energy_globe', 'nssm:great_energy_globe'}
  307. }
  308. })
  309. end
  310. --Registered weapons:
  311. nssm_register_weapon("kamehameha", {
  312. velocity = 25,
  313. on_step = function(self, dtime)
  314. default_on_step(self, dtime, 4, 20, default_dir, 1, "stone", 25)
  315. end,
  316. hit_node = function(self, pos, node)
  317. tnt.boom(pos, {damage_radius=10,radius=6,ignore_protection=false})
  318. end,
  319. material = "default:diamondblock",
  320. description = "Kamehameha from DragonBall",
  321. })
  322. nssm_register_weapon("kienzan", {
  323. velocity = 25,
  324. on_step = function(self, dtime)
  325. default_on_step(self, dtime, 5, 20, {x=1, y=0, z=1}, 1, nil, 25)
  326. end,
  327. hit_node = function(self, pos, node)
  328. end,
  329. material = "default:bronzeblock",
  330. description = "Kienzan from DragonBall",
  331. })
  332. nssm_register_weapon("spirit_ball", {
  333. velocity = 25,
  334. move = 0,
  335. on_step = function(self, dtime)
  336. search_on_step(self, dtime, 5, 30, 25)
  337. end,
  338. hit_node = function(self, pos, node)
  339. tnt.boom(pos, {damage_radius=8,radius=4,ignore_protection=false})
  340. end,
  341. material = "default:goldblock",
  342. description = "Spirit Ball from DragonBall",
  343. })
  344. nssm_register_weapon("hellzone_grenade", {
  345. velocity = 25,
  346. move = 0,
  347. on_step = function(self, dtime)
  348. search_on_step2(self, dtime, 30, 30, 25)
  349. end,
  350. hit_node = function(self, pos, node)
  351. tnt.boom(pos, {damage_radius=8,radius=4,ignore_protection=false})
  352. end,
  353. on_drop = function(itemstack, user, pointed_thing)
  354. local pos = user:get_pos()
  355. activate_balls(pos)
  356. end,
  357. material = "default:mese",
  358. description = "Hellzone grenade (Press q to activate)",
  359. })
  360. --[[nssm_register_weapon("particles_ball", {
  361. velocity = 25,
  362. move = 0,
  363. on_step = function(self, dtime)
  364. local pos = self.object:get_pos()
  365. local vel = 1
  366. minetest.add_particlespawner({
  367. amount = 2,
  368. time = 0.01,
  369. minpos = pos,
  370. maxpos = pos,
  371. minvel = {x=3, y=3, z=3},
  372. maxvel = {x=-3, y=-3, z=-3},
  373. minacc = {x=0, y=0, z=0},
  374. maxacc = {x=0, y=0, z=0},
  375. minexptime = 0.5,
  376. maxexptime = 0.5,
  377. minsize = 3,
  378. maxsize = 3,
  379. collisiondetection = false,
  380. vertical = false,
  381. texture = "morparticle.png"
  382. })
  383. --Disappear after a certain time
  384. if self.life_time == 0 then
  385. self.life_time = os.time()
  386. end
  387. if os.time() - self.life_time > 60 then
  388. self.object:remove()
  389. return
  390. end
  391. --Look for an entity to follow
  392. local objects = minetest.get_objects_inside_radius(pos, 20)
  393. local min_dist = 100
  394. local obj_min = nil
  395. local obj_p = nil
  396. local vec_min = nil
  397. for _,obj in ipairs(objects) do
  398. if (obj:is_player()) then
  399. elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item" and obj:get_luaentity().name ~= self.object:get_luaentity().name) then
  400. obj_p = obj:get_pos()
  401. local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
  402. local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
  403. if (dist<min_dist) then
  404. min_dist = dist
  405. obj_min = obj
  406. vec_min = vec
  407. end
  408. end
  409. end
  410. --Found an entity to follow:
  411. if obj_min ~= nil then
  412. local new_vel = {x=0, y=0, z=0}
  413. local dir = 0
  414. local max_diff = 0
  415. if (max_diff<math.abs(vec_min.x)) then
  416. dir = 1
  417. max_diff = math.abs(vec_min.x)
  418. end
  419. if (max_diff<math.abs(vec_min.y)) then
  420. dir = 2
  421. max_diff = math.abs(vec_min.y)
  422. end
  423. if (max_diff<math.abs(vec_min.z)) then
  424. dir = 3
  425. max_diff = math.abs(vec_min.z)
  426. end
  427. vec_min.x = (vec_min.x/max_diff)*vel
  428. vec_min.y = (vec_min.y/max_diff)*vel
  429. vec_min.z = (vec_min.z/max_diff)*vel
  430. obj_p = obj_min:get_pos()
  431. self.object:set_velocity(vec_min)
  432. if min_dist < 1 then
  433. local node = nssm:node_ok(pos).name
  434. self.hit_node(self, pos, node)
  435. self.object:remove()
  436. return
  437. else
  438. self.object:set_velocity(vec_min)
  439. end
  440. end
  441. local n = minetest.get_node(pos).name
  442. if n ~= "air" and n ~= "default:water_source" and n ~= "default:water_flowing" then
  443. local node = nssm:node_ok(pos).name
  444. self.hit_node(self, pos, node)
  445. self.object:remove()
  446. return
  447. end
  448. end,
  449. hit_node = function(self, pos, node)
  450. --nssm:explosion(pos, 4, 0)
  451. end,
  452. on_drop = function(itemstack, user, pointed_thing)
  453. local pos = user:get_pos()
  454. --activate_balls(pos)
  455. end,
  456. material = "group:wood",
  457. description = "Particles ball",
  458. })]]
  459. --[[
  460. nssm_register_weapon("light_ball", {
  461. velocity = 25,
  462. move = 0,
  463. on_step = function(self, dtime, last_pos)
  464. local pos = self.object:get_pos()
  465. local vel = 1
  466. --Disappear after a certain time
  467. if self.life_time == 0 then
  468. self.life_time = os.time()
  469. end
  470. if os.time() - self.life_time > 60 then
  471. self.object:remove()
  472. return
  473. end
  474. if self.custom_timer == 0 then
  475. self.custom_timer = os.time()
  476. end
  477. if last_pos == nil or (last_pos ~= nil and last_pos ~= pos) then
  478. minetest.set_node(pos, {name="nssm:invisible_light"})
  479. if last_pos ~= nil then
  480. minetest.set_node(last_pos, {name="air"})
  481. end
  482. last_pos = pos
  483. end
  484. --Look for an entity to follow
  485. local objects = minetest.get_objects_inside_radius(pos, 20)
  486. local min_dist = 100
  487. local obj_min = nil
  488. local obj_p = nil
  489. local vec_min = nil
  490. for _,obj in ipairs(objects) do
  491. if (obj:is_player()) then
  492. elseif (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item" and obj:get_luaentity().name ~= self.object:get_luaentity().name) then
  493. obj_p = obj:get_pos()
  494. local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
  495. local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
  496. if (dist<min_dist) then
  497. min_dist = dist
  498. obj_min = obj
  499. vec_min = vec
  500. end
  501. end
  502. end
  503. --Found an entity to follow:
  504. if obj_min ~= nil then
  505. local new_vel = {x=0, y=0, z=0}
  506. local dir = 0
  507. local max_diff = 0
  508. if (max_diff<math.abs(vec_min.x)) then
  509. dir = 1
  510. max_diff = math.abs(vec_min.x)
  511. end
  512. if (max_diff<math.abs(vec_min.y)) then
  513. dir = 2
  514. max_diff = math.abs(vec_min.y)
  515. end
  516. if (max_diff<math.abs(vec_min.z)) then
  517. dir = 3
  518. max_diff = math.abs(vec_min.z)
  519. end
  520. vec_min.x = (vec_min.x/max_diff)*vel
  521. vec_min.y = (vec_min.y/max_diff)*vel
  522. vec_min.z = (vec_min.z/max_diff)*vel
  523. obj_p = obj_min:get_pos()
  524. self.object:set_velocity(vec_min)
  525. if min_dist < 1 then
  526. local node = nssm:node_ok(pos).name
  527. self.hit_node(self, pos, node)
  528. self.object:remove()
  529. return
  530. else
  531. self.object:set_velocity(vec_min)
  532. end
  533. end
  534. local n = minetest.get_node(pos).name
  535. if n ~= "air" and n ~= "default:water_source" and n ~= "default:water_flowing" then
  536. local node = nssm:node_ok(pos).name
  537. self.hit_node(self, pos, node)
  538. self.object:remove()
  539. return
  540. end
  541. end,
  542. hit_node = function(self, pos, node)
  543. --nssm:explosion(pos, 4, 0)
  544. end,
  545. on_drop = function(itemstack, user, pointed_thing)
  546. local pos = user:get_pos()
  547. --activate_balls(pos)
  548. end,
  549. material = "group:sand",
  550. description = "Light Ball",
  551. })
  552. ]]
  553. local function nssm_register_throwitem(name, descr, def)
  554. minetest.register_craftitem("nssm:"..name.."_bomb", {
  555. description = descr,
  556. inventory_image = name.."_bomb.png",
  557. on_use = function(itemstack, placer, pointed_thing)
  558. --weapons_shot(itemstack, placer, pointed_thing, def.velocity, name)
  559. local velocity = 15
  560. local dir = placer:get_look_dir();
  561. local playerpos = placer:get_pos();
  562. posthrow = playerpos
  563. local obj = minetest.add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+0+dir.z}, "nssm:"..name.."_bomb_flying")
  564. local vec = {x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}
  565. local acc = {x=0, y=-9.8, z=0}
  566. obj:set_velocity(vec)
  567. obj:set_acceleration(acc)
  568. itemstack:take_item()
  569. return itemstack
  570. end,
  571. })
  572. minetest.register_entity("nssm:"..name.."_bomb_flying",{
  573. textures = {name.."_bomb.png"},
  574. hp_max = 20,
  575. collisionbox = {-0.1,-0.1,-0.1, 0.1,0.1,0.1},
  576. on_step = function(self, dtime)
  577. local pos = self.object:get_pos()
  578. local node = minetest.get_node(pos)
  579. local n = node.name
  580. if n ~= "air" then
  581. def.hit_node(self, pos)
  582. self.object:remove()
  583. end
  584. end,
  585. })
  586. end
  587. nssm_register_throwitem("cobweb", "Cobweb Bomb", {
  588. hit_node = function(self,pos)
  589. for dx = -1,1 do
  590. for dy = -1,1 do
  591. for dz = -1,1 do
  592. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  593. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  594. minetest.set_node(pos1, {name="nssm:web"})
  595. end
  596. end
  597. end
  598. end
  599. end,
  600. })
  601. minetest.register_craft({
  602. output = 'nssm:cobweb_bomb 8',
  603. recipe = {
  604. {'nssm:silk_gland', 'nssm:black_powder', 'nssm:silk_gland'},
  605. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  606. {'nssm:silk_gland', 'nssm:black_powder', 'nssm:silk_gland'},
  607. }
  608. })
  609. nssm_register_throwitem("ice", "Ice Bomb", {
  610. hit_node = function(self,pos)
  611. for dx = -1,1 do
  612. for dy = 1,3 do
  613. for dz = -1,1 do
  614. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  615. local pos2 = {x = pos.x, y=pos.y+1, z=pos.z}
  616. local pos3 = {x = pos.x, y=pos.y+2, z=pos.z}
  617. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  618. minetest.set_node(pos1, {name="default:ice"})
  619. minetest.set_node(pos2, {name="air"})
  620. minetest.set_node(pos3, {name="air"})
  621. end
  622. end
  623. end
  624. end
  625. end,
  626. })
  627. minetest.register_craft({
  628. output = 'nssm:ice_bomb 8',
  629. recipe = {
  630. {'nssm:frosted_amphibian_heart', 'nssm:black_powder', 'nssm:frosted_amphibian_heart'},
  631. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  632. {'nssm:frosted_amphibian_heart', 'nssm:black_powder', 'nssm:frosted_amphibian_heart'},
  633. }
  634. })
  635. if minetest.get_modpath("nssb") then
  636. nssm_register_throwitem("mantis", "Mantis Clay Bomb", {
  637. hit_node = function(self,pos)
  638. for dx = -1,1 do
  639. for dy = 1,3 do
  640. for dz = -1,1 do
  641. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  642. local pos2 = {x = pos.x, y=pos.y+1, z=pos.z}
  643. local pos3 = {x = pos.x, y=pos.y+2, z=pos.z}
  644. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  645. minetest.set_node(pos1, {name="nssb:hardened_mantis_clay"})
  646. minetest.set_node(pos2, {name="air"})
  647. minetest.set_node(pos3, {name="air"})
  648. end
  649. end
  650. end
  651. end
  652. end,
  653. })
  654. minetest.register_craft({
  655. output = 'nssm:mantis_bomb 8',
  656. recipe = {
  657. {'nssm:mantis_meat', 'nssm:black_powder', 'nssm:mantis_meat'},
  658. {'nssm:black_powder', 'nssb:hardened_mantis_clay', 'nssm:black_powder'},
  659. {'nssm:mantis_meat', 'nssm:black_powder', 'nssm:mantis_meat'},
  660. }
  661. })
  662. end
  663. nssm_register_throwitem("lava", "Lava Bomb", {
  664. hit_node = function(self,pos)
  665. for dx = -1,1 do
  666. for dy = -1,0 do
  667. for dz = -1,1 do
  668. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  669. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  670. minetest.set_node(pos1, {name="default:lava_source"})
  671. end
  672. end
  673. end
  674. end
  675. end,
  676. })
  677. minetest.register_craft({
  678. output = 'nssm:lava_bomb 12',
  679. recipe = {
  680. {'bucket:bucket_lava', 'nssm:black_powder', 'bucket:bucket_lava'},
  681. {'nssm:black_powder', 'nssm:lava_titan_eye', 'nssm:black_powder'},
  682. {'bucket:bucket_lava', 'nssm:black_powder', 'bucket:bucket_lava'},
  683. }
  684. })
  685. nssm_register_throwitem("water", "Water Bomb", {
  686. hit_node = function(self,pos)
  687. for dx = -2,2 do
  688. for dy = -1,0 do
  689. for dz = -2,2 do
  690. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  691. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  692. minetest.set_node(pos1, {name="default:water_source"})
  693. end
  694. end
  695. end
  696. end
  697. end,
  698. })
  699. minetest.register_craft({
  700. output = 'nssm:water_bomb 10',
  701. recipe = {
  702. {'bucket:bucket_water', 'nssm:black_powder', 'bucket:bucket_water'},
  703. {'nssm:black_powder', 'nssm:tentacle_curly', 'nssm:black_powder'},
  704. {'bucket:bucket_water', 'nssm:black_powder', 'bucket:bucket_water'},
  705. }
  706. })
  707. nssm_register_throwitem("fire", "Fire Bomb", {
  708. hit_node = function(self,pos)
  709. for dx = -1,1 do
  710. for dy = 1,1 do
  711. for dz = -1,1 do
  712. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  713. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  714. minetest.set_node(pos1, {name="fire:basic_flame"})
  715. end
  716. end
  717. end
  718. end
  719. end,
  720. })
  721. minetest.register_craft({
  722. output = 'nssm:fire_bomb 6',
  723. recipe = {
  724. {'fire:flint_and_steel', 'nssm:black_powder', 'fire:flint_and_steel'},
  725. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  726. {'fire:flint_and_steel', 'nssm:black_powder', 'fire:flint_and_steel'},
  727. }
  728. })
  729. if minetest.get_modpath("nssb") then
  730. nssm_register_throwitem("mornar", "Mornar Bomb", {
  731. hit_node = function(self,pos)
  732. for dx = -1,1 do
  733. for dy = 1,1 do
  734. for dz = -1,1 do
  735. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  736. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  737. minetest.set_node(pos1, {name="nssb:mornar"})
  738. end
  739. end
  740. end
  741. end
  742. end,
  743. })
  744. minetest.register_craft({
  745. output = 'nssm:mornar_bomb 6',
  746. recipe = {
  747. {'nssm:wrathful_soul_fragment', 'nssm:black_powder', 'nssm:wrathful_soul_fragment'},
  748. {'nssm:black_powder', 'nssm:wrathful_soul_fragment', 'nssm:black_powder'},
  749. {'nssm:wrathful_soul_fragment', 'nssm:black_powder', 'nssm:wrathful_soul_fragment'},
  750. }
  751. })
  752. end
  753. nssm_register_throwitem("hole", "Hole Bomb", {
  754. hit_node = function(self,pos)
  755. for dx = -1,1 do
  756. for dy = -10,0 do
  757. for dz = -1,1 do
  758. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  759. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  760. minetest.set_node(pos1, {name="air"})
  761. end
  762. end
  763. end
  764. end
  765. end,
  766. })
  767. minetest.register_craft({
  768. output = 'nssm:hole_bomb 10',
  769. recipe = {
  770. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  771. {'nssm:black_powder', 'nssm:digested_sand', 'nssm:black_powder'},
  772. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  773. }
  774. })
  775. nssm_register_throwitem("food", "Food Bomb", {
  776. hit_node = function(self,pos)
  777. for dx = -1,1 do
  778. for dy = -1,1 do
  779. for dz = -1,1 do
  780. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  781. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  782. minetest.set_node(pos1, {name="air"})
  783. minetest.add_item(pos1, "nssm:roasted_duck_legs")
  784. end
  785. end
  786. end
  787. end
  788. end,
  789. })
  790. minetest.register_craft({
  791. output = 'nssm:food_bomb 8',
  792. recipe = {
  793. {'nssm:gluttonous_soul_fragment', 'nssm:black_powder', 'nssm:gluttonous_soul_fragment'},
  794. {'nssm:black_powder', 'nssm:gluttonous_soul_fragment', 'nssm:black_powder'},
  795. {'nssm:gluttonous_soul_fragment', 'nssm:black_powder', 'nssm:gluttonous_soul_fragment'},
  796. }
  797. })
  798. nssm_register_throwitem("phoenix_fire", "Phoenix Fire Bomb", {
  799. hit_node = function(self,pos)
  800. for dx = -2,2 do
  801. for dy = 0,1 do
  802. for dz = -2,2 do
  803. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  804. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  805. minetest.set_node(pos1, {name="nssm:phoenix_fire"})
  806. end
  807. end
  808. end
  809. end
  810. end,
  811. })
  812. minetest.register_craft({
  813. output = 'nssm:phoenix_fire_bomb 10',
  814. recipe = {
  815. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  816. {'nssm:black_powder', 'nssm:sun_feather', 'nssm:black_powder'},
  817. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  818. }
  819. })
  820. nssm_register_throwitem("kaboom", "Explosive Bomb", {
  821. hit_node = function(self,pos)
  822. local pos1 = {x = pos.x, y=pos.y, z=pos.z}
  823. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  824. tnt.boom(pos1, {damage_radius=3,radius=2,ignore_protection=false})
  825. end
  826. end,
  827. })
  828. minetest.register_craft({
  829. output = 'nssm:kaboom_bomb 3',
  830. recipe = {
  831. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  832. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  833. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  834. }
  835. })
  836. nssm_register_throwitem("teleport", "Teleport Bomb", {
  837. hit_node = function(self,pos,placer)
  838. local pos1 = {x = pos.x, y=pos.y+1, z=pos.z}
  839. local pos2 = {x = pos.x, y=pos.y+2, z=pos.z}
  840. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  841. for _,obj in ipairs(minetest.get_objects_inside_radius(posthrow, 2)) do
  842. if obj:is_player() then
  843. obj:set_pos(pos1)
  844. minetest.set_node(pos1, {name="air"})
  845. minetest.set_node(pos2, {name="air"})
  846. end
  847. end
  848. end
  849. end,
  850. })
  851. minetest.register_craft({
  852. output = 'nssm:teleport_bomb 10',
  853. recipe = {
  854. {'nssm:slothful_soul_fragment', 'nssm:black_powder', 'nssm:slothful_soul_fragment'},
  855. {'nssm:black_powder', 'nssm:slothful_soul_fragment', 'nssm:black_powder'},
  856. {'nssm:slothful_soul_fragment', 'nssm:black_powder', 'nssm:slothful_soul_fragment'},
  857. }
  858. })
  859. nssm_register_throwitem("boom", "Boom Bomb", {
  860. hit_node = function(self,pos)
  861. local pos1 = {x = pos.x, y=pos.y, z=pos.z}
  862. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  863. tnt.boom(pos1, {damage_radius=4,radius=3,ignore_protection=false})
  864. end
  865. end,
  866. })
  867. minetest.register_craft({
  868. output = 'nssm:boom_bomb 10',
  869. recipe = {
  870. {'nssm:greedy_soul_fragment', 'nssm:black_powder', 'nssm:greedy_soul_fragment'},
  871. {'nssm:black_powder', 'nssm:greedy_soul_fragment', 'nssm:black_powder'},
  872. {'nssm:greedy_soul_fragment', 'nssm:black_powder', 'nssm:greedy_soul_fragment'},
  873. }
  874. })
  875. nssm_register_throwitem("smoke", "Smoke Bomb", {
  876. hit_node = function(self,pos)
  877. local pos1 = {x = pos.x, y=pos.y, z=pos.z}
  878. minetest.add_particlespawner({
  879. amount = 6000,
  880. time = 20,
  881. minpos = {x=pos1.x-3, y=pos1.y+0.5, z=pos1.z-3},
  882. maxpos = {x=pos1.x+3, y=pos1.y+0.5, z=pos1.z+3},
  883. minvel = {x=0.2, y=0.2, z=0.2},
  884. maxvel = {x=0.4, y=0.8, z=0.4},
  885. minacc = {x=-0.2,y=0,z=-0.2},
  886. maxacc = {x=0.2,y=0.1,z=0.2},
  887. minexptime = 6,
  888. maxexptime = 8,
  889. minsize = 10,
  890. maxsize = 12,
  891. collisiondetection = false,
  892. vertical = false,
  893. texture = "tnt_smoke.png",})
  894. end,
  895. })
  896. minetest.register_craft({
  897. output = 'nssm:smoke_bomb 6',
  898. recipe = {
  899. {'nssm:proud_soul_fragment', 'nssm:black_powder', 'nssm:proud_soul_fragment'},
  900. {'nssm:black_powder', 'nssm:proud_soul_fragment', 'nssm:black_powder'},
  901. {'nssm:proud_soul_fragment', 'nssm:black_powder', 'nssm:proud_soul_fragment'},
  902. }
  903. })
  904. nssm_register_throwitem("thick_web", "Thick Web Bomb", {
  905. hit_node = function(self,pos)
  906. local pos1 = {x = pos.x, y=pos.y+1, z=pos.z}
  907. local pos2 = {x = pos.x, y=pos.y+2, z=pos.z}
  908. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  909. minetest.set_node(pos1, {name="nssm:thick_web"})
  910. minetest.set_node(pos2, {name="nssm:thick_web"})
  911. end
  912. end,
  913. })
  914. minetest.register_craft({
  915. output = 'nssm:thick_web_bomb 12',
  916. recipe = {
  917. {'nssm:super_silk_gland', 'nssm:black_powder', 'nssm:super_silk_gland'},
  918. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  919. {'nssm:super_silk_gland', 'nssm:black_powder', 'nssm:super_silk_gland'},
  920. }
  921. })
  922. nssm_register_throwitem("poison", "Poison Bomb", {
  923. hit_node = function(self,pos)
  924. for dx = -1,1 do
  925. for dy = 1,3 do
  926. for dz = -1,1 do
  927. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  928. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  929. minetest.set_node(pos1, {name="nssm:venomous_gas"})
  930. end
  931. end
  932. end
  933. end
  934. end,
  935. })
  936. minetest.register_craft({
  937. output = 'nssm:poison_bomb 10',
  938. recipe = {
  939. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  940. {'nssm:black_powder', 'nssm:snake_scute', 'nssm:black_powder'},
  941. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  942. }
  943. })
  944. nssm_register_throwitem("stone", "Cobblestone Bomb", {
  945. hit_node = function(self,pos)
  946. for dx = -1,1 do
  947. for dy = 1,3 do
  948. for dz = -1,1 do
  949. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  950. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  951. minetest.set_node(pos1, {name="default:cobble"})
  952. end
  953. end
  954. end
  955. end
  956. end,
  957. })
  958. minetest.register_craft({
  959. output = 'nssm:stone_bomb 6',
  960. recipe = {
  961. {'default:stone', 'nssm:black_powder', 'default:stone'},
  962. {'nssm:black_powder', 'nssm:black_powder', 'nssm:black_powder'},
  963. {'default:stone', 'nssm:black_powder', 'default:stone'},
  964. }
  965. })
  966. nssm_register_throwitem("fire_ring", "Fire Ring Bomb", {
  967. hit_node = function(self,pos)
  968. for dx = -2,2 do
  969. for dy = 1,2 do
  970. for dz = -2,2 do
  971. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  972. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  973. minetest.set_node(pos1, {name="fire:basic_flame"})
  974. for dx = -1,1 do
  975. for dy = 1,2 do
  976. for dz = -1,1 do
  977. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  978. minetest.set_node(pos1, {name="air"})
  979. end
  980. end
  981. end
  982. end
  983. end
  984. end
  985. end
  986. end,
  987. })
  988. minetest.register_craft({
  989. output = 'nssm:fire_ring_bomb 3',
  990. recipe = {
  991. {'fire:flint_and_steel', 'fire:flint_and_steel', 'fire:flint_and_steel'},
  992. {'fire:flint_and_steel', 'nssm:black_powder', 'fire:flint_and_steel'},
  993. {'fire:flint_and_steel', 'fire:flint_and_steel', 'fire:flint_and_steel'},
  994. }
  995. })
  996. if minetest.get_modpath("nssb") then
  997. nssm_register_throwitem("cage", "Cage Bomb", {
  998. hit_node = function(self,pos)
  999. for dx = -2,2 do
  1000. for dy = 0,3 do
  1001. for dz = -2,2 do
  1002. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  1003. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  1004. minetest.set_node(pos1, {name="nssb:morentir"})
  1005. for dx = -1,1 do
  1006. for dy = 1,2 do
  1007. for dz = -1,1 do
  1008. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  1009. minetest.set_node(pos1, {name="air"})
  1010. end
  1011. end
  1012. end
  1013. end
  1014. end
  1015. end
  1016. end
  1017. end,
  1018. })
  1019. minetest.register_craft({
  1020. output = 'nssm:cage_bomb 10',
  1021. recipe = {
  1022. {'nssm:lustful_soul_fragment', 'nssm:black_powder', 'nssm:lustful_soul_fragment'},
  1023. {'nssm:black_powder', 'nssm:lustful_soul_fragment', 'nssm:black_powder'},
  1024. {'nssm:lustful_soul_fragment', 'nssm:black_powder', 'nssm:lustful_soul_fragment'},
  1025. }
  1026. })
  1027. end
  1028. nssm_register_throwitem("water_column", "Water Column Bomb", {
  1029. hit_node = function(self,pos)
  1030. for dx = 0,0 do
  1031. for dy = 1,10 do
  1032. for dz = 0,0 do
  1033. local pos1 = {x = pos.x+dx, y=pos.y+dy, z=pos.z+dz}
  1034. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  1035. minetest.set_node(pos1, {name="default:water_source"})
  1036. end
  1037. end
  1038. end
  1039. end
  1040. end,
  1041. })
  1042. minetest.register_craft({
  1043. output = 'nssm:water_column_bomb 6',
  1044. recipe = {
  1045. {'bucket:bucket_water', 'nssm:black_powder', 'bucket:bucket_water'},
  1046. {'bucket:bucket_water', 'nssm:black_powder', 'bucket:bucket_water'},
  1047. {'bucket:bucket_water', 'nssm:black_powder', 'bucket:bucket_water'},
  1048. }
  1049. })
  1050. minetest.register_craft({
  1051. output = 'nssm:empty_evocation_bomb 10',
  1052. recipe = {
  1053. {'nssm:envious_soul_fragment', 'nssm:black_powder', 'nssm:envious_soul_fragment'},
  1054. {'nssm:black_powder', 'nssm:envious_soul_fragment', 'nssm:black_powder'},
  1055. {'nssm:envious_soul_fragment', 'nssm:black_powder', 'nssm:envious_soul_fragment'},
  1056. }
  1057. })
  1058. local function nssm_register_throwegg(name, descr, def)
  1059. minetest.register_craftitem("nssm:"..name.."_bomb", {
  1060. description = descr,
  1061. inventory_image = "evocation_bomb.png^"..name.."_egg.png",
  1062. on_use = function(itemstack, placer, pointed_thing)
  1063. --weapons_shot(itemstack, placer, pointed_thing, def.velocity, name)
  1064. local velocity = 15
  1065. local dir = placer:get_look_dir();
  1066. local playerpos = placer:get_pos();
  1067. local obj = minetest.add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+2+dir.y,z=playerpos.z+0+dir.z}, "nssm:"..name.."_bomb_flying")
  1068. local vec = {x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity}
  1069. local acc = {x=0, y=-9.8, z=0}
  1070. obj:set_velocity(vec)
  1071. obj:set_acceleration(acc)
  1072. itemstack:take_item()
  1073. return itemstack
  1074. end,
  1075. })
  1076. minetest.register_entity("nssm:"..name.."_bomb_flying",{
  1077. textures = {"evocation_bomb.png^"..name.."_egg.png"},
  1078. on_step = function(self, dtime)
  1079. local pos = self.object:get_pos()
  1080. local node = minetest.get_node(pos)
  1081. local n = node.name
  1082. if n ~= "air" then
  1083. def.hit_node(self, pos)
  1084. self.object:remove()
  1085. end
  1086. end,
  1087. })
  1088. end
  1089. local function nssm_register_evocation (evomob, evodescr, numbe)
  1090. nssm_register_throwegg(evomob, evodescr.." Bomb", {
  1091. hit_node = function(self,pos)
  1092. local pos1 = {x = pos.x, y=pos.y+1, z=pos.z}
  1093. if not minetest.is_protected(pos1, "") or not minetest.get_item_group(minetest.get_node(pos1).name, "unbreakable") == 1 then
  1094. for n=1,numbe do
  1095. minetest.add_entity(pos1, "nssm:".. evomob)
  1096. end
  1097. end
  1098. end,
  1099. })
  1100. minetest.register_craft({
  1101. output = 'nssm:'..evomob.."_bomb",
  1102. type = "shapeless",
  1103. recipe = {'nssm:empty_evocation_bomb', 'nssm:'..evomob},
  1104. })
  1105. minetest.register_craft({
  1106. output = 'nssm:duckking_bomb',
  1107. type = "shapeless",
  1108. recipe = {'nssm:empty_evocation_bomb', 'nssm:duckking_egg'},
  1109. })
  1110. end
  1111. nssm_register_evocation ("duck","Duck Evocation", 4)
  1112. nssm_register_evocation ("bloco","Bloco Evocation", 3)
  1113. nssm_register_evocation ("enderduck","Enderduck Evocation", 2)
  1114. nssm_register_evocation ("flying_duck","Flying Duck Evocation", 3)
  1115. nssm_register_evocation ("swimming_duck","Swimming Duck Evocation", 3)
  1116. nssm_register_evocation ("duckking","Duckking Evocation", 1)
  1117. nssm_register_evocation ("spiderduck","Spiderduck Evocation", 2)