From a9c391b4af42f138509826861c986042fb5c20d8 Mon Sep 17 00:00:00 2001 From: Luan Santos Date: Tue, 7 Nov 2023 18:05:52 -0800 Subject: [PATCH] fix: convert forgotten knowledge boss levers to lib (#1783) Also adds a `/clearcooldown ,` to reset these cooldowns more easily. --- .../grave_danger/bosses/scarlett_etzel.lua | 5 + .../forgotten_knowledge/horror_lever.lua | 2 +- .../forgotten_knowledge/last_lore_lever.lua | 137 ++++------------ .../forgotten_knowledge/tenebris_lever.lua | 102 ++---------- .../thorn_knight_lever.lua | 94 ++--------- .../time_guardian_lever.lua | 105 ++----------- .../grave_danger/cobra_bastion/scarlett.lua | 147 +++++++----------- .../grave_danger/cobra_bastion/scarlett.lua | 2 +- data/libs/functions/player.lua | 2 +- data/scripts/reward_chest/boss_death.lua | 9 +- data/scripts/talkactions/god/manage_kv.lua | 41 +++-- 11 files changed, 180 insertions(+), 466 deletions(-) diff --git a/data-otservbr-global/monster/quests/grave_danger/bosses/scarlett_etzel.lua b/data-otservbr-global/monster/quests/grave_danger/bosses/scarlett_etzel.lua index 589dced3c53..6673313045f 100644 --- a/data-otservbr-global/monster/quests/grave_danger/bosses/scarlett_etzel.lua +++ b/data-otservbr-global/monster/quests/grave_danger/bosses/scarlett_etzel.lua @@ -13,6 +13,11 @@ monster.outfit = { lookMount = 0, } +monster.events = { + "scarlettThink", + "scarlettHealth", +} + monster.bosstiary = { bossRaceId = 1804, bossRace = RARITY_ARCHFOE, diff --git a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/horror_lever.lua b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/horror_lever.lua index c6803028ca5..073af13ec6a 100644 --- a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/horror_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/horror_lever.lua @@ -1,7 +1,7 @@ local eggPos = Position(32269, 31084, 14) local config = { boss = { - name = "Frozen Horror", + name = "Melting Frozen Horror", createFunction = function() Tile(eggPos):getTopCreature():setHealth(1) return Game.createMonster("solid frozen horror", Position(32269, 31091, 14), true, true) diff --git a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/last_lore_lever.lua b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/last_lore_lever.lua index 38116e880d0..27c3be87cd7 100644 --- a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/last_lore_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/last_lore_lever.lua @@ -1,33 +1,35 @@ local config = { - bossName = "The Last Lore Keeper", - timeToFightAgain = 14 * 24, -- In hour - timeToDefeat = 17, -- In minutes + boss = { + name = "The Last Lore Keeper", + position = Position(31987, 32839, 14), + }, + timeToFightAgain = ParseDuration("14d") / 1000, + timeToDefeat = ParseDuration("17m") / 1000, playerPositions = { - { pos = Position(32018, 32844, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32019, 32844, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32020, 32844, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32018, 32845, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32019, 32845, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32020, 32845, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32018, 32846, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32019, 32846, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32020, 32846, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32018, 32847, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32019, 32847, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32020, 32847, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32018, 32848, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32019, 32848, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32020, 32848, 14), teleport = Position(31984, 32851, 14), effect = CONST_ME_TELEPORT }, + { pos = Position(32018, 32844, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32019, 32844, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32020, 32844, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32018, 32845, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32019, 32845, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32020, 32845, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32018, 32846, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32019, 32846, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32020, 32846, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32018, 32847, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32019, 32847, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32020, 32847, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32018, 32848, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32019, 32848, 14), teleport = Position(31984, 32851, 14) }, + { pos = Position(32020, 32848, 14), teleport = Position(31984, 32851, 14) }, }, - bossPosition = Position(31987, 32839, 14), monsters = { - { pos = Position(31973, 32840, 15), monster = "bound astral power" }, - { pos = Position(31973, 32856, 15), monster = "bound astral power" }, - { pos = Position(31989, 32856, 15), monster = "bound astral power" }, - { pos = Position(31989, 32840, 15), monster = "bound astral power" }, - { pos = Position(31986, 32840, 14), monster = "a shielded astral glyph" }, - { pos = Position(31986, 32823, 15), monster = "the distorted astral source" }, - { pos = Position(31989, 32823, 15), monster = "an astral glyph" }, + { name = "bound astral power", pos = Position(31973, 32840, 15) }, + { name = "bound astral power", pos = Position(31973, 32856, 15) }, + { name = "bound astral power", pos = Position(31989, 32856, 15) }, + { name = "bound astral power", pos = Position(31989, 32840, 15) }, + { name = "a shielded astral glyph", pos = Position(31986, 32840, 14) }, + { name = "the distorted astral source", pos = Position(31986, 32823, 15) }, + { name = "an astral glyph", pos = Position(31989, 32823, 15) }, }, specPos = { from = Position(31968, 32821, 14), @@ -36,83 +38,6 @@ local config = { exit = Position(32035, 32859, 14), } -local forgottenKnowledgeLastLore = Action() -function forgottenKnowledgeLastLore.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if config.playerPositions[2].pos ~= player:getPosition() then - return false - end - - local spec = Spectators() - spec:setOnlyPlayer(false) - spec:setRemoveDestination(config.exit) - spec:setCheckPosition(config.specPos) - spec:setMultiFloor(true) - spec:check() - - if spec:getPlayers() > 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There's someone fighting with " .. config.bossName .. ".") - return true - end - - local lever = Lever() - lever:setPositions(config.playerPositions) - lever:setCondition(function(creature) - if not creature or not creature:isPlayer() then - return true - end - - if creature:getStorageValue(config.storage) > os.time() then - local info = lever:getInfoPositions() - for _, v in pairs(info) do - local newPlayer = v.creature - if newPlayer then - newPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. config.timeToFightAgain / 24 .. " days to face " .. config.bossName .. " again!") - if newPlayer:getStorageValue(config.storage) > os.time() then - newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) - end - end - end - return false - end - return true - end) - - lever:checkPositions() - if lever:checkConditions() then - spec:removeMonsters() - for n = 1, #config.monsters do - Game.createMonster(config.monsters[n].monster, config.monsters[n].pos, true, true) - end - local monster = Game.createMonster("the astral source", config.bossPosition, true, true) - if not monster then - return true - end - lever:teleportPlayers() - lever:setCooldownAllPlayers(config.bossName, os.time() + config.timeToFightAgain * 3600) - Game.setStorageValue(GlobalStorage.ForgottenKnowledge.AstralPowerCounter, 1) - Game.setStorageValue(GlobalStorage.ForgottenKnowledge.AstralGlyph, 0) - player:say("The Astral Glyph begins to draw upon bound astral power to expel you from the room!", TALKTYPE_MONSTER_SAY) - addEvent(function() - local old_players = lever:getInfoPositions() - spec:clearCreaturesCache() - spec:setOnlyPlayer(true) - spec:check() - local player_remove = {} - for i, v in pairs(spec:getCreatureDetect()) do - for _, v_old in pairs(old_players) do - if v_old.creature == nil or v_old.creature:isMonster() then - break - end - if v:getName() == v_old.creature:getName() then - table.insert(player_remove, v_old.creature) - break - end - end - end - spec:removePlayers(player_remove) - end, config.timeToDefeat * 60 * 1000) - end -end - -forgottenKnowledgeLastLore:position(Position(32019, 32843, 14)) -forgottenKnowledgeLastLore:register() +local lever = BossLever(config) +lever:position(Position(32019, 32843, 14)) +lever:register() diff --git a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/tenebris_lever.lua b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/tenebris_lever.lua index e5ab381f8a4..d1262a34140 100644 --- a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/tenebris_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/tenebris_lever.lua @@ -1,15 +1,20 @@ local config = { - bossName = "Lady Tenebris", - timeToFightAgain = 20, -- In hour - timeToDefeat = 15, -- In minutes + boss = { + name = "Lady Tenebris", + position = Position(32912, 31599, 14), + }, playerPositions = { - { pos = Position(32902, 31623, 14), teleport = Position(32911, 31603, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32902, 31624, 14), teleport = Position(32911, 31603, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32902, 31625, 14), teleport = Position(32911, 31603, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32902, 31626, 14), teleport = Position(32911, 31603, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(32902, 31627, 14), teleport = Position(32911, 31603, 14), effect = CONST_ME_TELEPORT }, + { pos = Position(32902, 31623, 14), teleport = Position(32911, 31603, 14) }, + { pos = Position(32902, 31624, 14), teleport = Position(32911, 31603, 14) }, + { pos = Position(32902, 31625, 14), teleport = Position(32911, 31603, 14) }, + { pos = Position(32902, 31626, 14), teleport = Position(32911, 31603, 14) }, + { pos = Position(32902, 31627, 14), teleport = Position(32911, 31603, 14) }, }, - bossPosition = Position(32912, 31599, 14), + onUseExtra = function(player) + for d = 1, 6 do + Game.createMonster("shadow tentacle", Position(math.random(32909, 32914), math.random(31596, 31601), 14), true, true) + end + end, specPos = { from = Position(32895, 31585, 14), to = Position(32830, 32855, 14), @@ -17,79 +22,6 @@ local config = { exit = Position(32902, 31629, 14), } -local forgottenKnowledgeTenebris = Action() -function forgottenKnowledgeTenebris.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if config.playerPositions[1].pos ~= player:getPosition() then - return false - end - - local spec = Spectators() - spec:setOnlyPlayer(false) - spec:setRemoveDestination(config.exit) - spec:setCheckPosition(config.specPos) - spec:check() - - if spec:getPlayers() > 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There's someone fighting with " .. config.bossName .. ".") - return true - end - - local lever = Lever() - lever:setPositions(config.playerPositions) - lever:setCondition(function(creature) - if not creature or not creature:isPlayer() then - return true - end - - if creature:getStorageValue(config.storage) > os.time() then - local info = lever:getInfoPositions() - for _, v in pairs(info) do - local newPlayer = v.creature - if newPlayer then - newPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. config.timeToFightAgain .. " hours to face " .. config.bossName .. " again!") - if newPlayer:getStorageValue(config.storage) > os.time() then - newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) - end - end - end - return false - end - return true - end) - - lever:checkPositions() - if lever:checkConditions() then - spec:removeMonsters() - for d = 1, 6 do - Game.createMonster("shadow tentacle", Position(math.random(32909, 32914), math.random(31596, 31601), 14), true, true) - end - local monster = Game.createMonster(config.bossName, config.bossPosition, true, true) - if not monster then - return true - end - lever:teleportPlayers() - lever:setCooldownAllPlayers(config.bossName, os.time() + config.timeToFightAgain * 3600) - addEvent(function() - local old_players = lever:getInfoPositions() - spec:clearCreaturesCache() - spec:setOnlyPlayer(true) - spec:check() - local player_remove = {} - for i, v in pairs(spec:getCreatureDetect()) do - for _, v_old in pairs(old_players) do - if v_old.creature == nil or v_old.creature:isMonster() then - break - end - if v:getName() == v_old.creature:getName() then - table.insert(player_remove, v_old.creature) - break - end - end - end - spec:removePlayers(player_remove) - end, config.timeToDefeat * 60 * 1000) - end -end - -forgottenKnowledgeTenebris:position(Position(32902, 31622, 14)) -forgottenKnowledgeTenebris:register() +local lever = BossLever(config) +lever:position(Position(32902, 31622, 14)) +lever:register() diff --git a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/thorn_knight_lever.lua b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/thorn_knight_lever.lua index c62514fbaf3..872841f4962 100644 --- a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/thorn_knight_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/thorn_knight_lever.lua @@ -1,7 +1,10 @@ local config = { - bossName = "Thorn Knight", - timeToFightAgain = 20, -- In hour - timeToDefeat = 15, -- In minutes + boss = { + name = "The Enraged Thorn Knight", + createFunction = function() + return Game.createMonster("Mounted Thorn Knight", Position(32624, 32880, 14), true, true) + end, + }, playerPositions = { { pos = Position(32657, 32877, 14), teleport = Position(32624, 32886, 14), effect = CONST_ME_TELEPORT }, { pos = Position(32657, 32878, 14), teleport = Position(32624, 32886, 14), effect = CONST_ME_TELEPORT }, @@ -9,7 +12,11 @@ local config = { { pos = Position(32657, 32880, 14), teleport = Position(32624, 32886, 14), effect = CONST_ME_TELEPORT }, { pos = Position(32657, 32881, 14), teleport = Position(32624, 32886, 14), effect = CONST_ME_TELEPORT }, }, - bossPosition = Position(32624, 32880, 14), + onUseExtra = function(player) + for d = 1, 6 do + Game.createMonster("possessed tree", Position(math.random(32619, 32629), math.random(32877, 32884), 14), true, true) + end + end, specPos = { from = Position(32613, 32869, 14), to = Position(32636, 32892, 14), @@ -17,79 +24,6 @@ local config = { exit = Position(32678, 32888, 14), } -local forgottenKnowledgeThorn = Action() -function forgottenKnowledgeThorn.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if config.playerPositions[1].pos ~= player:getPosition() then - return false - end - - local spec = Spectators() - spec:setOnlyPlayer(false) - spec:setRemoveDestination(config.exit) - spec:setCheckPosition(config.specPos) - spec:check() - - if spec:getPlayers() > 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There's someone fighting with " .. config.bossName .. ".") - return true - end - - local lever = Lever() - lever:setPositions(config.playerPositions) - lever:setCondition(function(creature) - if not creature or not creature:isPlayer() then - return true - end - - if creature:getStorageValue(config.storage) > os.time() then - local info = lever:getInfoPositions() - for _, v in pairs(info) do - local newPlayer = v.creature - if newPlayer then - newPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. config.timeToFightAgain .. " hours to face " .. config.bossName .. " again!") - if newPlayer:getStorageValue(config.storage) > os.time() then - newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) - end - end - end - return false - end - return true - end) - - lever:checkPositions() - if lever:checkConditions() then - spec:removeMonsters() - for d = 1, 6 do - Game.createMonster("possessed tree", Position(math.random(32619, 32629), math.random(32877, 32884), 14), true, true) - end - local monster = Game.createMonster("mounted thorn knight", config.bossPosition, true, true) - if not monster then - return true - end - lever:teleportPlayers() - lever:setCooldownAllPlayers("The Enraged Thorn Knight", os.time() + config.timeToFightAgain * 3600) - addEvent(function() - local old_players = lever:getInfoPositions() - spec:clearCreaturesCache() - spec:setOnlyPlayer(true) - spec:check() - local player_remove = {} - for i, v in pairs(spec:getCreatureDetect()) do - for _, v_old in pairs(old_players) do - if v_old.creature == nil or v_old.creature:isMonster() then - break - end - if v:getName() == v_old.creature:getName() then - table.insert(player_remove, v_old.creature) - break - end - end - end - spec:removePlayers(player_remove) - end, config.timeToDefeat * 60 * 1000) - end -end - -forgottenKnowledgeThorn:position(Position(32657, 32876, 14)) -forgottenKnowledgeThorn:register() +local lever = BossLever(config) +lever:position(Position(32657, 32876, 14)) +lever:register() diff --git a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/time_guardian_lever.lua b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/time_guardian_lever.lua index 832e42e2c6c..71808ad0efe 100644 --- a/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/time_guardian_lever.lua +++ b/data-otservbr-global/scripts/actions/quests/forgotten_knowledge/time_guardian_lever.lua @@ -1,99 +1,26 @@ local config = { - bossName = "The Time Guardian", - timeToFightAgain = 20, -- In hour - timeToDefeat = 15, -- In minutes + boss = { + name = "The Time Guardian", + position = Position(32977, 31662, 14), + }, playerPositions = { - { pos = Position(33010, 31660, 14), teleport = Position(32977, 31667, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33010, 31661, 14), teleport = Position(32977, 31667, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33010, 31662, 14), teleport = Position(32977, 31667, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33010, 31663, 14), teleport = Position(32977, 31667, 14), effect = CONST_ME_TELEPORT }, - { pos = Position(33010, 31664, 14), teleport = Position(32977, 31667, 14), effect = CONST_ME_TELEPORT }, + { pos = Position(33010, 31660, 14), teleport = Position(32977, 31667, 14) }, + { pos = Position(33010, 31661, 14), teleport = Position(32977, 31667, 14) }, + { pos = Position(33010, 31662, 14), teleport = Position(32977, 31667, 14) }, + { pos = Position(33010, 31663, 14), teleport = Position(32977, 31667, 14) }, + { pos = Position(33010, 31664, 14), teleport = Position(32977, 31667, 14) }, }, - bosses = { - { bossPosition = Position(32977, 31662, 14), bossName = "The Time Guardian" }, - { bossPosition = Position(32975, 31664, 13), bossName = "The Freezing Time Guardian" }, - { bossPosition = Position(32980, 31664, 13), bossName = "The Blazing Time Guardian" }, + monsters = { + { name = "The Freezing Time Guardian", pos = Position(32975, 31664, 13) }, + { name = "The Blazing Time Guardian", pos = Position(32980, 31664, 13) }, }, specPos = { - from = Position(32967, 31654, 13), + from = Position(32967, 31654, 14), to = Position(32989, 31677, 14), }, exit = Position(32870, 32724, 14), } -local forgottenKnowledgeGuardianLever = Action() -function forgottenKnowledgeGuardianLever.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if config.playerPositions[1].pos ~= player:getPosition() then - return false - end - - local spec = Spectators() - spec:setOnlyPlayer(false) - spec:setRemoveDestination(config.exit) - spec:setCheckPosition(config.specPos) - spec:setMultiFloor(true) - spec:check() - - if spec:getPlayers() > 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "There's someone fighting with " .. config.bossName .. ".") - return true - end - - local lever = Lever() - lever:setPositions(config.playerPositions) - lever:setCondition(function(creature) - if not creature or not creature:isPlayer() then - return true - end - - if creature:getStorageValue(config.storage) > os.time() then - local info = lever:getInfoPositions() - for _, v in pairs(info) do - local newPlayer = v.creature - if newPlayer then - newPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. config.timeToFightAgain .. " hours to face " .. config.bossName .. " again!") - if newPlayer:getStorageValue(config.storage) > os.time() then - newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) - end - end - end - return false - end - return true - end) - - lever:checkPositions() - if lever:checkConditions() then - spec:removeMonsters() - for b = 1, #config.bosses do - local monster = Game.createMonster(config.bosses[b].bossName, config.bosses[b].bossPosition, true, true) - if not monster then - return true - end - end - lever:teleportPlayers() - lever:setCooldownAllPlayers(config.bossName, os.time() + config.timeToFightAgain * 3600) - addEvent(function() - local old_players = lever:getInfoPositions() - spec:clearCreaturesCache() - spec:setOnlyPlayer(true) - spec:check() - local player_remove = {} - for i, v in pairs(spec:getCreatureDetect()) do - for _, v_old in pairs(old_players) do - if v_old.creature == nil or v_old.creature:isMonster() then - break - end - if v:getName() == v_old.creature:getName() then - table.insert(player_remove, v_old.creature) - break - end - end - end - spec:removePlayers(player_remove) - end, config.timeToDefeat * 60 * 1000) - end -end - -forgottenKnowledgeGuardianLever:position(Position(33010, 31659, 14)) -forgottenKnowledgeGuardianLever:register() +local lever = BossLever(config) +lever:position(Position(33010, 31659, 14)) +lever:register() diff --git a/data-otservbr-global/scripts/actions/quests/grave_danger/cobra_bastion/scarlett.lua b/data-otservbr-global/scripts/actions/quests/grave_danger/cobra_bastion/scarlett.lua index dea665f82d2..53dbb4f669d 100644 --- a/data-otservbr-global/scripts/actions/quests/grave_danger/cobra_bastion/scarlett.lua +++ b/data-otservbr-global/scripts/actions/quests/grave_danger/cobra_bastion/scarlett.lua @@ -1,25 +1,6 @@ -local info = { - bossName = "Scarlett Etzel", - middle = Position(33395, 32662, 6), - fromPos = Position(33385, 32638, 6), - toPos = Position(33406, 32660, 6), - exitPos = Position(33395, 32670, 6), - armorId = 31482, - armorPos = Position(33398, 32640, 6), -} - -local entry = { - metalWallId = 31449, - roomEntryPos = Position(33395, 32666, 6), - roomExitPos = Position(33395, 32668, 6), -} - -local transformTo = { - [31474] = 31475, - [31475] = 31476, - [31476] = 31477, - [31477] = 31474, -} +local armorId = 31482 +local armorPos = Position(33398, 32640, 6) +local metalWallId = 31449 local function createArmor(id, amount, pos) local armor = Game.createItem(id, amount, pos) @@ -28,49 +9,43 @@ local function createArmor(id, amount, pos) end end -local graveScarlettUid = Action() -function graveScarlettUid.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local playersTable = {} - if item:getUniqueId() == 40028 then - if player:doCheckBossRoom(info.bossName, info.fromPos, info.toPos) then - for x = info.middle.x - 1, info.middle.x + 1 do - for y = info.middle.y - 1, info.middle.y + 1 do - local sqm = Tile(Position(x, y, 6)) - if sqm and sqm:getGround():getId() == 18013 then - local player_ = sqm:getTopCreature() - if player_ and player_:isPlayer() then - if not player_:canFightBoss(info.bossName) then - player_:getPosition():sendMagicEffect(CONST_ME_POFF) - player_:sendCancelMessage("You are still exhausted from your last battle.") - return true - end - table.insert(playersTable, player_:getId()) - end - end - end - end - for _, p in pairs(playersTable) do - local nPlayer = Player(p) - if nPlayer then - nPlayer:teleportTo(Position(33395, 32656, 6)) - nPlayer:setBossCooldown(info.bossName, os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN)) - end - end - local scarlett = Game.createMonster("Scarlett Etzel", Position(33396, 32640, 6)) - if scarlett then - scarlett:registerEvent("scarlettThink") - scarlett:registerEvent("scarlettHealth") - scarlett:setStorageValue(Storage.GraveDanger.CobraBastion.Questline, 1) - end - SCARLETT_MAY_TRANSFORM = 0 - addEvent(kickPlayersAfterTime, 30 * 60 * 1000, playersTable, info.fromPos, info.toPos, info.exitPos) - end - end - return true -end +local config = { + boss = { + name = "Scarlett Etzel", + createFunction = function() + local scarlett = Game.createMonster("Scarlett Etzel", Position(33396, 32643, 6), true, true) + scarlett:setStorageValue(Storage.GraveDanger.CobraBastion.Questline, 1) + return scarlett + end, + }, + timeAfterKill = 60, + playerPositions = { + { pos = Position(33395, 32661, 6), teleport = Position(33396, 32651, 6) }, + { pos = Position(33394, 32662, 6), teleport = Position(33396, 32651, 6) }, + { pos = Position(33396, 32662, 6), teleport = Position(33396, 32651, 6) }, + { pos = Position(33395, 32662, 6), teleport = Position(33396, 32651, 6) }, + { pos = Position(33395, 32663, 6), teleport = Position(33396, 32651, 6) }, + }, + specPos = { + from = Position(33385, 32638, 6), + to = Position(33406, 32660, 6), + }, + onUseExtra = function() + SCARLETT_MAY_TRANSFORM = 0 + end, + exit = Position(33395, 32665, 6), +} + +local lever = BossLever(config) +lever:position(Position(33395, 32660, 6)) +lever:register() -graveScarlettUid:uid(40028) -graveScarlettUid:register() +local transformTo = { + [31474] = 31475, + [31475] = 31476, + [31476] = 31477, + [31477] = 31474, +} local mirror = { fromPos = Position(33389, 32641, 6), @@ -97,29 +72,27 @@ end local graveScarlettAid = Action() function graveScarlettAid.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if item.actionid == 40003 then - if table.contains(transformTo, item.itemid) then - local pilar = transformTo[item.itemid] - if pilar then - item:transform(pilar) - item:getPosition():sendMagicEffect(CONST_ME_POFF) - end - elseif item.itemid == info.armorId then - item:getPosition():sendMagicEffect(CONST_ME_THUNDER) - item:remove(1) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You hold the old chestplate of Galthein in front of you. It does not fit and far too old to withstand any attack.") - addEvent(createArmor, 20 * 1000, info.armorId, 1, info.armorPos) - addEvent(backMirror, 10 * 1000) - SCARLETT_MAY_TRANSFORM = 1 - addEvent(function() - SCARLETT_MAY_TRANSFORM = 0 - end, 1 * 1000) - elseif item.itemid == entry.metalWallId then - if player:getPosition().y == entry.roomExitPos.y then - player:teleportTo(entry.roomEntryPos) - else - player:teleportTo(entry.roomExitPos) - end + if table.contains(transformTo, item.itemid) then + local pilar = transformTo[item.itemid] + if pilar then + item:transform(pilar) + item:getPosition():sendMagicEffect(CONST_ME_POFF) + end + elseif item.itemid == armorId then + item:getPosition():sendMagicEffect(CONST_ME_THUNDER) + item:remove(1) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You hold the old chestplate of Galthein in front of you. It does not fit and far too old to withstand any attack.") + addEvent(createArmor, 20 * 1000, armorId, 1, armorPos) + addEvent(backMirror, 10 * 1000) + SCARLETT_MAY_TRANSFORM = 1 + addEvent(function() + SCARLETT_MAY_TRANSFORM = 0 + end, 2000) + elseif item.itemid == metalWallId then + if player:getPosition().y == 32666 then + player:teleportTo(Position(33395, 32668, 6)) + else + player:teleportTo(Position(33395, 32666, 6)) end end return true diff --git a/data-otservbr-global/scripts/creaturescripts/quests/grave_danger/cobra_bastion/scarlett.lua b/data-otservbr-global/scripts/creaturescripts/quests/grave_danger/cobra_bastion/scarlett.lua index 9287e1b5726..f68cdfc155d 100644 --- a/data-otservbr-global/scripts/creaturescripts/quests/grave_danger/cobra_bastion/scarlett.lua +++ b/data-otservbr-global/scripts/creaturescripts/quests/grave_danger/cobra_bastion/scarlett.lua @@ -103,7 +103,7 @@ function scarlettThink.onThink(creature) for _, p in pairs(rooms) do if creature:getPosition():isInRange(p.fromPos, p.toPos) then if isMirrorsCorrect(p.fromPos, p.toPos) then - addEvent(changeScarlett, 0.5 * 1000, creature:getId()) + addEvent(changeScarlett, 50, creature:getId()) return true end end diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index ac1706a364f..272b89b030c 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -677,5 +677,5 @@ end function Player:canFightBoss(bossNameOrId) local cooldown = self:getBossCooldown(bossNameOrId) - return cooldown > os.time() and false or true + return cooldown <= os.time() end diff --git a/data/scripts/reward_chest/boss_death.lua b/data/scripts/reward_chest/boss_death.lua index 1a979e945ab..81a64e0cd84 100644 --- a/data/scripts/reward_chest/boss_death.lua +++ b/data/scripts/reward_chest/boss_death.lua @@ -1,9 +1,6 @@ local bossDeath = CreatureEvent("BossDeath") function bossDeath.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified) - if not corpse or corpse == 0 then - return true - end -- Deny summons and players if not creature or creature:isPlayer() or creature:getMaster() then return true @@ -13,15 +10,15 @@ function bossDeath.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUn local monsterType = creature:getType() -- Make sure it is a boss if monsterType and monsterType:isRewardBoss() then - if not corpse.isContainer or not corpse:isContainer() then + if not corpse or not corpse.isContainer or not corpse:isContainer() then if corpse.getId then logger.warn("[bossDeath.onDeath] Corpse (id: {}, name: {}) for reward boss {} is not a container.", corpse:getId(), corpse:getName(), creature:getName()) else logger.warn("[bossDeath.onDeath] Error to get corpseId from boss: {}", creature:getName()) end - else - corpse:registerReward() + corpse = Game.createItem(ITEM_BAG, 1) end + corpse:registerReward() local bossId = creature:getId() local rewardId = corpse:getAttribute(ITEM_ATTRIBUTE_DATE) diff --git a/data/scripts/talkactions/god/manage_kv.lua b/data/scripts/talkactions/god/manage_kv.lua index 085bde31aa8..6a2f4e6c6b7 100644 --- a/data/scripts/talkactions/god/manage_kv.lua +++ b/data/scripts/talkactions/god/manage_kv.lua @@ -1,6 +1,6 @@ -local storageGet = TalkAction("/getkv") +local get = TalkAction("/getkv") -function storageGet.onSay(player, words, param) +function get.onSay(player, words, param) local value = kv.get(param) if value then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "kv[" .. param .. "]: " .. PrettyString(value)) @@ -9,11 +9,11 @@ function storageGet.onSay(player, words, param) end end -storageGet:separator(" ") -storageGet:groupType("god") -storageGet:register() +get:separator(" ") +get:groupType("god") +get:register() -local talkaction = TalkAction("/setkv") +local set = TalkAction("/setkv") local function splitFirst(str, delimiter) local start, finish = string.find(str, delimiter) @@ -25,13 +25,34 @@ local function splitFirst(str, delimiter) return firstPart, secondPart end -function talkaction.onSay(player, words, param) +function set.onSay(player, words, param) local key, value = splitFirst(param, " ") value = load("return " .. value)() kv.set(key, value) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "kv[" .. key .. "] = " .. PrettyString(value)) end -talkaction:separator(" ") -talkaction:groupType("god") -talkaction:register() +set:separator(" ") +set:groupType("god") +set:register() + +local bossCooldown = TalkAction("/clearcooldown") + +function bossCooldown.onSay(player, words, param) + local boss, playerName = splitFirst(param, ",") + if not playerName then + playerName = player:getName() + end + local targetPlayer = Player(playerName) + if not targetPlayer then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. playerName .. " not found.") + return + end + targetPlayer:setBossCooldown(boss, 0) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Boss cooldown for " .. playerName .. " cleared.") + targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Boss cooldown for " .. boss .. " cleared.") +end + +bossCooldown:separator(" ") +bossCooldown:groupType("god") +bossCooldown:register()