diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index ed834bf5977..741c481d865 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -3067,6 +3067,8 @@ GlobalStorage = { HeartOfDestruction = { -- Reserved storage from 60172 - 60190 ChargedAnomaly = 60172, + RuptureResonanceStage = 60177, + RuptureResonanceActive = 60178, EradicatorWeak = 60178, EradicatorReleaseT = 60179, OutburstStage = 60180, diff --git a/data-otservbr-global/scripts/actions/quests/heart_of_destruction/rupture_lever.lua b/data-otservbr-global/scripts/actions/quests/heart_of_destruction/rupture_lever.lua index 3c335c70716..ecb892cef8e 100644 --- a/data-otservbr-global/scripts/actions/quests/heart_of_destruction/rupture_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/heart_of_destruction/rupture_lever.lua @@ -1,130 +1,41 @@ --- FUNCTIONS -local function doCheckArea() - local upConer = { x = 32324, y = 31239, z = 14 } -- upLeftCorner - local downConer = { x = 32347, y = 31263, z = 14 } -- downRightCorner - - for i = upConer.x, downConer.x do - for j = upConer.y, downConer.y do - for k = upConer.z, downConer.z do - local room = { x = i, y = j, z = k } - local tile = Tile(room) - if tile then - local creatures = tile:getCreatures() - if creatures and #creatures > 0 then - for _, creature in pairs(creatures) do - local player = Player(creature) - if player then - return true - end - end - end - end - end - end - end - return false -end - -local function clearArea() - local upConer = { x = 32324, y = 31239, z = 14 } -- upLeftCorner - local downConer = { x = 32347, y = 31263, z = 14 } -- downRightCorner - - for i = upConer.x, downConer.x do - for j = upConer.y, downConer.y do - for k = upConer.z, downConer.z do - local room = { x = i, y = j, z = k } - local tile = Tile(room) - if tile then - local creatures = tile:getCreatures() - if creatures and #creatures > 0 then - for _, creatureUid in pairs(creatures) do - local creature = Creature(creatureUid) - if creature then - if creature:isPlayer() then - creature:teleportTo({ x = 32088, y = 31321, z = 13 }) - elseif creature:isMonster() then - creature:remove() - end - end - end - end - end - end - end - end -end --- FUNCTIONS END - -local heartDestructionRupture = Action() -function heartDestructionRupture.onUse(player, item, fromPosition, itemEx, toPosition) - local config = { - playerPositions = { - Position(32309, 31248, 14), - Position(32309, 31249, 14), - Position(32309, 31250, 14), - Position(32309, 31251, 14), - Position(32309, 31252, 14), - }, - - newPos = { x = 32335, y = 31257, z = 14 }, - } - - local pushPos = { x = 32309, y = 31248, z = 14 } - - if item.actionid == 14327 then - if item.itemid == 8911 then - if player:getPosition().x == pushPos.x and player:getPosition().y == pushPos.y and player:getPosition().z == pushPos.z then - local storePlayers = {} - for i = 1, #config.playerPositions do - local tile = Tile(Position(config.playerPositions[i])) - if tile then - local playerTile = tile:getTopCreature() - if playerTile and playerTile:isPlayer() then - storePlayers[#storePlayers + 1] = playerTile - end - end - end - - if doCheckArea() == false then - clearArea() - - local players - - for i = 1, #storePlayers do - players = storePlayers[i] - config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF) - players:teleportTo(config.newPos) - players:setBossCooldown("Rupture", os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN)) - end - Position(config.newPos):sendMagicEffect(11) - - areaRupture1 = addEvent(clearArea, 15 * 60000) - - ruptureResonanceStage = 0 - resonanceActive = false - - Game.createMonster("Spark of Destruction", { x = 32331, y = 31254, z = 14 }, false, true) - Game.createMonster("Spark of Destruction", { x = 32338, y = 31254, z = 14 }, false, true) - Game.createMonster("Spark of Destruction", { x = 32330, y = 31250, z = 14 }, false, true) - Game.createMonster("Spark of Destruction", { x = 32338, y = 31250, z = 14 }, false, true) - Game.createMonster("Rupture", { x = 32332, y = 31250, z = 14 }, false, true) - - local vortex = Tile({ x = 32326, y = 31250, z = 14 }):getItemById(23482) - if vortex then - vortex:transform(23483) - vortex:setActionId(14343) - end - else - player:sendTextMessage(19, "Someone is in the area.") - end - else - return true +local config = { + boss = { + name = "Rupture", + position = Position(32332, 31250, 14), + }, + playerPositions = { + { pos = Position(32309, 31248, 14), teleport = Position(32335, 31257, 14), effect = CONST_ME_TELEPORT }, + { pos = Position(32309, 31249, 14), teleport = Position(32335, 31257, 14), effect = CONST_ME_TELEPORT }, + { pos = Position(32309, 31250, 14), teleport = Position(32335, 31257, 14), effect = CONST_ME_TELEPORT }, + { pos = Position(32309, 31251, 14), teleport = Position(32335, 31257, 14), effect = CONST_ME_TELEPORT }, + { pos = Position(32309, 31252, 14), teleport = Position(32335, 31257, 14), effect = CONST_ME_TELEPORT }, + }, + specPos = { + from = Position(32324, 31239, 14), + to = Position(32347, 31263, 14), + }, + monsters = { + { name = "Spark of Destruction", pos = Position(32331, 31254, 14) }, + { name = "Spark of Destruction", pos = Position(32338, 31254, 14) }, + { name = "Spark of Destruction", pos = Position(32330, 31250, 14) }, + { name = "Spark of Destruction", pos = Position(32338, 31250, 14) }, + }, + onUseExtra = function() + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage, -1) + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive, -1) + + local tile = Tile(Position(32326, 31250, 14)) + if tile then + local vortex = tile:getItemById(23482) + if vortex then + vortex:transform(23483) + vortex:setActionId(14343) end end - item:transform(item.itemid == 8911 and 8912 or 8911) - end - return true -end + end, + exit = Position(32088, 31321, 13), +} -heartDestructionRupture:aid(14327) -heartDestructionRupture:register() +local lever = BossLever(config) +lever:aid(14327) +lever:register() diff --git a/data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_heal.lua b/data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_heal.lua index 9951dcd71e7..00915af16a8 100644 --- a/data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_heal.lua +++ b/data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_heal.lua @@ -1,7 +1,9 @@ local ruptureHeal = CreatureEvent("RuptureHeal") + function ruptureHeal.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) - local healthGain = math.random(5000, 10000) - if attacker and attacker:isPlayer() and resonanceActive == true then + local resonanceActive = Game.getStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive) + if attacker and attacker:isPlayer() and resonanceActive == 1 then + local healthGain = math.random(5000, 10000) creature:addHealth(healthGain) creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) end diff --git a/data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_resonance.lua b/data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_resonance.lua index 3736d47d7c0..fbbbfefbf12 100644 --- a/data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_resonance.lua +++ b/data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_resonance.lua @@ -1,50 +1,37 @@ +local function createSpawnWave(stage) + Game.createMonster("Spark of Destruction", Position(32331, 31254, 14), false, true) + Game.createMonster("Spark of Destruction", Position(32338, 31254, 14), false, true) + Game.createMonster("Spark of Destruction", Position(32330, 31250, 14), false, true) + Game.createMonster("Spark of Destruction", Position(32338, 31250, 14), false, true) + Game.createMonster("Damage Resonance", Position(32332, 31250, 14), false, true) + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage, stage) + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive, 1) +end + local ruptureResonance = CreatureEvent("RuptureResonance") + function ruptureResonance.onThink(creature) if not creature or not creature:isMonster() then return false end - local hp = (creature:getHealth() / creature:getMaxHealth()) * 100 - if hp <= 80 and ruptureResonanceStage == 0 and resonanceActive == false then - Game.createMonster("spark of destruction", { x = 32331, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32330, y = 31250, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31250, z = 14 }, false, true) - Game.createMonster("damage resonance", { x = 32332, y = 31250, z = 14 }, false, true) - ruptureResonanceStage = 1 - resonanceActive = true - elseif hp <= 60 and ruptureResonanceStage == 1 and resonanceActive == false then - Game.createMonster("spark of destruction", { x = 32331, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32330, y = 31250, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31250, z = 14 }, false, true) - Game.createMonster("damage resonance", { x = 32332, y = 31250, z = 14 }, false, true) - ruptureResonanceStage = 2 - resonanceActive = true - elseif hp <= 40 and ruptureResonanceStage == 2 and resonanceActive == false then - Game.createMonster("spark of destruction", { x = 32331, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32330, y = 31250, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31250, z = 14 }, false, true) - Game.createMonster("damage resonance", { x = 32332, y = 31250, z = 14 }, false, true) - ruptureResonanceStage = 3 - resonanceActive = true - elseif hp <= 25 and ruptureResonanceStage == 3 and resonanceActive == false then - Game.createMonster("spark of destruction", { x = 32331, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32330, y = 31250, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31250, z = 14 }, false, true) - Game.createMonster("damage resonance", { x = 32332, y = 31250, z = 14 }, false, true) - ruptureResonanceStage = 4 - resonanceActive = true - elseif hp <= 10 and ruptureResonanceStage == 4 and resonanceActive == false then - Game.createMonster("spark of destruction", { x = 32331, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31254, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32330, y = 31250, z = 14 }, false, true) - Game.createMonster("spark of destruction", { x = 32338, y = 31250, z = 14 }, false, true) - Game.createMonster("damage resonance", { x = 32332, y = 31250, z = 14 }, false, true) - ruptureResonanceStage = -1 - resonanceActive = true + local ruptureResonanceStage = Game.getStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage) > 0 and Game.getStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage) or 0 + local resonanceActive = Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive) + + local thresholds = { + { limit = 80, stage = 0, wave = 1 }, + { limit = 60, stage = 1, wave = 2 }, + { limit = 40, stage = 2, wave = 3 }, + { limit = 25, stage = 3, wave = 4 }, + { limit = 10, stage = 4, wave = -1 }, + } + + local hpPercent = (creature:getHealth() / creature:getMaxHealth()) * 100 + for _, threshold in ipairs(thresholds) do + if hpPercent <= threshold.limit and ruptureResonanceStage == threshold.stage and resonanceActive ~= 1 then + createSpawnWave(threshold.wave) + break + end end return true