Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. --[[
  2. <movevent event="StepIn" actionid="4318" script="tpquestfinal.lua" />
  3. ]]
  4. local tpVocation = {
  5. [Position(991, 1471, 15)] = {vocations = {4, 8, 19}, items = {{15431, 1}}},
  6. [Position(995, 1468, 15)] = {vocations = {2, 6, 17, 9, 10, 20}, items = {{5954, 50}}},
  7. [Position(991, 1465, 15)] = {vocations = {3, 7, 18, 13, 14 ,15}, items = {{8976, 1}}},
  8. [Position(987, 1468, 15)] = {vocations = {1, 5, 16, 11, 12 ,21}, items = {{2348, 1}}},
  9. }
  10.  
  11. local destino = {
  12. -- y = y + 4
  13. [1] = {_goto = Position(1049, 1393, 15)},
  14. [2] = {_goto = Position(1031, 1393, 15)},
  15. [3] = {_goto = Position(1014, 1393, 15)},
  16. [4] = {_goto = Position(997, 1393, 15)},
  17. [5] = {_goto = Position(1022, 1373, 15)},
  18. [6] = {_goto = Position(1004, 1373, 15)},
  19. [7] = {_goto = Position(1040, 1373, 15)},
  20. }
  21.  
  22. function onStepIn(creature, item, position, fromPosition)
  23. if not creature:isPlayer() then
  24. return false
  25. end
  26. local player = Player(creature:getId())
  27. local tp = tpVocation[position]
  28. for pos, pid in pairs(tpVocation) do
  29. if pos:compare(item:getPosition()) then
  30. tp = pid
  31. end
  32. end
  33.  
  34. if not tp then
  35. return true
  36. end
  37. local vocId = creature:getVocation():getId()
  38. if not isInArray(tp.vocations, vocId) then
  39. return true
  40. end
  41. local hasItem = 0
  42. local count = #tp.items
  43. for _, its in pairs(tp.items) do
  44. if creature:getItemCount(its[1]) >= its[2] then
  45. hasItem = hasItem + 1
  46. end
  47. end
  48. if hasItem < count then
  49. if player:getStorageValue(4326) < os.time() then
  50. return true
  51. end
  52. end
  53.  
  54.  
  55. local vcName = player:getVocation():getName():lower()
  56. local id = 0
  57. local name = 'sorcerer'
  58. if vcName:find('sorcerer') then
  59. id = 1
  60. name = 'sorcerer'
  61. elseif vcName:find('druid') then
  62. id = 2
  63. name = 'druid'
  64. elseif vcName:find('paladin') then
  65. id = 3
  66. name = 'paladin'
  67. elseif vcName:find('knight') then
  68. id = 4
  69. name = 'knight'
  70. elseif vcName:find('drunou') then
  71. id = 5
  72. name = 'drunou'
  73. elseif vcName:find('infernalist') then
  74. id = 6
  75. name = 'infernalist'
  76. elseif vcName:find('knocker') then
  77. id = 7
  78. name = 'knocker'
  79. end
  80.  
  81. local tpPos = destino[id]
  82. if not tpPos then
  83. return true
  84. end
  85. local bgn = tpPos._goto.y + 1
  86. -- verificando se tem jogador na sala
  87. for _y = bgn - 4, bgn, 1 do
  88. local tile = Tile(Position(tpPos._goto.x, _y, tpPos._goto.z))
  89. if tile and tile:getTopCreature() and tile:getTopCreature():isPlayer() then
  90. player:sendCancelMessage('The room is full')
  91. -- return para barrar o resto do script
  92. return true
  93. end
  94. end
  95.  
  96. -- removendo os monstros que estão na sala
  97. for _y = bgn - 4, bgn, 1 do
  98. local tile = Tile(Position(tpPos._goto.x, _y, tpPos._goto.z))
  99. if tile and tile:getTopCreature() then
  100. tile:getTopCreature():remove()
  101. end
  102. end
  103.  
  104. math.randomseed(os.time() + player:getId())
  105. local mathmonster = math.random(0, 100000)
  106.  
  107. local posMonster = {x = tpPos._goto.x, y = tpPos._goto.y - 2, z = tpPos._goto.z}
  108. local itemSorte = 26174
  109. local sorte = player:getItemCount(itemSorte)
  110. if sorte > 100 then
  111. sorte = sorte - 33
  112. end
  113. local others = 33
  114. if (100 - (sorte)) > 0 then
  115. others = (100 - (sorte))/2
  116. end
  117. broadcastMessage(sorte.. " random: "..mathmonster.." 33x1: "..(others * 1000).." 33x2: "..(others * 2 * 1000))
  118. if mathmonster <= (others * 1000) then
  119. nameMonster = string.format("Minion of Azulon %s", name)
  120. mName = 'Minion of Azulon'
  121. elseif mathmonster > (others * 1000) and mathmonster <= (others * 2 * 1000) then
  122. nameMonster = string.format("Greenash %s", name)
  123. mName = 'Greenash'
  124. else
  125. nameMonster = string.format("Azulon %s", name)
  126. mName = 'Azulon'
  127. end
  128. if sorte > 0 then
  129. player:removeItem(itemSorte, sorte)
  130. end
  131. if creature:getStorageValue(4326) < os.time() then
  132. for _, itm in pairs(tp.items) do
  133. player:removeItem(itm[1], itm[2])
  134. end
  135. end
  136. -- teleportando o jogador
  137. player:teleportTo(tpPos._goto, true)
  138. local event = 'AnnihiIVtpMonster'
  139. --criando os monstros
  140. local monster = Game.createMonster(nameMonster:lower(), posMonster)
  141. if monster then
  142. monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
  143. monster:registerEvent(event)
  144. end
  145. return true
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement