• 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 Error with halvar npc, svargrond arena.

nefinoo

Carnage.flv
Joined
Sep 11, 2010
Messages
551
Solutions
1
Reaction score
59
Location
Lo Mochis, Sinaloa
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)
    npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
    npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)
    npcHandler:onCreatureSay(cid, type, msg)
end
function onThink()
    npcHandler:onThink()
end

keywordHandler:addKeyword({'rules'}, StdModule.say, {npcHandler = npcHandler, text = 'What do you want to know? Something about the three different {difficulties}, the {general} rules or the {prices}? Maybe you also want to know what happens when you {die}?'})
keywordHandler:addKeyword({'difficulties'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'levels'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'difficulty'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'greenhorn'}, StdModule.say, {npcHandler = npcHandler, text = 'That is the easiest way in our arena. The {fee} is 1000 gold. We were setting this up for of our children to challenge some easy monsters and train them for the future.'})
keywordHandler:addKeyword({'scrapper'}, StdModule.say, {npcHandler = npcHandler, text = 'The most common difficulty for us. The {fee} is 5000 gold. So if you are experienced in fighting middle class monsters this is your challenge!'})
keywordHandler:addKeyword({'warlord'}, StdModule.say, {npcHandler = npcHandler, text = 'Only the strongest among us will take this challenge. The {fee} is 10000 gold. If you pass that I promise you the respect of all citizens here. You will be a hero!'})
keywordHandler:addKeyword({'fee'}, StdModule.say, {npcHandler = npcHandler, text = 'The fee is either 1000, 5000 or 10000 gold for one try. Remember that if you {die}, it is YOUR problem and you won\'t be able to get back to your corpse and your backpack.'})
keywordHandler:addKeyword({'die'}, StdModule.say, {npcHandler = npcHandler, text = 'It would be better not to die! In every pit there is an emergency exit, the portal to the south. If you die in a pit... well... your corpse and backpack are gone, so you enter the arena at your own risk.'})
keywordHandler:addKeyword({'general'}, StdModule.say, {npcHandler = npcHandler, text = 'Basically you pay me a {fee}, and you are sent into an arena with 10 different stages. If you succeed you will be rewarded accordingly.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'My job is to explain about the rules and to get the fee from the competitors.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, text = 'Well I would rather call it an {Ultimate Challenge} than a mission.'})

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local arenaId = player:getStorageValue(Storage.SvargrondArena.Arena)
    if msgcontains(msg, 'fight') or msgcontains(msg, 'pit') or msgcontains(msg, 'challenge') or msgcontains(msg, 'arena') then
        if player:getStorageValue(Storage.SvargrondArena.PitDoor) == 1 then
            npcHandler:say('You already paid the fee, go and fight!', cid)
            return true
        end

        if arenaId < 1 then
            arenaId = 1
            player:setStorageValue(Storage.SvargrondArena.Arena, arenaId)
        end

        if ARENA[arenaId] then
            npcHandler:say('So you agree with the {rules} and want to participate in the {challenge}? The {fee} for one try in {' .. ARENA[arenaId].name .. '} is ' .. ARENA[arenaId].price .. ' gold pieces. Do you really want to participate and pay the {fee}?', cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say('You\'ve already completed the arena in all {difficulty levels}.', cid)
            npcHandler.topic[cid] = 0
        end

    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, 'yes') then
            if not ARENA[arenaId] then
                npcHandler.topic[cid] = 0
                return true
            end

            if player:removeMoneyNpc(ARENA[arenaId].price) then
                player:setStorageValue(Storage.SvargrondArena.PitDoor, 1)
                npcHandler:say('As you wish! You can pass the door now and enter the teleporter to the pits.', cid)

                local cStorage = ARENA[arenaId].questLog
                if player:getStorageValue(cStorage) ~= 1 then
                    player:setStorageValue(cStorage, 1)
                end
            else
                npcHandler:say('You do not have enough money.', cid)
            end
        else
            npcHandler:say('Come back when you are ready then.', cid)
        end
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello competitor! Do you want to {fight} in the arena or shall I explain the {rules} first?')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

23:14 Halvar: Hello competitor! Do you want to fight in the arena or shall I explain the rules first?
23:14 Asus [8000]: fight
23:15 Halvar: You've already completed the arena in all difficulty levels.

In a new player, with 0 storages or access edited.
 
Solution
Lua:
--[[
TODO
- Include PITS and ARENA table in SvargrondArena -> SvargrondArena.arenas / SvargrondArena.PitDoors
- Restructure PITS and ARENA table (reward.storage does not seem to be used)
]]

SvargrondArena = {
    -- kick time in seconds (10 minutes)
    kickTime = 600,
    kickPosition = Position({x = 32251, y = 31098, z = 6}),
    rewardPosition = Position({x = 32222, y = 31080, z = 6}),

    -- used to store event ids
    kickEvents = {},
    timerEvents = {},
    effectPositionCache = {},

    -- item ids used by the script
    itemTimer = 10288,
    itemPillar = 1354,
    itemTeleport = 5023,
    itemsNotErasable = {10288, 1354, 1543, 1544, 1545},
}

-- Script automatically derives other pit positions from this one
local...
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)
    npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
    npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)
    npcHandler:onCreatureSay(cid, type, msg)
end
function onThink()
    npcHandler:onThink()
end

keywordHandler:addKeyword({'rules'}, StdModule.say, {npcHandler = npcHandler, text = 'What do you want to know? Something about the three different {difficulties}, the {general} rules or the {prices}? Maybe you also want to know what happens when you {die}?'})
keywordHandler:addKeyword({'difficulties'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'levels'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'difficulty'}, StdModule.say, {npcHandler = npcHandler, text = 'There are three difficulties: Greenhorn, Scrapper and Warlord. On each challenge you will be confronted with ten monsters increasing in strength.'})
keywordHandler:addKeyword({'greenhorn'}, StdModule.say, {npcHandler = npcHandler, text = 'That is the easiest way in our arena. The {fee} is 1000 gold. We were setting this up for of our children to challenge some easy monsters and train them for the future.'})
keywordHandler:addKeyword({'scrapper'}, StdModule.say, {npcHandler = npcHandler, text = 'The most common difficulty for us. The {fee} is 5000 gold. So if you are experienced in fighting middle class monsters this is your challenge!'})
keywordHandler:addKeyword({'warlord'}, StdModule.say, {npcHandler = npcHandler, text = 'Only the strongest among us will take this challenge. The {fee} is 10000 gold. If you pass that I promise you the respect of all citizens here. You will be a hero!'})
keywordHandler:addKeyword({'fee'}, StdModule.say, {npcHandler = npcHandler, text = 'The fee is either 1000, 5000 or 10000 gold for one try. Remember that if you {die}, it is YOUR problem and you won\'t be able to get back to your corpse and your backpack.'})
keywordHandler:addKeyword({'die'}, StdModule.say, {npcHandler = npcHandler, text = 'It would be better not to die! In every pit there is an emergency exit, the portal to the south. If you die in a pit... well... your corpse and backpack are gone, so you enter the arena at your own risk.'})
keywordHandler:addKeyword({'general'}, StdModule.say, {npcHandler = npcHandler, text = 'Basically you pay me a {fee}, and you are sent into an arena with 10 different stages. If you succeed you will be rewarded accordingly.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'My job is to explain about the rules and to get the fee from the competitors.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, text = 'Well I would rather call it an {Ultimate Challenge} than a mission.'})

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)
    local arenaId = player:getStorageValue(Storage.SvargrondArena.Arena)
    if msgcontains(msg, 'fight') or msgcontains(msg, 'pit') or msgcontains(msg, 'challenge') or msgcontains(msg, 'arena') then
        if player:getStorageValue(Storage.SvargrondArena.PitDoor) == 1 then
            npcHandler:say('You already paid the fee, go and fight!', cid)
            return true
        end

        if arenaId < 1 then
            arenaId = 1
            player:setStorageValue(Storage.SvargrondArena.Arena, arenaId)
        end

        if ARENA[arenaId] then
            npcHandler:say('So you agree with the {rules} and want to participate in the {challenge}? The {fee} for one try in {' .. ARENA[arenaId].name .. '} is ' .. ARENA[arenaId].price .. ' gold pieces. Do you really want to participate and pay the {fee}?', cid)
            npcHandler.topic[cid] = 1
        else
            npcHandler:say('You\'ve already completed the arena in all {difficulty levels}.', cid)
            npcHandler.topic[cid] = 0
        end

    elseif npcHandler.topic[cid] == 1 then
        if msgcontains(msg, 'yes') then
            if not ARENA[arenaId] then
                npcHandler.topic[cid] = 0
                return true
            end

            if player:removeMoneyNpc(ARENA[arenaId].price) then
                player:setStorageValue(Storage.SvargrondArena.PitDoor, 1)
                npcHandler:say('As you wish! You can pass the door now and enter the teleporter to the pits.', cid)

                local cStorage = ARENA[arenaId].questLog
                if player:getStorageValue(cStorage) ~= 1 then
                    player:setStorageValue(cStorage, 1)
                end
            else
                npcHandler:say('You do not have enough money.', cid)
            end
        else
            npcHandler:say('Come back when you are ready then.', cid)
        end
        npcHandler.topic[cid] = 0
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello competitor! Do you want to {fight} in the arena or shall I explain the {rules} first?')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

23:14 Halvar: Hello competitor! Do you want to fight in the arena or shall I explain the rules first?
23:14 Asus [8000]: fight
23:15 Halvar: You've already completed the arena in all difficulty levels.

In a new player, with 0 storages or access edited.
We need to see the Storage table and the ARENA table
 
You mean these?
Lua:
SvargrondArena = {
        -- Reserved storage from 51710 - 51729
        Arena = 51710,
        PitDoor = 51711,
        QuestLogGreenhorn = 51712,
        QuestLogScrapper = 51713,
        QuestLogWarlord = 51714,
        RewardGreenhorn = 51715,
        RewardScrapper = 51716,
        RewardWarlord = 51717,
        TrophyGreenhorn = 51718,
        TrophyScrapper = 51719,
        TrophyWarlord = 51720,
        GreenhornDoor = 51721,
        ScrapperDoor = 51722,
        WarlordDoor= 51723
    },

Lua:
[31] = {
            name = "The Ultimate Challenges",
            startstorageid = Storage.SvargrondArena.QuestLogGreenhorn,
            startstoragevalue = 1,
            missions = {
                [1] = {
                    name = "Barbarian Arena - Greenhorn Mode",
                    storageid = Storage.SvargrondArena.QuestLogGreenhorn,
                    missionId = 313, startvalue = 1,
                    endvalue = 2,
                    states = {
                        [1] = "You have to defeat all enemies in this mode.",
                        [2] = "You have defeated all enemies in this mode."
                    }
                },
                [2] = {
                    name = "Barbarian Arena - Scrapper Mode",
                    storageid = Storage.SvargrondArena.QuestLogScrapper,
                    missionId = 314, startvalue = 1,
                    endvalue = 2,
                    states = {
                        [1] = "You have to defeat all enemies in this mode.",
                        [2] = "You have defeated all enemies in this mode."
                    }
                },
                [3] = {
                    name = "Barbarian Arena - Warlord Mode",
                    storageid = Storage.SvargrondArena.QuestLogWarlord,
                    missionId = 315, startvalue = 1,
                    endvalue = 2,
                    states = {
                        [1] = "You have to defeat all enemies in this mode.",
                        [2] = "You have defeated all enemies in this mode."
                    }
                }
            }
        }
 
You mean these?
Lua:
SvargrondArena = {
        -- Reserved storage from 51710 - 51729
        Arena = 51710,
        PitDoor = 51711,
        QuestLogGreenhorn = 51712,
        QuestLogScrapper = 51713,
        QuestLogWarlord = 51714,
        RewardGreenhorn = 51715,
        RewardScrapper = 51716,
        RewardWarlord = 51717,
        TrophyGreenhorn = 51718,
        TrophyScrapper = 51719,
        TrophyWarlord = 51720,
        GreenhornDoor = 51721,
        ScrapperDoor = 51722,
        WarlordDoor= 51723
    },

Lua:
[31] = {
            name = "The Ultimate Challenges",
            startstorageid = Storage.SvargrondArena.QuestLogGreenhorn,
            startstoragevalue = 1,
            missions = {
                [1] = {
                    name = "Barbarian Arena - Greenhorn Mode",
                    storageid = Storage.SvargrondArena.QuestLogGreenhorn,
                    missionId = 313, startvalue = 1,
                    endvalue = 2,
                    states = {
                        [1] = "You have to defeat all enemies in this mode.",
                        [2] = "You have defeated all enemies in this mode."
                    }
                },
                [2] = {
                    name = "Barbarian Arena - Scrapper Mode",
                    storageid = Storage.SvargrondArena.QuestLogScrapper,
                    missionId = 314, startvalue = 1,
                    endvalue = 2,
                    states = {
                        [1] = "You have to defeat all enemies in this mode.",
                        [2] = "You have defeated all enemies in this mode."
                    }
                },
                [3] = {
                    name = "Barbarian Arena - Warlord Mode",
                    storageid = Storage.SvargrondArena.QuestLogWarlord,
                    missionId = 315, startvalue = 1,
                    endvalue = 2,
                    states = {
                        [1] = "You have to defeat all enemies in this mode.",
                        [2] = "You have defeated all enemies in this mode."
                    }
                }
            }
        }
Yeah, but still missing
Lua:
if ARENA[arenaId] then

Need to find this ARENA one, since that's the gate-keeper
 
Lua:
--[[
TODO
- Include PITS and ARENA table in SvargrondArena -> SvargrondArena.arenas / SvargrondArena.PitDoors
- Restructure PITS and ARENA table (reward.storage does not seem to be used)
]]

SvargrondArena = {
    -- kick time in seconds (10 minutes)
    kickTime = 600,
    kickPosition = Position({x = 32251, y = 31098, z = 6}),
    rewardPosition = Position({x = 32222, y = 31080, z = 6}),

    -- used to store event ids
    kickEvents = {},
    timerEvents = {},
    effectPositionCache = {},

    -- item ids used by the script
    itemTimer = 10288,
    itemPillar = 1354,
    itemTeleport = 5023,
    itemsNotErasable = {10288, 1354, 1543, 1544, 1545},
}

-- Script automatically derives other pit positions from this one
local firstPit = {
    fromPos = {x = 32205, y = 31094, z = 7},
    toPos = {x = 32214, y = 31103, z = 7},
    center = {x = 32210, y = 31098, z = 7},
    pillar = {x = 32204, y = 31098, z = 7},
    tp = {x = 32204, y = 31098, z = 7},
    summon = {x = 32210, y = 31100, z = 7}
}

PITS = {
    [1] = {
        fromPos = firstPit.fromPos,
        toPos = firstPit.toPos,
        center = firstPit.center,
        pillar = firstPit.pillar,
        tp = firstPit.tp,
        summon = firstPit.summon
    },
    [2] = {
        fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 14, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [3] = {
        fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 28, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [4] = {
        fromPos = {x = firstPit.fromPos.x - 42, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 42, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 42, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 42, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 42, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 42, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [5] = {
        fromPos = {x = firstPit.fromPos.x - 35, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 35, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 35, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 35, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 35, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 35, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [6] = {
        fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 21, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [7] = {
        fromPos = {x = firstPit.fromPos.x - 7, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 7, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 7, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 7, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 7, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 7, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [8] = {
        fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 14, y = firstPit.center.y - 28, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y - 28, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y - 28, z = firstPit.summon.z}
    },
    [9] = {
        fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 28, y = firstPit.center.y - 28, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y - 28, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y - 28, z = firstPit.summon.z}
    },
    [10] = {
        fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 42, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 42, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 21, y = firstPit.center.y - 41, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 41, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 41, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 41, z = firstPit.summon.z}
    }
}

ARENA = {
    [3264] = {
        name = 'Greenhorn',
        price = 1000,
        questLog = Storage.SvargrondArena.QuestLogGreenhorn,
        achievement = 'Greenhorn',
        creatures = {
            [1] = 'frostfur',
            [2] = 'bloodpaw',
            [3] = 'bovinus',
            [4] = 'achad',
            [5] = 'colerian the barbarian',
            [6] = 'the hairy one',
            [7] = 'axeitus headbanger',
            [8] = 'rocky',
            [9] = 'cursed gladiator',
            [10] = 'orcus the cruel'
        },
        reward = {
            trophy = 5807,
            trophyStorage = Storage.SvargrondArena.TrophyGreenhorn,
            desc = 'It is given to the courageous victor of the barbarian arena in greenhorn difficulty. Awarded to %s',
        }
    },
    [3265] = {
        name = 'Scrapper',
        price = 5000,
        questLog = Storage.SvargrondArena.QuestLogScrapper,
        achievement = 'Scrapper',
        creatures = {
            [1] = 'avalanche',
            [2] = 'kreebosh the exile',
            [3] = 'the dark dancer',
            [4] = 'the hag',
            [5] = 'slim',
            [6] = 'grimgor guteater',
            [7] = 'drasilla',
            [8] = 'spirit of earth',
            [9] = 'spirit of water',
            [10] = 'spirit of fire'
        },
        reward = {
            trophy = 5806,
            trophyStorage = Storage.SvargrondArena.TrophyScrapper,
            desc = 'It is given to the courageous victor of the barbarian arena in scrapper difficulty. Awarded to %s.',
        }
    },
    [3266] = {
        name = 'Warlord',
        price = 10000,
        questLog = Storage.SvargrondArena.QuestLogWarlord,
        achievement = 'Warlord of Svargrond',
        creatures = {
            [1] = 'webster',
            [2] = 'darakan the executioner',
            [3] = 'norgle glacierbeard',
            [4] = 'the pit lord',
            [5] = 'svoren the mad',
            [6] = 'the masked marauder',
            [7] = 'gnorre chyllson',
            [8] = 'fallen mooh\'tah master ghar',
            [9] = 'deathbringer',
            [10] = 'the obliverator'
        },
        reward = {
            trophy = 5805,
            trophyStorage = Storage.SvargrondArena.TrophyWarlord,
            desc = 'It is given to the courageous victor of the barbarian arena in warlord difficulty. Awarded to %s.',
        }
    }
}

function SvargrondArena.getPitCreatures(pitId)
    if not PITS[pitId] then
        return {}
    end

    local ret = {}
    local specs = Game.getSpectators(PITS[pitId].center, false, false, 5, 5, 5, 5)
    for i = 1, #specs do
        ret[#ret+1] = specs[i]
    end

    return ret
end

function SvargrondArena.resetPit(pitId)
    if not PITS[pitId] then
        return
    end

    for x = PITS[pitId].fromPos.x, PITS[pitId].toPos.x do
        for y = PITS[pitId].fromPos.y, PITS[pitId].toPos.y do
            for z = PITS[pitId].fromPos.z, PITS[pitId].toPos.z do
                local tile = Tile({x=x, y=y, z=z})
                if tile then
                    local movableItem = tile:getThing(255)
                    if movableItem and movableItem:isItem() then
                        local itemType = ItemType(movableItem:getId())
                        if itemType and itemType:isMovable() and not isInArray(SvargrondArena.itemsNotErasable, movableItem:getId()) then
                            moveableItem:remove()
                        end
                    end

                    local creature = tile:getTopCreature()
                    if creature and creature:isMonster() then
                        creature:remove()
                    end
                end
            end
        end
    end

    local pillarTile = Tile(PITS[pitId].pillar)
    if pillarTile then
        local teleportItem = pillarTile:getItemById(SvargrondArena.itemTeleport)
        if teleportItem then
            teleportItem:remove()
        end

        local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
        if not pillarItem then
            Game.createItem(SvargrondArena.itemPillar, 1, PITS[pitId].pillar)
        end
    end
end

function SvargrondArena.getPitOccupant(pitId, ignorePlayer)
    local creatures = SvargrondArena.getPitCreatures(pitId)
    for i = 1, #creatures do
        if creatures[i]:isPlayer() and creatures[i]:getId() ~= ignorePlayer:getId() then
            return creatures[i]
        end
    end

    return nil
end

function SvargrondArena.kickPlayer(cid, hideMessage)
    SvargrondArena.cancelEvents(cid)
    local player = Player(cid)
    if not player then
        return
    end

    if player:getStorageValue(Storage.SvargrondArena.PitDoor) > 0 then
        player:teleportTo(SvargrondArena.kickPosition)
        SvargrondArena.kickPosition:sendMagicEffect(CONST_ME_TELEPORT)
        player:setStorageValue(Storage.SvargrondArena.PitDoor, 0)
        if not hideMessage then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Your time ran out!')
        end
    end
end

function SvargrondArena.cancelEvents(cid)
    local kickEvent = SvargrondArena.kickEvents[cid]
    if kickEvent then
        SvargrondArena.removeTimer(kickEvent.pitId)
        stopEvent(kickEvent.eventId)
    end
    SvargrondArena.kickEvents[cid] = nil
end

function SvargrondArena.scheduleKickPlayer(cid, pitId)
    SvargrondArena.cancelEvents(cid)
    SvargrondArena.startTimer(pitId)
    local eventId = addEvent(SvargrondArena.kickPlayer, SvargrondArena.kickTime * 1000, cid)
    SvargrondArena.kickEvents[cid] = {eventId = eventId, pitId = pitId}
end

function SvargrondArena.startTimer(pitId)
    local tile = Tile(PITS[pitId].fromPos)
    if not tile then
        return
    end

    local timerItem = tile:getItemById(SvargrondArena.itemTimer)
    if timerItem then
        timerItem:remove()
    end

    timerItem = Game.createItem(SvargrondArena.itemTimer, 1, PITS[pitId].fromPos)
    if timerItem then
        timerItem:decay()
    end

    if SvargrondArena.timerEvents[pitId] then
        stopEvent(SvargrondArena.timerEvents[pitId])
    end
    SvargrondArena.timerEvents[pitId] = addEvent(SvargrondArena.removeTimer, SvargrondArena.kickTime * 1000, pitId)
end

function SvargrondArena.removeTimer(pitId)
    local tile = Tile(PITS[pitId].fromPos)
    if not tile then
        return
    end

    local timerItem = tile:getItemById(SvargrondArena.itemTimer)
    if timerItem then
        timerItem:remove()
    end
    SvargrondArena.timerEvents[pitId] = nil
end

function SvargrondArena.sendPillarEffect(pitId)
    local positions = SvargrondArena.effectPositionCache[pitId]
    if not positions then
        local position = PITS[pitId].pillar
        local effectPositions = {
            Position(position.x - 1, position.y, position.z),
            Position(position.x + 1, position.y, position.z),
            Position(position.x + 1, position.y - 1, position.z),
            Position(position.x + 1, position.y + 1, position.z),
            Position(position.x, position.y, position.z)
        }
        SvargrondArena.effectPositionCache[pitId] = effectPositions
        positions = effectPositions
    end

    for i = 1, #positions do
        positions[i]:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
end
 
Lua:
--[[
TODO
- Include PITS and ARENA table in SvargrondArena -> SvargrondArena.arenas / SvargrondArena.PitDoors
- Restructure PITS and ARENA table (reward.storage does not seem to be used)
]]

SvargrondArena = {
    -- kick time in seconds (10 minutes)
    kickTime = 600,
    kickPosition = Position({x = 32251, y = 31098, z = 6}),
    rewardPosition = Position({x = 32222, y = 31080, z = 6}),

    -- used to store event ids
    kickEvents = {},
    timerEvents = {},
    effectPositionCache = {},

    -- item ids used by the script
    itemTimer = 10288,
    itemPillar = 1354,
    itemTeleport = 5023,
    itemsNotErasable = {10288, 1354, 1543, 1544, 1545},
}

-- Script automatically derives other pit positions from this one
local firstPit = {
    fromPos = {x = 32205, y = 31094, z = 7},
    toPos = {x = 32214, y = 31103, z = 7},
    center = {x = 32210, y = 31098, z = 7},
    pillar = {x = 32204, y = 31098, z = 7},
    tp = {x = 32204, y = 31098, z = 7},
    summon = {x = 32210, y = 31100, z = 7}
}

PITS = {
    [1] = {
        fromPos = firstPit.fromPos,
        toPos = firstPit.toPos,
        center = firstPit.center,
        pillar = firstPit.pillar,
        tp = firstPit.tp,
        summon = firstPit.summon
    },
    [2] = {
        fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 14, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [3] = {
        fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 28, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [4] = {
        fromPos = {x = firstPit.fromPos.x - 42, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 42, y = firstPit.toPos.y, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 42, y = firstPit.center.y, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 42, y = firstPit.pillar.y, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 42, y = firstPit.tp.y, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 42, y = firstPit.summon.y, z = firstPit.summon.z}
    },
    [5] = {
        fromPos = {x = firstPit.fromPos.x - 35, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 35, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 35, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 35, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 35, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 35, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [6] = {
        fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 21, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [7] = {
        fromPos = {x = firstPit.fromPos.x - 7, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 7, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 7, y = firstPit.center.y - 14, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 7, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 7, y = firstPit.tp.y - 14, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 7, y = firstPit.summon.y - 14, z = firstPit.summon.z}
    },
    [8] = {
        fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 14, y = firstPit.center.y - 28, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y - 28, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y - 28, z = firstPit.summon.z}
    },
    [9] = {
        fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 28, y = firstPit.center.y - 28, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y - 28, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y - 28, z = firstPit.summon.z}
    },
    [10] = {
        fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 42, z = firstPit.fromPos.z},
        toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 42, z = firstPit.toPos.z},
        center = {x = firstPit.center.x - 21, y = firstPit.center.y - 41, z = firstPit.center.z},
        pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 41, z = firstPit.pillar.z},
        tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 41, z = firstPit.tp.z},
        summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 41, z = firstPit.summon.z}
    }
}

ARENA = {
    [3264] = {
        name = 'Greenhorn',
        price = 1000,
        questLog = Storage.SvargrondArena.QuestLogGreenhorn,
        achievement = 'Greenhorn',
        creatures = {
            [1] = 'frostfur',
            [2] = 'bloodpaw',
            [3] = 'bovinus',
            [4] = 'achad',
            [5] = 'colerian the barbarian',
            [6] = 'the hairy one',
            [7] = 'axeitus headbanger',
            [8] = 'rocky',
            [9] = 'cursed gladiator',
            [10] = 'orcus the cruel'
        },
        reward = {
            trophy = 5807,
            trophyStorage = Storage.SvargrondArena.TrophyGreenhorn,
            desc = 'It is given to the courageous victor of the barbarian arena in greenhorn difficulty. Awarded to %s',
        }
    },
    [3265] = {
        name = 'Scrapper',
        price = 5000,
        questLog = Storage.SvargrondArena.QuestLogScrapper,
        achievement = 'Scrapper',
        creatures = {
            [1] = 'avalanche',
            [2] = 'kreebosh the exile',
            [3] = 'the dark dancer',
            [4] = 'the hag',
            [5] = 'slim',
            [6] = 'grimgor guteater',
            [7] = 'drasilla',
            [8] = 'spirit of earth',
            [9] = 'spirit of water',
            [10] = 'spirit of fire'
        },
        reward = {
            trophy = 5806,
            trophyStorage = Storage.SvargrondArena.TrophyScrapper,
            desc = 'It is given to the courageous victor of the barbarian arena in scrapper difficulty. Awarded to %s.',
        }
    },
    [3266] = {
        name = 'Warlord',
        price = 10000,
        questLog = Storage.SvargrondArena.QuestLogWarlord,
        achievement = 'Warlord of Svargrond',
        creatures = {
            [1] = 'webster',
            [2] = 'darakan the executioner',
            [3] = 'norgle glacierbeard',
            [4] = 'the pit lord',
            [5] = 'svoren the mad',
            [6] = 'the masked marauder',
            [7] = 'gnorre chyllson',
            [8] = 'fallen mooh\'tah master ghar',
            [9] = 'deathbringer',
            [10] = 'the obliverator'
        },
        reward = {
            trophy = 5805,
            trophyStorage = Storage.SvargrondArena.TrophyWarlord,
            desc = 'It is given to the courageous victor of the barbarian arena in warlord difficulty. Awarded to %s.',
        }
    }
}

function SvargrondArena.getPitCreatures(pitId)
    if not PITS[pitId] then
        return {}
    end

    local ret = {}
    local specs = Game.getSpectators(PITS[pitId].center, false, false, 5, 5, 5, 5)
    for i = 1, #specs do
        ret[#ret+1] = specs[i]
    end

    return ret
end

function SvargrondArena.resetPit(pitId)
    if not PITS[pitId] then
        return
    end

    for x = PITS[pitId].fromPos.x, PITS[pitId].toPos.x do
        for y = PITS[pitId].fromPos.y, PITS[pitId].toPos.y do
            for z = PITS[pitId].fromPos.z, PITS[pitId].toPos.z do
                local tile = Tile({x=x, y=y, z=z})
                if tile then
                    local movableItem = tile:getThing(255)
                    if movableItem and movableItem:isItem() then
                        local itemType = ItemType(movableItem:getId())
                        if itemType and itemType:isMovable() and not isInArray(SvargrondArena.itemsNotErasable, movableItem:getId()) then
                            moveableItem:remove()
                        end
                    end

                    local creature = tile:getTopCreature()
                    if creature and creature:isMonster() then
                        creature:remove()
                    end
                end
            end
        end
    end

    local pillarTile = Tile(PITS[pitId].pillar)
    if pillarTile then
        local teleportItem = pillarTile:getItemById(SvargrondArena.itemTeleport)
        if teleportItem then
            teleportItem:remove()
        end

        local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
        if not pillarItem then
            Game.createItem(SvargrondArena.itemPillar, 1, PITS[pitId].pillar)
        end
    end
end

function SvargrondArena.getPitOccupant(pitId, ignorePlayer)
    local creatures = SvargrondArena.getPitCreatures(pitId)
    for i = 1, #creatures do
        if creatures[i]:isPlayer() and creatures[i]:getId() ~= ignorePlayer:getId() then
            return creatures[i]
        end
    end

    return nil
end

function SvargrondArena.kickPlayer(cid, hideMessage)
    SvargrondArena.cancelEvents(cid)
    local player = Player(cid)
    if not player then
        return
    end

    if player:getStorageValue(Storage.SvargrondArena.PitDoor) > 0 then
        player:teleportTo(SvargrondArena.kickPosition)
        SvargrondArena.kickPosition:sendMagicEffect(CONST_ME_TELEPORT)
        player:setStorageValue(Storage.SvargrondArena.PitDoor, 0)
        if not hideMessage then
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Your time ran out!')
        end
    end
end

function SvargrondArena.cancelEvents(cid)
    local kickEvent = SvargrondArena.kickEvents[cid]
    if kickEvent then
        SvargrondArena.removeTimer(kickEvent.pitId)
        stopEvent(kickEvent.eventId)
    end
    SvargrondArena.kickEvents[cid] = nil
end

function SvargrondArena.scheduleKickPlayer(cid, pitId)
    SvargrondArena.cancelEvents(cid)
    SvargrondArena.startTimer(pitId)
    local eventId = addEvent(SvargrondArena.kickPlayer, SvargrondArena.kickTime * 1000, cid)
    SvargrondArena.kickEvents[cid] = {eventId = eventId, pitId = pitId}
end

function SvargrondArena.startTimer(pitId)
    local tile = Tile(PITS[pitId].fromPos)
    if not tile then
        return
    end

    local timerItem = tile:getItemById(SvargrondArena.itemTimer)
    if timerItem then
        timerItem:remove()
    end

    timerItem = Game.createItem(SvargrondArena.itemTimer, 1, PITS[pitId].fromPos)
    if timerItem then
        timerItem:decay()
    end

    if SvargrondArena.timerEvents[pitId] then
        stopEvent(SvargrondArena.timerEvents[pitId])
    end
    SvargrondArena.timerEvents[pitId] = addEvent(SvargrondArena.removeTimer, SvargrondArena.kickTime * 1000, pitId)
end

function SvargrondArena.removeTimer(pitId)
    local tile = Tile(PITS[pitId].fromPos)
    if not tile then
        return
    end

    local timerItem = tile:getItemById(SvargrondArena.itemTimer)
    if timerItem then
        timerItem:remove()
    end
    SvargrondArena.timerEvents[pitId] = nil
end

function SvargrondArena.sendPillarEffect(pitId)
    local positions = SvargrondArena.effectPositionCache[pitId]
    if not positions then
        local position = PITS[pitId].pillar
        local effectPositions = {
            Position(position.x - 1, position.y, position.z),
            Position(position.x + 1, position.y, position.z),
            Position(position.x + 1, position.y - 1, position.z),
            Position(position.x + 1, position.y + 1, position.z),
            Position(position.x, position.y, position.z)
        }
        SvargrondArena.effectPositionCache[pitId] = effectPositions
        positions = effectPositions
    end

    for i = 1, #positions do
        positions[i]:sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
end
So the way this is scripted makes it seem like it's a 1-time quest where you go greenhorn -> scrapper -> warlord -> finished.

But in real tibia you can re-do the quest infinite times, and in whatever skill/order you want.

But okay.. so idk which way to go, since Idk how the movements is setup..

So we'll alter the npc to match the table I guess.

change
Lua:
if arenaId < 1 then
    arenaId = 1
to
Lua:
if arenaId < 3264 then
    arenaId = 3264
 
Solution
Hey Xikini.

Now we are able to do the arena but we still not able to access the reward room. Do you know how to fix that?

Thank you.

arena.jpg
 
Hey Xikini.

Now we are able to do the arena but we still not able to access the reward room. Do you know how to fix that?

Thank you.

View attachment 49448
I would assume that these 3 uniqueid's need to be placed on those doors.
I'm only guessing though, as I don't see the actionscript responsible for that part of this quest in this thread.
Lua:
        GreenhornDoor = 51721,
        ScrapperDoor = 51722,
        WarlordDoor= 51723
 
I only have this one..

svargrond_arena.lua

--[[
TODO
  • Include PITS and ARENA table in SvargrondArena -> SvargrondArena.arenas / SvargrondArena.PitDoors
  • Restructure PITS and ARENA table (reward.storage does not seem to be used)
]]

SvargrondArena = {
-- kick time in seconds (10 minutes)
kickTime = 600,
kickPosition = Position({x = 32251, y = 31098, z = 6}),
rewardPosition = Position({x = 32222, y = 31080, z = 6}),

-- used to store event ids
kickEvents = {},
timerEvents = {},
effectPositionCache = {},

-- item ids used by the script
itemTimer = 10288,
itemPillar = 1354,
itemTeleport = 5023,
itemsNotErasable = {10288, 1354, 1543, 1544, 1545},
}

-- Script automatically derives other pit positions from this one
local firstPit = {
fromPos = {x = 32205, y = 31094, z = 7},
toPos = {x = 32214, y = 31103, z = 7},
center = {x = 32210, y = 31098, z = 7},
pillar = {x = 32204, y = 31098, z = 7},
tp = {x = 32204, y = 31098, z = 7},
summon = {x = 32210, y = 31100, z = 7}
}

PITS = {
[1] = {
fromPos = firstPit.fromPos,
toPos = firstPit.toPos,
center = firstPit.center,
pillar = firstPit.pillar,
tp = firstPit.tp,
summon = firstPit.summon
},
[2] = {
fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 14, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y, z = firstPit.summon.z}
},
[3] = {
fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 28, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y, z = firstPit.summon.z}
},
[4] = {
fromPos = {x = firstPit.fromPos.x - 42, y = firstPit.fromPos.y, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 42, y = firstPit.toPos.y, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 42, y = firstPit.center.y, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 42, y = firstPit.pillar.y, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 42, y = firstPit.tp.y, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 42, y = firstPit.summon.y, z = firstPit.summon.z}
},
[5] = {
fromPos = {x = firstPit.fromPos.x - 35, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 35, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 35, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 35, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 35, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 35, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[6] = {
fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 21, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[7] = {
fromPos = {x = firstPit.fromPos.x - 7, y = firstPit.fromPos.y - 14, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 7, y = firstPit.toPos.y - 14, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 7, y = firstPit.center.y - 14, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 7, y = firstPit.pillar.y - 14, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 7, y = firstPit.tp.y - 14, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 7, y = firstPit.summon.y - 14, z = firstPit.summon.z}
},
[8] = {
fromPos = {x = firstPit.fromPos.x - 14, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 14, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 14, y = firstPit.center.y - 28, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 14, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 14, y = firstPit.tp.y - 28, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 14, y = firstPit.summon.y - 28, z = firstPit.summon.z}
},
[9] = {
fromPos = {x = firstPit.fromPos.x - 28, y = firstPit.fromPos.y - 28, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 28, y = firstPit.toPos.y - 28, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 28, y = firstPit.center.y - 28, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 28, y = firstPit.pillar.y - 28, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 28, y = firstPit.tp.y - 28, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 28, y = firstPit.summon.y - 28, z = firstPit.summon.z}
},
[10] = {
fromPos = {x = firstPit.fromPos.x - 21, y = firstPit.fromPos.y - 42, z = firstPit.fromPos.z},
toPos = {x = firstPit.toPos.x - 21, y = firstPit.toPos.y - 42, z = firstPit.toPos.z},
center = {x = firstPit.center.x - 21, y = firstPit.center.y - 41, z = firstPit.center.z},
pillar = {x = firstPit.pillar.x - 21, y = firstPit.pillar.y - 41, z = firstPit.pillar.z},
tp = {x = firstPit.tp.x - 21, y = firstPit.tp.y - 41, z = firstPit.tp.z},
summon = {x = firstPit.summon.x - 21, y = firstPit.summon.y - 41, z = firstPit.summon.z}
}
}

ARENA = {
[3264] = {
name = 'Greenhorn',
price = 1000,
questLog = Storage.SvargrondArena.QuestLogGreenhorn,
achievement = 'Greenhorn',
creatures = {
[1] = 'frostfur',
[2] = 'bloodpaw',
[3] = 'bovinus',
[4] = 'achad',
[5] = 'colerian the barbarian',
[6] = 'the hairy one',
[7] = 'axeitus headbanger',
[8] = 'rocky',
[9] = 'cursed gladiator',
[10] = 'orcus the cruel'
},
reward = {
trophy = 5807,
trophyStorage = Storage.SvargrondArena.TrophyGreenhorn,
desc = 'It is given to the courageous victor of the barbarian arena in greenhorn difficulty. Awarded to %s',
}
},
[3265] = {
name = 'Scrapper',
price = 5000,
questLog = Storage.SvargrondArena.QuestLogScrapper,
achievement = 'Scrapper',
creatures = {
[1] = 'avalanche',
[2] = 'kreebosh the exile',
[3] = 'the dark dancer',
[4] = 'the hag',
[5] = 'slim',
[6] = 'grimgor guteater',
[7] = 'drasilla',
[8] = 'spirit of earth',
[9] = 'spirit of water',
[10] = 'spirit of fire'
},
reward = {
trophy = 5806,
trophyStorage = Storage.SvargrondArena.TrophyScrapper,
desc = 'It is given to the courageous victor of the barbarian arena in scrapper difficulty. Awarded to %s.',
}
},
[3266] = {
name = 'Warlord',
price = 10000,
questLog = Storage.SvargrondArena.QuestLogWarlord,
achievement = 'Warlord of Svargrond',
creatures = {
[1] = 'webster',
[2] = 'darakan the executioner',
[3] = 'norgle glacierbeard',
[4] = 'the pit lord',
[5] = 'svoren the mad',
[6] = 'the masked marauder',
[7] = 'gnorre chyllson',
[8] = 'fallen mooh\'tah master ghar',
[9] = 'deathbringer',
[10] = 'the obliverator'
},
reward = {
trophy = 5805,
trophyStorage = Storage.SvargrondArena.TrophyWarlord,
desc = 'It is given to the courageous victor of the barbarian arena in warlord difficulty. Awarded to %s.',
}
}
}

function SvargrondArena.getPitCreatures(pitId)
if not PITS[pitId] then
return {}
end

local ret = {}
local specs = Game.getSpectators(PITS[pitId].center, false, false, 5, 5, 5, 5)
for i = 1, #specs do
ret[#ret+1] = specs
end

return ret
end

function SvargrondArena.resetPit(pitId)
if not PITS[pitId] then
return
end

for x = PITS[pitId].fromPos.x, PITS[pitId].toPos.x do
for y = PITS[pitId].fromPos.y, PITS[pitId].toPos.y do
for z = PITS[pitId].fromPos.z, PITS[pitId].toPos.z do
local tile = Tile({x=x, y=y, z=z})
if tile then
local movableItem = tile:getThing(255)
if movableItem and movableItem:isItem() then
local itemType = ItemType(movableItem:getId())
if itemType and itemType:isMovable() and not isInArray(SvargrondArena.itemsNotErasable, movableItem:getId()) then
moveableItem:remove()
end
end

local creature = tile:getTopCreature()
if creature and creature:isMonster() then
creature:remove()
end
end
end
end
end

local pillarTile = Tile(PITS[pitId].pillar)
if pillarTile then
local teleportItem = pillarTile:getItemById(SvargrondArena.itemTeleport)
if teleportItem then
teleportItem:remove()
end

local pillarItem = pillarTile:getItemById(SvargrondArena.itemPillar)
if not pillarItem then
Game.createItem(SvargrondArena.itemPillar, 1, PITS[pitId].pillar)
end
end
end

function SvargrondArena.getPitOccupant(pitId, ignorePlayer)
local creatures = SvargrondArena.getPitCreatures(pitId)
for i = 1, #creatures do
if creatures:isPlayer() and creatures:getId() ~= ignorePlayer:getId() then
return creatures
end
end

return nil
end

function SvargrondArena.kickPlayer(cid, hideMessage)
SvargrondArena.cancelEvents(cid)
local player = Player(cid)
if not player then
return
end

if player:getStorageValue(Storage.SvargrondArena.PitDoor) > 0 then
player:teleportTo(SvargrondArena.kickPosition)
SvargrondArena.kickPosition:sendMagicEffect(CONST_ME_TELEPORT)
player:setStorageValue(Storage.SvargrondArena.PitDoor, 0)
if not hideMessage then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Your time ran out!')
end
end
end

function SvargrondArena.cancelEvents(cid)
local kickEvent = SvargrondArena.kickEvents[cid]
if kickEvent then
SvargrondArena.removeTimer(kickEvent.pitId)
stopEvent(kickEvent.eventId)
end
SvargrondArena.kickEvents[cid] = nil
end

function SvargrondArena.scheduleKickPlayer(cid, pitId)
SvargrondArena.cancelEvents(cid)
SvargrondArena.startTimer(pitId)
local eventId = addEvent(SvargrondArena.kickPlayer, SvargrondArena.kickTime * 1000, cid)
SvargrondArena.kickEvents[cid] = {eventId = eventId, pitId = pitId}
end

function SvargrondArena.startTimer(pitId)
local tile = Tile(PITS[pitId].fromPos)
if not tile then
return
end

local timerItem = tile:getItemById(SvargrondArena.itemTimer)
if timerItem then
timerItem:remove()
end

timerItem = Game.createItem(SvargrondArena.itemTimer, 1, PITS[pitId].fromPos)
if timerItem then
timerItem:decay()
end

if SvargrondArena.timerEvents[pitId] then
stopEvent(SvargrondArena.timerEvents[pitId])
end
SvargrondArena.timerEvents[pitId] = addEvent(SvargrondArena.removeTimer, SvargrondArena.kickTime * 1000, pitId)
end

function SvargrondArena.removeTimer(pitId)
local tile = Tile(PITS[pitId].fromPos)
if not tile then
return
end

local timerItem = tile:getItemById(SvargrondArena.itemTimer)
if timerItem then
timerItem:remove()
end
SvargrondArena.timerEvents[pitId] = nil
end

function SvargrondArena.sendPillarEffect(pitId)
local positions = SvargrondArena.effectPositionCache[pitId]
if not positions then
local position = PITS[pitId].pillar
local effectPositions = {
Position(position.x - 1, position.y, position.z),
Position(position.x + 1, position.y, position.z),
Position(position.x + 1, position.y - 1, position.z),
Position(position.x + 1, position.y + 1, position.z),
Position(position.x, position.y, position.z)
}
SvargrondArena.effectPositionCache[pitId] = effectPositions
positions = effectPositions
end

for i = 1, #positions do
positions:sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
end

Post automatically merged:

Action is already linked with that number...


21:45 You see a closed door.
Item ID: 5132, Action ID: 51721
Client ID: 5131
Position: 32227, 31066, 7

21:45 The door seems to be sealed against unwanted intruders.
21:45 You see a closed door.
Item ID: 5132, Action ID: 51722
Client ID: 5131
Position: 32227, 31059, 7

21:45 You see a closed door.
Item ID: 5132, Action ID: 51723
Client ID: 5131
Position: 32227, 31052, 7
 
Last edited:
Back
Top