Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.19 KB | None | 0 0
  1. local CURSED_CHESTS_VERSION = "1.1.1"
  2.  
  3. local CURSED_CHESTS_SKULL_DEFAULT = SKULL_WHITE
  4. local CURSED_CHESTS_SKULL_BOSS = SKULL_BLACK
  5.  
  6. CURSED_CHESTS_TIER_COMMON = 1
  7. CURSED_CHESTS_TIER_RARE = 2
  8. CURSED_CHESTS_TIER_EPIC = 3
  9. CURSED_CHESTS_TIER_LEGENDARY = 4
  10.  
  11. CURSED_CHESTS_TIERS = {
  12. {
  13. tier = CURSED_CHESTS_TIER_COMMON,
  14. chance = 70,
  15. text = "Common Cursed Chest",
  16. item = 12664,
  17. monstersPerWave = 5,
  18. reqLevel = 25
  19. },
  20. {
  21. tier = CURSED_CHESTS_TIER_RARE,
  22. chance = 45,
  23. text = "Rare Cursed Chest",
  24. item = 12664,
  25. monstersPerWave = 7,
  26. reqLevel = 50
  27. },
  28. {
  29. tier = CURSED_CHESTS_TIER_EPIC,
  30. chance = 25,
  31. text = "Epic Cursed Chest",
  32. item = 12664,
  33. monstersPerWave = 9,
  34. reqLevel = 80
  35. },
  36. {
  37. tier = CURSED_CHESTS_TIER_LEGENDARY,
  38. chance = 10,
  39. text = "Legendary Cursed Chest",
  40. item = 12664,
  41. monstersPerWave = 11,
  42. reqLevel = 120
  43. }
  44. }
  45.  
  46. CURSED_CHESTS_CONFIG = {
  47. [1] = {
  48. message = "Prepare to defend against 5 waves of demon type monsters and a boss at the end.",
  49. rewards = {
  50. [CURSED_CHESTS_TIER_COMMON] = {
  51. {
  52. -- Platinum Coins
  53. chance = 100,
  54. item = 2152,
  55. random = true,
  56. amount = 100
  57. },
  58. {
  59. -- Platinum Coins
  60. chance = 80,
  61. item = 2152,
  62. random = true,
  63. amount = 100
  64. },
  65. {
  66. -- crystal coins
  67. chance = 100,
  68. item = 2160,
  69. random = true,
  70. amount = 7
  71. },
  72. {
  73. -- crystal coins
  74. chance = 40,
  75. item = 2160,
  76. random = true,
  77. amount = 3
  78. },
  79. {
  80. -- Strong Health Potion
  81. chance = 100,
  82. item = 7588,
  83. random = true,
  84. amount = 100
  85. },
  86. {
  87. -- Strong Health Potion
  88. chance = 100,
  89. item = 7588,
  90. random = true,
  91. amount = 100
  92. },
  93. {
  94. -- Strong Mana Potion
  95. chance = 100,
  96. item = 7589,
  97. random = true,
  98. amount = 100
  99. },
  100. {
  101. -- Strong Mana Potion
  102. chance = 100,
  103. item = 7589,
  104. random = true,
  105. amount = 100
  106. },
  107. {
  108. -- Mana Potion
  109. chance = 100,
  110. item = 7620,
  111. random = true,
  112. amount = 100
  113. },
  114. {
  115. -- Mana Potion
  116. chance = 100,
  117. item = 7620,
  118. random = true,
  119. amount = 100
  120. },
  121. {
  122. -- Gold Token
  123. chance = 100,
  124. item = 25377,
  125. amount = 1
  126. },
  127. {
  128. -- Gold Token
  129. chance = 40,
  130. item = 25377,
  131. amount = 1
  132. },
  133. {
  134. -- Blue Crystal Splinter
  135. chance = 100,
  136. item = 18418,
  137. random = true,
  138. amount = 25
  139. },
  140. {
  141. -- Brown Crystal Splinter
  142. chance = 100,
  143. item = 18417,
  144. random = true,
  145. amount = 25
  146. },
  147. {
  148. -- Green Crystal Splinter
  149. chance = 100,
  150. item = 18416,
  151. random = true,
  152. amount = 25
  153. },
  154. {
  155. -- Small Amethyst
  156. chance = 100,
  157. item = 2150,
  158. random = true,
  159. amount = 25
  160. },
  161. {
  162. -- Small Emerald
  163. chance = 100,
  164. item = 2149,
  165. random = true,
  166. amount = 25
  167. },
  168. {
  169. -- Small Ruby
  170. chance = 100,
  171. item = 2147,
  172. random = true,
  173. amount = 25
  174. },
  175. {
  176. -- Small Sapphire
  177. chance = 100,
  178. item = 2146,
  179. random = true,
  180. amount = 25
  181. },
  182. {
  183. -- Candy
  184. chance = 80,
  185. item = 6569,
  186. random = true,
  187. amount = 40
  188. },
  189. {
  190. -- Talon
  191. chance = 60,
  192. item = 2151,
  193. random = true,
  194. amount = 15
  195. },
  196. {
  197. -- Vampire Teeth
  198. chance = 50,
  199. item = 10602,
  200. random = true,
  201. amount = 5
  202. },
  203. {
  204. -- Rope Belt
  205. chance = 50,
  206. item = 12448,
  207. random = true,
  208. amount = 5
  209. },
  210. {
  211. -- Batwing Hat
  212. chance = 20,
  213. item = 10016,
  214. amount = 1
  215. },
  216. {
  217. -- Crown Helmet
  218. chance = 45,
  219. item = 2491,
  220. amount = 1
  221. },
  222. {
  223. -- Crown Helmet
  224. chance = 45,
  225. item = 2491,
  226. amount = 1
  227. },
  228. {
  229. -- Crown Armor
  230. chance = 20,
  231. item = 2487,
  232. amount = 1
  233. },
  234. {
  235. -- Crown Armor
  236. chance = 20,
  237. item = 2487,
  238. amount = 1
  239. },
  240. {
  241. -- Crown Legs
  242. chance = 20,
  243. item = 2488,
  244. amount = 1
  245. },
  246. {
  247. -- Crown Legs
  248. chance = 20,
  249. item = 2488,
  250. amount = 1
  251. },
  252. {
  253. -- Crystalline armor
  254. chance = 15,
  255. item = 8878,
  256. amount = 1
  257. },
  258. {
  259. -- Zaoan armor
  260. chance = 20,
  261. item = 11301,
  262. amount = 1
  263. },
  264. {
  265. -- Dragon scale mail
  266. chance = 10,
  267. item = 2492,
  268. amount = 1
  269. },
  270. {
  271. -- Spellbook of warding
  272. chance = 20,
  273. item = 8901,
  274. amount = 1
  275. },
  276. {
  277. -- Dragon shield
  278. chance = 25,
  279. item = 2516,
  280. amount = 1
  281. },
  282. {
  283. -- Crown shield
  284. chance = 25,
  285. item = 2519,
  286. amount = 1
  287. },
  288. {
  289. -- Crown shield
  290. chance = 25,
  291. item = 2519,
  292. amount = 1
  293. },
  294. {
  295. -- Goo Shell
  296. chance = 1,
  297. item = 21706,
  298. amount = 1
  299. },
  300. {
  301. -- Albino Plate
  302. chance = 1,
  303. item = 21692,
  304. amount = 1
  305. },
  306. {
  307. -- Lavos Armor
  308. chance = 2,
  309. item = 8877,
  310. amount = 1
  311. },
  312. {
  313. -- Ancient Tiara
  314. chance = 1,
  315. item = 2139,
  316. amount = 1
  317. },
  318. {
  319. -- Djinn Blade
  320. chance = 2,
  321. item = 2451,
  322. amount = 1
  323. },
  324. {
  325. -- Twin Axe
  326. chance = 1,
  327. item = 2447,
  328. amount = 1
  329. },
  330. {
  331. -- Bag of Apple Slices
  332. chance = 10,
  333. item = 13537,
  334. amount = 1
  335. },
  336. {
  337. -- Bamboo Leaves
  338. chance = 10,
  339. item = 13538,
  340. amount = 1
  341. },
  342. },
  343. [CURSED_CHESTS_TIER_RARE] = {
  344. {
  345. -- Platinum Coins
  346. chance = 100,
  347. item = 2152,
  348. amount = 100
  349. },
  350. {
  351. -- Platinum Coins
  352. chance = 80,
  353. item = 2152,
  354. random = true,
  355. amount = 100
  356. },
  357. {
  358. -- Platinum Coins
  359. chance = 60,
  360. item = 2152,
  361. random = true,
  362. amount = 100
  363. },
  364. {
  365. -- crystal coins
  366. chance = 100,
  367. item = 2160,
  368. random = true,
  369. amount = 15
  370. },
  371. {
  372. -- crystal coins
  373. chance = 40,
  374. item = 2160,
  375. random = true,
  376. amount = 7
  377. },
  378. {
  379. -- Ultimate Health Potion
  380. chance = 100,
  381. item = 8473,
  382. random = true,
  383. amount = 100
  384. },
  385. {
  386. -- Ultimate Health Potion
  387. chance = 100,
  388. item = 8473,
  389. random = true,
  390. amount = 100
  391. },
  392. {
  393. -- Great Mana Potion
  394. chance = 100,
  395. item = 7590,
  396. random = true,
  397. amount = 100
  398. },
  399. {
  400. -- Great Mana Potion
  401. chance = 100,
  402. item = 7590,
  403. random = true,
  404. amount = 100
  405. },
  406. {
  407. -- Mana Potion
  408. chance = 100,
  409. item = 7620,
  410. random = true,
  411. amount = 100
  412. },
  413. {
  414. -- Mana Potion
  415. chance = 100,
  416. item = 7620,
  417. random = true,
  418. amount = 100
  419. },
  420. {
  421. -- Mana Potion
  422. chance = 100,
  423. item = 7620,
  424. random = true,
  425. amount = 100
  426. },
  427. {
  428. -- Gold Token
  429. chance = 100,
  430. item = 25377,
  431. amount = 2
  432. },
  433. {
  434. -- Gold Token
  435. chance = 40,
  436. item = 25377,
  437. random = true,
  438. amount = 2
  439. },
  440. {
  441. -- Cyan Crystal Fragment
  442. chance = 100,
  443. item = 18419,
  444. random = true,
  445. amount = 35
  446. },
  447. {
  448. -- Green Crystal Fragment
  449. chance = 100,
  450. item = 18421,
  451. random = true,
  452. amount = 35
  453. },
  454. {
  455. -- Red Crystal Fragment
  456. chance = 100,
  457. item = 18420,
  458. random = true,
  459. amount = 35
  460. },
  461. {
  462. -- Small Amethyst
  463. chance = 100,
  464. item = 2150,
  465. random = true,
  466. amount = 50
  467. },
  468. {
  469. -- Small Emerald
  470. chance = 100,
  471. item = 2149,
  472. random = true,
  473. amount = 50
  474. },
  475. {
  476. -- Small Ruby
  477. chance = 100,
  478. item = 2147,
  479. random = true,
  480. amount = 50
  481. },
  482. {
  483. -- Small Sapphire
  484. chance = 100,
  485. item = 2146,
  486. random = true,
  487. amount = 50
  488. },
  489. {
  490. -- Talon
  491. chance = 60,
  492. item = 2151,
  493. random = true,
  494. amount = 25
  495. },
  496. {
  497. -- Blood herb
  498. chance = 100,
  499. item = 2798,
  500. amount = 2
  501. },
  502. {
  503. -- Blood herbs
  504. chance = 45,
  505. item = 2798,
  506. random = true,
  507. amount = 2
  508. },
  509. {
  510. -- Vampire Teeth
  511. chance = 100,
  512. item = 10602,
  513. random = true,
  514. amount = 7
  515. },
  516. {
  517. -- Vampire Teeth
  518. chance = 50,
  519. item = 10602,
  520. random = true,
  521. amount = 4
  522. },
  523. {
  524. -- Bloody Pincers
  525. chance = 100,
  526. item = 10550,
  527. random = true,
  528. amount = 4
  529. },
  530. {
  531. -- Bloody Pincers
  532. chance = 50,
  533. item = 10550,
  534. random = true,
  535. amount = 2
  536. },
  537. {
  538. -- Rope Belt
  539. chance = 100,
  540. item = 12448,
  541. random = true,
  542. amount = 7
  543. },
  544. {
  545. -- Rope Belt
  546. chance = 50,
  547. item = 12448,
  548. random = true,
  549. amount = 4
  550. },
  551. {
  552. -- Silencer Claws
  553. chance = 50,
  554. item = 22534,
  555. random = true,
  556. amount = 7
  557. },
  558. {
  559. -- Silencer Claws
  560. chance = 50,
  561. item = 22534,
  562. random = true,
  563. amount = 4
  564. },
  565. {
  566. -- Hat of the Mad
  567. chance = 20,
  568. item = 2323,
  569. amount = 1
  570. },
  571. {
  572. -- Warrior Helmet
  573. chance = 45,
  574. item = 2475,
  575. amount = 1
  576. },
  577. {
  578. -- Golden Armor
  579. chance = 20,
  580. item = 2466,
  581. amount = 1
  582. },
  583. {
  584. -- Golden Armor
  585. chance = 20,
  586. item = 2466,
  587. amount = 1
  588. },
  589. {
  590. -- Blue Robe
  591. chance = 20,
  592. item = 2656,
  593. amount = 1
  594. },
  595. {
  596. -- Blue Robe
  597. chance = 20,
  598. item = 2656,
  599. amount = 1
  600. },
  601. {
  602. -- Paladin Armor
  603. chance = 40,
  604. item = 8891,
  605. amount = 1
  606. },
  607. {
  608. -- Paladin Armor
  609. chance = 40,
  610. item = 8891,
  611. amount = 1
  612. },
  613. {
  614. -- Blue legs
  615. chance = 20,
  616. item = 7730,
  617. amount = 1
  618. },
  619. {
  620. -- Crown Legs
  621. chance = 40,
  622. item = 2488,
  623. amount = 1
  624. },
  625. {
  626. -- Crown Legs
  627. chance = 40,
  628. item = 2488,
  629. amount = 1
  630. },
  631. {
  632. -- Medusa shield
  633. chance = 40,
  634. item = 2536,
  635. amount = 1
  636. },
  637. {
  638. -- Medusa shield
  639. chance = 40,
  640. item = 2536,
  641. amount = 1
  642. },
  643. {
  644. -- Vampire shield
  645. chance = 20,
  646. item = 2534,
  647. amount = 1
  648. },
  649. {
  650. -- Vampire shield
  651. chance = 20,
  652. item = 2534,
  653. amount = 1
  654. },
  655. {
  656. -- Demon shield
  657. chance = 15,
  658. item = 2520,
  659. amount = 1
  660. },
  661. {
  662. -- Spellbook of Mind Control
  663. chance = 50,
  664. item = 8902,
  665. amount = 1
  666. },
  667. {
  668. -- Spellbook of Lost souls
  669. chance = 20,
  670. item = 8903,
  671. amount = 1
  672. },
  673. {
  674. -- Blade of corruption
  675. chance = 15,
  676. item = 12649,
  677. amount = 1
  678. },
  679. {
  680. -- Demonrage sword
  681. chance = 30,
  682. item = 7382,
  683. amount = 1
  684. },
  685. {
  686. -- Dragon Lance
  687. chance = 40,
  688. item = 2414,
  689. amount = 1
  690. },
  691. {
  692. -- Demonbone
  693. chance = 15,
  694. item = 7431,
  695. amount = 1
  696. },
  697. {
  698. -- Mythril Axe
  699. chance = 15,
  700. item = 7455,
  701. amount = 1
  702. },
  703. {
  704. -- Earthborn Titan Armor
  705. chance = 2,
  706. item = 8882,
  707. amount = 1
  708. },
  709. {
  710. -- Windborn Colossus Armor
  711. chance = 2,
  712. item = 8883,
  713. amount = 1
  714. },
  715. {
  716. -- Voltage Armor
  717. chance = 1,
  718. item = 8879,
  719. amount = 1
  720. },
  721. {
  722. -- Ceremonial Mask
  723. chance = 0.75,
  724. item = 2501,
  725. amount = 1
  726. },
  727. {
  728. -- Fur Cap
  729. chance = 1,
  730. item = 7458,
  731. amount = 1
  732. },
  733. {
  734. -- Pair of Soft Boots
  735. chance = 7,
  736. item = 6132,
  737. amount = 1
  738. },
  739. {
  740. -- Pharaoh Sword
  741. chance = 1,
  742. item = 2446,
  743. amount = 1
  744. },
  745. {
  746. -- Holy Falcon
  747. chance = 1,
  748. item = 3141,
  749. amount = 1
  750. },
  751. {
  752. -- Slingshot
  753. chance = 7,
  754. item = 5907,
  755. amount = 1
  756. },
  757. {
  758. -- Diapason
  759. chance = 4,
  760. item = 13536,
  761. amount = 1
  762. },
  763. {
  764. -- Golden Fir Cone
  765. chance = 4,
  766. item = 13539,
  767. amount = 1
  768. }
  769. },
  770. [CURSED_CHESTS_TIER_EPIC] = {
  771. {
  772. -- crystal coins
  773. chance = 100,
  774. item = 2160,
  775. random = true,
  776. amount = 25
  777. },
  778. {
  779. -- crystal coins
  780. chance = 40,
  781. item = 2160,
  782. random = true,
  783. amount = 8
  784. },
  785. {
  786. -- Supreme Health Potion
  787. chance = 100,
  788. item = 26031,
  789. random = true,
  790. amount = 100
  791. },
  792. {
  793. -- Supreme Health Potion
  794. chance = 100,
  795. item = 26031,
  796. random = true,
  797. amount = 100
  798. },
  799. {
  800. -- Ultimate Mana Potion
  801. chance = 100,
  802. item = 26029,
  803. random = true,
  804. amount = 100
  805. },
  806. {
  807. -- Ultimate Mana Potion
  808. chance = 100,
  809. item = 26029,
  810. random = true,
  811. amount = 100
  812. },
  813. {
  814. -- Ultimate Spirit Potion
  815. chance = 100,
  816. item = 26030,
  817. random = true,
  818. amount = 100
  819. },
  820. {
  821. -- Ultimate Spirit Potion
  822. chance = 100,
  823. item = 26030,
  824. random = true,
  825. amount = 100
  826. },
  827. {
  828. -- Gold Token
  829. chance = 100,
  830. item = 25377,
  831. amount = 3
  832. },
  833. {
  834. -- Gold Token
  835. chance = 40,
  836. item = 25377,
  837. random = true,
  838. amount = 3
  839. },
  840. {
  841. -- Green Crystal Shard
  842. chance = 100,
  843. item = 18415,
  844. random = true,
  845. amount = 50
  846. },
  847. {
  848. -- Blue Crystal Shard
  849. chance = 100,
  850. item = 18413,
  851. random = true,
  852. amount = 50
  853. },
  854. {
  855. -- Violet Crystal Fragment
  856. chance = 100,
  857. item = 18414,
  858. random = true,
  859. amount = 50
  860. },
  861. {
  862. -- Small Amethyst
  863. chance = 100,
  864. item = 2150,
  865. random = true,
  866. amount = 75
  867. },
  868. {
  869. -- Small Emerald
  870. chance = 100,
  871. item = 2149,
  872. random = true,
  873. amount = 75
  874. },
  875. {
  876. -- Small Ruby
  877. chance = 100,
  878. item = 2147,
  879. random = true,
  880. amount = 75
  881. },
  882. {
  883. -- Small Sapphire
  884. chance = 100,
  885. item = 2146,
  886. random = true,
  887. amount = 75
  888. },
  889. {
  890. -- Talon
  891. chance = 60,
  892. item = 2151,
  893. random = true,
  894. amount = 35
  895. },
  896. {
  897. -- Blood herb
  898. chance = 100,
  899. item = 2798,
  900. amount = 3
  901. },
  902. {
  903. -- Blood herbs
  904. chance = 45,
  905. item = 2798,
  906. random = true,
  907. amount = 3
  908. },
  909. {
  910. -- Vampire Teeth
  911. chance = 100,
  912. item = 10602,
  913. random = true,
  914. amount = 10
  915. },
  916. {
  917. -- Vampire Teeth
  918. chance = 50,
  919. item = 10602,
  920. random = true,
  921. amount = 6
  922. },
  923. {
  924. -- Bloody Pincers
  925. chance = 100,
  926. item = 10550,
  927. random = true,
  928. amount = 6
  929. },
  930. {
  931. -- Bloody Pincers
  932. chance = 50,
  933. item = 10550,
  934. random = true,
  935. amount = 3
  936. },
  937. {
  938. -- Rope Belt
  939. chance = 100,
  940. item = 12448,
  941. random = true,
  942. amount = 10
  943. },
  944. {
  945. -- Rope Belt
  946. chance = 50,
  947. item = 12448,
  948. random = true,
  949. amount = 6
  950. },
  951. {
  952. -- Silencer Claws
  953. chance = 100,
  954. item = 22534,
  955. random = true,
  956. amount = 10
  957. },
  958. {
  959. -- Silencer Claws
  960. chance = 50,
  961. item = 22534,
  962. random = true,
  963. amount = 6
  964. },
  965. {
  966. -- Protective Charm
  967. chance = 100,
  968. item = 12400,
  969. random = true,
  970. amount = 8
  971. },
  972. {
  973. -- Protective Charm
  974. chance = 50,
  975. item = 12400,
  976. random = true,
  977. amount = 5
  978. },
  979. {
  980. -- Sabretoth
  981. chance = 100,
  982. item = 11228,
  983. random = true,
  984. amount = 10
  985. },
  986. {
  987. -- Sabretoth
  988. chance = 100,
  989. item = 11228,
  990. random = true,
  991. amount = 6
  992. },
  993. {
  994. -- Crest of the Deep Seas
  995. chance = 60,
  996. item = 24261,
  997. amount = 1
  998. },
  999. {
  1000. -- Royal Helmet
  1001. chance = 45,
  1002. item = 2498,
  1003. amount = 1
  1004. },
  1005. {
  1006. -- Royal Helmet
  1007. chance = 20,
  1008. item = 2498,
  1009. amount = 1
  1010. },
  1011. {
  1012. -- Skull Helmet
  1013. chance = 50,
  1014. item = 5741,
  1015. amount = 1
  1016. },
  1017. {
  1018. -- Zaoan Helmet
  1019. chance = 35,
  1020. item = 5741,
  1021. amount = 1
  1022. },
  1023. {
  1024. -- Demon Helmet
  1025. chance = 8,
  1026. item = 2493,
  1027. amount = 1
  1028. },
  1029. {
  1030. -- Magic Plate Armor
  1031. chance = 30,
  1032. item = 2472,
  1033. amount = 1
  1034. },
  1035. {
  1036. -- Magic Plate Armor
  1037. chance = 10,
  1038. item = 2472,
  1039. amount = 1
  1040. },
  1041. {
  1042. -- Golden Armor
  1043. chance = 40,
  1044. item = 2466,
  1045. amount = 1
  1046. },
  1047. {
  1048. -- Golden Armor
  1049. chance = 20,
  1050. item = 2466,
  1051. amount = 1
  1052. },
  1053. {
  1054. -- Paladin Armor
  1055. chance = 60,
  1056. item = 8891,
  1057. amount = 1
  1058. },
  1059. {
  1060. -- Divine Plate
  1061. chance = 30,
  1062. item = 8885,
  1063. amount = 1
  1064. },
  1065. {
  1066. -- Ornate Chestplate
  1067. chance = 5,
  1068. item = 15406,
  1069. amount = 1
  1070. },
  1071. {
  1072. -- Depth Lorica
  1073. chance = 7,
  1074. item = 15407,
  1075. amount = 1
  1076. },
  1077. {
  1078. -- Ornate Legs
  1079. chance = 3,
  1080. item = 15412,
  1081. amount = 1
  1082. },
  1083. {
  1084. -- Golden Legs
  1085. chance = 30,
  1086. item = 2470,
  1087. amount = 1
  1088. },
  1089. {
  1090. -- Golden Legs
  1091. chance = 15,
  1092. item = 2470,
  1093. amount = 1
  1094. },
  1095. {
  1096. -- Crown Legs
  1097. chance = 60,
  1098. item = 2488,
  1099. amount = 1
  1100. },
  1101. {
  1102. -- Steel Boots
  1103. chance = 35,
  1104. item = 2645,
  1105. amount = 1
  1106. },
  1107. {
  1108. -- Steel Boots
  1109. chance = 25,
  1110. item = 2645,
  1111. amount = 1
  1112. },
  1113. {
  1114. -- Ornate Shield
  1115. chance = 10,
  1116. item = 15413,
  1117. amount = 1
  1118. },
  1119. {
  1120. -- Vampire shield
  1121. chance = 80,
  1122. item = 2534,
  1123. amount = 1
  1124. },
  1125. {
  1126. -- Demon shield
  1127. chance = 45,
  1128. item = 2520,
  1129. amount = 1
  1130. },
  1131. {
  1132. -- Demon shield
  1133. chance = 30,
  1134. item = 2520,
  1135. amount = 1
  1136. },
  1137. {
  1138. -- Mastermind Shield
  1139. chance = 20,
  1140. item = 2514,
  1141. amount = 1
  1142. },
  1143. {
  1144. -- Rift Shield
  1145. chance = 20,
  1146. item = 25382,
  1147. amount = 1
  1148. },
  1149. {
  1150. -- Spellbook Dark Mysteries
  1151. chance = 35,
  1152. item = 8918,
  1153. amount = 1
  1154. },
  1155. {
  1156. -- Rift Lance
  1157. chance = 20,
  1158. item = 25383,
  1159. amount = 1
  1160. },
  1161. {
  1162. -- Demonrage sword
  1163. chance = 30,
  1164. item = 7382,
  1165. amount = 1
  1166. },
  1167. {
  1168. -- Shiny Blade
  1169. chance = 7,
  1170. item = 18465,
  1171. amount = 1
  1172. },
  1173. {
  1174. -- Crystalline axe
  1175. chance = 7,
  1176. item = 18451,
  1177. amount = 1
  1178. },
  1179. {
  1180. -- Mycological Mace
  1181. chance = 7,
  1182. item = 18452,
  1183. amount = 1
  1184. },
  1185. {
  1186. -- Tunic
  1187. chance = 1,
  1188. item = 8875,
  1189. amount = 1
  1190. },
  1191. {
  1192. -- Native Armor
  1193. chance = 2,
  1194. item = 2508,
  1195. amount = 1
  1196. },
  1197. {
  1198. -- Elven Mail
  1199. chance = 2,
  1200. item = 2505,
  1201. amount = 1
  1202. },
  1203. {
  1204. -- Swan Feather Cloak
  1205. chance = 2,
  1206. item = 29079,
  1207. amount = 1
  1208. },
  1209. {
  1210. -- Molten Plate
  1211. chance = 1,
  1212. item = 8886,
  1213. amount = 1
  1214. },
  1215. {
  1216. -- Dwarven Helmet
  1217. chance = 3,
  1218. item = 2502,
  1219. amount = 1
  1220. },
  1221. {
  1222. -- Demon Legs
  1223. chance = 5,
  1224. item = 2495,
  1225. amount = 1
  1226. },
  1227. {
  1228. -- Nightmare shield
  1229. chance = 4,
  1230. item = 6391,
  1231. amount = 1
  1232. },
  1233. {
  1234. -- Necromancer Shield
  1235. chance = 4,
  1236. item = 6433,
  1237. amount = 1
  1238. },
  1239. {
  1240. -- Carrot on a Stick
  1241. chance = 4,
  1242. item = 13298,
  1243. amount = 1
  1244. },
  1245. {
  1246. -- Fist on a Stick
  1247. chance = 4,
  1248. item = 13535,
  1249. amount = 1
  1250. },
  1251. {
  1252. -- Reins
  1253. chance = 4,
  1254. item = 13295,
  1255. amount = 1
  1256. }
  1257. },
  1258. [CURSED_CHESTS_TIER_LEGENDARY] = {
  1259. {
  1260. -- crystal coins
  1261. chance = 100,
  1262. item = 2160,
  1263. random = true,
  1264. amount = 50
  1265. },
  1266. {
  1267. -- crystal coins
  1268. chance = 50,
  1269. item = 2160,
  1270. random = true,
  1271. amount = 50
  1272. },
  1273. {
  1274. -- crystal coins
  1275. chance = 30,
  1276. item = 2160,
  1277. random = true,
  1278. amount = 100
  1279. },
  1280. {
  1281. -- Supreme Health Potion
  1282. chance = 100,
  1283. item = 26031,
  1284. amount = 100
  1285. },
  1286. {
  1287. -- Supreme Health Potion
  1288. chance = 100,
  1289. item = 26031,
  1290. amount = 100
  1291. },
  1292. {
  1293. -- Supreme Health Potion
  1294. chance = 100,
  1295. item = 26031,
  1296. amount = 100
  1297. },
  1298. {
  1299. -- Ultimate Mana Potion
  1300. chance = 100,
  1301. item = 26029,
  1302. amount = 100
  1303. },
  1304. {
  1305. -- Ultimate Mana Potion
  1306. chance = 100,
  1307. item = 26029,
  1308. amount = 100
  1309. },
  1310. {
  1311. -- Ultimate Mana Potion
  1312. chance = 100,
  1313. item = 26029,
  1314. amount = 100
  1315. },
  1316. {
  1317. -- Ultimate Spirit Potion
  1318. chance = 100,
  1319. item = 26030,
  1320. amount = 100
  1321. },
  1322. {
  1323. -- Ultimate Spirit Potion
  1324. chance = 100,
  1325. item = 26030,
  1326. amount = 100
  1327. },
  1328. {
  1329. -- Ultimate Spirit Potion
  1330. chance = 100,
  1331. item = 26030,
  1332. amount = 100
  1333. },
  1334. {
  1335. -- Gold Token
  1336. chance = 100,
  1337. item = 25377,
  1338. amount = 5
  1339. },
  1340. {
  1341. -- Gold Token
  1342. chance = 40,
  1343. item = 25377,
  1344. random = true,
  1345. amount = 5
  1346. },
  1347. {
  1348. -- Giant emerald
  1349. chance = 100,
  1350. item = 34698,
  1351. amount = 1
  1352. },
  1353. {
  1354. -- Giant emerald
  1355. chance = 40,
  1356. item = 34698,
  1357. amount = 1
  1358. },
  1359. {
  1360. -- Giant ruby
  1361. chance = 100,
  1362. item = 34697,
  1363. amount = 1
  1364. },
  1365. {
  1366. -- Giant ruby
  1367. chance = 60,
  1368. item = 34697,
  1369. amount = 1
  1370. },
  1371. {
  1372. -- Giant Sapphire
  1373. chance = 100,
  1374. item = 34699,
  1375. amount = 1
  1376. },
  1377. {
  1378. -- Giant Sapphire
  1379. chance = 100,
  1380. item = 34699,
  1381. amount = 1
  1382. },
  1383. {
  1384. -- Small Amethyst
  1385. chance = 100,
  1386. item = 2150,
  1387. random = true,
  1388. amount = 100
  1389. },
  1390. {
  1391. -- Small Emerald
  1392. chance = 100,
  1393. item = 2149,
  1394. random = true,
  1395. amount = 100
  1396. },
  1397. {
  1398. -- Small Ruby
  1399. chance = 100,
  1400. item = 2147,
  1401. random = true,
  1402. amount = 100
  1403. },
  1404. {
  1405. -- Small Sapphire
  1406. chance = 100,
  1407. item = 2146,
  1408. random = true,
  1409. amount = 100
  1410. },
  1411. {
  1412. -- Talon
  1413. chance = 60,
  1414. item = 2151,
  1415. random = true,
  1416. amount = 50
  1417. },
  1418. {
  1419. -- Blood herb
  1420. chance = 100,
  1421. item = 2798,
  1422. amount = 5
  1423. },
  1424. {
  1425. -- Blood herbs
  1426. chance = 45,
  1427. item = 2798,
  1428. random = true,
  1429. amount = 5
  1430. },
  1431. {
  1432. -- Batwing Hat
  1433. chance = 20,
  1434. item = 10016,
  1435. amount = 1
  1436. },
  1437. {
  1438. -- Skull Helmet
  1439. chance = 100,
  1440. item = 5741,
  1441. amount = 1
  1442. },
  1443. {
  1444. -- Skull Helmet
  1445. chance = 75,
  1446. item = 5741,
  1447. amount = 1
  1448. },
  1449. {
  1450. -- Skull Helmet
  1451. chance = 50,
  1452. item = 5741,
  1453. amount = 1
  1454. },
  1455. {
  1456. -- Prismatic Helmet
  1457. chance = 50,
  1458. item = 18403,
  1459. amount = 1
  1460. },
  1461. {
  1462. -- Royal Helmet
  1463. chance = 100,
  1464. item = 2498,
  1465. amount = 1
  1466. },
  1467. {
  1468. -- Royal Helmet
  1469. chance = 80,
  1470. item = 2498,
  1471. amount = 1
  1472. },
  1473. {
  1474. -- Royal Helmet
  1475. chance = 60,
  1476. item = 2498,
  1477. amount = 1
  1478. },
  1479. {
  1480. -- Magic Plate armor
  1481. chance = 100,
  1482. item = 2472,
  1483. amount = 1
  1484. },
  1485. {
  1486. -- Magic Plate armor
  1487. chance = 70,
  1488. item = 2472,
  1489. amount = 1
  1490. },
  1491. {
  1492. -- Magic Plate armor
  1493. chance = 40,
  1494. item = 2472,
  1495. amount = 1
  1496. },
  1497. {
  1498. -- Dragon Scale Mail
  1499. chance = 100,
  1500. item = 2492,
  1501. amount = 1
  1502. },
  1503. {
  1504. -- Dragon Scale Mail
  1505. chance = 80,
  1506. item = 2492,
  1507. amount = 1
  1508. },
  1509. {
  1510. -- Dragon Scale Mail
  1511. chance = 70,
  1512. item = 2492,
  1513. amount = 1
  1514. },
  1515. {
  1516. -- Golden Legs
  1517. chance = 100,
  1518. item = 2470,
  1519. amount = 1
  1520. },
  1521. {
  1522. -- Golden Legs
  1523. chance = 100,
  1524. item = 2470,
  1525. amount = 1
  1526. },
  1527. {
  1528. -- Prismatic Legs
  1529. chance = 25,
  1530. item = 18405,
  1531. amount = 1
  1532. },
  1533. {
  1534. -- Boots of Haste
  1535. chance = 100,
  1536. item = 2195,
  1537. amount = 1
  1538. },
  1539. {
  1540. -- Boots of Haste
  1541. chance = 75,
  1542. item = 2195,
  1543. amount = 1
  1544. },
  1545. {
  1546. -- Boots of Haste
  1547. chance = 60,
  1548. item = 2195,
  1549. amount = 1
  1550. },
  1551. {
  1552. -- Steel Boots
  1553. chance = 100,
  1554. item = 2645,
  1555. amount = 1
  1556. },
  1557. {
  1558. -- Steel Boots
  1559. chance = 50,
  1560. item = 2645,
  1561. amount = 1
  1562. },
  1563. {
  1564. -- Mastermind shield
  1565. chance = 100,
  1566. item = 2514,
  1567. amount = 1
  1568. },
  1569. {
  1570. -- Mastermind shield
  1571. chance = 60,
  1572. item = 2514,
  1573. amount = 1
  1574. },
  1575. {
  1576. -- Heavy Mace
  1577. chance = 60,
  1578. item = 2452,
  1579. amount = 1
  1580. },
  1581. {
  1582. -- Dragon Scale Helmet
  1583. chance = 0.75,
  1584. item = 2506,
  1585. amount = 1
  1586. },
  1587. {
  1588. -- Gnome Helmet
  1589. chance = 3,
  1590. item = 30882,
  1591. amount = 1
  1592. },
  1593. {
  1594. -- Mage's Cap
  1595. chance = 20,
  1596. item = 13756,
  1597. amount = 1
  1598. },
  1599. {
  1600. -- Furious Frock
  1601. chance = 2,
  1602. item = 21725,
  1603. amount = 1
  1604. },
  1605. {
  1606. -- Gnome Armor
  1607. chance = 4,
  1608. item = 30883,
  1609. amount = 1
  1610. },
  1611. {
  1612. -- White Dress
  1613. chance = 0.75,
  1614. item = 2658,
  1615. amount = 1
  1616. },
  1617. {
  1618. -- Whitchhunter's Cloak
  1619. chance = 1,
  1620. item = 8821,
  1621. amount = 1
  1622. },
  1623. {
  1624. -- Gnome Legs
  1625. chance = 4,
  1626. item = 30884,
  1627. amount = 1
  1628. },
  1629. {
  1630. -- Icy Culottes
  1631. chance = 3,
  1632. item = 21700,
  1633. amount = 1
  1634. },
  1635. {
  1636. -- Golden Boots
  1637. chance = 12,
  1638. item = 2646,
  1639. amount = 1
  1640. },
  1641. {
  1642. -- Dragon Scale Boots
  1643. chance = 6,
  1644. item = 11118,
  1645. amount = 1
  1646. },
  1647. {
  1648. -- Crystal Boots
  1649. chance = 6,
  1650. item = 11117,
  1651. amount = 1
  1652. },
  1653. {
  1654. -- Gnome Shield
  1655. chance = 5,
  1656. item = 30885,
  1657. amount = 1
  1658. },
  1659. {
  1660. -- Hunted Mirror Piece
  1661. chance = 4,
  1662. item = 21707,
  1663. amount = 1
  1664. },
  1665. {
  1666. -- Silver Mace
  1667. chance = 3,
  1668. item = 2424,
  1669. amount = 1
  1670. },
  1671. {
  1672. -- Reaper's Axe
  1673. chance = 3,
  1674. item = 7420,
  1675. amount = 1
  1676. },
  1677. {
  1678. -- Great Axe
  1679. chance = 2,
  1680. item = 2415,
  1681. amount = 1
  1682. },
  1683. {
  1684. -- Elemental Spikes
  1685. chance = 8,
  1686. item = 13940,
  1687. amount = 1
  1688. },
  1689. {
  1690. -- Dream Warden Mask
  1691. chance = 20,
  1692. item = 22610,
  1693. amount = 1
  1694. },
  1695. {
  1696. -- Dream Warden Claw
  1697. chance = 20,
  1698. item = 22611,
  1699. amount = 1
  1700. },
  1701. {
  1702. -- Slug Drug
  1703. chance = 7,
  1704. item = 13508,
  1705. amount = 1
  1706. },
  1707. {
  1708. -- Giant Shrimp
  1709. chance = 5,
  1710. item = 13505,
  1711. amount = 1
  1712. },
  1713. {
  1714. -- Melting Horn
  1715. chance = 4,
  1716. item = 22726,
  1717. amount = 1
  1718. },
  1719. {
  1720. -- Sweet Smelling Bait
  1721. chance = 12,
  1722. item = 13307,
  1723. amount = 1
  1724. },
  1725. {
  1726. -- Leather Whip
  1727. chance = 3,
  1728. item = 13293,
  1729. amount = 1
  1730. },
  1731. {
  1732. -- Nail Case
  1733. chance = 4,
  1734. item = 21452,
  1735. amount = 1
  1736. },
  1737. },
  1738. },
  1739. waves = {
  1740. [CURSED_CHESTS_TIER_COMMON] = {
  1741. {
  1742. -- Wave 1
  1743. "Fire Devil",
  1744. "Gozzler",
  1745. "Nightstalker"
  1746. },
  1747. {
  1748. -- Wave 2
  1749. "Fire Devil",
  1750. "Gozzler",
  1751. "Nightstalker"
  1752. },
  1753. {
  1754. -- Wave 3
  1755. "Fire Devil",
  1756. "Gozzler",
  1757. "Nightstalker"
  1758. },
  1759. {
  1760. -- Wave 4
  1761. "Fire Devil",
  1762. "Gozzler",
  1763. "Nightstalker",
  1764. "Necromancer"
  1765. },
  1766. {
  1767. -- Wave 5
  1768. "Fire Devil",
  1769. "Gozzler",
  1770. "Nightstalker",
  1771. "Necromancer"
  1772. }
  1773. },
  1774. [CURSED_CHESTS_TIER_RARE] = {
  1775. {
  1776. -- Wave 1
  1777. "Vampire",
  1778. "Nightstalker"
  1779. },
  1780. {
  1781. -- Wave 2
  1782. "Vampire",
  1783. "Giant Spider",
  1784. "Dragon"
  1785. },
  1786. {
  1787. -- Wave 3
  1788. "Giant Spider",
  1789. "Dragon",
  1790. "Fire Elemental"
  1791. },
  1792. {
  1793. -- Wave 4
  1794. "Dragon",
  1795. "Blistering Fire Elemental",
  1796. "Giant Spider",
  1797. "NIghtmare"
  1798. },
  1799. {
  1800. -- Wave 5
  1801. "Dragon",
  1802. "Blistering Fire Elemental",
  1803. "Giant Spider",
  1804. "NIghtmare",
  1805. "Diabolic Imp"
  1806. }
  1807. },
  1808. [CURSED_CHESTS_TIER_EPIC] = {
  1809. {
  1810. -- Wave 1
  1811. "Dragon",
  1812. "Nightmare Scion",
  1813. "Braindeath"
  1814. },
  1815. {
  1816. -- Wave 2
  1817. "Nightmare Scion",
  1818. "Dragon Lord",
  1819. "Blazing Fire Elemental",
  1820. "Braindeath"
  1821. },
  1822. {
  1823. -- Wave 3
  1824. "Diabolic Imp",
  1825. "Dragon Lord",
  1826. "Behemoth",
  1827. "Hydra"
  1828. },
  1829. {
  1830. -- Wave 4
  1831. "Dragon Lord",
  1832. "Diabolic Imp",
  1833. "Grim Reaper",
  1834. "Hydra",
  1835. "Behemoth"
  1836. },
  1837. {
  1838. -- Wave 5
  1839. "Destroyer",
  1840. "Diabolic Imp",
  1841. "Grim Reaper",
  1842. "Hellspawn",
  1843. "Lich",
  1844. "Behemoth"
  1845. }
  1846. },
  1847. [CURSED_CHESTS_TIER_LEGENDARY] = {
  1848. {
  1849. -- Wave 1
  1850. "Warlock",
  1851. "Dragon Lord",
  1852. "Hydra",
  1853. "Demon"
  1854. },
  1855. {
  1856. -- Wave 2
  1857. "Demon",
  1858. "Thanatursus",
  1859. "Hellfire Fighter",
  1860. "Diabolic Imp",
  1861. "Grimeleech",
  1862. "Vexclaw"
  1863. },
  1864. {
  1865. -- Wave 3
  1866. "Demon",
  1867. "Thanatursus",
  1868. "Grimeleech",
  1869. "Vexclaw",
  1870. "Phantasm",
  1871. "Hellhound",
  1872. "Undead Dragon"
  1873. },
  1874. {
  1875. -- Wave 4
  1876. "Demon",
  1877. "Vexclaw",
  1878. "Phantasm",
  1879. "Hellhound",
  1880. "Hellfire Fighter",
  1881. "Hellflayer",
  1882. "Juggernaut",
  1883. "Hand of Cursed Faith",
  1884. "Undead Dragon"
  1885. },
  1886. {
  1887. -- Wave 5
  1888. "Demon",
  1889. "Vexclaw",
  1890. "Sight of Surrender",
  1891. "Hellhound",
  1892. "Hellfire Fighter",
  1893. "Hellflayer",
  1894. "Juggernaut",
  1895. "Hand of Cursed Faith",
  1896. "Undead Dragon",
  1897. "Grim Reaper",
  1898. "Ripper Spectre"
  1899. }
  1900. }
  1901. },
  1902. boss = {
  1903. name = "Clone Orshabaal",
  1904. fightDuration = 90,
  1905. message = "Boss incoming! You have 90 seconds to kill Clone Orshabaal!"
  1906. }
  1907. }
  1908. }
  1909.  
  1910. CURSED_CHESTS_DATA = {}
  1911.  
  1912. function CursedChestsLoad()
  1913. print(">> Loaded Cursed Chests v" .. CURSED_CHESTS_VERSION)
  1914. ShowEffects()
  1915. end
  1916.  
  1917. function ShowEffects()
  1918. for _, data in ipairs(CURSED_CHESTS_DATA) do
  1919. local tile = Tile(data.pos)
  1920. if tile then
  1921. for _, item in ipairs(tile:getItems()) do
  1922. if item:getId() == data.rarity.item then
  1923. if data.active == 0 and data.finished == false then
  1924. data.pos:sendMagicEffect(CONST_ME_YALAHARIGHOST)
  1925. data.pos:sendAnimatedText(data.rarity.text)
  1926. elseif data.active == 1 and data.wave > 0 then
  1927. data.pos:sendMagicEffect(CONST_ME_YALAHARIGHOST)
  1928. if data.wave <= #data.chest.waves[data.rarity.tier] and not data.bossWave then
  1929. data.pos:sendAnimatedText(
  1930. string.format("Wave %d / %d\nMonsters Alive: %d", data.wave, #data.chest.waves[data.rarity.tier], #data.monsters)
  1931. )
  1932. elseif data.chest.boss ~= nil and data.bossWave == true then
  1933. data.pos:sendAnimatedText(string.format("Boss Fight\n%s", data.chest.boss.name))
  1934. end
  1935. elseif data.finished == true then
  1936. data.pos:sendMagicEffect(CONST_ME_GIFT_WRAPS)
  1937. data.pos:sendAnimatedText("Get your reward!")
  1938. end
  1939. end
  1940. end
  1941. end
  1942. end
  1943. addEvent(ShowEffects, 3000)
  1944. end
  1945.  
  1946. function CursedChestEvent(data)
  1947. data.wave = data.wave + 1
  1948. local from = Position(data.pos.x - 5, data.pos.y - 5, data.pos.z)
  1949. local to = Position(data.pos.x + 5, data.pos.y + 5, data.pos.z)
  1950. if data.wave <= #data.chest.waves[data.rarity.tier] then
  1951. local mobs = CURSED_CHESTS_TIERS[data.rarity.tier].monstersPerWave * data.wave
  1952. for i = 1, mobs do
  1953. local mobName = data.chest.waves[data.rarity.tier][data.wave][math.random(1, #data.chest.waves[data.rarity.tier][data.wave])]
  1954. local spawnPos = Position(math.random(from.x, to.x), math.random(from.y, to.y), data.pos.z)
  1955. local tile = Tile(spawnPos)
  1956. local spawnTest = 0
  1957. while spawnTest < 100 do
  1958. if data.pos == spawnPos or isBadTile(tile) then
  1959. spawnPos = Position(math.random(from.x, to.x), math.random(from.y, to.y), data.pos.z)
  1960. tile = Tile(spawnPos)
  1961. spawnTest = spawnTest + 1
  1962. else
  1963. break
  1964. end
  1965. end
  1966.  
  1967. if spawnTest < 100 then
  1968. local mob = Game.createMonster(mobName, spawnPos, false, true)
  1969. if mob then
  1970. mob:setSkull(CURSED_CHESTS_SKULL_DEFAULT)
  1971. mob:registerEvent("CursedChestsDeath")
  1972. table.insert(data.monsters, mob:getId())
  1973. end
  1974. end
  1975. end
  1976. elseif data.chest.boss ~= nil then
  1977. data.bossWave = true
  1978. local spawnPos = Position(math.random(from.x, to.x), math.random(from.y, to.y), data.pos.z)
  1979. local tile = Tile(spawnPos)
  1980. local spawnTest = 0
  1981. while spawnTest < 100 do
  1982. if data.pos == spawnPos or isBadTile(tile) then
  1983. spawnPos = Position(math.random(from.x, to.x), math.random(from.y, to.y), data.pos.z)
  1984. tile = Tile(spawnPos)
  1985. spawnTest = spawnTest + 1
  1986. else
  1987. break
  1988. end
  1989. end
  1990.  
  1991. if spawnTest < 100 then
  1992. local mob = Game.createMonster(data.chest.boss.name, spawnPos, false, true)
  1993. if mob then
  1994. mob:setSkull(CURSED_CHESTS_SKULL_BOSS)
  1995. mob:registerEvent("CursedChestsDeath")
  1996. table.insert(data.monsters, mob:getId())
  1997. stopEvent(data.event)
  1998. data.event = addEvent(CursedChestBoss, data.chest.boss.fightDuration * 1000, data)
  1999. end
  2000. end
  2001. end
  2002. end
  2003.  
  2004. function CursedChestBoss(data)
  2005. if #data.monsters == 1 then
  2006. local boss = Monster(data.monsters[1])
  2007. if boss then
  2008. boss:remove()
  2009. stopEvent(data.event)
  2010. for i = 1, #CURSED_CHESTS_DATA do
  2011. if CURSED_CHESTS_DATA[i] == data then
  2012. table.remove(CURSED_CHESTS_DATA, i)
  2013. end
  2014. end
  2015. data.container:getPosition():sendMagicEffect(CONST_ME_POFF)
  2016. data.container:remove()
  2017. CURSED_CHESTS_SPAWNS[data.spawnId].spawned = false
  2018. data.pos:sendAnimatedText("Boss fight is over! You failed!")
  2019. end
  2020. end
  2021. end
  2022.  
  2023. function FinishCursedChestEvent(data)
  2024. if
  2025. data.chest.boss ~= nil and data.bossWave == true and #data.monsters == 0 or
  2026. not data.chest.boss and data.wave == #data.chest.waves[data.rarity.tier] and #data.monsters == 0
  2027. then
  2028. stopEvent(data.event)
  2029. data.finished = true
  2030. data.active = 0
  2031. local loot = "Cursed Chest reward: "
  2032. local items = {}
  2033.  
  2034. for i = 1, #data.chest.rewards[data.rarity.tier] do
  2035. if data.container:getEmptySlots() == 0 then
  2036. break
  2037. end
  2038.  
  2039. local reward = data.chest.rewards[data.rarity.tier][i]
  2040. if reward.chance == 100 then
  2041. local amount = reward.random == true and math.random(1, reward.amount) or reward.amount
  2042. local item = Game.createItem(reward.item, amount)
  2043. data.container:addItemEx(item)
  2044. table.insert(items, item)
  2045. elseif math.random(1, 100) <= reward.chance then
  2046. local amount = reward.random == true and math.random(1, reward.amount) or reward.amount
  2047. local item = Game.createItem(reward.item, amount)
  2048. data.container:addItemEx(item)
  2049. table.insert(items, item)
  2050. end
  2051. end
  2052.  
  2053. for i = #items, 1, -1 do
  2054. if items[i]:getCount() > 1 then
  2055. loot = loot .. items[i]:getCount() .. " "
  2056. loot = loot .. items[i]:getPluralName()
  2057. else
  2058. loot = loot .. items[i]:getName()
  2059. end
  2060. if i > 1 then
  2061. loot = loot .. ", "
  2062. end
  2063. end
  2064.  
  2065. loot = loot .. "."
  2066.  
  2067. local specs = Game.getSpectators(data.pos, false, true, 9, 9, 9, 9)
  2068. if #specs > 0 then
  2069. for i = 1, #specs do
  2070. specs[i]:sendTextMessage(MESSAGE_STATUS_WARNING, loot)
  2071. end
  2072. end
  2073.  
  2074. data.checks = 0
  2075. data.event = addEvent(CursedChestCheck, 1000, data)
  2076. end
  2077. end
  2078.  
  2079. function CursedChestCheck(data)
  2080. data.event = addEvent(CursedChestCheck, 1000, data)
  2081. addEvent(CursedChestDelete, 5 * 60 * 1000, data)
  2082. if data.container:getEmptySlots() == data.container:getCapacity() then
  2083. stopEvent(data.event)
  2084. for i = 1, #CURSED_CHESTS_DATA do
  2085. if CURSED_CHESTS_DATA[i] == data then
  2086. table.remove(CURSED_CHESTS_DATA, i)
  2087. end
  2088. end
  2089. data.container:getPosition():sendMagicEffect(CONST_ME_POFF)
  2090. data.container:remove()
  2091. CURSED_CHESTS_SPAWNS[data.spawnId].spawned = false
  2092. end
  2093. end
  2094.  
  2095. function CursedChestDelete(data)
  2096. for i = 1, #CURSED_CHESTS_DATA do
  2097. if CURSED_CHESTS_DATA[i] == data then
  2098. stopEvent(data.event)
  2099. data.container:getPosition():sendMagicEffect(CONST_ME_POFF)
  2100. data.container:remove()
  2101. CURSED_CHESTS_SPAWNS[data.spawnId].spawned = false
  2102. table.remove(CURSED_CHESTS_DATA, i)
  2103. end
  2104. end
  2105. end
  2106.  
  2107. function CursedChests_onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
  2108. for _, data in ipairs(CURSED_CHESTS_DATA) do
  2109. if data.active == 1 then
  2110. for i = 1, #data.monsters do
  2111. if data.monsters[i] == creature:getId() then
  2112. table.remove(data.monsters, i)
  2113. if data.wave < #data.chest.waves[data.rarity.tier] and #data.monsters == 0 then
  2114. addEvent(CursedChestEvent, 1500, data)
  2115. elseif data.chest.boss ~= nil and not data.bossWave and #data.monsters == 0 then
  2116. killer:getPosition():sendAnimatedText(data.chest.boss.message)
  2117. addEvent(CursedChestEvent, 3000, data)
  2118. end
  2119. if data.wave == #data.chest.waves[data.rarity.tier] and #data.monsters == 0 or data.bossWave == true and #data.monsters == 0 then
  2120. FinishCursedChestEvent(data)
  2121. end
  2122. break
  2123. end
  2124. end
  2125. end
  2126. end
  2127. return true
  2128. end
  2129.  
  2130. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  2131. for _, data in ipairs(CURSED_CHESTS_DATA) do
  2132. if data.pos == item:getPosition() then
  2133. if data.active == 0 and data.finished == false then
  2134. if CURSED_CHESTS_TIERS[data.rarity.tier].reqLevel > player:getLevel() then
  2135. player:sendTextMessage(
  2136. MESSAGE_STATUS_WARNING,
  2137. "Required level to open this chest is " .. CURSED_CHESTS_TIERS[data.rarity.tier].reqLevel
  2138. )
  2139. return false
  2140. else
  2141. player:getPosition():sendAnimatedText(data.chest.message .. "\nKill all monsters to get awesome rewards!")
  2142. if player:getParty() then
  2143. data.solo = false
  2144. else
  2145. data.solo = true
  2146. end
  2147. data.owner = player:getName()
  2148. data.wave = 0
  2149. data.monsters = {}
  2150. data.active = 1
  2151. data.finished = false
  2152. data.container = item
  2153. data.event = addEvent(CursedChestEvent, 2000, data)
  2154. end
  2155. elseif data.finished == true then
  2156. if data.solo and data.owner == player:getName() then
  2157. return false
  2158. elseif not data.solo then
  2159. local party = player:getParty()
  2160. if not party then
  2161. return true
  2162. end
  2163. if data.owner == player:getName() then
  2164. return false
  2165. end
  2166. local members = party:getMembers()
  2167. for i = 1, #members do
  2168. if members[i]:getName() == player:getName() then
  2169. return false
  2170. end
  2171. end
  2172. end
  2173. return true
  2174. end
  2175. return true
  2176. end
  2177. end
  2178. return false
  2179. end
  2180.  
  2181. function isBadTile(tile)
  2182. return (tile == nil or tile:getGround() == nil or tile:hasProperty(TILESTATE_NONE) or tile:hasProperty(TILESTATE_FLOORCHANGE_EAST) or
  2183. isItem(tile:getThing()) and not isMoveable(tile:getThing()) or
  2184. tile:getTopCreature() or
  2185. tile:hasFlag(TILESTATE_PROTECTIONZONE))
  2186. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement