Good afternoon,
I have a code that gives me a 100% chance of reward if I am only one player in the boss, what I wanted to do is this:
Who attacks the boss enters the list of participants who will win the estorage
The more participants the change of winning storage was bigger
example: 1 only killed the boss he would have a 60% chance to get estorage
2 killed the boss, each of them would have a 70% chance to get estorage
3 killed the boss, each of them would have an 80% chance to get estorage
4 killed the boss, each of them would have 90% chance of getting estorage
5 killed the boss, each of them would have a 100% chance of getting estorage
But it could not be a draw for all participants, but it would have to be individual.
Follow the code and I use today
I have a code that gives me a 100% chance of reward if I am only one player in the boss, what I wanted to do is this:
Who attacks the boss enters the list of participants who will win the estorage
The more participants the change of winning storage was bigger
example: 1 only killed the boss he would have a 60% chance to get estorage
2 killed the boss, each of them would have a 70% chance to get estorage
3 killed the boss, each of them would have an 80% chance to get estorage
4 killed the boss, each of them would have 90% chance of getting estorage
5 killed the boss, each of them would have a 100% chance of getting estorage
But it could not be a draw for all participants, but it would have to be individual.
LUA:
local bosses = {
['behemoth'] = {storage = 77076},
}
function onKill(creature, target)
local targetMonster = target:getMonster()
if not targetMonster then
return true
end
local bossConfig = bosses[targetMonster:getName():lower()]
if not bossConfig then
return true
end
local participantes = {}
for pid, _ in pairs(targetMonster:getDamageMap()) do
local attackerPlayer = Player(pid)
if attackerPlayer then
table.insert(participantes, attackerPlayer)
end
end
math.randomseed(os.time())
for i = 1, #participantes do
local playerSorteado = participantes[math.random(i)]
if playerSorteado and playerSorteado:getStorageValue(bossConfig.storage) ~= 1 then
playerSorteado:setStorageValue(bossConfig.storage, 1)
playerSorteado:getPosition():sendMagicEffect(56)
playerSorteado:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You were chosen to take the boss's treasure in Adventurers Guild.")
end
end
return true
end
Follow the code and I use today