From 4b57c4e08928fc215517bca575209c34aec8dbda Mon Sep 17 00:00:00 2001 From: HT Cesta <58153179+htc16@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:47:15 -0300 Subject: [PATCH] Ferumbras Ascension - Levers --- .../actions_ferumbras_lever.lua | 164 ++++++++---------- .../ferumbras_ascension/actions_mazoran.lua | 135 ++++---------- .../ferumbras_ascension/actions_plagirath.lua | 130 ++++---------- .../ferumbras_ascension/actions_rat_lever.lua | 119 ++++--------- .../ferumbras_ascension/actions_shulgrax.lua | 135 ++++---------- .../ferumbras_ascension/actions_tarbaz.lua | 132 ++++---------- .../actions_the_shatterer_lever.lua | 127 ++++---------- .../actions_the_shatterer_levers.lua | 41 +++-- .../ferumbras_ascension/actions_zamulosh.lua | 155 ++++------------- 9 files changed, 342 insertions(+), 796 deletions(-) diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_lever.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_lever.lua index 80c82795673..a32ae4340bf 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_lever.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_lever.lua @@ -1,113 +1,91 @@ +local crystals = { + [1] = {crystalPosition = Position(33390, 31468, 14), globalStorage = Storage.Quest.U10_90.FerumbrasAscension.Crystals.Crystal1}, + [2] = {crystalPosition = Position(33394, 31468, 14), globalStorage = Storage.Quest.U10_90.FerumbrasAscension.Crystals.Crystal2}, + [3] = {crystalPosition = Position(33397, 31471, 14), globalStorage = Storage.Quest.U10_90.FerumbrasAscension.Crystals.Crystal3}, + [4] = {crystalPosition = Position(33397, 31475, 14), globalStorage = Storage.Quest.U10_90.FerumbrasAscension.Crystals.Crystal4}, + [5] = {crystalPosition = Position(33394, 31478, 14), globalStorage = Storage.Quest.U10_90.FerumbrasAscension.Crystals.Crystal5}, + [6] = {crystalPosition = Position(33390, 31478, 14), globalStorage = Storage.Quest.U10_90.FerumbrasAscension.Crystals.Crystal6}, + [7] = {crystalPosition = Position(33387, 31475, 14), globalStorage = Storage.Quest.U10_90.FerumbrasAscension.Crystals.Crystal7}, + [8] = {crystalPosition = Position(33387, 31471, 14), globalStorage = Storage.Quest.U10_90.FerumbrasAscension.Crystals.Crystal8} +} + local config = { - boss = { - name = "Ferumbras Mortal Shell", - position = Position(33392, 31473, 14), - }, + centerRoom = Position(33392, 31473, 14), + BossPosition = Position(33392, 31473, 14), playerPositions = { - { pos = Position(33269, 31477, 14), teleport = Position(33390, 31483, 14), effect = CONST_ME_TELEPORT }, - }, - specPos = { - from = Position(33374, 31458, 14), - to = Position(33414, 31498, 14), + Position(33269, 31477, 14), + Position(33269, 31478, 14), + Position(33269, 31479, 14), + Position(33269, 31480, 14), + Position(33269, 31481, 14), + Position(33270, 31477, 14), + Position(33270, 31478, 14), + Position(33270, 31479, 14), + Position(33270, 31480, 14), + Position(33270, 31481, 14), + Position(33271, 31477, 14), + Position(33271, 31478, 14), + Position(33271, 31479, 14), + Position(33271, 31480, 14), + Position(33271, 31481, 14) }, - exit = Position(33319, 32318, 13), - centerRoom = Position(33392, 31473, 14), - summonName = "Rift Fragment", - maxSummon = 3, + newPosition = Position(33392, 31479, 14) } local leverFerumbras = Action() function leverFerumbras.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local cooldownTime = player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.FerumbrasMortalShellTime) - if cooldownTime > os.time() then - local remainingTime = cooldownTime - os.time() - local hours = math.floor(remainingTime / 3600) - local minutes = math.floor((remainingTime % 3600) / 60) - player:sendCancelMessage("You must wait " .. hours .. " hours and " .. minutes .. " minutes to challenge again.") - return true - end - - local spectators = Game.getSpectators(config.specPos.from, false, false, 0, 0, 0, 0, config.specPos.to) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - player:say("Someone is already inside the room.", TALKTYPE_MONSTER_SAY) - return true - end - end - - if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then - player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY) - return true - end - - local players = {} - for i = 1, #config.playerPositions do - local pos = config.playerPositions[i].pos - local creature = Tile(pos):getTopCreature() - if not creature or not creature:isPlayer() then - player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".") + local playersTable = {} + if item.itemid == 8911 then + if player:getPosition() ~= Position(33270, 31477, 14) then + item:transform(8912) return true end - table.insert(players, creature) - end - - for i = 1, #players do - local playerToTeleport = players[i] - local teleportPos = config.playerPositions[i].teleport - local effect = config.playerPositions[i].effect - playerToTeleport:teleportTo(teleportPos) - teleportPos:sendMagicEffect(effect) - end - - Game.createMonster(config.boss.name, config.boss.position, true, true) - for b = 1, config.maxSummon do - local xrand = math.random(-5, 5) - local yrand = math.random(-5, 5) - local position = Position(config.boss.position.x + xrand, config.boss.position.y + yrand, config.boss.position.z) - Game.createMonster(config.summonName, position) end - if item.itemid == 8911 then - item:transform(8912) - else - item:transform(8911) - end - - return true -end - -function clearBossRoom(fromPos, toPos, exitPos) - local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - spec:teleportTo(exitPos) - exitPos:sendMagicEffect(CONST_ME_TELEPORT) - spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.") - else - spec:remove() - end - end -end - -function isBossInRoom(fromPos, toPos, bossName) - local monstersRemoved = false - for x = fromPos.x, toPos.x do - for y = fromPos.y, toPos.y do - for z = fromPos.z, toPos.z do - local tile = Tile(Position(x, y, z)) - if tile then - local creature = tile:getTopCreature() - if creature and creature:isMonster() then - creature:remove() - monstersRemoved = true + if doCheckBossRoom(player:getId(), "Ascending Ferumbras", Position(33379, 31460, 14), Position(33405, 31485, 14)) then + Game.createMonster("Ascending Ferumbras", config.BossPosition, true, true) + for b = 1,10 do + local xrand = math.random(-10, 10) + local yrand = math.random(-10, 10) + local position = Position(33392 + xrand, 31473 + yrand, 14) + if Game.createMonster("rift invader", position) then + end + end + for x = 33269, 33271 do + for y = 31477, 31481 do + local playerTile = Tile(Position(x, y, 14)):getTopCreature() + if playerTile and playerTile:isPlayer() then + playerTile:getPosition():sendMagicEffect(CONST_ME_POFF) + playerTile:teleportTo(config.newPosition) + playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + playerTile:setStorageValue(Storage.FerumbrasAscension.FerumbrasTimer, os.time() + 60 * 60 * 20 * 24) + table.insert(playersTable, playerTile:getId()) end end end + Game.setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.Crystals.AllCrystals, 0) + Game.setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.FerumbrasEssence, 0) + for _, crystal in pairs(crystals) do + local pos = crystal.crystalPosition + local stg = crystal.globalStorage + local sqm = Tile(pos) + if sqm then + local item = sqm:getItemById(17586) + if item then + item:transform(17580) + end + end + Game.setStorageValue(stg, 0) + end + addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, Position(33379, 31460, 14), Position(33405, 31485, 14), Position(33319, 32318, 13)) + item:transform(8912) end + elseif item.itemid == 8912 then + item:transform(8911) end - return monstersRemoved + return true end leverFerumbras:uid(1021) -leverFerumbras:register() +leverFerumbras:register() \ No newline at end of file diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_mazoran.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_mazoran.lua index 7edf91121fd..fca741dfd17 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_mazoran.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_mazoran.lua @@ -1,119 +1,58 @@ local config = { - boss = { - name = "Mazoran", - position = Position(33584, 32689, 14), - }, - timeToDefeat = 17 * 60, -- 17 minutes in seconds + centerRoom = Position(33584, 32689, 14), + BossPosition = Position(33584, 32689, 14), playerPositions = { - { pos = Position(33593, 32644, 14), teleport = Position(33585, 32693, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33593, 32645, 14), teleport = Position(33585, 32693, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33593, 32646, 14), teleport = Position(33585, 32693, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33593, 32647, 14), teleport = Position(33585, 32693, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33593, 32648, 14), teleport = Position(33585, 32693, 14), effect = CONST_ME_TELEPORT }, - }, - specPos = { - from = Position(33570, 32677, 14), - to = Position(33597, 32700, 14), + Position(33593, 32644, 14), + Position(33593, 32645, 14), + Position(33593, 32646, 14), + Position(33593, 32647, 14), + Position(33593, 32648, 14) }, - exit = Position(33319, 32318, 13), + newPosition = Position(33585, 32693, 14) } local leverMazoran = Action() function leverMazoran.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local players = {} - local spectators = Game.getSpectators(config.specPos.from, false, false, 0, 0, 0, 0, config.specPos.to) - - for i = 1, #config.playerPositions do - local pos = config.playerPositions[i].pos - local creature = Tile(pos):getTopCreature() - - if not creature or not creature:isPlayer() then - player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".") - return true - end - - local cooldownTime = creature:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.MazoranTime) - if cooldownTime > os.time() then - local remainingTime = cooldownTime - os.time() - local hours = math.floor(remainingTime / 3600) - local minutes = math.floor((remainingTime % 3600) / 60) - player:sendCancelMessage(creature:getName() .. " must wait " .. hours .. " hours and " .. minutes .. " minutes to challenge again.") - return true - end - - if creature:getLevel() < config.requiredLevel then - player:sendCancelMessage(creature:getName() .. " needs to be at least level " .. config.requiredLevel .. " to challenge " .. config.boss.name .. ".") - return true - end - - table.insert(players, creature) - end - - for _, spec in pairs(spectators) do - if spec:isPlayer() then - player:say("Someone is already inside the room.", TALKTYPE_MONSTER_SAY) + if item.itemid == 8911 then + if player:getPosition() ~= Position(33593, 32644, 14) then + item:transform(8912) return true end end - if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then - player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY) - return true - end - - for i = 1, #players do - local playerToTeleport = players[i] - local teleportPos = config.playerPositions[i].teleport - local effect = config.playerPositions[i].effect - playerToTeleport:teleportTo(teleportPos) - teleportPos:sendMagicEffect(effect) - end - - local boss = Game.createMonster(config.boss.name, config.boss.position) - - addEvent(clearBossRoom, config.timeToDefeat * 1000, config.specPos.from, config.specPos.to, config.exit) - if item.itemid == 8911 then - item:transform(8912) - else + local playersTable = {} + if doCheckBossRoom(player:getId(), "Mazoran", Position(33572, 32679, 14), Position(33599, 32701, 14)) then + local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15) + for i = 1, #specs do + spec = specs[i] + if spec:isPlayer() then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with Mazoran.") + return true + end + end + Game.createMonster("Mazoran", config.BossPosition, true, true) + for y = 32644, 32648 do + local playerTile = Tile(Position(33593, y, 14)):getTopCreature() + if playerTile and playerTile:isPlayer() then + playerTile:getPosition():sendMagicEffect(CONST_ME_POFF) + playerTile:teleportTo(config.newPosition) + playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + playerTile:setStorageValue(Storage.FerumbrasAscension.MazoranTimer, os.time() + os.time() + 60 * 60 * 2 * 24) + table.insert(playersTable, playerTile:getId()) + end + end + addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, Position(33572, 32679, 14), Position(33599, 32701, 14), Position(33319, 32318, 13)) + item:transform(8912) + end + elseif item.itemid == 8912 then item:transform(8911) end return true end -function clearBossRoom(fromPos, toPos, exitPos) - local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - spec:teleportTo(exitPos) - exitPos:sendMagicEffect(CONST_ME_TELEPORT) - spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.") - else - spec:remove() - end - end -end - -function isBossInRoom(fromPos, toPos, bossName) - local monstersRemoved = false - for x = fromPos.x, toPos.x do - for y = fromPos.y, toPos.y do - for z = fromPos.z, toPos.z do - local tile = Tile(Position(x, y, z)) - if tile then - local creature = tile:getTopCreature() - if creature and creature:isMonster() then - creature:remove() - monstersRemoved = true - end - end - end - end - end - return monstersRemoved -end leverMazoran:uid(1025) -leverMazoran:register() +leverMazoran:register() \ No newline at end of file diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_plagirath.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_plagirath.lua index a3ed6fd05d3..2cc68052073 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_plagirath.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_plagirath.lua @@ -1,119 +1,57 @@ local config = { - boss = { - name = "Plagirath", - position = Position(33172, 31501, 13), - }, - timeToDefeat = 17 * 60, -- 17 minutes in seconds + centerRoom = Position(33172, 31501, 13), + BossPosition = Position(33172, 31501, 13), playerPositions = { - { pos = Position(33229, 31500, 13), teleport = Position(33173, 31504, 13), effect = CONST_ME_TELEPORT }, - { pos = Position(33229, 31501, 13), teleport = Position(33173, 31504, 13), effect = CONST_ME_TELEPORT }, - { pos = Position(33229, 31502, 13), teleport = Position(33173, 31504, 13), effect = CONST_ME_TELEPORT }, - { pos = Position(33229, 31503, 13), teleport = Position(33173, 31504, 13), effect = CONST_ME_TELEPORT }, - { pos = Position(33229, 31504, 13), teleport = Position(33173, 31504, 13), effect = CONST_ME_TELEPORT }, - }, - specPos = { - from = Position(33159, 31488, 13), - to = Position(33190, 31515, 13), + Position(33229, 31500, 13), + Position(33229, 31501, 13), + Position(33229, 31502, 13), + Position(33229, 31503, 13), + Position(33229, 31504, 13) }, - exit = Position(33319, 32318, 13), + newPosition = Position(33173, 31504, 13) } local leverPlagirath = Action() function leverPlagirath.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local players = {} - local spectators = Game.getSpectators(config.specPos.from, false, false, 0, 0, 0, 0, config.specPos.to) - - for i = 1, #config.playerPositions do - local pos = config.playerPositions[i].pos - local creature = Tile(pos):getTopCreature() - - if not creature or not creature:isPlayer() then - player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".") + if item.itemid == 8911 then + if player:getPosition() ~= Position(33229, 31500, 13) then + item:transform(8912) return true end - - local cooldownTime = creature:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.PlagirathTime) - if cooldownTime > os.time() then - local remainingTime = cooldownTime - os.time() - local hours = math.floor(remainingTime / 3600) - local minutes = math.floor((remainingTime % 3600) / 60) - player:sendCancelMessage(creature:getName() .. " must wait " .. hours .. " hours and " .. minutes .. " minutes to challenge again.") + end + if item.itemid == 8911 then + if Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.PlagirathTimer) >= 1 then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait a while, recently someone challenge Plagirath.") return true end - - if creature:getLevel() < config.requiredLevel then - player:sendCancelMessage(creature:getName() .. " needs to be at least level " .. config.requiredLevel .. " to challenge " .. config.boss.name .. ".") - return true + local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15) + for i = 1, #specs do + spec = specs[i] + if spec:isPlayer() then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with Plagirath.") + return true + end end - - table.insert(players, creature) - end - - for _, spec in pairs(spectators) do - if spec:isPlayer() then - player:say("Someone is already inside the room.", TALKTYPE_MONSTER_SAY) - return true + Game.createMonster("Plagirath", config.BossPosition, true, true) + for y = 31500, 31504 do + local playerTile = Tile(Position(33229, y, 13)):getTopCreature() + if playerTile and playerTile:isPlayer() then + playerTile:getPosition():sendMagicEffect(CONST_ME_POFF) + playerTile:teleportTo(config.newPosition) + playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + playerTile:setStorageValue(Storage.FerumbrasAscension.PlagirathTimer, os.time() + 60 * 60 * 24 * 2) + end end - end - - if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then - player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY) - return true - end - - for i = 1, #players do - local playerToTeleport = players[i] - local teleportPos = config.playerPositions[i].teleport - local effect = config.playerPositions[i].effect - playerToTeleport:teleportTo(teleportPos) - teleportPos:sendMagicEffect(effect) - end - - Game.createMonster(config.boss.name, config.boss.position) - - addEvent(clearBossRoom, config.timeToDefeat * 1000, config.specPos.from, config.specPos.to, config.exit) - - if item.itemid == 8911 then + Game.setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.PlagirathTimer, 1) + addEvent(clearForgotten, 30 * 60 * 1000, Position(33159, 31491, 13), Position(33185, 31513, 13), Position(33319, 32318, 13), Storage.Quest.U10_90.FerumbrasAscension.PlagirathTimer) item:transform(8912) - else + elseif item.itemid == 8912 then item:transform(8911) end return true end -function clearBossRoom(fromPos, toPos, exitPos) - local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - spec:teleportTo(exitPos) - exitPos:sendMagicEffect(CONST_ME_TELEPORT) - spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.") - else - spec:remove() - end - end -end - -function isBossInRoom(fromPos, toPos, bossName) - local monstersRemoved = false - for x = fromPos.x, toPos.x do - for y = fromPos.y, toPos.y do - for z = fromPos.z, toPos.z do - local tile = Tile(Position(x, y, z)) - if tile then - local creature = tile:getTopCreature() - if creature and creature:isMonster() then - creature:remove() - monstersRemoved = true - end - end - end - end - end - return monstersRemoved -end - leverPlagirath:uid(1022) leverPlagirath:register() diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_rat_lever.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_rat_lever.lua index 13ef7bb84e2..434ffdf1776 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_rat_lever.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_rat_lever.lua @@ -1,102 +1,57 @@ local config = { - boss = { - name = "The Lord of The Lice", - position = Position(33220, 31460, 12), - }, - timeToDefeat = 17 * 60, -- 17 minutes in seconds + centerRoom = Position(33215, 31456, 12), + BossPosition = Position(33220, 31460, 12), playerPositions = { - { pos = Position(33197, 31475, 11), teleport = Position(33215, 31470, 12), effect = CONST_ME_TELEPORT }, - { pos = Position(33198, 31475, 11), teleport = Position(33215, 31470, 12), effect = CONST_ME_TELEPORT }, - { pos = Position(33199, 31475, 11), teleport = Position(33215, 31470, 12), effect = CONST_ME_TELEPORT }, - { pos = Position(33200, 31475, 11), teleport = Position(33215, 31470, 12), effect = CONST_ME_TELEPORT }, - { pos = Position(33201, 31475, 11), teleport = Position(33215, 31470, 12), effect = CONST_ME_TELEPORT }, - }, - specPos = { - from = Position(33187, 31429, 12), - to = Position(33242, 31487, 12), + Position(33197, 31475, 11), + Position(33198, 31475, 11), + Position(33199, 31475, 11), + Position(33200, 31475, 11), + Position(33201, 31475, 11) }, - exit = Position(33319, 32318, 13), + newPosition = Position(33215, 31470, 12) } local ferumbrasAscendantRatLever = Action() function ferumbrasAscendantRatLever.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local spectators = Game.getSpectators(config.specPos.from, false, false, 0, 0, 0, 0, config.specPos.to) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - player:say("Someone is already inside the room.", TALKTYPE_MONSTER_SAY) - return true - end - end - - if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then - player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY) - return true - end - - local players = {} - for i = 1, #config.playerPositions do - local pos = config.playerPositions[i].pos - local creature = Tile(pos):getTopCreature() - if not creature or not creature:isPlayer() then - player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".") + if item.itemid == 8911 then + if player:getPosition() ~= Position(33201, 31475, 11) then + item:transform(8912) return true end - table.insert(players, creature) - end - - for i = 1, #players do - local playerToTeleport = players[i] - local teleportPos = config.playerPositions[i].teleport - local effect = config.playerPositions[i].effect - playerToTeleport:teleportTo(teleportPos) - teleportPos:sendMagicEffect(effect) end - Game.createMonster(config.boss.name, config.boss.position) - - addEvent(clearBossRoom, config.timeToDefeat * 1000, config.specPos.from, config.specPos.to, config.exit) - if item.itemid == 8911 then - item:transform(8912) - else - item:transform(8911) - end - - return true -end - -function clearBossRoom(fromPos, toPos, exitPos) - local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - spec:teleportTo(exitPos) - exitPos:sendMagicEffect(CONST_ME_TELEPORT) - spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.") - else - spec:remove() - end - end -end - -function isBossInRoom(fromPos, toPos, bossName) - local bossRemoved = false - for x = fromPos.x, toPos.x do - for y = fromPos.y, toPos.y do - for z = fromPos.z, toPos.z do - local tile = Tile(Position(x, y, z)) - if tile then - local creature = tile:getTopCreature() - if creature and creature:isMonster() and creature:getName() == bossName then - creature:remove() - bossRemoved = true - end + local playersTable = {} + if doCheckBossRoom(player:getId(), "The Lord of the Lice", Position(33187, 31429, 12), Position(33242, 31487, 12)) then + local specs, spec = Game.getSpectators(config.centerRoom, false, false, 30, 30, 30, 30) + for i = 1, #specs do + spec = specs[i] + if spec:isPlayer() then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with The Lord of The Lice.") + return true + end + end + Game.createMonster("the lord of the lice", config.BossPosition, true, true) + for x = 33197, 33201 do + local playerTile = Tile(Position(x, 31475, 11)):getTopCreature() + if playerTile and playerTile:isPlayer() then + playerTile:getPosition():sendMagicEffect(CONST_ME_POFF) + playerTile:teleportTo(config.newPosition) + playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + playerTile:setStorageValue(Storage.FerumbrasAscension.TheLordOfTheLiceTimer, os.time() + 60 * 60 * 2 * 24) + table.insert(playersTable, playerTile:getId()) end end + addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, Position(33187, 31429, 12), Position(33242, 31487, 12), Position(33319, 32318, 13)) + item:transform(8912) end + elseif item.itemid == 8912 then + item:transform(8911) end - return bossRemoved + + return true end ferumbrasAscendantRatLever:uid(1030) -ferumbrasAscendantRatLever:register() +ferumbrasAscendantRatLever:register() \ No newline at end of file diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_shulgrax.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_shulgrax.lua index 61f7bc205ec..1e029ab47f2 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_shulgrax.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_shulgrax.lua @@ -1,118 +1,55 @@ local config = { - boss = { - name = "Shulgrax", - position = Position(33485, 32786, 13), - }, - timeToDefeat = 17 * 60, -- 17 minutes in seconds + centerRoom = Position(33485, 32786, 13), + BossPosition = Position(33485, 32786, 13), playerPositions = { - { pos = Position(33434, 32785, 13), teleport = Position(33485, 32790, 13), effect = CONST_ME_TELEPORT }, - { pos = Position(33434, 32786, 13), teleport = Position(33485, 32790, 13), effect = CONST_ME_TELEPORT }, - { pos = Position(33434, 32787, 13), teleport = Position(33485, 32790, 13), effect = CONST_ME_TELEPORT }, - { pos = Position(33434, 32788, 13), teleport = Position(33485, 32790, 13), effect = CONST_ME_TELEPORT }, - { pos = Position(33434, 32789, 13), teleport = Position(33485, 32790, 13), effect = CONST_ME_TELEPORT }, - }, - specPos = { - from = Position(33474, 32775, 13), - to = Position(33496, 32798, 13), + Position(33434, 32785, 13), + Position(33434, 32786, 13), + Position(33434, 32787, 13), + Position(33434, 32788, 13), + Position(33434, 32789, 13) }, - exit = Position(33319, 32318, 13), + newPosition = Position(33485, 32790, 13) } local leverShulgrax = Action() function leverShulgrax.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local players = {} - local spectators = Game.getSpectators(config.specPos.from, false, false, 0, 0, 0, 0, config.specPos.to) - - for i = 1, #config.playerPositions do - local pos = config.playerPositions[i].pos - local creature = Tile(pos):getTopCreature() - - if not creature or not creature:isPlayer() then - player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".") - return true - end - - local cooldownTime = creature:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.ShulgraxTime) - if cooldownTime > os.time() then - local remainingTime = cooldownTime - os.time() - local hours = math.floor(remainingTime / 3600) - local minutes = math.floor((remainingTime % 3600) / 60) - player:sendCancelMessage(creature:getName() .. " must wait " .. hours .. " hours and " .. minutes .. " minutes to challenge again.") - return true - end - - if creature:getLevel() < config.requiredLevel then - player:sendCancelMessage(creature:getName() .. " needs to be at least level " .. config.requiredLevel .. " to challenge " .. config.boss.name .. ".") - return true - end - - table.insert(players, creature) - end - - for _, spec in pairs(spectators) do - if spec:isPlayer() then - player:say("Someone is already inside the room.", TALKTYPE_MONSTER_SAY) + if item.itemid == 8911 then + if player:getPosition() ~= Position(33434, 32785, 13) then + item:transform(8912) return true end end - - if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then - player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY) - return true - end - - for i = 1, #players do - local playerToTeleport = players[i] - local teleportPos = config.playerPositions[i].teleport - local effect = config.playerPositions[i].effect - playerToTeleport:teleportTo(teleportPos) - teleportPos:sendMagicEffect(effect) - end - - Game.createMonster(config.boss.name, config.boss.position) - - addEvent(clearBossRoom, config.timeToDefeat * 1000, config.specPos.from, config.specPos.to, config.exit) - if item.itemid == 8911 then - item:transform(8912) - else - item:transform(8911) - end - - return true -end - -function clearBossRoom(fromPos, toPos, exitPos) - local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - spec:teleportTo(exitPos) - exitPos:sendMagicEffect(CONST_ME_TELEPORT) - spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.") - else - spec:remove() - end - end -end - -function isBossInRoom(fromPos, toPos, bossName) - local monstersRemoved = false - for x = fromPos.x, toPos.x do - for y = fromPos.y, toPos.y do - for z = fromPos.z, toPos.z do - local tile = Tile(Position(x, y, z)) - if tile then - local creature = tile:getTopCreature() - if creature and creature:isMonster() then - creature:remove() - monstersRemoved = true - end + local playersTable = {} + if doCheckBossRoom(player:getId(), "Shulgrax", Position(33473, 32776, 13), Position(33496, 32798, 13)) then + local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15) + for i = 1, #specs do + spec = specs[i] + if spec:isPlayer() then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with Shulgrax.") + return true end end + Game.createMonster("Shulgrax", config.BossPosition, true, true) + for y = 32785, 32789 do + local playerTile = Tile(Position(33434, y, 13)):getTopCreature() + if playerTile and playerTile:isPlayer() then + playerTile:getPosition():sendMagicEffect(CONST_ME_POFF) + playerTile:teleportTo(config.newPosition) + playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + playerTile:setStorageValue(Storage.FerumbrasAscension.ShulgraxTimer, os.time() + 60 * 60 * 2 * 24) + table.insert(playersTable, playerTile:getId()) + end + end + addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, Position(33473, 32776, 13), Position(33496, 32798, 13), Position(33319, 32318, 13)) + item:transform(8912) end + elseif item.itemid == 8912 then + item:transform(8911) end - return monstersRemoved + + return true end leverShulgrax:uid(1028) diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_tarbaz.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_tarbaz.lua index fbfc4574903..bee69146c4a 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_tarbaz.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_tarbaz.lua @@ -1,118 +1,48 @@ local config = { - boss = { - name = "Tarbaz", - position = Position(33459, 32844, 11), - }, - timeToDefeat = 17 * 60, -- 17 minutes in seconds - playerPositions = { - { pos = Position(33418, 32849, 11), teleport = Position(33459, 32848, 11), effect = CONST_ME_TELEPORT }, - { pos = Position(33418, 32850, 11), teleport = Position(33459, 32848, 11), effect = CONST_ME_TELEPORT }, - { pos = Position(33418, 32851, 11), teleport = Position(33459, 32848, 11), effect = CONST_ME_TELEPORT }, - { pos = Position(33418, 32852, 11), teleport = Position(33459, 32848, 11), effect = CONST_ME_TELEPORT }, - { pos = Position(33418, 32853, 11), teleport = Position(33459, 32848, 11), effect = CONST_ME_TELEPORT }, - }, - specPos = { - from = Position(33447, 32832, 11), - to = Position(33473, 32856, 11), - }, - exit = Position(33319, 32318, 13), + centerRoom = Position(33459, 32844, 11), + BossPosition = Position(33459, 32844, 11), + newPosition = Position(33459, 32848, 11) } local leverTarbaz = Action() function leverTarbaz.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local players = {} - local spectators = Game.getSpectators(config.specPos.from, false, false, 0, 0, 0, 0, config.specPos.to) - - for i = 1, #config.playerPositions do - local pos = config.playerPositions[i].pos - local creature = Tile(pos):getTopCreature() - - if not creature or not creature:isPlayer() then - player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".") - return true - end - - local cooldownTime = creature:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TarbazTime) - if cooldownTime > os.time() then - local remainingTime = cooldownTime - os.time() - local hours = math.floor(remainingTime / 3600) - local minutes = math.floor((remainingTime % 3600) / 60) - player:sendCancelMessage(creature:getName() .. " must wait " .. hours .. " hours and " .. minutes .. " minutes to challenge again.") - return true - end - - if creature:getLevel() < config.requiredLevel then - player:sendCancelMessage(creature:getName() .. " needs to be at least level " .. config.requiredLevel .. " to challenge " .. config.boss.name .. ".") - return true - end - - table.insert(players, creature) - end - - for _, spec in pairs(spectators) do - if spec:isPlayer() then - player:say("Someone is already inside the room.", TALKTYPE_MONSTER_SAY) + if item.itemid == 8911 then + if player:getPosition() ~= Position(33418, 32849, 11) then + item:transform(8912) return true end end - - if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then - player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY) - return true - end - - for i = 1, #players do - local playerToTeleport = players[i] - local teleportPos = config.playerPositions[i].teleport - local effect = config.playerPositions[i].effect - playerToTeleport:teleportTo(teleportPos) - teleportPos:sendMagicEffect(effect) - end - - Game.createMonster(config.boss.name, config.boss.position) - - addEvent(clearBossRoom, config.timeToDefeat * 1000, config.specPos.from, config.specPos.to, config.exit) - if item.itemid == 8911 then - item:transform(8912) - else - item:transform(8911) - end - - return true -end - -function clearBossRoom(fromPos, toPos, exitPos) - local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - spec:teleportTo(exitPos) - exitPos:sendMagicEffect(CONST_ME_TELEPORT) - spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.") - else - spec:remove() - end - end -end - -function isBossInRoom(fromPos, toPos, bossName) - local monstersRemoved = false - for x = fromPos.x, toPos.x do - for y = fromPos.y, toPos.y do - for z = fromPos.z, toPos.z do - local tile = Tile(Position(x, y, z)) - if tile then - local creature = tile:getTopCreature() - if creature and creature:isMonster() then - creature:remove() - monstersRemoved = true - end + local playersTable = {} + if doCheckBossRoom(player:getId(), "Tarbaz", Position(33446, 32833, 11), Position(33515, 32875, 12)) then + local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15) + for i = 1, #specs do + spec = specs[i] + if spec:isPlayer() then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with Tarbaz.") + return true end end + Game.createMonster("Tarbaz", config.BossPosition, true, true) + for y = 32849, 32853 do + local playerTile = Tile(Position(33418, y, 11)):getTopCreature() + if playerTile and playerTile:isPlayer() then + playerTile:getPosition():sendMagicEffect(CONST_ME_POFF) + playerTile:teleportTo(config.newPosition) + playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + playerTile:setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TarbazTimer, os.time() + 60 * 60 * 2 * 24) + table.insert(playersTable, playerTile:getId()) + end + end + addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, Position(33446, 32833, 11), Position(33515, 32875, 12), Position(33319, 32318, 13)) + item:transform(8912) end + elseif item.itemid == 8912 then + item:transform(8911) end - return monstersRemoved + + return true end leverTarbaz:uid(1027) diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_the_shatterer_lever.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_the_shatterer_lever.lua index 221a4bdc850..bcacf042627 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_the_shatterer_lever.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_the_shatterer_lever.lua @@ -1,112 +1,57 @@ local config = { - boss = { - name = "The Shatterer", - position = Position(33406, 32418, 14), - }, - timeToDefeat = 17 * 60, -- 17 minutes in seconds - playerPositions = { - { pos = Position(33403, 32465, 13), teleport = Position(33398, 32414, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33404, 32465, 13), teleport = Position(33398, 32414, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33405, 32465, 13), teleport = Position(33398, 32414, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33406, 32465, 13), teleport = Position(33398, 32414, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33407, 32465, 13), teleport = Position(33398, 32414, 14), effect = CONST_ME_TELEPORT }, - }, - specPos = { - from = Position(33377, 32390, 14), - to = Position(33446, 32447, 14), - }, - exit = Position(33319, 32318, 13), centerRoom = Position(33406, 32418, 14), - storage = { - lever = Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, - timer = Storage.Quest.U10_90.FerumbrasAscension.TheShattererTimer, + BossPosition = Position(33406, 32418, 14), + playerPositions = { + Position(33403, 32465, 13), + Position(33404, 32465, 13), + Position(33405, 32465, 13), + Position(33406, 32465, 13), + Position(33407, 32465, 13) }, + newPosition = Position(33398, 32414, 14) } local ferumbrasAscendantTheShattererLever = Action() function ferumbrasAscendantTheShattererLever.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local spectators = Game.getSpectators(config.centerRoom, false, false, 30, 30, 30, 30) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with The Shatterer.") + if item.itemid == 8912 then + if player:getPosition() ~= Position(33403, 32465, 13) then + item:transform(8911) return true end end - - if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then - player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY) - return true - end - - local players = {} - for i = 1, #config.playerPositions do - local pos = config.playerPositions[i].pos - local creature = Tile(pos):getTopCreature() - if not creature or not creature:isPlayer() then - player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".") - return true + if item.itemid == 8912 then + local playersTable = {} + if doCheckBossRoom(player:getId(), "The Shatterer", Position(33377, 32390, 14), Position(33446, 32447, 14)) then + local specs, spec = Game.getSpectators(config.centerRoom, false, false, 30, 30, 30, 30) + for i = 1, #specs do + spec = specs[i] + if spec:isPlayer() then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with The Shatterer.") + return true + end + end + Game.createMonster("The Shatterer", config.BossPosition, true, true) + for x = 33403, 33407 do + local playerTile = Tile(Position(x, 32465, 13)):getTopCreature() + if playerTile and playerTile:isPlayer() then + playerTile:getPosition():sendMagicEffect(CONST_ME_POFF) + playerTile:teleportTo(config.newPosition) + playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + playerTile:setStorageValue(Storage.FerumbrasAscension.TheShattererTimer, os.time() + 60 * 60 * 2 * 24) + table.insert(playersTable, playerTile:getId()) + end + end + addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, Position(33377, 32390, 14), Position(33446, 32447, 14), Position(33319, 32318, 13)) + item:transform(8911) end - table.insert(players, creature) - end - - for i = 1, #players do - local playerToTeleport = players[i] - local teleportPos = config.playerPositions[i].teleport - local effect = config.playerPositions[i].effect - playerToTeleport:teleportTo(teleportPos) - teleportPos:sendMagicEffect(effect) - end - - Game.createMonster(config.boss.name, config.boss.position, true, true) - - for _, participant in pairs(players) do - participant:setStorageValue(config.storage.lever, 0) - participant:setStorageValue(config.storage.timer, 1) - end - - addEvent(clearBossRoom, config.timeToDefeat * 1000, config.specPos.from, config.specPos.to, config.exit, config.storage.timer) - - if item.itemid == 8911 then + elseif item.itemid == 8911 then item:transform(8912) - else - item:transform(8911) end return true end -function clearBossRoom(fromPos, toPos, exitPos) - local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - spec:teleportTo(exitPos) - exitPos:sendMagicEffect(CONST_ME_TELEPORT) - spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.") - else - spec:remove() - end - end -end - -function isBossInRoom(fromPos, toPos, bossName) - local bossRemoved = false - for x = fromPos.x, toPos.x do - for y = fromPos.y, toPos.y do - for z = fromPos.z, toPos.z do - local tile = Tile(Position(x, y, z)) - if tile then - local creature = tile:getTopCreature() - if creature and creature:isMonster() and creature:getName() == bossName then - creature:remove() - bossRemoved = true - end - end - end - end - end - return bossRemoved -end ferumbrasAscendantTheShattererLever:uid(1029) ferumbrasAscendantTheShattererLever:register() diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_the_shatterer_levers.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_the_shatterer_levers.lua index b7e7916ebdf..b8fb7e2acbe 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_the_shatterer_levers.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_the_shatterer_levers.lua @@ -39,11 +39,13 @@ local chains = { } local ferumbrasAscendantTheShattererLevers = Action() + function ferumbrasAscendantTheShattererLevers.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShatterer) >= 1 then - player:sendCancelMessage("You cannot use this lever again.") + if player:getStorageValue(Storage.FerumbrasAscension.TheShatterer) >= 1 then + player:sendCancelMessage('You cannot use this lever again.') return true end + if item.itemid == 8911 then item:transform(8912) if item:getPosition() == Position(33385, 32410, 14) then @@ -52,13 +54,13 @@ function ferumbrasAscendantTheShattererLevers.onUse(player, item, fromPosition, local bla = Tile(chain.position):getItemById(chain.itemid) if bla then bla:remove() - Game.createMonster("Fury", { x = player:getPosition().x + math.random(-3, 3), y = player:getPosition().y + math.random(-3, 3), z = player:getPosition().z }) + Game.createMonster("Fury", { x=player:getPosition().x+math.random(-3, 3), y=player:getPosition().y+math.random(-3, 3), z=player:getPosition().z }) end end - player:setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, math.max(player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever), 0) + 1) - if player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) >= 4 then + Game.setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) + 1) + if Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) >= 4 then local boss = Tile(Position(33406, 32418, 14)):getTopCreature() - if boss and boss:getName():lower() == "the shatterer" then + if boss:getName():lower() == 'the shatterer' then boss:teleportTo(Position(33400, 32415, 14)) boss:getPosition():sendMagicEffect(CONST_ME_TELEPORT) return true @@ -70,13 +72,13 @@ function ferumbrasAscendantTheShattererLevers.onUse(player, item, fromPosition, local bla = Tile(chain.position):getItemById(chain.itemid) if bla then bla:remove() - Game.createMonster("Destroyer", { x = player:getPosition().x + math.random(-3, 3), y = player:getPosition().y + math.random(-3, 3), z = player:getPosition().z }) + Game.createMonster("Destroyer", { x=player:getPosition().x+math.random(-3, 3), y=player:getPosition().y+math.random(-3, 3), z=player:getPosition().z }) end end - player:setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, math.max(player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever), 0) + 1) - if player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) >= 4 then + Game.setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) + 1) + if Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) >= 4 then local boss = Tile(Position(33406, 32418, 14)):getTopCreature() - if boss and boss:getName():lower() == "the shatterer" then + if boss:getName():lower() == 'the shatterer' then boss:teleportTo(Position(33400, 32415, 14)) boss:getPosition():sendMagicEffect(CONST_ME_TELEPORT) return true @@ -90,10 +92,10 @@ function ferumbrasAscendantTheShattererLevers.onUse(player, item, fromPosition, bla:remove() end end - player:setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, math.max(player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever), 0) + 1) - if player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) >= 4 then + Game.setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) + 1) + if Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) >= 4 then local boss = Tile(Position(33406, 32418, 14)):getTopCreature() - if boss and boss:getName():lower() == "the shatterer" then + if boss:getName():lower() == 'the shatterer' then boss:teleportTo(Position(33400, 32415, 14)) boss:getPosition():sendMagicEffect(CONST_ME_TELEPORT) return true @@ -107,23 +109,24 @@ function ferumbrasAscendantTheShattererLevers.onUse(player, item, fromPosition, bla:remove() end end - player:setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, math.max(player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever), 0) + 1) - if player:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) >= 4 then + Game.setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever, Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) + 1) + if Game.getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.TheShattererLever) >= 4 then local boss = Tile(Position(33406, 32418, 14)):getTopCreature() - if boss and boss:getName():lower() == "the shatterer" then + if boss:getName():lower() == 'the shatterer' then boss:teleportTo(Position(33400, 32415, 14)) boss:getPosition():sendMagicEffect(CONST_ME_TELEPORT) return true end end end - player:say("CLICK", TALKTYPE_MONSTER_SAY, false, nil, toPosition) + player:say('CLICK', TALKTYPE_MONSTER_SAY, false, nil, toPosition) elseif item.itemid == 8912 then - player:sendCancelMessage("Sorry, not possible.") + player:sendCancelMessage('Sorry, not possible.') return true end + return true end ferumbrasAscendantTheShattererLevers:uid(1031, 1032, 1033, 1034) -ferumbrasAscendantTheShattererLevers:register() +ferumbrasAscendantTheShattererLevers:register() \ No newline at end of file diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_zamulosh.lua b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_zamulosh.lua index 8ba9fe077b0..358f10d6532 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_zamulosh.lua +++ b/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_zamulosh.lua @@ -1,137 +1,58 @@ local config = { - boss = { - name = "Zamulosh", - position = Position(33643, 32756, 11), - }, - timeToDefeat = 17 * 60, -- 17 minutes in seconds - playerPositions = { - { pos = Position(33680, 32741, 11), teleport = Position(33644, 32760, 11), effect = CONST_ME_TELEPORT }, - { pos = Position(33680, 32742, 11), teleport = Position(33644, 32760, 11), effect = CONST_ME_TELEPORT }, - { pos = Position(33680, 32743, 11), teleport = Position(33644, 32760, 11), effect = CONST_ME_TELEPORT }, - { pos = Position(33680, 32744, 11), teleport = Position(33644, 32760, 11), effect = CONST_ME_TELEPORT }, - { pos = Position(33680, 32745, 11), teleport = Position(33644, 32760, 11), effect = CONST_ME_TELEPORT }, - }, - specPos = { - from = Position(33632, 32747, 11), - to = Position(33654, 32765, 11), - }, - exit = Position(33319, 32318, 13), - summons = { + centerRoom = Position(33643, 32756, 11), + BossPosition = Position(33643, 32756, 11), + newPosition = Position(33644, 32760, 11), + zamuloshSummons = { Position(33642, 32756, 11), Position(33642, 32756, 11), Position(33642, 32756, 11), Position(33644, 32756, 11), Position(33644, 32756, 11), - Position(33644, 32756, 11), - }, + Position(33644, 32756, 11) + } } -local leverZamulosh = Action() - -function leverZamulosh.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local players = {} - local spectators = Game.getSpectators(config.specPos.from, false, false, 0, 0, 0, 0, config.specPos.to) - - for i = 1, #config.playerPositions do - local pos = config.playerPositions[i].pos - local creature = Tile(pos):getTopCreature() - - if not creature or not creature:isPlayer() then - player:sendCancelMessage("You need " .. #config.playerPositions .. " players to challenge " .. config.boss.name .. ".") - return true - end - - local cooldownTime = creature:getStorageValue(Storage.Quest.U10_90.FerumbrasAscension.ZamuloshTime) - if cooldownTime > os.time() then - local remainingTime = cooldownTime - os.time() - local hours = math.floor(remainingTime / 3600) - local minutes = math.floor((remainingTime % 3600) / 60) - player:sendCancelMessage(creature:getName() .. " must wait " .. hours .. " hours and " .. minutes .. " minutes to challenge again.") - return true - end - - if creature:getLevel() < config.requiredLevel then - player:sendCancelMessage(creature:getName() .. " needs to be at least level " .. config.requiredLevel .. " to challenge " .. config.boss.name .. ".") - return true - end - - table.insert(players, creature) - end - - for _, spec in pairs(spectators) do - if spec:isPlayer() then - player:say("Someone is already inside the room.", TALKTYPE_MONSTER_SAY) +function onUse(player, item, fromPosition, target, toPosition, isHotkey) + if item.itemid == 8911 then + if player:getPosition() ~= Position(33680, 32741, 11) then + item:transform(8912) return true end end - - if isBossInRoom(config.specPos.from, config.specPos.to, config.boss.name) then - player:say("The room is being cleared. Please wait a moment.", TALKTYPE_MONSTER_SAY) - return true - end - - for i = 1, #players do - local playerToTeleport = players[i] - local teleportPos = config.playerPositions[i].teleport - local effect = config.playerPositions[i].effect - playerToTeleport:teleportTo(teleportPos) - teleportPos:sendMagicEffect(effect) - end - - Game.createMonster(config.boss.name, config.boss.position) - - local zamuloshIndex = math.random(#config.summons) - - for i, summonPos in ipairs(config.summons) do - if i == zamuloshIndex then - Game.createMonster(config.boss.name, summonPos) - else - Game.createMonster("Zamulosh3", summonPos) - end - end - - addEvent(clearBossRoom, config.timeToDefeat * 1000, config.specPos.from, config.specPos.to, config.exit) - if item.itemid == 8911 then + local playersTable = {} + if doCheckBossRoom(player:getId(), "Zamulosh", Position(33634, 32749, 11), Position(33654, 32765, 11)) then + local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15) + for i = 1, #specs do + spec = specs[i] + if spec:isPlayer() then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with Zamulosh.") + return true + end + end + Game.createMonster("Zamulosh", config.BossPosition, true, true) + for d = 1, #config.zamuloshSummons do + Game.createMonster('Zamulosh3', config.zamuloshSummons[d], true, true) + end + for y = 32741, 32745 do + local playerTile = Tile(Position(33680, y, 11)):getTopCreature() + if playerTile and playerTile:isPlayer() then + playerTile:getPosition():sendMagicEffect(CONST_ME_POFF) + playerTile:teleportTo(config.newPosition) + playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + playerTile:setStorageValue(Storage.Quest.U10_90.FerumbrasAscension.ZamuloshTimer, os.time() + 60 * 60 * 2 * 24) + table.insert(playersTable, playerTile:getId()) + end + end + addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, Position(33634, 32749, 11), Position(33654, 32765, 11), Position(33319, 32318, 13)) item:transform(8912) - else + end + elseif item.itemid == 8912 then item:transform(8911) end return true end -function clearBossRoom(fromPos, toPos, exitPos) - local spectators = Game.getSpectators(fromPos, false, false, 0, 0, 0, 0, toPos) - for _, spec in pairs(spectators) do - if spec:isPlayer() then - spec:teleportTo(exitPos) - exitPos:sendMagicEffect(CONST_ME_TELEPORT) - spec:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You took too long, the battle has ended.") - else - spec:remove() - end - end -end - -function isBossInRoom(fromPos, toPos, bossName) - local monstersRemoved = false - for x = fromPos.x, toPos.x do - for y = fromPos.y, toPos.y do - for z = fromPos.z, toPos.z do - local tile = Tile(Position(x, y, z)) - if tile then - local creature = tile:getTopCreature() - if creature and creature:isMonster() then - creature:remove() - monstersRemoved = true - end - end - end - end - end - return monstersRemoved -end - leverZamulosh:uid(1026) -leverZamulosh:register() +leverZamulosh:register() \ No newline at end of file