Manda o script ai pra nós
6
2k
info
Grupo: Conde
Registrado: 11/03/13
Posts: 629
Reputação: +183

25 de abril de 2023 às 18:04
26 de abril de 2023 às 04:52
10 horas atrás, GamerGoiano disse:Manda o script ai pra nós
local bossDeath = CreatureEvent("BossDeath")
function bossDeath.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
-- Deny summons and players
if not creature or creature:isPlayer() or creature:getMaster() then
return true
end
-- Boss function
local monsterType = creature:getType()
-- Make sure it is a boss
if monsterType and monsterType:isRewardBoss() then
local bossId = creature:getId()
local timestamp = os.time()
ResetAndSetTargetList(creature)
-- Avoid dividing by zero
local totalDamageOut, totalDamageIn, totalHealing = 0.1, 0.1, 0.1
local scores = {}
local info = GlobalBosses[bossId]
local damageMap = creature:getDamageMap()
for guid, stats in pairs(info) do
local player = Player(stats.playerId)
local part = damageMap[stats.playerId]
local damageOut, damageIn, healing = (stats.damageOut or 0) + (part and part.total or 0), stats.damageIn or 0, stats.healing or 0
totalDamageOut = totalDamageOut + damageOut
totalDamageIn = totalDamageIn + damageIn
totalHealing = totalHealing + healing
table.insert(scores, {
player = player,
guid = guid,
damageOut = damageOut,
damageIn = damageIn,
healing = healing,
})
end
local participants = 0
for _, con in ipairs(scores) do
local score = (con.damageOut / totalDamageOut) + (con.damageIn / totalDamageIn) + (con.healing / totalHealing)
-- Normalize to 0-1
con.score = score / 3
if score ~= 0 then
participants = participants + 1
end
end
table.sort(scores, function(a, b) return a.score > b.score end)
local expectedScore = 1 / participants
for _, con in ipairs(scores) do
-- Ignoring stamina for now because I heard you get receive rewards even when it's depleted
local reward, stamina
if con.player then
reward = con.player:getReward(timestamp, true)
stamina = con.player:getStamina()
else
stamina = con.stamina or 0
end
local playerLoot
if con.score ~= 0 then
local lootFactor = 1
-- Tone down the loot a notch if there are many participants
lootFactor = lootFactor / participants ^ (1 / 3)
-- Increase the loot multiplicatively by how many times the player surpassed the expected score
lootFactor = lootFactor * (1 + lootFactor) ^ (con.score / expectedScore)
playerLoot = monsterType:getBossReward(lootFactor, _ == 1)
if con.player then
for _, p in ipairs(playerLoot) do
reward:addItem(p[1], p[2])
end
end
end
if con.player and con.score ~= 0 then
local lootMessage = ("The following items dropped by %s are available in your reward chest: %s"):format(creature:getName(), reward:getContentDescription())
if stamina > 840 then
reward:getContentDescription(lootMessage)
end
con.player:sendTextMessage(MESSAGE_LOOT, lootMessage)
elseif con.score ~= 0 then
InsertRewardItems(con.guid, timestamp, playerLoot)
end
end
GlobalBosses[bossId] = nil
end
return true
end
bossDeath:register()
Isso n e em todos os boss .. eu copie uns boss de outra pasta e joguei na pasta do meu ot . e coloquei os boss no map. esse boss q n ta entregando a reward para todos os player sp para o q da mas dano.
info
Grupo: Conde
Registrado: 11/03/13
Posts: 629
Reputação: +183

26 de abril de 2023 às 09:38
Testa aew
local bossDeath = CreatureEvent("BossDeath") function bossDeath.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified) -- Deny summons and players if not creature or creature:isPlayer() or creature:getMaster() then return true end -- Boss function local monsterType = creature:getType() -- Make sure it is a boss if monsterType and monsterType:isRewardBoss() then local bossId = creature:getId() local timestamp = os.time() ResetAndSetTargetList(creature) -- Avoid dividing by zero local totalDamageOut, totalDamageIn, totalHealing = 0.1, 0.1, 0.1 local scores = {} local info = GlobalBosses[bossId] -- Check if info table is not empty if info ~= nil and next(info) ~= nil then local damageMap = creature:getDamageMap() for guid, stats in pairs(info) do local player = Player(stats.playerId) local part = damageMap[stats.playerId] local damageOut, damageIn, healing = (stats.damageOut or 0) + (part and part.total or 0), stats.damageIn or 0, stats.healing or 0 totalDamageOut = totalDamageOut + damageOut totalDamageIn = totalDamageIn + damageIn totalHealing = totalHealing + healing table.insert(scores, { player = player, guid = guid, damageOut = damageOut, damageIn = damageIn, healing = healing, }) end local participants = 0 for _, con in ipairs(scores) do local score = (con.damageOut / totalDamageOut) + (con.damageIn / totalDamageIn) + (con.healing / totalHealing) -- Normalize to 0-1 con.score = score / 3 if score ~= 0 then participants = participants + 1 end end table.sort(scores, function(a, b) return a.score > b.score end) local expectedScore = 1 / participants for _, con in ipairs(scores) do -- Ignoring stamina for now because I heard you get receive rewards even when it's depleted local reward, stamina if con.player then reward = con.player:getReward(timestamp, true) stamina = con.player:getStamina() else stamina = con.stamina or 0 end -- Initialize playerLoot as a table local playerLoot = {} if con.score ~= 0 then local lootFactor = 1 -- Tone down the loot a notch if there are many participants lootFactor = lootFactor / participants ^ (1 / 3) -- Increase the loot multiplicatively by how many times the player surpassed the expected score local lootMultiplier = con.score / expectedScore local lootAmount = math.floor(info.lootAmount * lootFactor * lootMultiplier) -- Make sure the player gets at least 1 gold if lootAmount < 1 then lootAmount = 1 end playerLoot[ITEM_GOLD_COIN] = lootAmount -- Add items to playerLoot table if info.items then for _, item in ipairs(info.items) do local itemId, count = item[1], item[2] local itemLootAmount = math.floor(count * lootFactor * lootMultiplier) playerLoot[itemId] = itemLootAmount end end if con.player then -- Add loot to player con.player:sendTextMessage(MESSAGE_INFO_DESCR, "You have received the following rewards for participating in a boss battle:") for itemId, count in pairs(playerLoot) do local item = ItemType(itemId) con.player:addItem(itemId, count) con.player:sendTextMessage(MESSAGE_INFO_DESCR, count .. " x " .. item:getDescription()) end -- Add reward to player con.player:addReward(timestamp, info.rewardAmount) local newReward = con.player:getReward(timestamp, true) con.player:sendTextMessage(MESSAGE_INFO_DESCR, "You received " .. (newReward - reward) .. " reward points for your performance.") end end end end end
26 de abril de 2023 às 14:33
4 horas atrás, GamerGoiano disse:Testa aew
local bossDeath = CreatureEvent("BossDeath") function bossDeath.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified) -- Deny summons and players if not creature or creature:isPlayer() or creature:getMaster() then return true end -- Boss function local monsterType = creature:getType() -- Make sure it is a boss if monsterType and monsterType:isRewardBoss() then local bossId = creature:getId() local timestamp = os.time() ResetAndSetTargetList(creature) -- Avoid dividing by zero local totalDamageOut, totalDamageIn, totalHealing = 0.1, 0.1, 0.1 local scores = {} local info = GlobalBosses[bossId] -- Check if info table is not empty if info ~= nil and next(info) ~= nil then local damageMap = creature:getDamageMap() for guid, stats in pairs(info) do local player = Player(stats.playerId) local part = damageMap[stats.playerId] local damageOut, damageIn, healing = (stats.damageOut or 0) + (part and part.total or 0), stats.damageIn or 0, stats.healing or 0 totalDamageOut = totalDamageOut + damageOut totalDamageIn = totalDamageIn + damageIn totalHealing = totalHealing + healing table.insert(scores, { player = player, guid = guid, damageOut = damageOut, damageIn = damageIn, healing = healing, }) end local participants = 0 for _, con in ipairs(scores) do local score = (con.damageOut / totalDamageOut) + (con.damageIn / totalDamageIn) + (con.healing / totalHealing) -- Normalize to 0-1 con.score = score / 3 if score ~= 0 then participants = participants + 1 end end table.sort(scores, function(a, b) return a.score > b.score end) local expectedScore = 1 / participants for _, con in ipairs(scores) do -- Ignoring stamina for now because I heard you get receive rewards even when it's depleted local reward, stamina if con.player then reward = con.player:getReward(timestamp, true) stamina = con.player:getStamina() else stamina = con.stamina or 0 end -- Initialize playerLoot as a table local playerLoot = {} if con.score ~= 0 then local lootFactor = 1 -- Tone down the loot a notch if there are many participants lootFactor = lootFactor / participants ^ (1 / 3) -- Increase the loot multiplicatively by how many times the player surpassed the expected score local lootMultiplier = con.score / expectedScore local lootAmount = math.floor(info.lootAmount * lootFactor * lootMultiplier) -- Make sure the player gets at least 1 gold if lootAmount < 1 then lootAmount = 1 end playerLoot[ITEM_GOLD_COIN] = lootAmount -- Add items to playerLoot table if info.items then for _, item in ipairs(info.items) do local itemId, count = item[1], item[2] local itemLootAmount = math.floor(count * lootFactor * lootMultiplier) playerLoot[itemId] = itemLootAmount end end if con.player then -- Add loot to player con.player:sendTextMessage(MESSAGE_INFO_DESCR, "You have received the following rewards for participating in a boss battle:") for itemId, count in pairs(playerLoot) do local item = ItemType(itemId) con.player:addItem(itemId, count) con.player:sendTextMessage(MESSAGE_INFO_DESCR, count .. " x " .. item:getDescription()) end -- Add reward to player con.player:addReward(timestamp, info.rewardAmount) local newReward = con.player:getReward(timestamp, true) con.player:sendTextMessage(MESSAGE_INFO_DESCR, "You received " .. (newReward - reward) .. " reward points for your performance.") end end end end end
vou testa aki e te falo o que deu
obg .
1 ano depois...
info
Grupo: Lorde
Registrado: 05/06/12
Posts: 2.2k
Reputação: +215
Gênero: Masculino

16 de fevereiro de 2025 às 14:50
Em 26/04/2023 em 14:33, MalBack disse:
vou testa aki e te falo o que deu
obg .
Funcionou?
Avise para fecharmos o tópico.
Atenciosamente




info
Grupo: Campones
Registrado: 03/10/15
Posts: 15
Reputação: 0
Alguém ajuda com esse erro pfv.
scriptId: [C:\Users\andrepaulo695847\Desktop\empera-ot\Global-vip\Global-vip\data-otservbr-global\scripts\reward_chest\boss_death.lua:callback] timerEvent: [] callbackId:[] function: [] error [...data-otservbr-global\scripts\reward_chest\boss_death.lua:76: bad argument #1 to 'ipairs' (table expected, got nil) stack traceback: [C]: at 0x7ff60cbfc1a0 [C]: in function 'ipairs' ...data-otservbr-global\scripts\reward_chest\boss_death.lua:76: in function <...data-otservbr-global\scripts\reward_chest\boss_death.lua:3>] [2023-25-04 16:32:56.926] [error] Lua script error: scriptInterface: [Scripts Interface] scriptId: [C:\Users\andrepaulo695847\Desktop\empera-ot\Global-vip\Global-vip\data-otservbr-global\scripts\reward_chest\boss_death.lua:callback] timerEvent: [] callbackId:[] function: [] error [...data-otservbr-global\scripts\reward_chest\boss_death.lua:76: bad argument #1 to 'ipairs' (table expected, got nil) stack traceback: [C]: at 0x7ff60cbfc1a0 [C]: in function 'ipairs' ...data-otservbr-global\scripts\reward_chest\boss_death.lua:76: in function <...data-otservbr-global\scripts\reward_chest\boss_death.lua:3>] [2023-25-04 16:34:48.603] [error] Lua script error: scriptInterface: [Scripts Interface] scriptId: [C:\Users\andrepaulo695847\Desktop\empera-ot\Global-vip\Global-vip\data-otservbr-global\scripts\reward_chest\boss_death.lua:callback] timerEvent: [] callbackId:[] function: [] error [...data-otservbr-global\scripts\reward_chest\boss_death.lua:76: bad argument #1 to 'ipairs' (table expected, got nil) stack traceback: [C]: at 0x7ff60cbfc1a0 [C]: in function 'ipairs' ...data-otservbr-global\scripts\reward_chest\boss_death.lua:76: in function <...data-otservbr-global\scripts\reward_chest\boss_death.lua:3>]add uma imagem . pra facilitar