From 74e7303d4c18f4db350dca26e3d95975e81cb158 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 00:55:18 -0300 Subject: [PATCH 01/11] Update rupture_lever.lua --- .../heart_of_destruction/rupture_lever.lua | 165 ++++-------------- 1 file changed, 38 insertions(+), 127 deletions(-) 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..8eebb11cc37 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, 0) + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive, false) + + 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() From a1230e7fad799ca56dd5017f5805704a20462856 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 00:57:12 -0300 Subject: [PATCH 02/11] Update storages.lua --- data-otservbr-global/lib/core/storages.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index 888da1b113f..2598e24e61d 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -3065,8 +3065,10 @@ GlobalStorage = { }, }, HeartOfDestruction = { - -- Reserved storage from 60172 - 60177 + -- Reserved storage from 60172 - 60178 ChargedAnomaly = 60172, + RuptureResonanceStage = 60177, + RuptureResonanceActive = 60178, }, FuryGates = 65000, Yakchal = 65001, From 6b023ab83f81d4f1cba44be8d07f5ec36775e560 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 01:04:43 -0300 Subject: [PATCH 03/11] Update rupture_heal.lua --- .../quests/heart_of_destruction/rupture_heal.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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..d629f65e58e 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,13 @@ 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 resonanceActive and resonanceActive < 1 then + resonanceActive = false + end + + if attacker and attacker:isPlayer() and resonanceActive then creature:addHealth(healthGain) creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) end From b35a103ca494592650c6ca3fc84dab613dba6d60 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 01:05:17 -0300 Subject: [PATCH 04/11] Update rupture_heal.lua --- .../quests/heart_of_destruction/rupture_heal.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d629f65e58e..d90838f1732 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,13 +1,13 @@ local ruptureHeal = CreatureEvent("RuptureHeal") function ruptureHeal.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) - local healthGain = math.random(5000, 10000) local resonanceActive = Game.getStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive) if resonanceActive and resonanceActive < 1 then resonanceActive = false end if attacker and attacker:isPlayer() and resonanceActive then + local healthGain = math.random(5000, 10000) creature:addHealth(healthGain) creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) end From 32e6218ab580d16fbc15d5dc1f0f70938f1554d1 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 01:11:33 -0300 Subject: [PATCH 05/11] Update rupture_heal.lua --- .../quests/heart_of_destruction/rupture_heal.lua | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 d90838f1732..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 @@ -2,11 +2,7 @@ local ruptureHeal = CreatureEvent("RuptureHeal") function ruptureHeal.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) local resonanceActive = Game.getStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive) - if resonanceActive and resonanceActive < 1 then - resonanceActive = false - end - - if attacker and attacker:isPlayer() and resonanceActive then + 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) From f41b8c13e58ebecafadc89602726cb1cd80f3808 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 01:12:18 -0300 Subject: [PATCH 06/11] Update rupture_lever.lua --- .../actions/quests/heart_of_destruction/rupture_lever.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8eebb11cc37..f47ab9133af 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 @@ -22,7 +22,7 @@ local config = { }, onUseExtra = function() Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage, 0) - Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive, false) + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive, 0) local tile = Tile(Position(32326, 31250, 14)) if tile then From c08debde7b9aee1dd2f6928b899e79ee65987fbd Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 01:16:47 -0300 Subject: [PATCH 07/11] Update rupture_resonance.lua --- .../rupture_resonance.lua | 67 +++++++------------ 1 file changed, 26 insertions(+), 41 deletions(-) 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..cabe176b734 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,35 @@ +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) + local resonanceActive = Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive) + + local hpPercent = (creature:getHealth() / creature:getMaxHealth()) * 100 + if hpPercent <= 80 and ruptureResonanceStage == 0 and resonanceActive ~= 1 then + createSpawnWave(1) + elseif hpPercent <= 60 and ruptureResonanceStage == 1 and resonanceActive ~= 1 then + createSpawnWave(2) + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage, 0) + elseif hpPercent <= 40 and ruptureResonanceStage == 2 and resonanceActive ~= 1 then + createSpawnWave(3) + elseif hpPercent <= 25 and ruptureResonanceStage == 3 and resonanceActive ~= 1 then + createSpawnWave(4) + elseif hpPercent <= 10 and ruptureResonanceStage == 4 and resonanceActive ~= 1 then + createSpawnWave(-1) end return true From b060f40ffa5fbfd22e40c2f9aeef069588cbaa10 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 04:57:57 -0300 Subject: [PATCH 08/11] Update rupture_lever.lua --- .../actions/quests/heart_of_destruction/rupture_lever.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 f47ab9133af..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 @@ -21,8 +21,8 @@ local config = { { name = "Spark of Destruction", pos = Position(32338, 31250, 14) }, }, onUseExtra = function() - Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage, 0) - Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive, 0) + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage, -1) + Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive, -1) local tile = Tile(Position(32326, 31250, 14)) if tile then From 43277b6b85bdcf64fa23590f87be7b95a8ea55b8 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 20 Jan 2024 04:59:11 -0300 Subject: [PATCH 09/11] Update rupture_resonance.lua --- .../quests/heart_of_destruction/rupture_resonance.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 cabe176b734..a3c46b7e841 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 @@ -15,7 +15,7 @@ function ruptureResonance.onThink(creature) return false end - local ruptureResonanceStage = Game.getStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage) + local ruptureResonanceStage = Game.getStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage) > 0 and Game.getStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage) or 0 local resonanceActive = Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceActive) local hpPercent = (creature:getHealth() / creature:getMaxHealth()) * 100 @@ -23,7 +23,6 @@ function ruptureResonance.onThink(creature) createSpawnWave(1) elseif hpPercent <= 60 and ruptureResonanceStage == 1 and resonanceActive ~= 1 then createSpawnWave(2) - Game.setStorageValue(GlobalStorage.HeartOfDestruction.RuptureResonanceStage, 0) elseif hpPercent <= 40 and ruptureResonanceStage == 2 and resonanceActive ~= 1 then createSpawnWave(3) elseif hpPercent <= 25 and ruptureResonanceStage == 3 and resonanceActive ~= 1 then From 1013707d5c32b3b2c5f4659738fe7fb0a58cb8d5 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Sat, 27 Jan 2024 19:02:57 -0300 Subject: [PATCH 10/11] Update data-otservbr-global/scripts/creaturescripts/quests/heart_of_destruction/rupture_resonance.lua Co-authored-by: Eduardo Dantas --- .../rupture_resonance.lua | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) 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 a3c46b7e841..279f763b15f 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 @@ -18,19 +18,23 @@ function ruptureResonance.onThink(creature) 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 - if hpPercent <= 80 and ruptureResonanceStage == 0 and resonanceActive ~= 1 then - createSpawnWave(1) - elseif hpPercent <= 60 and ruptureResonanceStage == 1 and resonanceActive ~= 1 then - createSpawnWave(2) - elseif hpPercent <= 40 and ruptureResonanceStage == 2 and resonanceActive ~= 1 then - createSpawnWave(3) - elseif hpPercent <= 25 and ruptureResonanceStage == 3 and resonanceActive ~= 1 then - createSpawnWave(4) - elseif hpPercent <= 10 and ruptureResonanceStage == 4 and resonanceActive ~= 1 then - createSpawnWave(-1) + 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 end From bae644dab57283257f6b62d2cda0792e63b882d7 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 27 Jan 2024 22:03:33 +0000 Subject: [PATCH 11/11] Lua code format - (Stylua) --- .../heart_of_destruction/rupture_resonance.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 279f763b15f..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 @@ -19,13 +19,13 @@ function ruptureResonance.onThink(creature) 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}, + { 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 @@ -34,7 +34,6 @@ function ruptureResonance.onThink(creature) end end - return true end