From e6fa0596b5a0dd5c7b74fd3fed10cd154a3e7636 Mon Sep 17 00:00:00 2001 From: CarlosEDev Date: Mon, 18 Mar 2024 15:53:46 -0300 Subject: [PATCH 1/4] added mechanic --- data-otservbr-global/lib/core/storages.lua | 3 + .../the_dream_courts/bosses/faceless_bane.lua | 16 ++- .../monster/faceless_bane_immunity.lua | 49 +++++++ .../faceless_bane_on_death.lua | 17 +++ .../faceless_bane_step_positions.lua | 125 ++++++++++++++++++ 5 files changed, 204 insertions(+), 6 deletions(-) create mode 100644 data-otservbr-global/scripts/creaturescripts/monster/faceless_bane_immunity.lua create mode 100644 data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua create mode 100644 data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index 69f1d7f7948..7b29268b2fe 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -3097,6 +3097,9 @@ GlobalStorage = { Yasir = 65014, IceCrack = 65016, UglyMonster = 65017, + FacelessBaneStepsOn = 65018, + FacelessBaneDeaths = 65019, + FacelessBaneResetSteps = 65020, KeysUpdate = 40000, -- Reserved storage from 40000 - 40000 } diff --git a/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua b/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua index e4d8553c46a..31b4c3fa10e 100644 --- a/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua +++ b/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Faceless Bane") local monster = {} monster.description = "Faceless Bane" -monster.experience = 30000 +monster.experience = 20000 monster.outfit = { lookType = 1119, lookHead = 0, @@ -22,7 +22,11 @@ monster.manaCost = 0 monster.changeTarget = { interval = 4000, - chance = 10, + chance = 20 +} + +monster.reflects = { + { type = COMBAT_DEATHDAMAGE, percent = 90 }, } monster.bosstiary = { @@ -131,12 +135,9 @@ monster.elements = { { type = COMBAT_DROWNDAMAGE, percent = 0 }, { type = COMBAT_ICEDAMAGE, percent = 0 }, { type = COMBAT_HOLYDAMAGE, percent = 0 }, - { type = COMBAT_DEATHDAMAGE, percent = 99 }, + { type = COMBAT_DEATHDAMAGE, percent = 50 }, } -monster.heals = { - { type = COMBAT_DEATHDAMAGE, percent = 100 }, -} monster.immunities = { { type = "paralyze", condition = true }, @@ -149,6 +150,9 @@ mType.onThink = function(monster, interval) end mType.onAppear = function(monster, creature) if monster:getType():isRewardBoss() then + Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1) + monster:registerEvent("facelessBaneImmunity") + monster:registerEvent("facelessBaneOnDeath") monster:setReward(true) end end diff --git a/data-otservbr-global/scripts/creaturescripts/monster/faceless_bane_immunity.lua b/data-otservbr-global/scripts/creaturescripts/monster/faceless_bane_immunity.lua new file mode 100644 index 00000000000..01ebd1aa5b3 --- /dev/null +++ b/data-otservbr-global/scripts/creaturescripts/monster/faceless_bane_immunity.lua @@ -0,0 +1,49 @@ +local bossName = "Faceless Bane" + +-- reset monster HP to 100% +function healBoss(creature) + creature:addHealth(creature:getMaxHealth()) + creature:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT) + return true +end + +-- summon spectres +function createSummons(pos) + Game.createMonster("Gazer Spectre", pos) + Game.createMonster("Ripper Spectre", pos) + Game.createMonster("Burster Spectre", pos) + return true +end + +-- reset the monster HP and summon spectres upon death +function resetBoss(creature, deaths) + healBoss(creature) + createSummons(creature:getPosition()) + Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, deaths + 1) + Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 0) + Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1) +end + +local facelessBaneImmunity = CreatureEvent("facelessBaneImmunity") + +-- ensure that the boss stay invulnerable when the mechanic has not been executed +function facelessBaneImmunity.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) + if creature and creature:isMonster() and creature:getName() == bossName then + local creatureHealthPercent = (creature:getHealth() * 100) / creature:getMaxHealth() + + if creatureHealthPercent <= 20 and Game.getStorageValue(GlobalStorage.FacelessBaneDeaths) < 1 then + resetBoss(creature, Game.getStorageValue(GlobalStorage.FacelessBaneDeaths)) + return true + end + + if Game.getStorageValue(GlobalStorage.FacelessBaneStepsOn) < 1 then + healBoss(creature) + return true + else + return primaryDamage, primaryType, secondaryDamage, secondaryType + end + end + return true +end + +facelessBaneImmunity:register() diff --git a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua new file mode 100644 index 00000000000..eae46adcc5b --- /dev/null +++ b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua @@ -0,0 +1,17 @@ +local bossName = "Faceless Bane" + +local facelessBaneOnDeath = CreatureEvent("facelessBaneOnDeath") +function facelessBaneOnDeath.onDeath(creature) + + if creature:getName() == bossName then + onDeathForDamagingPlayers(creature, function(creature, player) + -- reset global storage state to default / ensure sqm's reset for the next team + Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, -1) + Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, -1) + Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1) + end) + end + return true +end + +facelessBaneOnDeath:register() diff --git a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua new file mode 100644 index 00000000000..00025eaf17b --- /dev/null +++ b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua @@ -0,0 +1,125 @@ +local walkedPositions = {} + +-- this variable controls the time to boss become immortal again, (after 1 minute, if dont die) +local lastResetTime = os.time() + +-- reset sqm's / make the boss immortal again +local function resetWalkedPositions() + if lastResetTime > os.time() then + return true + end + walkedPositions = {} + Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 0) + lastResetTime = os.time() + (1 * 60) +end + +-- energy effect to make the boss mortal +local function sendEnergyEffect() + -- positions: pipes on room, that should be electrocuted + local pipePositions = { + Position(33612, 32568, 13), + Position(33612, 32567, 13), + Position(33612, 32566, 13), + Position(33612, 32565, 13), + Position(33612, 32564, 13), + Position(33612, 32563, 13), + Position(33612, 32562, 13), + Position(33612, 32561, 13), + Position(33612, 32560, 13), + Position(33612, 32559, 13), + Position(33612, 32558, 13), + Position(33612, 32557, 13), + Position(33612, 32556, 13), + Position(33622, 32556, 13), + Position(33622, 32557, 13), + Position(33622, 32558, 13), + Position(33622, 32559, 13), + Position(33622, 32560, 13), + Position(33622, 32561, 13), + Position(33622, 32562, 13), + Position(33622, 32563, 13), + Position(33622, 32564, 13), + Position(33622, 32565, 13), + Position(33622, 32566, 13), + Position(33622, 32567, 13), + Position(33622, 32568, 13) + } + + -- energy effect / sound on pipes + for _, pp in ipairs(pipePositions) do + pp:sendMagicEffect(CONST_ME_PURPLEENERGY) + pp:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_GREAT_ENERGY_BEAM) + end + + return true +end + +local facelessBaneStepPositions = MoveEvent() + + -- capture steps in the specific SQM's to make the boss mortal + -- +function facelessBaneStepPositions.onStepIn(creature, item, position, fromPosition) + local player = creature:getPlayer() + if not player then + return true + end + + if Game.getStorageValue(GlobalStorage.FacelessBaneResetSteps) == 1 then + Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 0) + lastResetTime = os.time() + resetWalkedPositions() + end + + if Game.getStorageValue(GlobalStorage.FacelessBaneStepsOn) < 1 then + local positionAlreadyAdded = false + if #walkedPositions == 0 then + position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) + position:sendMagicEffect(CONST_ME_YELLOWENERGY) + table.insert(walkedPositions, position) + return true + end + + for _, p in ipairs(walkedPositions) do + if p == position then + positionAlreadyAdded = true + break + end + end + + if positionAlreadyAdded then + return true + else + position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) + position:sendMagicEffect(CONST_ME_YELLOWENERGY) + table.insert(walkedPositions, position) + + if #walkedPositions == 13 then + Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 1) + addEvent(resetWalkedPositions, 60 * 1000) + sendEnergyEffect() + return true + end + end + + return true + end + return true +end + +-- positions: SQM's to step +facelessBaneStepPositions:position( + Position(33615, 32567, 13), + Position(33613, 32567, 13), + Position(33611, 32563, 13), + Position(33610, 32561, 13), + Position(33611, 32558, 13), + Position(33614, 32557, 13), + Position(33617, 32558, 13), + Position(33620, 32557, 13), + Position(33623, 32558, 13), + Position(33624, 32561, 13), + Position(33623, 32563, 13), + Position(33621, 32567, 13), + Position(33619, 32567, 13) +) +facelessBaneStepPositions:register() From eee4ea71e971fbde4ef3934d4036e2132c256e92 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 18 Mar 2024 18:54:34 +0000 Subject: [PATCH 2/4] Lua code format - (Stylua) --- .../the_dream_courts/bosses/faceless_bane.lua | 3 +- .../faceless_bane_on_death.lua | 9 +- .../faceless_bane_step_positions.lua | 94 ++++++++----------- 3 files changed, 45 insertions(+), 61 deletions(-) diff --git a/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua b/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua index 31b4c3fa10e..5737ef10033 100644 --- a/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua +++ b/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua @@ -22,7 +22,7 @@ monster.manaCost = 0 monster.changeTarget = { interval = 4000, - chance = 20 + chance = 20, } monster.reflects = { @@ -138,7 +138,6 @@ monster.elements = { { type = COMBAT_DEATHDAMAGE, percent = 50 }, } - monster.immunities = { { type = "paralyze", condition = true }, { type = "outfit", condition = false }, diff --git a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua index eae46adcc5b..0ec1656c2ad 100644 --- a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua +++ b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua @@ -2,13 +2,12 @@ local bossName = "Faceless Bane" local facelessBaneOnDeath = CreatureEvent("facelessBaneOnDeath") function facelessBaneOnDeath.onDeath(creature) - if creature:getName() == bossName then onDeathForDamagingPlayers(creature, function(creature, player) - -- reset global storage state to default / ensure sqm's reset for the next team - Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, -1) - Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, -1) - Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1) + -- reset global storage state to default / ensure sqm's reset for the next team + Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, -1) + Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, -1) + Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1) end) end return true diff --git a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua index 00025eaf17b..80ca5d331ab 100644 --- a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua +++ b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua @@ -15,7 +15,7 @@ end -- energy effect to make the boss mortal local function sendEnergyEffect() - -- positions: pipes on room, that should be electrocuted + -- positions: pipes on room, that should be electrocuted local pipePositions = { Position(33612, 32568, 13), Position(33612, 32567, 13), @@ -42,7 +42,7 @@ local function sendEnergyEffect() Position(33622, 32565, 13), Position(33622, 32566, 13), Position(33622, 32567, 13), - Position(33622, 32568, 13) + Position(33622, 32568, 13), } -- energy effect / sound on pipes @@ -56,70 +56,56 @@ end local facelessBaneStepPositions = MoveEvent() - -- capture steps in the specific SQM's to make the boss mortal - -- +-- capture steps in the specific SQM's to make the boss mortal +-- function facelessBaneStepPositions.onStepIn(creature, item, position, fromPosition) - local player = creature:getPlayer() - if not player then - return true - end + local player = creature:getPlayer() + if not player then + return true + end - if Game.getStorageValue(GlobalStorage.FacelessBaneResetSteps) == 1 then - Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 0) - lastResetTime = os.time() - resetWalkedPositions() + if Game.getStorageValue(GlobalStorage.FacelessBaneResetSteps) == 1 then + Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 0) + lastResetTime = os.time() + resetWalkedPositions() + end + + if Game.getStorageValue(GlobalStorage.FacelessBaneStepsOn) < 1 then + local positionAlreadyAdded = false + if #walkedPositions == 0 then + position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) + position:sendMagicEffect(CONST_ME_YELLOWENERGY) + table.insert(walkedPositions, position) + return true end - if Game.getStorageValue(GlobalStorage.FacelessBaneStepsOn) < 1 then - local positionAlreadyAdded = false - if #walkedPositions == 0 then - position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) - position:sendMagicEffect(CONST_ME_YELLOWENERGY) - table.insert(walkedPositions, position) - return true + for _, p in ipairs(walkedPositions) do + if p == position then + positionAlreadyAdded = true + break end + end - for _, p in ipairs(walkedPositions) do - if p == position then - positionAlreadyAdded = true - break - end - end + if positionAlreadyAdded then + return true + else + position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) + position:sendMagicEffect(CONST_ME_YELLOWENERGY) + table.insert(walkedPositions, position) - if positionAlreadyAdded then + if #walkedPositions == 13 then + Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 1) + addEvent(resetWalkedPositions, 60 * 1000) + sendEnergyEffect() return true - else - position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) - position:sendMagicEffect(CONST_ME_YELLOWENERGY) - table.insert(walkedPositions, position) - - if #walkedPositions == 13 then - Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 1) - addEvent(resetWalkedPositions, 60 * 1000) - sendEnergyEffect() - return true - end end - - return true end + + return true + end return true end -- positions: SQM's to step -facelessBaneStepPositions:position( - Position(33615, 32567, 13), - Position(33613, 32567, 13), - Position(33611, 32563, 13), - Position(33610, 32561, 13), - Position(33611, 32558, 13), - Position(33614, 32557, 13), - Position(33617, 32558, 13), - Position(33620, 32557, 13), - Position(33623, 32558, 13), - Position(33624, 32561, 13), - Position(33623, 32563, 13), - Position(33621, 32567, 13), - Position(33619, 32567, 13) -) +facelessBaneStepPositions:position(Position(33615, 32567, 13), Position(33613, 32567, 13), Position(33611, 32563, 13), Position(33610, 32561, 13), Position(33611, 32558, 13), Position(33614, 32557, 13), Position(33617, 32558, 13), Position(33620, 32557, 13), Position(33623, 32558, 13), Position(33624, 32561, 13), Position(33623, 32563, 13), Position(33621, 32567, 13), Position(33619, 32567, 13)) facelessBaneStepPositions:register() From 350af756d9d5c0f46fd2d69c73e8fa70a905feb3 Mon Sep 17 00:00:00 2001 From: CarlosEDev Date: Mon, 18 Mar 2024 20:29:39 -0300 Subject: [PATCH 3/4] fix: dry/reset storages --- .../the_dream_courts/bosses/faceless_bane.lua | 4 +++- .../monster/faceless_bane_immunity.lua | 6 ++++-- .../the_dream_courts/faceless_bane_on_death.lua | 17 ----------------- 3 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua diff --git a/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua b/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua index 31b4c3fa10e..7621a9995e5 100644 --- a/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua +++ b/data-otservbr-global/monster/quests/the_dream_courts/bosses/faceless_bane.lua @@ -150,9 +150,11 @@ mType.onThink = function(monster, interval) end mType.onAppear = function(monster, creature) if monster:getType():isRewardBoss() then + -- reset global storage state to default / ensure sqm's reset for the next team + Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, -1) + Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, -1) Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1) monster:registerEvent("facelessBaneImmunity") - monster:registerEvent("facelessBaneOnDeath") monster:setReward(true) end end diff --git a/data-otservbr-global/scripts/creaturescripts/monster/faceless_bane_immunity.lua b/data-otservbr-global/scripts/creaturescripts/monster/faceless_bane_immunity.lua index 01ebd1aa5b3..43a94756e95 100644 --- a/data-otservbr-global/scripts/creaturescripts/monster/faceless_bane_immunity.lua +++ b/data-otservbr-global/scripts/creaturescripts/monster/faceless_bane_immunity.lua @@ -22,6 +22,7 @@ function resetBoss(creature, deaths) Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, deaths + 1) Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 0) Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1) + return true end local facelessBaneImmunity = CreatureEvent("facelessBaneImmunity") @@ -30,9 +31,10 @@ local facelessBaneImmunity = CreatureEvent("facelessBaneImmunity") function facelessBaneImmunity.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType) if creature and creature:isMonster() and creature:getName() == bossName then local creatureHealthPercent = (creature:getHealth() * 100) / creature:getMaxHealth() + local facelessBaneDeathsStorage = Game.getStorageValue(GlobalStorage.FacelessBaneDeaths) - if creatureHealthPercent <= 20 and Game.getStorageValue(GlobalStorage.FacelessBaneDeaths) < 1 then - resetBoss(creature, Game.getStorageValue(GlobalStorage.FacelessBaneDeaths)) + if creatureHealthPercent <= 20 and facelessBaneDeathsStorage < 1 then + resetBoss(creature, facelessBaneDeathsStorage) return true end diff --git a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua deleted file mode 100644 index eae46adcc5b..00000000000 --- a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_on_death.lua +++ /dev/null @@ -1,17 +0,0 @@ -local bossName = "Faceless Bane" - -local facelessBaneOnDeath = CreatureEvent("facelessBaneOnDeath") -function facelessBaneOnDeath.onDeath(creature) - - if creature:getName() == bossName then - onDeathForDamagingPlayers(creature, function(creature, player) - -- reset global storage state to default / ensure sqm's reset for the next team - Game.setStorageValue(GlobalStorage.FacelessBaneDeaths, -1) - Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, -1) - Game.setStorageValue(GlobalStorage.FacelessBaneResetSteps, 1) - end) - end - return true -end - -facelessBaneOnDeath:register() From 6846be7dae2f203ed528624e6daae4ad6e507e94 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Silva <104630060+CarlosE-Dev@users.noreply.github.com> Date: Sat, 30 Mar 2024 15:18:57 -0300 Subject: [PATCH 4/4] Update data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua Co-authored-by: Luan Luciano --- .../faceless_bane_step_positions.lua | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua index 80ca5d331ab..ae810047d2e 100644 --- a/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua +++ b/data-otservbr-global/scripts/creaturescripts/quests/the_dream_courts/faceless_bane_step_positions.lua @@ -71,37 +71,23 @@ function facelessBaneStepPositions.onStepIn(creature, item, position, fromPositi end if Game.getStorageValue(GlobalStorage.FacelessBaneStepsOn) < 1 then - local positionAlreadyAdded = false - if #walkedPositions == 0 then - position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) - position:sendMagicEffect(CONST_ME_YELLOWENERGY) - table.insert(walkedPositions, position) - return true - end - - for _, p in ipairs(walkedPositions) do - if p == position then - positionAlreadyAdded = true - break + if #walkedPositions > 0 then + for _, walkedPos in ipairs(walkedPositions) do + if walkedPos == position then + return true + end end end - if positionAlreadyAdded then - return true - else - position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) - position:sendMagicEffect(CONST_ME_YELLOWENERGY) - table.insert(walkedPositions, position) + position:sendSingleSoundEffect(SOUND_EFFECT_TYPE_SPELL_BUZZ) + position:sendMagicEffect(CONST_ME_YELLOWENERGY) + table.insert(walkedPositions, position) - if #walkedPositions == 13 then - Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 1) - addEvent(resetWalkedPositions, 60 * 1000) - sendEnergyEffect() - return true - end + if #walkedPositions == 13 then + Game.setStorageValue(GlobalStorage.FacelessBaneStepsOn, 1) + addEvent(resetWalkedPositions, 60 * 1000) + sendEnergyEffect() end - - return true end return true end