Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local itemList = { 7402, {1, 1}, 500, 25, -- Glove of Nunoboko
- 7416, {1, 1}, 250, 25, -- Deadly Katar [Quest]
- 7403, {1, 1}, 500, 25, -- Sword of Nunoboko
- 7407, {1, 1}, 250, 25, -- Shichiseiken [Quest]
- 2446, {1, 1}, 500, 25, -- Bashosen
- 7406, {1, 1}, 250, 25, -- Susanoo Bow [Quest]
- 8866, {1, 1}, 250, 25, -- Chakra Mode Protector
- 8874, {1, 1}, 250, 25, -- Rikudou Sennin Mask
- 8878, {1, 1}, 500, 25, -- Kaguya Mask
- 8879, {1, 1}, 500, 25, -- Kaguya Coat
- 8867, {1, 1}, 250, 25, -- Chakra Mode Coat
- 8875, {1, 1}, 250, 25, -- Rikudou Sennin Coat
- 8868, {1, 1}, 250, 25, -- Chakra Mode Legs
- 8876, {1, 1}, 250, 25, -- Rikudou Sennin Legs
- 8869, {1, 1}, 250, 25, -- Chakra Mode Boots
- 8877, {1, 1}, 250, 25, -- Rikudou Sennin Boots
- 2161, {1, 1}, 500, 25, -- Premium Ring
- 2511, {1, 1}, 500, 25, -- Yata no Kagami
- 2512, {1, 1}, 250, 25, -- Shield of Nunoboko
- 6099, {1, 1}, 100, 25, -- Brikus Crystal
- 2344, {1, 5}, 500, 25, -- Perfect Upgrade Stone
- 2159, {25, 35}, 500, 25, -- Casino Coins
- 5904, {10, 25}, 500, 25 -- MVP Chakra
- }
- local minimumAmount = 0
- local maximumAmount = 0
- for i = 1, #itemList / 4 do
- maximumAmount = math.max(maximumAmount, itemList[i * 4])
- minimumAmount = math.min(minimumAmount, itemList[i * 4])
- end
- local cache = {}
- local CASINO_NONE = 0
- local CASINO_LEVER = 100
- local CASINO_REWARD = 101
- local CASINO_LAST_REWARD = 102
- local CASINO_COINS = 103
- local POSITION_LAST_REWARD = 1
- local POSITION_REWARD = 2
- local POSITION_LAST = 3
- local POSITION_COINS = 4
- local casinoCoin = 2159
- local config = {
- [1000] = {
- rewardTile = 4,
- area = {
- {CASINO_LAST_REWARD, 0, 1, 0, 0, 0, 0, 0, 0},
- {0, 12, 0, 2, 0, 0, 0, 0, 0},
- {11, 0, 0, 0, 3, 0, 0, 0, 0},
- {10, 0, 0, 0, 4, 0, CASINO_REWARD, CASINO_LEVER, CASINO_COINS},
- {9, 0, 0, 0, 5, 0, 0, 0, 0},
- {0, 8, 0, 6, 0, 0, 0, 0, 0},
- {0, 0, 7, 0, 0, 0, 0, 0, 0}
- }
- }
- }
- local function getItem(amount)
- while true do
- for i = 1, #itemList / 4 do
- if amount >= itemList[i * 4] and math.random(100000) <= itemList[i * 4 - 1] then
- return itemList[i * 4 - 3], itemList[i * 4 - 2]
- end
- end
- end
- return nil
- end
- local function executeReward(position, positions, items, list)
- local item = getTileItemById(list[positions[POSITION_LAST]], items[positions[POSITION_LAST]][1])
- if item.uid > 0 then
- doTeleportThing(item.uid, positions[POSITION_REWARD])
- doSendMagicEffect(positions[POSITION_REWARD], 40)
- doCleanTile(positions[POSITION_LAST_REWARD])
- doCreateItem(item.itemid, item.type, positions[POSITION_LAST_REWARD])
- doSendMagicEffect(positions[POSITION_LAST_REWARD], 40)
- end
- cache[position.y][position.x] = nil
- for i = #list, 1, -1 do
- doCleanTile(list[i])
- end
- end
- local function executeRoll(position, positions, items, list, n, duration)
- local item = getTileItemById(list[1], items[1][1])
- if item.uid > 0 then
- doRemoveItem(item.uid)
- end
- local itemList = {}
- for i = #list, 1, -1 do
- if i > 1 then
- item = getTileItemById(list[i], items[i][1])
- if item.uid > 0 then
- if i < #list then
- doTeleportThing(item.uid, list[i + 1])
- else
- doTeleportThing(item.uid, list[1])
- end
- end
- end
- if i < #list then
- itemList[i + 1] = items[i]
- else
- itemList[1] = items[i]
- end
- end
- doCreateItem(items[1][1], items[1][2], list[2])
- if n > 0 then
- local delay = 200
- if n > duration / 2 then
- delay = 50
- elseif n > duration / 4 then
- delay = 100
- elseif n > duration / 8 then
- delay = 150
- elseif n > duration / 16 then
- delay = 200
- elseif n > duration / 32 then
- delay = 250
- end
- addEvent(executeRoll, delay, position, positions, itemList, list, n - 1, duration)
- else
- addEvent(executeReward, 2000, position, positions, itemList, list)
- end
- end
- local function doCreateItems(position, positions, list, n, amount, items)
- if not items then
- items = {}
- end
- if n > #list then
- local duration = math.random(100, 200)
- addEvent(executeRoll, 2000, position, positions, items, list, duration, duration)
- return true
- end
- local id, count = getItem(amount)
- if type(count) == 'table' then
- count = math.random(count[1], count[2])
- end
- doCleanTile(list[n])
- doCreateItem(id, count, list[n])
- doSendMagicEffect(list[n], CONST_ME_POFF)
- items[n] = {id, count}
- addEvent(doCreateItems, 50, position, positions, list, n + 1, amount, items)
- end
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- local var = config[item.actionid]
- if not var then
- return false
- end
- local x, y, position = 0, 0, getThingPos(item.uid)
- if not cache[position.y] then
- cache[position.y] = {}
- end
- if cache[position.y][position.x] then
- doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You can\'t roll right now.')
- return true
- end
- for py = 1, #var.area do
- for px = 1, #var.area[py] do
- if var.area[py][px] == CASINO_LEVER then
- x = px - 1
- y = py - 1
- break
- end
- end
- end
- local positions = {}
- local rollList = {}
- for py = 1, #var.area do
- for px = 1, #var.area[py] do
- local value, pos = var.area[py][px], {x = position.x + (px - x - 1), y = position.y + (py - y - 1), z = position.z}
- if value == CASINO_REWARD then
- positions[POSITION_REWARD] = pos
- elseif value == CASINO_LAST_REWARD then
- positions[POSITION_LAST_REWARD] = pos
- elseif value == CASINO_COINS then
- positions[POSITION_COINS] = pos
- elseif value ~= CASINO_NONE and value ~= CASINO_LEVER then
- if value == var.rewardTile then
- positions[POSITION_LAST] = value
- end
- rollList[value] = pos
- end
- end
- end
- if #rollList == 0 then
- return false
- end
- local item = getTileItemById(positions[POSITION_COINS], casinoCoin)
- if item.uid == 0 or item.type < minimumAmount then
- return true
- end
- cache[position.y][position.x] = true
- doCreateItems(position, positions, rollList, 1, item.type)
- doRemoveItem(item.uid, math.min(item.type, maximumAmount))
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement