Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. CURSED_CHESTS_AID = 9000
  2.  
  3. CURSED_CHESTS_SPAWNS = {
  4. [1] = {
  5. pos = Position(32368, 32083, 7),
  6. size = 6,
  7. chests = {1}
  8. },
  9. [2] = {
  10. pos = Position(32283, 32092, 7),
  11. size = 6,
  12. chests = {1}
  13. },
  14. [3] = {
  15. pos = Position(32255, 32298, 7),
  16. size = 6,
  17. chests = {1}
  18. },
  19. [4] = {
  20. pos = Position(32606, 32026, 7),
  21. size = 6,
  22. chests = {1}
  23. },
  24. [5] = {
  25. pos = Position(32649, 32101, 7),
  26. size = 6,
  27. chests = {1}
  28. },
  29. [5] = {
  30. pos = Position(32744, 32362, 7),
  31. size = 6,
  32. chests = {1}
  33. },
  34. [6] = {
  35. pos = Position(32204, 31832, 7),
  36. size = 6,
  37. chests = {1}
  38. },
  39. [7] = {
  40. pos = Position(32237, 32791, 7),
  41. size = 6,
  42. chests = {1}
  43. },
  44. [8] = {
  45. pos = Position(33137, 32453, 7),
  46. size = 6,
  47. chests = {1}
  48. },
  49. [9] = {
  50. pos = Position(33118, 31700, 7),
  51. size = 6,
  52. chests = {1}
  53. },
  54. [10] = {
  55. pos = Position(32214, 31075, 5),
  56. size = 6,
  57. chests = {1}
  58. },
  59. [11] = {
  60. pos = Position(33641, 31698, 7),
  61. size = 6,
  62. chests = {1}
  63. },
  64. [12] = {
  65. pos = Position(33499, 32304, 7),
  66. size = 6,
  67. chests = {1}
  68. }
  69. }
  70.  
  71. function onThink(cid, interval, lastExecution)
  72. for spawnId, data in ipairs(CURSED_CHESTS_SPAWNS) do
  73. if not data.spawned then
  74. local from = Position(data.pos.x - data.size, data.pos.y - data.size, data.pos.z)
  75. local to = Position(data.pos.x + data.size, data.pos.y + data.size, data.pos.z)
  76. local chestId = math.random(1, #data.chests)
  77. local spawnPos = Position(math.random(from.x, to.x), math.random(from.y, to.y), data.pos.z)
  78. local tile = Tile(spawnPos)
  79. local spawnTest = 0
  80.  
  81. while spawnTest < 100 do
  82. if isBadTile(tile) then
  83. spawnPos = Position(math.random(from.x, to.x), math.random(from.y, to.y), data.pos.z)
  84. tile = Tile(spawnPos)
  85. spawnTest = spawnTest + 1
  86. else
  87. break
  88. end
  89. end
  90.  
  91. if spawnTest < 100 then
  92. local rarity = nil
  93. for i = #CURSED_CHESTS_TIERS, 1, -1 do
  94. rarity = CURSED_CHESTS_TIERS[i]
  95. if math.random(1, 100) <= rarity.chance then
  96. break
  97. end
  98. end
  99. if rarity ~= nil then
  100. local chest = Game.createItem(rarity.item, 1, spawnPos)
  101. chest:setActionId(CURSED_CHESTS_AID)
  102. spawnPos:sendMagicEffect(CONST_ME_GROUNDSHAKER)
  103. local chestData = {}
  104. chestData.pos = spawnPos
  105. chestData.spawnId = spawnId
  106. chestData.wave = 0
  107. chestData.monsters = {}
  108. chestData.active = 0
  109. chestData.finished = false
  110. chestData.container = chest
  111. chestData.chest = CURSED_CHESTS_CONFIG[chestId]
  112. chestData.rarity = rarity
  113. CURSED_CHESTS_DATA[#CURSED_CHESTS_DATA + 1] = chestData
  114. data.spawned = true
  115. end
  116. end
  117.  
  118. end
  119. end
  120. return true
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement