Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Com esse sistema desenvolvido pelo TFS 0.4 8.60 do @Luan Luciano, peguei e adaptei para TFS 1x.
 

Basicamente, o sistema funciona da seguinte forma :

 

Você determina as criaturas que funcionarão com este sistema (geralmente chefes).

Durante a batalha com a criatura, o sistema concede pontos aos jogadores por atacar, bloquear e apoiar (curar) aqueles em batalha.

Quando a criatura é morta, o sistema cria o saque com base nos pontos e o envia para o depósito do jogador em uma sacola especificada nas configurações

Aqui está o GIF, mostrando quando o chefe é morto e o saque é enviado pelo correio.

https://imgur.com/AJiM1mh

 

 

 

registre o evento em determinado arquivo de monstro.

XML.

 <script>
            <event name="RewardChestDeath"/>
             <event name="RewardChestMonster"/>
    </script>

defina o cadáver do chefe como 0.

<look type="201" corpse="0" />

Isto é RevScripts. Coloque o script em qualquer lugar da pasta data/scripts, seja uma subpasta ou seu local preferido .

Reward_Chest_System.lua

local function addRewardLoot(uid, bossName, rewardTable)
    local money = math.random(10, 40)
    local msg = "The following items are available in your reward chest:"
    local player = Player(uid)
    local chest = Game.createItem(REWARDCHEST.rewardBagId)

    if not player or not chest then return end

    chest:setAttribute("description", "Reward System has kill the boss " .. bossName .. ".")

    for _, reward in ipairs(rewardTable) do
        if math.random(100) <= reward[3] then
            local count = math.random(1, reward[2])
            chest:addItem(reward[1], count)
            msg = msg .. " " .. (count > 1 and count or "") .. " " .. ItemType(reward[1]):getName() .. ","
        end
    end

    chest:addItem(2152, money)
    chest:moveTo(player:getInbox())
    player:sendTextMessage(MESSAGE_INFO_DESCR, msg .. " and " .. money .. " platinum coins.")
 
    local boss = REWARDCHEST.bosses[bossName]
    player:setStorageValue(boss.storage, 0)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end

local function addLoot(lootTable, rewardTable, allLoot)
    if allLoot then
        for _, loot in ipairs(lootTable) do
            table.insert(rewardTable, loot)
        end
    else
        table.insert(rewardTable, lootTable[math.random(#lootTable)])
    end
end

local function rewardChestSystem(bossName)
    local players = {}
    local boss = REWARDCHEST.bosses[bossName]

    for _, player in ipairs(Game.getPlayers()) do
        local points = player:getStorageValue(boss.storage)
        if points > 0 then
            table.insert(players, {player = player, points = points})
        end
    end

    table.sort(players, function(a, b) return a.points > b.points end)

    local topPoints = players[1] and players[1].points or 0

    for i, playerData in ipairs(players) do
        local player = playerData.player
        local points = playerData.points
        local rewardTable = {}

        if i == 1 then
            addLoot(boss.common, rewardTable, false)
            addLoot(boss.semiRare, rewardTable, false)
            addLoot(boss.rare, rewardTable, false)
            addLoot(boss.always, rewardTable, true)
        elseif points >= math.ceil(topPoints * 0.8) then
            addLoot(boss.common, rewardTable, false)
            addLoot(boss.semiRare, rewardTable, false)
            addLoot(boss.rare, rewardTable, false)
            addLoot(boss.veryRare, rewardTable, false)
        elseif points >= math.ceil(topPoints * 0.6) then
            addLoot(boss.common, rewardTable, false)
            addLoot(boss.semiRare, rewardTable, false)
            addLoot(boss.rare, rewardTable, false)
        elseif points >= math.ceil(topPoints * 0.4) then
            addLoot(boss.common, rewardTable, false)
            addLoot(boss.semiRare, rewardTable, false)
        elseif points >= math.ceil(topPoints * 0.1) then
            addLoot(boss.common, rewardTable, false)
        end

        addRewardLoot(player:getId(), bossName, rewardTable)
    end
end

local RewardChestDeath = CreatureEvent("RewardChestDeath")
function RewardChestDeath.onDeath(creature, corpse, killer)
    local boss = REWARDCHEST.bosses[creature:getName():lower()]
    if boss then
        addEvent(rewardChestSystem, 1000, creature:getName():lower())
    end
    return true
end
RewardChestDeath:register()

local RewardChestMonster = CreatureEvent("RewardChestMonster")
function RewardChestMonster.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if creature:isMonster() and primaryType == COMBAT_PHYSICALDAMAGE and attacker:isPlayer() then
        local boss = REWARDCHEST.bosses[creature:getName():lower()]
        if boss then
            local currentPoints = attacker:getStorageValue(boss.storage)
            local newPoints = currentPoints + math.ceil(primaryDamage / REWARDCHEST.formula.hit)
            attacker:setStorageValue(boss.storage, newPoints)
        end
    end
    return primaryDamage, primaryType
end
RewardChestMonster:register()

local LoginPlayer = CreatureEvent("LoginPlayer")
function LoginPlayer.onLogin(player)
    for _, value in pairs(REWARDCHEST.bosses) do
        if player:getStorageValue(value.storage) > 0 then
            player:setStorageValue(value.storage, 0)
        end
    end
    player:registerEvent("RewardChestStats")
    return true
end
LoginPlayer:register()

local RewardChestStats = CreatureEvent("RewardChestStats")
function RewardChestStats.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if attacker and attacker:isMonster() and (primaryType == COMBAT_PHYSICALDAMAGE or secondaryType == COMBAT_PHYSICALDAMAGE) then
        local boss = REWARDCHEST.bosses[attacker:getName():lower()]
        if boss then
            local currentPoints = creature:getStorageValue(boss.storage)
            local newPoints = currentPoints + math.ceil(math.abs(primaryDamage) / REWARDCHEST.formula.block)
            creature:setStorageValue(boss.storage, newPoints)
            creature:setStorageValue(REWARDCHEST.storageExaust, os.time() + 5)
        end
    elseif attacker and attacker:isPlayer() and (primaryType == COMBAT_HEALING or secondaryType == COMBAT_HEALING) and (creature:getHealth() < creature:getMaxHealth()) and (creature:getStorageValue(REWARDCHEST.storageExaust) >= os.time()) then
        for _, valor in pairs(REWARDCHEST.bosses) do
            if creature:getStorageValue(valor.storage) > 0 then
                local add = math.min(primaryDamage, creature:getMaxHealth() - creature:getHealth())
                local currentPoints = attacker:getStorageValue(valor.storage)
                local newPoints = currentPoints + math.ceil(add / REWARDCHEST.formula.suport)
                attacker:setStorageValue(valor.storage, newPoints)
            end
        end
    end
    return primaryDamage, primaryType
end
RewardChestStats:register()

Agora, esta parte sobre raridades de loot de monstros... deve ser adicionada ao data/lib e criar um arquivo.lua chamado RewardChestSystem.lua e adicionar tudo isso.

-- Reward system created by luanluciano93 for TFS 0.4, function adapted by Mateus Roberto for TFS 1.3+ using RevScripts.

REWARDCHEST = {
    rewardBagId = 2595,
    formula = {hit = 3, block = 1, support = 9},
    storageExhaust = 60000,
    town_id = 1,
    bosses = {
        ["ghazbaran"] = -- the boss's entire name in lower case.
        {
            common = {
                {2143, 10, 100}, -- white pearl
                {2146, 10, 100}, -- small sapphire
                {2145, 10, 100}, -- small diamond
                {2144, 10, 100}, -- black pearl
                {2149, 10, 100}, -- small emeralds
                {5954, 3, 100}, -- demon horn
                {7896, 1, 100}, -- glacier kilt
                {7590, 1, 100}, -- great mana potion
                {2179, 1, 100}, -- gold ring
                {2151, 1, 100}, -- talon
            },

            semiRare = {
                {2152, 90, 100}, -- platinum coin
                {7368, 50, 100}, -- assassin star
                {2130, 1, 100}, -- golden amulet
                {2436, 1, 100}, -- skull staff
                {2447, 1, 100}, -- twin axe
                {2171, 1, 100}, -- platinum amulet
                {2158, 1, 100}, -- blue gem
                {2393, 1, 100}, -- giant sword
                {2164, 1, 100}, -- might ring
                {7454, 1, 100}, -- glorious axe
                {6553, 1, 100}, -- ruthless axe
                {9971, 1, 100}, -- gold ingot
            },

            rare = {
                {2160, 3, 100}, -- crystal coin
                {8887, 1, 100}, -- frozen plate
                {2470, 1, 100}, -- golden legs
                {2472, 1, 100}, -- magic plate armor
                {7431, 1, 100}, -- demonbone
                {2520, 1, 100}, -- demon shield
                {5943, 1, 100}, -- morgaroth heart
                {2466, 1, 100}, -- golden armor
                {2514, 1, 100}, -- mastermind shield
                {2142, 1, 100}, -- ancient amulet
                {2123, 1, 100}, -- ring of the sky
                {1984, 1, 100}, -- blue tome
            },

            veryRare = {
                {8866, 1, 100}, -- robe of the ice queen
                {6553, 1, 100}, -- ruthless axe
                {8884, 1, 100}, -- oceanborn leviathan armor
                {2421, 1, 100}, -- thunder hammer
                {2646, 1, 100}, -- golden boots
                {7455, 1, 100}, -- mythril axe
            },
         
            always = {
                {2148, 90, 100}, -- gold coin
                {6500, 9, 100}, -- demonic essence
                {2177, 1, 100}, -- life crystal
                {2214, 1, 100}, -- ring of healing
            },
         
            storage = 65479,
        },
     
        ["orshabaal"] = -- the boss's entire name in lower case.
        {
            common = {
                {2143, 10, 100}, -- white pearl
                {2146, 10, 100}, -- small sapphire
                {2145, 10, 100}, -- small diamond
                {2144, 10, 100}, -- black pearl
                {2149, 10, 100}, -- small emeralds
                {5954, 3, 100}, -- demon horn
                {7896, 1, 100}, -- glacier kilt
                {2432, 1, 100}, -- fire axe
                {2462, 1, 100}, -- devil helmet
                {7590, 1, 100}, -- great mana potion
                {2179, 1, 100}, -- gold ring
                {2151, 1, 100}, -- talon
            },

            semiRare = {
                {2195, 1, 100}, -- boots of haste
                {2436, 1, 100}, -- skull staff
                {2393, 1, 100}, -- giant sword
                {5954, 5, 100}, -- demon horn
            },

            rare = {
                {2470, 1, 100}, -- golden legs
                {2472, 1, 100}, -- magic plate armor
                {2514, 1, 100}, -- mastermind shield
                {2520, 1, 100}, -- demon shield
                {1982, 1, 100}, -- purple tome
                {2123, 1, 100}, -- ring of the sky
            },

            veryRare = {
                {8890, 1, 100}, -- robe of the underworld
                {2421, 1, 100}, -- thunder hammer
            },
         
            always = {
                {5808, 1, 100}, -- orshabaal's brain
                {2171, 1, 100}, -- platinum amulet
                {2148, 90, 100}, -- gold coin
                {2146, 10, 100}, -- small sapphire
            },
         
            storage = 65480,
        },
     
        ["ferumbras"] = -- the boss's entire name in lower case.
        {
            common = {
                {2143, 10, 100}, -- white pearl
                {2146, 10, 100}, -- small sapphire
                {2145, 10, 100}, -- small diamond
                {2144, 10, 100}, -- black pearl
                {2149, 10, 100}, -- small emeralds
                {7416, 1, 100}, -- bloody edge
                {7896, 1, 100}, -- glacier kilt
                {2432, 1, 100}, -- fire axe
                {2462, 1, 100}, -- devil helmet
                {7590, 1, 100}, -- great mana potion
                {2179, 1, 100}, -- gold ring
                {2151, 1, 100}, -- talon
            },

            semiRare = {
                {2195, 1, 100}, -- boots of haste
                {2472, 1, 100}, -- magic plate armor
                {2393, 1, 100}, -- giant sword
                {2470, 1, 100}, -- golden legs
                {2514, 1, 100}, -- mastermind shield
            },

            rare = {
                {8885, 1, 100}, -- divine plate
                {2520, 1, 100}, -- demon shield
                {8930, 1, 100}, -- emerald sword
                {2522, 1, 100}, -- great shield
                {2421, 1, 100}, -- thunder hammer
            },

            veryRare = {
                {5903, 1, 100}, -- ferumbras' hat
            },
         
            always = {
                {2171, 1, 100}, -- platinum amulet
                {2148, 90, 100}, -- gold coin
                {2146, 10, 100}, -- small sapphire
            },
         
            storage = 65481,
        },
        ["zulazza the corruptor"] = --- the boss's entire name in lower case.
        {
            common = {
                {2158, 1, 100}, -- blue gem
                {2156, 1, 100}, -- red gem
                {2155, 1, 100}, -- green gem
                {2154, 1, 100}, -- yellow gem
                {2153, 1, 100}, -- violet gem
            },

            semiRare = {
                {5944, 5, 100}, -- soul orb
            },

            rare = {
                {2514, 1, 100}, -- mastermind shield
            },

            veryRare = {
                {11114, 1, 100}, -- dragon scale boots
                {8882, 1, 100}, -- earthborn titan armor
            },
         
            always = {
                {2152, 90, 100}, -- platinum coin
                {9971, 5, 100}, -- gold ingot
            },
         
            storage = 65482,
        },
        ["morgaroth"] = -- the boss's entire name in lower case.
        {
            common = {
                {2143, 10, 100}, -- white pearl
                {2146, 10, 100}, -- small sapphire
                {2145, 10, 100}, -- small diamond
                {2144, 10, 100}, -- black pearl
                {2149, 10, 100}, -- small emeralds
                {5954, 3, 100}, -- demon horn
                {7896, 1, 100}, -- glacier kilt
                {2432, 1, 100}, -- fire axe
                {2462, 1, 100}, -- devil helmet
                {7590, 1, 100}, -- great mana potion
                {2179, 1, 100}, -- gold ring
                {2151, 1, 100}, -- talon
            },

            semiRare = {
                {2195, 1, 100}, -- boots of haste
                {2393, 1, 100}, -- giant sword
                {5954, 5, 100}, -- demon horn
                {2123, 1, 100}, -- ring of the sky
            },

            rare = {
                {8886, 1, 100}, -- molten plate
                {2472, 1, 100}, -- magic plate armor
                {8867, 1, 100}, -- dragon robe
                {2514, 1, 100}, -- mastermind shield
                {2520, 1, 100}, -- demon shield
                {1982, 1, 100}, -- purple tome
                {8851, 1, 100}, -- royal crossbow
            },

            veryRare = {
                {2421, 1, 100}, -- thunder hammer
                {2522, 1, 100}, -- great shield
                {8850, 1, 100}, -- chain bolter
            },
         
            always = {
                {5943, 1, 100}, -- morgaroth's brain
                {2171, 1, 100}, -- platinum amulet
                {2148, 90, 100}, -- gold coin
                {2146, 10, 100}, -- small sapphire
            },
            storage = 65483,
        },
    }
}

Por último, adicione isto a data/lib/lib.lua e inclua-o.

----Reward Chest System
dofile('data/lib/RewardChestSystem.lua')

Incrível, você pode configurar os itens de saque de cada chefe individualmente. Está dentro da lib/RewardChestSystem, então aproveite.

 

Para quem usa Nekiro ou qualquer base TFS 1.x Downgrades,
basta alterar esta linha.

chest:moveTo(player:getInbox())
para.
local depotChest = player:getDepotChest(REWARDCHEST.town_id, true)
    chest:moveTo(depotChest)

 

Editado por Mateus Robeerto (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por Anderson Sacani
      Venho publicar uma alteração que eu e minha equipe fizemos no script já existente do Canary.
      O arquivo do script se chama quest_system1.lua.
      Fizemos essa alteração, porque o sistema original não entregava chave com actionid ao jogador. A chave vinha com o código 0000, ou seja, não abria nenhuma porta.
      A alteração que fizemos foi justamente para arrumar esse bug, por tanto, agora quando o quest ter uma chave com actionid dentro do baú, o jogador receberá essa mesma chave com o actionid definido.
       
      local specialQuests = { -- {x = 32752, y = 32343, z = 14} [52167] = Storage.DreamersChallenge.Reward, -- {x = 32806, y = 32230, z = 11} [52003] = Storage.PitsOfInferno.WeaponReward, -- {x = 32311, y = 32211, z = 8} [51400] = Storage.ThievesGuild.Reward, [51324] = Storage.WrathoftheEmperor.mainReward, -- {x = 32232, y = 31066, z = 7} [51715] = Storage.SvargrondArena.RewardGreenhorn, -- {x = 32232, y = 31059, z = 7} [51716] = Storage.SvargrondArena.RewardScrapper, -- {x = 32232, y = 31052, z = 7} [51717] = Storage.SvargrondArena.RewardWarlord } local questsExperience = { [3101] = 1 -- dummy values } local questLog = { [8213] = Storage.HiddenCityOfBeregar.DefaultStart } local tutorialIds = { [50080] = 5, [50082] = 6, [50084] = 10, [50086] = 11 } local hotaQuest = { 50950, 50951, 50952, 50953, 50954, 50955 } local questSystem1 = Action() function questSystem1.onUse(player, item, fromPosition, target, toPosition, isHotkey) local storage = specialQuests[item.actionid] if not storage then storage = item.uid if storage > 65535 then return false end end if storage == 23644 or storage == 24632 or storage == 14338 then player:setStorageValue(Storage.SvargrondArena.PitDoor, -1) end if player:getStorageValue(storage) > 0 and player:getAccountType() < ACCOUNT_TYPE_GOD then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The ' .. ItemType(item.itemid):getName() .. ' is empty.') return true end local function copyContainer(originalContainer, newContainer) for i = 0, originalContainer:getSize() - 1 do local originalItem = originalContainer:getItem(i) local newItem = Game.createItem(originalItem.itemid, originalItem.type) newItem:setActionId(originalItem:getActionId()) newItem:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, originalItem:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)) if originalItem:isContainer() then copyContainer(Container(originalItem.uid), Container(newItem.uid)) end newContainer:addItemEx(newItem) end end local items, reward = {} local size = item:isContainer() and item:getSize() or 0 if size == 0 then local actionId = item:getActionId() reward = Game.createItem(item.itemid, item.type) reward:setActionId(actionId) reward:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)) else local container = Container(item.uid) for i = 0, container:getSize() - 1 do local originalItem = container:getItem(i) local newItem = Game.createItem(originalItem.itemid, originalItem.type) newItem:setActionId(originalItem:getActionId()) newItem:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, originalItem:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)) if originalItem:isContainer() then copyContainer(Container(originalItem.uid), Container(newItem.uid)) end items[#items + 1] = newItem end if size == 1 then reward = items[1] end end local result = '' if reward then local ret = ItemType(reward.itemid) if ret:isRune() then result = ret:getArticle() .. ' ' .. ret:getName() .. ' (' .. reward.type .. ' charges)' elseif ret:isStackable() and reward:getCount() > 1 then result = reward:getCount() .. ' ' .. ret:getPluralName() elseif ret:getArticle() ~= '' then result = ret:getArticle() .. ' ' .. ret:getName() else result = ret:getName() end else if size > 20 then reward = Game.createItem(item.itemid, 1) elseif size > 8 then reward = Game.createItem(2854, 1) else reward = Game.createItem(2853, 1) end for i = 1, size do local tmp = items[i] if reward:addItemEx(tmp) ~= RETURNVALUE_NOERROR then Spdlog.warn("[questSystem1.onUse] - Could not add quest reward to container") end end local ret = ItemType(reward.itemid) result = ret:getArticle() .. ' ' .. ret:getName() end if player:addItemEx(reward) ~= RETURNVALUE_NOERROR then local weight = reward:getWeight() if player:getFreeCapacity() < weight then player:sendCancelMessage(string.format('You have found %s weighing %.2f oz. You have no capacity.', result, (weight / 100))) else player:sendCancelMessage('You have found ' .. result .. ', but you have no room to take it.') end return true end if questsExperience[storage] then player:addExperience(questsExperience[storage], true) end if questLog[storage] then player:setStorageValue(questLog[storage], 1) end if tutorialIds[storage] then player:sendTutorial(tutorialIds[storage]) if item.uid == 50080 then player:setStorageValue(Storage.RookgaardTutorialIsland.SantiagoNpcGreetStorage, 3) end end if isInArray(hotaQuest, item.uid) then if player:getStorageValue(Storage.TheAncientTombs.DefaultStart) ~= 1 then player:setStorageValue(Storage.TheAncientTombs.DefaultStart, 1) end end player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. result .. '.') player:setStorageValue(storage, 1) return true end for index, value in pairs(specialQuests) do questSystem1:aid(index) end questSystem1:aid(2000) questSystem1:register()  
    • Por Anderson Sacani
      Bom dia!
      Estava de bobeira agora pela manhã e resolvi brincar um pouco.
      Criei um script de SD no qual se for noite, ela retornará um valor X de dano, e, se for dia, ela retornará um valor Y de dano.
      Estou compartilhando esse script para vocês terem como base e usarem até mesmo em outros:
       
      local config = { damageDay = { min = 0.70, max = 0.75 }, damageNight = { min = 0.95, max = 1 }, hourStartDay = 6, hourEndDay = 18 } local combat = Combat() combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE) combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA) combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH) function onGetFormulaValues(player, level, maglevel) local min, max = ((level / 5) + (maglevel * 4.605)), ((level / 5) + (maglevel * 7.395)) local hour = tonumber(os.date("%H", os.time())) -- Obtém a hora atual -- Define o valor do dano com base na hora do dia if hour >= config.hourStartDay and hour < config.hourEndDay then -- Dia min = min * config.damageDay.min max = max * config.damageDay.max else -- Noite min = min * config.damageNight.min max = max * config.damageNight.max end return -min, -max end combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues") local rune = Spell("rune") function rune.onCastSpell(creature, var, isHotkey) return combat:execute(creature, var) end rune:group("attack") rune:name("sudden death rune") rune:runeId(3155) rune:allowFarUse(true) rune:charges(3) rune:level(45) rune:magicLevel(15) rune:cooldown(2 * 1000) rune:groupCooldown(2 * 1000) rune:needTarget(true) rune:isBlocking(true) -- True = Solid / False = Creature rune:register()  
    • Por amoxicilina
      Olá Kings, venho aqui trazer uma TalkAction pra você comprar premium account, sei que pode ser algo meio inútil por existir a store.
      Então vamos script:
       
       
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo