Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local CriaturaInfo = {
- ['Korzus'] = {mindmg = 30000, str1 = 3686, str2 = 3687}
- }
- local ativarLootMsg = true -- coloca true para ficar show rs rs rs // por default é false
- local function mandarMensagemBoss(oCara, nomeDoBicho, tabelaDeItem, haMsg)
- local msg = ''
- for _, itemLoot in pairs(tabelaDeItem) do
- if table.maxn(tabelaDeItem) >= 1 then
- if msg == '' then
- if itemLoot.count > 1 then
- msg = itemLoot.count..' '..ItemType(itemLoot.item):getName()
- else
- msg = ItemType(itemLoot.item):getName()
- end
- else
- if itemLoot.count > 1 then
- msg = msg..', '..itemLoot.count..' '..ItemType(itemLoot.item):getName()
- else
- msg = msg..', '..ItemType(itemLoot.item):getName()
- end
- end
- end
- end
- if haMsg then
- oCara:sendTextMessage(MESSAGE_INFO_DESCR, 'Loot of '.. MonsterType(nomeDoBicho):getNameDescription() ..' (in mailbox): '.. (msg == '' and 'nothing' or msg) ..'')
- end
- end
- local function EnviarPremio(jogador,colocacao,nomecriatura,modoc)
- local dificuldadegeral = 5
- -- variavel para armazenar itens e quantidade
- local lootMsg = {}
- -- fim da variavel para armazenar itens e quantidade
- if colocacao == 1 then
- chancepremio = 30000
- elseif colocacao == 2 then
- chancepremio = 40000
- elseif colocacao >= 3 and colocacao <= 7 then
- chancepremio = 70000
- else
- chancepremio = 100000
- end
- local premio = false
- local crioubolsa = false
- local randomloot = os.time()
- for i, v in ipairs(MonsterType(nomecriatura):getLoot()) do
- math.randomseed(math.random(randomloot))
- local randomloot = math.random(1,100000)
- local randomamount = toint(math.random(1,v.maxCount)/colocacao)
- if randomamount < 1 then
- randomamount = 1
- end
- if chancepremio <= v.chance and randomloot <= v.chance then
- if crioubolsa == false then
- parcel = jogador:getInbox():addItem(2596, 1, false, 1)
- bag = parcel:addItem(1988, 1, false, 1)
- crioubolsa = true
- end
- bag:addItem(v.itemId, randomamount, false, 1)
- -- agrupar o loot
- lootMsg[#lootMsg + 1] = {item = v.itemId, count = randomamount}
- -- fim agrupar loot
- premio = true
- end
- end
- if ativarLootMsg then
- -- gera a mensagem do loot--
- mandarMensagemBoss(jogador, nomecriatura, lootMsg, premio)
- -- fim da mensagem do loot --
- end
- if premio then
- doPlayerSendTextMessage(jogador, MESSAGE_EVENT_ADVANCE, "Parabéns! Você ganhou itens ao matar " .. nomecriatura .. ", confira seu mailbox em seu depot. Sua colocação foi " .. colocacao .. "º como " .. modoc .. ".")
- end
- end
- local function IniciarPremiacao(storage,nomecri,modo)
- local colocacao = 1
- local resultId = db.storeQuery("SELECT `player_id`,`value` FROM `player_storage` WHERE `key` = " .. storage .. " AND `value` > 0 ORDER BY `value` DESC")
- if resultId ~= false then
- repeat
- local playerid = result.getDataInt(resultId, "player_id")
- local resultId2 = db.storeQuery("SELECT `name` FROM `players` WHERE `id` = " .. playerid)
- if resultId2 ~= false then
- name = result.getDataString(resultId2, "name")
- end
- result.free(resultId2)
- local player = Player(getPlayerByName(name))
- if player then
- EnviarPremio(player,colocacao,nomecri,modo)
- setPlayerStorageValue(player,storage,-1)
- player:save()
- end
- colocacao = colocacao+1
- until not result.next(resultId)
- end
- result.free(resultId)
- return true
- end
- function onKill(cid, target, lastHit)
- --Evitar execucao de mais de uma vez:
- if getGlobalStorageValue(3688)+5 >= os.time() then
- return true
- else
- setGlobalStorageValue(3688, os.time())
- end
- local monster = Monster(target)
- if not monster or isSummon(target) then
- return true
- end
- local nomecri = getCreatureName(monster)
- if CriaturaInfo[nomecri] == nil then
- return true
- end
- local attacker = false
- for ida, damagea in pairs(monster:getDamageMap()) do
- local player = Player(ida)
- if player then
- setPlayerStorageValue(player,CriaturaInfo[nomecri].str1,-1)
- setPlayerStorageValue(player,CriaturaInfo[nomecri].str2,-1)
- if damagea.total > CriaturaInfo[nomecri].mindmg then
- attacker = true
- end
- for idb, damageb in pairs(player:getDamageMap()) do
- local monsterb = Monster(idb)
- if monsterb and getCreatureName(monsterb) == nomecri and damageb.total > CriaturaInfo[nomecri].mindmg and damageb.total > damagea.total then
- setPlayerStorageValue(player,CriaturaInfo[nomecri].str2,damageb.total)
- attacker = false
- end
- end
- if attacker then
- setPlayerStorageValue(player,CriaturaInfo[nomecri].str1,damagea.total)
- end
- player:save()
- end
- end
- if ativarLootMsg then
- --não da loot--
- monster:setDropLoot(false)
- local corpoId = MonsterType(monster:getName()):getCorpseId()
- Game.createItem(corpoId, 1, monster:getPosition())
- --fim nao da loot --
- end
- IniciarPremiacao(CriaturaInfo[nomecri].str1,nomecri,'attacker')
- IniciarPremiacao(CriaturaInfo[nomecri].str2,nomecri,'blocker')
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement