• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Sequential boss logic

darkmu

Well-Known Member
Joined
Aug 26, 2007
Messages
274
Solutions
1
Reaction score
50
Location
Paraná,Brazil
Could someone help me, I need to adapt this script so that the person needs to kill the bosses in increasing order to release the chest.
Being that if she tries to kill the boss who will give status 4 for example and she is in status 2, she still won't change to 4 and will continue in 2.

Lua:
local bosses = {
    ['shadowpelt'] = {status = 1, storage = 15422},
    ['black vixen'] = {status = 2, storage = 15422},
    ['sharpclaw'] = {status = 3, storage = 15422},
    ['bloodback'] = {status = 4, storage = 15422},
}

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

    for pid, _ in pairs(targetMonster:getDamageMap()) do
        local attackerPlayer = Player(pid)
        if attackerPlayer then
            attackerPlayer:setStorageValue(15422, bossConfig.status)   
        end
    end
end
 
Solution
Lua:
if attackerPlayer then
    local current_storage = attackerPlayer:getStorageValue(bossConfig.storage)
    if current_storage == bossConfig.status then
        attackerPlayer:setStorageValue(bossConfig.storage, current_storage + 1)
    end
end
You would probably need to use -1, 0, 1, 2 as the status, unless something else changes that storage value beforehand.
Lua:
if attackerPlayer then
    local current_storage = attackerPlayer:getStorageValue(bossConfig.storage)
    if current_storage == bossConfig.status then
        attackerPlayer:setStorageValue(bossConfig.storage, current_storage + 1)
    end
end
You would probably need to use -1, 0, 1, 2 as the status, unless something else changes that storage value beforehand.
 
Solution
Back
Top