Postado Maio 20, 2024 1 ano 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 Maio 20, 2024 1 ano por Mateus Robeerto (veja o histórico de edições)
Postado Maio 20, 2024 1 ano Administrador Ótimo! Contato :https://www.linkedin.com/in/rafhael-oliveira/Projetos :https://github.com/thetibiaking
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.