morvalar.lua 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. local time_limit = 120
  2. local posmorvalarblock = {x=827, y=-30094, z=-817}
  3. function respawn_block(self)
  4. --start a timer if it doesn't exist
  5. self.stop_timer = self.stop_timer or os.time()
  6. --create a variable to record the hp if it doesn't exist
  7. self.hp_record = self.hp_record or self.health
  8. if self.hp_record ~= self.health then
  9. self.stop_timer = os.time()
  10. self.hp_record = self.health
  11. else
  12. if os.time() - self.stop_timer > time_limit then
  13. minetest.chat_send_all("Time is over!")
  14. self.object:remove()
  15. minetest.set_node(posmorvalarblock, {name="nssb:morvalar_block"})
  16. end
  17. end
  18. end
  19. mobs:register_mob("nssm:morvalar", {
  20. type = "monster",
  21. hp_max = 100,
  22. hp_min = 100,
  23. collisionbox = {-0.4, -0.1, -0.4, 0.4, 1.8, 0.4},
  24. visual = "mesh",
  25. --rotate= 270,
  26. mesh = "morvalar.x",
  27. textures = {
  28. {"morvalar.png"}
  29. },
  30. visual_size = {x = 5, y = 5},
  31. makes_footstep_sound = true,
  32. view_range = 50,
  33. walk_velocity = 1.6,
  34. reach = 3,
  35. run_velocity = 3.2,
  36. damage = 8,
  37. runaway = true,
  38. jump = true,
  39. sounds = {
  40. random = "morvalar7",
  41. },
  42. armor = 50,
  43. drawtype = "front",
  44. water_damage = 0,
  45. fear_height = 4,
  46. floats = 1,
  47. lava_damage = 0,
  48. fire_damage = 0,
  49. blood_texture = "morparticle.png",
  50. blood_amount = 10,
  51. knock_back = 0,
  52. light_damage = 0,
  53. attack_type = "dogfight",
  54. animation = {
  55. speed_normal = 15,
  56. speed_run = 30,
  57. stand_start = 5,
  58. stand_end = 6,
  59. walk_start = 10,
  60. walk_end = 50,
  61. run_start = 10,
  62. run_end = 50,
  63. punch_start = 55,
  64. punch_end = 80,
  65. },
  66. do_custom = function(self)
  67. respawn_block(self)
  68. end,
  69. custom_attack = function (self)
  70. self.curr_attack = (self.curr_attack or self.attack)
  71. self.morvalar_timer = (self.morvalar_timer or os.time())
  72. self.dir = (self.dir or 0)
  73. if (os.time() - self.morvalar_timer) > 2 then
  74. local s = self.object:get_pos()
  75. local p = self.attack:get_pos()
  76. mobs:set_animation(self, "punch")
  77. local m = 1
  78. if self.attack:is_player() then
  79. if minetest.get_modpath("3d_armor") then
  80. local pname, player_inv, armor_inv, ppos = armor:get_valid_player(
  81. self.attack, "[set_player_armor]")
  82. local pname = self.attack:get_player_name()
  83. local player_inv = minetest.get_inventory({type='player', name = pname})
  84. if player_inv:is_empty('armor') then
  85. -- punch player if he doesn't own an armor
  86. self.attack:punch(self.object, 1.0, {
  87. full_punch_interval = 1.0,
  88. damage_groups = {fleshy = self.damage}
  89. }, nil)
  90. else
  91. local armor_elements = {}
  92. local armor_num = 0
  93. local steal_pos
  94. for i = 1, 6 do
  95. local armor_stack = player_inv:get_stack("armor", i)
  96. local armor_item = armor_stack:get_name()
  97. if armor_stack:get_count() > 0 then
  98. armor_elements[armor_num]={name=armor_item, pos=i}
  99. armor_num = armor_num + 1
  100. end
  101. end
  102. if armor_num > 0 then
  103. steal_pos = math.random(1,armor_num)
  104. steal_pos = steal_pos-1
  105. local cpos = string.find(armor_elements[steal_pos].name, ":")
  106. local mod_name = string.sub(armor_elements[steal_pos].name, 0, cpos - 1)
  107. local nname = string.sub(armor_elements[steal_pos].name, cpos + 1)
  108. if mod_name == "3d_armor" then
  109. nname = "3d_armor_inv_"..nname..".png"
  110. elseif mod_name == "nssm" then
  111. nname = "inv_"..nname..".png"
  112. else
  113. nname = "3d_armor_inv_chestplate_diamond.png"
  114. end
  115. minetest.add_particlespawner({
  116. amount = 1,
  117. time = 1,
  118. minpos = {x=p.x, y=p.y+1, z=p.z},
  119. maxpos = {x=p.x, y=p.y+1, z=p.z},
  120. minvel = {x=(s.x-p.x)*m, y=(s.y-p.y)*m, z=(s.z-p.z)*m},
  121. maxvel = {x=(s.x-p.x)*m, y=(s.y-p.y)*m, z=(s.z-p.z)*m},
  122. minacc = {x=s.x-p.x, y=s.y-p.y-1, z=s.z-p.z},
  123. maxacc = {x=s.x-p.x, y=s.y-p.y-1, z=s.z-p.z},
  124. minexptime = 0.5,
  125. maxexptime = 0.5,
  126. minsize = 10,
  127. maxsize = 10,
  128. collisiondetection = false,
  129. texture = nname
  130. })
  131. minetest.after(1, function (self)
  132. local armor_stack = player_inv:get_stack("armor", armor_elements[steal_pos].pos)
  133. armor_stack:take_item()
  134. player_inv:set_stack('armor', armor_elements[steal_pos].pos, armor_stack)
  135. armor_stack = armor_inv:get_stack("armor", armor_elements[steal_pos].pos)
  136. armor_stack:take_item()
  137. armor_inv:set_stack('armor', armor_elements[steal_pos].pos, armor_stack)
  138. armor:set_player_armor(self.attack, self.attack)
  139. armor:update_inventory(self.attack)
  140. end, self)
  141. end
  142. end
  143. else
  144. local s = self.object:get_pos()
  145. local p = self.attack:get_pos()
  146. mobs:set_animation(self, "punch")
  147. if minetest.line_of_sight(
  148. {x = p.x, y = p.y + 1.5, z = p.z},
  149. {x = s.x, y = s.y +1.5, z = s.z}) == true then
  150. -- play attack sound
  151. if self.sounds.attack then
  152. minetest.sound_play(self.sounds.attack, {
  153. object = self.object,
  154. max_hear_distance = self.sounds.distance
  155. })
  156. end
  157. -- punch player
  158. self.attack:punch(self.object, 1.0, {
  159. full_punch_interval = 1.0,
  160. damage_groups = {fleshy = self.damage}
  161. }, nil)
  162. end
  163. end
  164. end
  165. end
  166. end,
  167. on_die = function(self)
  168. local pos = self.object:get_pos()
  169. self.object:remove()
  170. add_entity_and_particles("nssm:morvalar6", pos, "morparticle.png", 10)
  171. end,
  172. })
  173. mobs:register_mob("nssm:morvalar6", {
  174. type = "monster",
  175. hp_max = 120,
  176. hp_min = 120,
  177. collisionbox = {-0.4, -0.1, -0.4, 0.4, 1.8, 0.4},
  178. visual = "mesh",
  179. --rotate= 270,
  180. mesh = "morvalar.x",
  181. textures = {
  182. {"morvalar.png"}
  183. },
  184. visual_size = {x = 5, y = 5},
  185. makes_footstep_sound = true,
  186. view_range = 50,
  187. walk_velocity = 1.6,
  188. reach =4,
  189. run_velocity = 3.2,
  190. damage = 8,
  191. runaway = true,
  192. jump = true,
  193. sounds = {
  194. random = "morvalar6",
  195. },
  196. armor = 50,
  197. drawtype = "front",
  198. water_damage = 0,
  199. fear_height = 4,
  200. floats = 1,
  201. lava_damage = 0,
  202. fire_damage = 0,
  203. light_damage = 0,
  204. blood_texture = "morparticle.png",
  205. blood_amount = 10,
  206. knock_back = 0,
  207. attack_type = "dogfight",
  208. animation = {
  209. speed_normal = 15,
  210. speed_run = 30,
  211. stand_start = 85,
  212. stand_end = 86,
  213. walk_start = 90,
  214. walk_end = 130,
  215. run_start = 90,
  216. run_end = 130,
  217. punch_start = 132,
  218. punch_end = 162,
  219. },
  220. do_custom = function(self)
  221. respawn_block(self)
  222. end,
  223. custom_attack = function (self)
  224. self.morvalar6_timer = (self.morvalar6_timer or os.time())
  225. self.dir = (self.dir or 0)
  226. if (os.time() - self.morvalar6_timer) > 1 then
  227. local s = self.object:get_pos()
  228. local p = self.attack:get_pos()
  229. mobs:set_animation(self, "punch")
  230. local m = 2
  231. minetest.after(1, function (self)
  232. if self.attack:is_player() then
  233. local pname = self.attack:get_player_name()
  234. local player_inv = minetest.get_inventory({type='player', name = pname})
  235. if player_inv:is_empty('main') then
  236. --minetest.chat_send_all("Inventory empty")
  237. else
  238. local imhungry = 0
  239. for i = 1, 32 do
  240. --minetest.chat_send_all("Inventory is not empty")
  241. local items = player_inv:get_stack('main', i)
  242. local n = items:get_name()
  243. if minetest.get_item_group(n, "eatable")==1 then
  244. imhungry = 1
  245. for t = 0,2 do
  246. items:take_item()
  247. end
  248. player_inv:set_stack('main', i, items)
  249. end
  250. end
  251. if imhungry == 0 then
  252. self.attack:punch(self.object, 1.0, {
  253. full_punch_interval = 1.0,
  254. damage_groups = {fleshy = self.damage}
  255. }, nil)
  256. else
  257. s.y = s.y+1.8
  258. minetest.add_particlespawner({
  259. amount = 1,
  260. time = 1,
  261. minpos = {x=p.x, y=p.y+1, z=p.z},
  262. maxpos = {x=p.x, y=p.y+1, z=p.z},
  263. minvel = {x=(s.x-p.x)*m, y=(s.y-p.y)*m, z=(s.z-p.z)*m},
  264. maxvel = {x=(s.x-p.x)*m, y=(s.y-p.y)*m, z=(s.z-p.z)*m},
  265. minacc = {x=s.x-p.x, y=s.y-p.y-1, z=s.z-p.z},
  266. maxacc = {x=s.x-p.x, y=s.y-p.y-1, z=s.z-p.z},
  267. minexptime = 0.5,
  268. maxexptime = 0.5,
  269. minsize = 10,
  270. maxsize = 10,
  271. collisiondetection = false,
  272. texture = "roasted_duck_legs.png"
  273. })
  274. end
  275. self.morvalar6_timer = os.time()
  276. end
  277. end
  278. end,self)
  279. end
  280. end,
  281. on_die = function(self)
  282. local pos = self.object:get_pos()
  283. self.object:remove()
  284. add_entity_and_particles("nssm:morvalar5", pos, "morparticle.png", 10)
  285. end,
  286. })
  287. mobs:register_mob("nssm:morvalar5", {
  288. type = "monster",
  289. hp_max = 130,
  290. hp_min = 130,
  291. collisionbox = {-0.4, -0.1, -0.4, 0.4, 1.8, 0.4},
  292. visual = "mesh",
  293. --rotate= 270,
  294. mesh = "morvalar.x",
  295. textures = {{"morvalar.png"}},
  296. visual_size = {x=5, y=5},
  297. makes_footstep_sound = true,
  298. view_range = 50,
  299. walk_velocity = 1.6,
  300. reach =6,
  301. run_velocity = 3.2,
  302. damage = 4,
  303. runaway = true,
  304. jump = true,
  305. sounds = {
  306. random = "morvalar5",
  307. },
  308. armor = 40,
  309. drawtype = "front",
  310. water_damage = 0,
  311. fear_height = 4,
  312. floats = 1,
  313. lava_damage = 0,
  314. fire_damage = 0,
  315. light_damage = 0,
  316. blood_texture="morparticle.png",
  317. blood_amount=10,
  318. knock_back=0,
  319. on_rightclick = nil,
  320. attack_type = "dogfight",
  321. animation = {
  322. speed_normal = 15,
  323. speed_run = 30,
  324. stand_start = 165,
  325. stand_end = 166,
  326. walk_start = 170,
  327. walk_end = 210,
  328. run_start = 170,
  329. run_end = 210,
  330. punch_start = 215,
  331. punch_end = 245,
  332. },
  333. do_custom = function(self)
  334. respawn_block(self)
  335. end,
  336. custom_attack = function (self)
  337. self.morvalar5_timer = (self.morvalar5_timer or os.time())
  338. self.dir = (self.dir or 0)
  339. if (os.time() - self.morvalar5_timer) > 2 then
  340. local s = self.object:get_pos()
  341. local p = self.attack:get_pos()
  342. minetest.after(2, function(self)
  343. mobs:set_animation(self, "punch")
  344. tnt_boom_nssm(p, {damage_radius=6,radius=5,ignore_protection=false})
  345. self.morvalar5_timer = os.time()
  346. end,self)
  347. end
  348. end,
  349. on_die = function(self)
  350. local pos = self.object:get_pos()
  351. self.object:remove()
  352. add_entity_and_particles("nssm:morvalar4", pos, "morparticle.png", 10)
  353. end,
  354. })
  355. mobs:register_mob("nssm:morvalar4", {
  356. type = "monster",
  357. hp_max = 100,
  358. hp_min = 100,
  359. collisionbox = {-0.4, -0.1, -0.4, 0.4, 1.8, 0.4},
  360. visual = "mesh",
  361. --rotate= 270,
  362. mesh = "morvalar.x",
  363. textures = {{"morvalar.png"}},
  364. visual_size = {x=5, y=5},
  365. makes_footstep_sound = true,
  366. view_range = 50,
  367. walk_velocity = 1.6,
  368. reach = 3,
  369. run_velocity = 3.2,
  370. damage = 4,
  371. runaway = true,
  372. jump = true,
  373. sounds = {
  374. random = "morvalar4",
  375. },
  376. armor = 30,
  377. drawtype = "front",
  378. water_damage = 0,
  379. fear_height = 4,
  380. floats = 1,
  381. lava_damage = 0,
  382. fire_damage = 0,
  383. light_damage = 0,
  384. blood_texture="morparticle.png",
  385. blood_amount=10,
  386. knock_back=0,
  387. on_rightclick = nil,
  388. attack_type = "dogfight",
  389. animation = {
  390. speed_normal = 15,
  391. speed_run = 30,
  392. stand_start = 250,
  393. stand_end = 251,
  394. walk_start = 255,
  395. walk_end = 295,
  396. run_start = 255,
  397. run_end = 295,
  398. punch_start = 300,
  399. punch_end = 320,
  400. },
  401. do_custom = function(self)
  402. respawn_block(self)
  403. end,
  404. custom_attack = function(self)
  405. self.morvalar4_timer = (self.morvalar4_timer or os.time())
  406. if (os.time() - self.morvalar4_timer) > 1 then
  407. self.morvalar4_timer = os.time()
  408. local s = self.object:get_pos()
  409. local p = self.attack:get_pos()
  410. mobs:set_animation(self, "punch")
  411. if minetest.line_of_sight({x = p.x, y = p.y +1.5, z = p.z}, {x = s.x, y = s.y +1.5, z = s.z}) == true then
  412. -- play attack sound
  413. if self.sounds.attack then
  414. minetest.sound_play(self.sounds.attack, {
  415. object = self.object,
  416. max_hear_distance = self.sounds.distance
  417. })
  418. end
  419. -- punch player
  420. self.attack:punch(self.object, 1.0, {
  421. full_punch_interval=1.0,
  422. damage_groups = {fleshy=self.damage}
  423. }, nil)
  424. end
  425. minetest.after(1.4, function()
  426. local ty = s.y
  427. local flag = 0
  428. local m = 3
  429. local v = {x=(p.x-s.x)*m, y = ty, z = (p.z-s.z)*m}
  430. local d = {x=s.x+v.x, y = ty, z = s.z+v.z}
  431. d.y = ty
  432. for j = -3,3 do
  433. ty = d.y + j
  434. local current = minetest.get_node({x = d.x, y = ty, z = d.z}).name
  435. local up = minetest.get_node({x = d.x, y = ty+1, z = d.z}).name
  436. if up == "air" and current ~= "air" then
  437. d.y = d.y + j+1.5
  438. flag = 1
  439. break
  440. end
  441. end
  442. while flag ~= 1 do
  443. d.x = p.x + math.random(-m,m)
  444. d.z = p.z + math.random(-m,m)
  445. d.y = p.y
  446. local dist = dist_pos(d, p)
  447. if dist>=2 then
  448. for j = -3,3 do
  449. ty = d.y + j
  450. local current = minetest.get_node({x = d.x, y = ty, z = d.z}).name
  451. local up = minetest.get_node({x = d.x, y = ty+1, z = d.z}).name
  452. if up == "air" and current ~= "air" then
  453. d.y = d.y + j+1.5
  454. flag = 1
  455. break
  456. end
  457. end
  458. end
  459. end
  460. self.object:set_pos(d)
  461. end)
  462. end
  463. end,
  464. on_die = function(self)
  465. local pos = self.object:get_pos()
  466. self.object:remove()
  467. add_entity_and_particles("nssm:morvalar3", pos, "morparticle.png", 10)
  468. end,
  469. })
  470. mobs:register_mob("nssm:morvalar3", {
  471. type = "monster",
  472. hp_max = 120,
  473. hp_min = 120,
  474. collisionbox = {-0.4, -0.1, -0.4, 0.4, 1.8, 0.4},
  475. visual = "mesh",
  476. --rotate= 270,
  477. mesh = "morvalar.x",
  478. textures = {{"morvalar.png"}},
  479. visual_size = {x=5, y=5},
  480. makes_footstep_sound = true,
  481. view_range = 50,
  482. walk_velocity = 1.6,
  483. reach = 3,
  484. run_velocity = 3.2,
  485. damage = 16,
  486. runaway = true,
  487. jump = true,
  488. sounds = {
  489. random = "morvalar3",
  490. },
  491. armor = 30,
  492. drawtype = "front",
  493. water_damage = 0,
  494. fear_height = 4,
  495. floats = 1,
  496. lava_damage = 0,
  497. fire_damage = 0,
  498. light_damage = 0,
  499. blood_texture="morparticle.png",
  500. blood_amount=10,
  501. knock_back=0,
  502. on_rightclick = nil,
  503. attack_type = "dogshoot",
  504. dogshoot_switch = true,
  505. arrow = "nssm:morarrow",
  506. shoot_interval = 2,
  507. shoot_offset = 0,
  508. animation = {
  509. speed_normal = 15,
  510. speed_run = 30,
  511. stand_start = 325,
  512. stand_end = 326,
  513. walk_start = 330,
  514. walk_end = 370,
  515. run_start = 330,
  516. run_end = 370,
  517. punch_start = 375,
  518. punch_end = 395,
  519. shoot_start = 400,
  520. shoot_end = 450,
  521. },
  522. do_custom = function(self)
  523. respawn_block(self)
  524. end,
  525. on_die = function(self)
  526. local pos = self.object:get_pos()
  527. self.object:remove()
  528. add_entity_and_particles("nssm:morvalar2", pos, "morparticle.png", 10)
  529. end,
  530. })
  531. mobs:register_mob("nssm:morvalar2", {
  532. type = "monster",
  533. hp_max = 90,
  534. hp_min = 90,
  535. collisionbox = {-0.4, -0.1, -0.4, 0.4, 1.8, 0.4},
  536. visual = "mesh",
  537. --rotate= 270,
  538. mesh = "morvalar.x",
  539. textures = {{"morvalar.png"}},
  540. visual_size = {x=5, y=5},
  541. makes_footstep_sound = true,
  542. view_range = 50,
  543. walk_velocity = 1.6,
  544. reach = 6,
  545. run_velocity = 3.2,
  546. damage = 4,
  547. runaway = true,
  548. jump = true,
  549. sounds = {
  550. random = "morvalar2",
  551. },
  552. armor = 50,
  553. drawtype = "front",
  554. water_damage = 0,
  555. fear_height = 4,
  556. floats = 1,
  557. lava_damage = 0,
  558. fire_damage = 0,
  559. light_damage = 0,
  560. blood_texture="morparticle.png",
  561. blood_amount=10,
  562. knock_back=0,
  563. on_rightclick = nil,
  564. attack_type = "dogfight",
  565. animation = {
  566. speed_normal = 15,
  567. speed_run = 30,
  568. stand_start = 455,
  569. stand_end = 456,
  570. walk_start = 460,
  571. walk_end = 500,
  572. run_start = 460,
  573. run_end = 500,
  574. punch_start = 505,
  575. punch_end = 545,
  576. },
  577. do_custom = function(self)
  578. respawn_block(self)
  579. end,
  580. custom_attack = function(self)
  581. self.morvalar2_timer = (self.morvalar2_timer or os.time())
  582. if (os.time() - self.morvalar2_timer) > 1 then
  583. self.morvalar2_timer = os.time()
  584. local s = self.object:get_pos()
  585. local p = self.attack:get_pos()
  586. local counter = 0
  587. local objects = minetest.get_objects_inside_radius(s, 7)
  588. for _,obj in ipairs(objects) do
  589. if obj:get_luaentity() then
  590. local name = obj:get_luaentity().name
  591. if (name == "nssm:mordain" or name == "nssm:morde" or name == "nssm:morgut" or name == "nssm:morgre" or name == "nssm:morlu" or name == "nssm:morwa" or name == "nssm:morvy") then
  592. counter = counter + 1
  593. end
  594. end
  595. end
  596. minetest.chat_send_all("Ne ho contati: "..counter)
  597. if counter < 2 then
  598. mobs:set_animation(self, "punch")
  599. local v = vector.subtract(p,s)
  600. --local v = {x = s.x-p.x, y = s.y-p.y , z= s.z-p.z}
  601. v = vector.normalize(v)
  602. local per = perpendicular_vector(v)
  603. local p1 = vector.add(s,v)
  604. p1 = vector.subtract(p1,vector.multiply(per,4))
  605. add_entity_and_particles("nssm:morwa", p1, "morparticle.png", 1)
  606. p1 = vector.add(p1,per)
  607. add_entity_and_particles("nssm:mordain", p1, "morparticle.png", 1)
  608. p1 = vector.add(p1,per)
  609. add_entity_and_particles("nssm:morgre", p1, "morparticle.png", 1)
  610. p1 = vector.add(p1,per)
  611. add_entity_and_particles("nssm:morlu", p1, "morparticle.png", 1)
  612. p1 = vector.add(p1,per)
  613. add_entity_and_particles("nssm:morgut", p1, "morparticle.png", 1)
  614. p1 = vector.add(p1,per)
  615. add_entity_and_particles("nssm:morde", p1, "morparticle.png", 1)
  616. p1 = vector.add(p1,per)
  617. add_entity_and_particles("nssm:morvy", p1, "morparticle.png", 1)
  618. p1 = vector.add(p1,per)
  619. end
  620. end
  621. end,
  622. on_die = function(self)
  623. local pos = self.object:get_pos()
  624. self.object:remove()
  625. add_entity_and_particles("nssm:morvalar1", pos, "morparticle.png", 10)
  626. end,
  627. })
  628. mobs:register_mob("nssm:morvalar1", {
  629. type = "monster",
  630. hp_max = 160,
  631. hp_min = 160,
  632. collisionbox = {-0.4, -0.1, -0.4, 0.4, 1.8, 0.4},
  633. visual = "mesh",
  634. --rotate= 270,
  635. mesh = "morvalar.x",
  636. textures = {{"morvalar.png"}},
  637. visual_size = {x=5, y=5},
  638. makes_footstep_sound = true,
  639. view_range = 50,
  640. walk_velocity = 1.6,
  641. reach = 6,
  642. run_velocity = 3.2,
  643. damage = 4,
  644. runaway = true,
  645. jump = true,
  646. sounds = {
  647. random = "morvalar1",
  648. },
  649. armor = 20,
  650. drawtype = "front",
  651. water_damage = 0,
  652. fear_height = 4,
  653. floats = 1,
  654. lava_damage = 0,
  655. fire_damage = 0,
  656. light_damage = 0,
  657. blood_texture="morparticle.png",
  658. blood_amount=10,
  659. knock_back=0,
  660. on_rightclick = nil,
  661. attack_type = "dogfight",
  662. animation = {
  663. speed_normal = 15,
  664. speed_run = 30,
  665. stand_start = 550,
  666. stand_end = 551,
  667. walk_start = 560,
  668. walk_end = 600,
  669. run_start = 560,
  670. run_end = 600,
  671. punch_start = 610,
  672. punch_end = 640,
  673. },
  674. do_custom = function(self)
  675. respawn_block(self)
  676. end,
  677. custom_attack = function (self)
  678. self.morvalar1_timer = (self.morvalar1_timer or os.time())
  679. if (os.time() - self.morvalar1_timer) > 3 then
  680. self.morvalar1_timer = os.time()
  681. local s = self.object:get_pos()
  682. local p = self.attack:get_pos()
  683. mobs:set_animation(self, "punch")
  684. local m = 3
  685. if minetest.line_of_sight({x = p.x, y = p.y +1.5, z = p.z}, {x = s.x, y = s.y +1.5, z = s.z}) == true then
  686. -- play attack sound
  687. if self.sounds.attack then
  688. minetest.sound_play(self.sounds.attack, {
  689. object = self.object,
  690. max_hear_distance = self.sounds.distance
  691. })
  692. end
  693. -- punch player
  694. self.health = self.health + (self.damage*3)
  695. self.attack:punch(self.object, 1.0, {
  696. full_punch_interval=1.0,
  697. damage_groups = {fleshy=self.damage}
  698. }, nil)
  699. end
  700. end
  701. end,
  702. on_die = function(self)
  703. local pos = self.object:get_pos()
  704. self.object:remove()
  705. add_entity_and_particles("nssm:morvalar0", pos, "morparticle.png", 10)
  706. end,
  707. })
  708. mobs:register_mob("nssm:morvalar0", {
  709. type = "monster",
  710. hp_max = 100,
  711. hp_min = 100,
  712. collisionbox = {-0.4, -0.1, -0.4, 0.4, 1.8, 0.4},
  713. visual = "mesh",
  714. --rotate= 270,
  715. mesh = "morvalar.x",
  716. textures = {{"morvalar.png"}},
  717. visual_size = {x=5, y=5},
  718. makes_footstep_sound = true,
  719. view_range = 50,
  720. walk_velocity = 1.6,
  721. reach = 16,
  722. run_velocity = 3.2,
  723. damage = 4,
  724. runaway = true,
  725. jump = true,
  726. sounds = {
  727. random = "kamehameha",
  728. },
  729. drops = {
  730. {name = "nssm:death_scythe",
  731. chance = 1,
  732. min = 1,
  733. max = 1,},
  734. },
  735. armor = 30,
  736. drawtype = "front",
  737. water_damage = 0,
  738. fear_height = 4,
  739. floats = 1,
  740. lava_damage = 0,
  741. fire_damage = 0,
  742. light_damage = 0,
  743. blood_texture="morparticle.png",
  744. blood_amount=10,
  745. knock_back=0,
  746. on_rightclick = nil,
  747. attack_type = "dogfight",
  748. animation = {
  749. speed_normal = 15,
  750. speed_run = 30,
  751. stand_start = 645,
  752. stand_end = 646,
  753. walk_start = 650,
  754. walk_end = 690,
  755. run_start = 650,
  756. run_end = 690,
  757. punch_start = 700,
  758. punch_end = 750,
  759. },
  760. do_custom = function(self)
  761. respawn_block(self)
  762. end,
  763. custom_attack = function (self)
  764. self.morvalar1_timer = (self.morvalar1_timer or os.time())
  765. if (os.time() - self.morvalar1_timer) > 1 then
  766. self.morvalar1_timer = os.time()
  767. local s = self.object:get_pos()
  768. local p = self.attack:get_pos()
  769. mobs:set_animation(self, "punch")
  770. local m = 5 --velocity of the kamehameha
  771. local obj = minetest.add_entity(s, "nssm:kamehameha_bad")
  772. s.y = s.y+0.5
  773. p.y = p.y+0.9
  774. local dir = {x=(p.x-s.x)*m, y=(p.y-s.y)*m, z=(p.z-s.z)*m} --direction of the kamehameha
  775. obj:set_velocity(dir)
  776. end
  777. end,
  778. on_die = function(self)
  779. local pos = self.object:get_pos()
  780. self.object:remove()
  781. minetest.add_particlespawner({
  782. amount = 500,
  783. time = 2,
  784. minpos = {x=pos.x-2, y=pos.y-1, z=pos.z-2},
  785. maxpos = {x=pos.x+2, y=pos.y+4, z=pos.z+2},
  786. minvel = {x=0, y=0, z=0},
  787. maxvel = {x=1, y=2, z=1},
  788. minacc = {x=-0.5,y=0.6,z=-0.5},
  789. maxacc = {x=0.5,y=0.7,z=0.5},
  790. minexptime = 2,
  791. maxexptime = 3,
  792. minsize = 3,
  793. maxsize = 5,
  794. collisiondetection = false,
  795. vertical = false,
  796. texture = "morparticle.png",
  797. })
  798. minetest.set_node(posmorvalarblock, {name="nssb:dis_morvalar_block"})
  799. --minetest.add_entity(pos, "nssm:morvalar3")
  800. end,
  801. })
  802. minetest.register_entity("nssm:kamehameha_bad", {
  803. textures = {"kamehameha.png"},
  804. on_step = function(self, dtime)
  805. local pos = self.object:get_pos();
  806. if self.timer == 0 then
  807. self.timer = os.time()
  808. end
  809. if os.time() - self.timer > self.life_time then
  810. self.object:remove()
  811. end
  812. local objects = minetest.get_objects_inside_radius(pos, 2)
  813. for _,obj in ipairs(objects) do
  814. if obj:is_player() then
  815. minetest.chat_send_all("Dentro il raggio grande")
  816. obj:set_hp(obj:get_hp()-5)
  817. end
  818. if obj:get_luaentity() then
  819. local name = obj:get_luaentity().name
  820. if name ~= "nssm:morvalar0" and name ~="nssm:kamehameha_bad" then
  821. obj:set_hp(obj:get_hp()-5)
  822. if (obj:get_hp() <= 0) then
  823. if (not obj:is_player()) then
  824. obj:remove()
  825. end
  826. end
  827. end
  828. end
  829. end
  830. local objects = minetest.get_objects_inside_radius(pos, 1)
  831. for _,obj in ipairs(objects) do
  832. if obj:is_player() then
  833. tnt_boom_nssm(pos, {damage_radius=6,radius=5,ignore_protection=false})
  834. self.object:remove()
  835. minetest.chat_send_all("Dentro il raggio piccolo")
  836. end
  837. if obj:get_luaentity() then
  838. local name = obj:get_luaentity().name
  839. if name ~= "nssm:morvalar0" and name ~="nssm:kamehameha_bad" then
  840. tnt_boom_nssm(pos, {damage_radius=6,radius=5,ignore_protection=false})
  841. self.object:remove()
  842. end
  843. end
  844. end
  845. local nodename = minetest.get_node(pos).name
  846. if nodename ~= "air" then
  847. explosion(pos, 5, 0, 1, true)
  848. self.object:remove()
  849. end
  850. end,
  851. life_time = 40,
  852. timer = 0,
  853. custom_timer = 0,
  854. })
  855. --[[
  856. 7 code: ruba l'armatura come il morlu, ma poi non scappa e ti attacca normalmente. O un po' un po' o prima ruba e poi ti ara e basta.
  857. 6 code: stand: 85-86 walk: 90-130 attack: 132-162
  858. Attacca come prima con 7 ma ruba il cibo come il morvalar6 al posto dell'armatura, e non scappa ma attacca.
  859. 5 code: stand: 165-166 walk: 170-210 attack: 215-245
  860. Fa esplodere un po' la sua coda come un Morgre fa esplodere se stesso.
  861. 4 code: stand: 250-251 walk: 255-295 attack: 300-320
  862. Attacca esattamente come un Mordain
  863. 3 code: stand: 325-326 walk: 330-370 attack: 375-395(punch) 400-450(shoot)
  864. Dogshoot con lo stesso intervel del Morwa, che mi pare sia 2.
  865. 2 code: stand: 455-456 walk: 460-500 attack: 505-545
  866. Evoca intorno a s� i 7 mostri del Morlendor contemporaneamente, non fa nulla fino a quando sono nel suo raggio visivo, quando muoiono ne evoca altri 7 e cos� via fino a che non lo abbatti, sei libero di reinterpretare questo attacco in base alle tue capacit�.
  867. 1 code: stand: 550-551 walk: 560-600 attack: 610-640
  868. Attacca assorbendo la vita come un morde, si ricarica in questo modo, ma di pi� del numero che assorbe.
  869. 0 code: stand: 645-646 walk: 650-690 attack: 700-750
  870. Shoota delle kamehameha
  871. ]]--