Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- <movevent event="StepIn" actionid="4318" script="tpquestfinal.lua" />
- ]]
- local tpVocation = {
- [Position(991, 1471, 15)] = {vocations = {4, 8, 19}, items = {{15431, 1}}},
- [Position(995, 1468, 15)] = {vocations = {2, 6, 17, 9, 10, 20}, items = {{5954, 50}}},
- [Position(991, 1465, 15)] = {vocations = {3, 7, 18, 13, 14 ,15}, items = {{8976, 1}}},
- [Position(987, 1468, 15)] = {vocations = {1, 5, 16, 11, 12 ,21}, items = {{2348, 1}}},
- }
- local destino = {
- -- y = y + 4
- [1] = {_goto = Position(1049, 1393, 15)},
- [2] = {_goto = Position(1031, 1393, 15)},
- [3] = {_goto = Position(1014, 1393, 15)},
- [4] = {_goto = Position(997, 1393, 15)},
- [5] = {_goto = Position(1022, 1373, 15)},
- [6] = {_goto = Position(1004, 1373, 15)},
- [7] = {_goto = Position(1040, 1373, 15)},
- }
- function onStepIn(creature, item, position, fromPosition)
- if not creature:isPlayer() then
- return false
- end
- local player = Player(creature:getId())
- local tp = tpVocation[position]
- for pos, pid in pairs(tpVocation) do
- if pos:compare(item:getPosition()) then
- tp = pid
- end
- end
- if not tp then
- return true
- end
- local vocId = creature:getVocation():getId()
- if not isInArray(tp.vocations, vocId) then
- return true
- end
- local hasItem = 0
- local count = #tp.items
- for _, its in pairs(tp.items) do
- if creature:getItemCount(its[1]) >= its[2] then
- hasItem = hasItem + 1
- end
- end
- if hasItem < count then
- if player:getStorageValue(4326) < os.time() then
- return true
- end
- end
- local vcName = player:getVocation():getName():lower()
- local id = 0
- local name = 'sorcerer'
- if vcName:find('sorcerer') then
- id = 1
- name = 'sorcerer'
- elseif vcName:find('druid') then
- id = 2
- name = 'druid'
- elseif vcName:find('paladin') then
- id = 3
- name = 'paladin'
- elseif vcName:find('knight') then
- id = 4
- name = 'knight'
- elseif vcName:find('drunou') then
- id = 5
- name = 'drunou'
- elseif vcName:find('infernalist') then
- id = 6
- name = 'infernalist'
- elseif vcName:find('knocker') then
- id = 7
- name = 'knocker'
- end
- local tpPos = destino[id]
- if not tpPos then
- return true
- end
- local bgn = tpPos._goto.y + 1
- -- verificando se tem jogador na sala
- for _y = bgn - 4, bgn, 1 do
- local tile = Tile(Position(tpPos._goto.x, _y, tpPos._goto.z))
- if tile and tile:getTopCreature() and tile:getTopCreature():isPlayer() then
- player:sendCancelMessage('The room is full')
- -- return para barrar o resto do script
- return true
- end
- end
- -- removendo os monstros que estão na sala
- for _y = bgn - 4, bgn, 1 do
- local tile = Tile(Position(tpPos._goto.x, _y, tpPos._goto.z))
- if tile and tile:getTopCreature() then
- tile:getTopCreature():remove()
- end
- end
- math.randomseed(os.time() + player:getId())
- local mathmonster = math.random(0, 100000)
- local posMonster = {x = tpPos._goto.x, y = tpPos._goto.y - 2, z = tpPos._goto.z}
- local itemSorte = 26174
- local sorte = player:getItemCount(itemSorte)
- if sorte > 100 then
- sorte = sorte - 33
- end
- local others = 33
- if (100 - (sorte)) > 0 then
- others = (100 - (sorte))/2
- end
- broadcastMessage(sorte.. " random: "..mathmonster.." 33x1: "..(others * 1000).." 33x2: "..(others * 2 * 1000))
- if mathmonster <= (others * 1000) then
- nameMonster = string.format("Minion of Azulon %s", name)
- mName = 'Minion of Azulon'
- elseif mathmonster > (others * 1000) and mathmonster <= (others * 2 * 1000) then
- nameMonster = string.format("Greenash %s", name)
- mName = 'Greenash'
- else
- nameMonster = string.format("Azulon %s", name)
- mName = 'Azulon'
- end
- if sorte > 0 then
- player:removeItem(itemSorte, sorte)
- end
- if creature:getStorageValue(4326) < os.time() then
- for _, itm in pairs(tp.items) do
- player:removeItem(itm[1], itm[2])
- end
- end
- -- teleportando o jogador
- player:teleportTo(tpPos._goto, true)
- local event = 'AnnihiIVtpMonster'
- --criando os monstros
- local monster = Game.createMonster(nameMonster:lower(), posMonster)
- if monster then
- monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
- monster:registerEvent(event)
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement