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