From e27545511730372dad850156d3c79481d20a55ac Mon Sep 17 00:00:00 2001 From: Luan Santos Date: Mon, 20 Nov 2023 13:23:05 -0800 Subject: [PATCH] fix: warzone IV-VI cooldown (#1851) --- .../bosses_mission_depths.lua | 13 ++----- .../quests/dangerous_depth/boss_entrance.lua | 39 ++++++++++--------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/data-otservbr-global/scripts/creaturescripts/quests/dangerous_depths/bosses_mission_depths.lua b/data-otservbr-global/scripts/creaturescripts/quests/dangerous_depths/bosses_mission_depths.lua index 63ffa3c6ffd..9880d96626e 100644 --- a/data-otservbr-global/scripts/creaturescripts/quests/dangerous_depths/bosses_mission_depths.lua +++ b/data-otservbr-global/scripts/creaturescripts/quests/dangerous_depths/bosses_mission_depths.lua @@ -1,7 +1,7 @@ local bosses = { - ["the count of the core"] = { storage = Storage.DangerousDepths.Bosses.TheCountOfTheCore, value = os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN), teleportPosition = Position(33681, 32340, 15), toPosition = Position(33682, 32315, 15), toPositionBack = Position(33324, 32111, 15) }, - ["the duke of the depths"] = { storage = Storage.DangerousDepths.Bosses.TheDukeOfTheDepths, value = os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN), teleportPosition = Position(33719, 32302, 15), toPosition = Position(33691, 32301, 15), toPositionBack = Position(33275, 32318, 15) }, - ["the baron from below"] = { storage = Storage.DangerousDepths.Bosses.TheBaronFromBelow, value = os.time() + configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN), teleportPosition = Position(33650, 32312, 15), toPosition = Position(33668, 32301, 15), toPositionBack = Position(33462, 32267, 15) }, + ["the count of the core"] = { teleportPosition = Position(33681, 32340, 15), toPosition = Position(33682, 32315, 15), toPositionBack = Position(33324, 32111, 15) }, + ["the duke of the depths"] = { teleportPosition = Position(33719, 32302, 15), toPosition = Position(33691, 32301, 15), toPositionBack = Position(33275, 32318, 15) }, + ["the baron from below"] = { teleportPosition = Position(33650, 32312, 15), toPosition = Position(33668, 32301, 15), toPositionBack = Position(33462, 32267, 15) }, } local function revert(position, toPosition) @@ -14,15 +14,10 @@ end local bossesMissionDepth = CreatureEvent("DepthWarzoneBossDeath") function bossesMissionDepth.onDeath(creature) - local boss = bosses[player:getName():lower()] + local boss = bosses[creature:getName():lower()] if not boss then return true end - onDeathForDamagingPlayers(creature, function(player, _value) - if player:getStorageValue(boss.storage) < boss.value then - player:setStorageValue(boss.storage, boss.value) - end - end) local teleport = Tile(boss.teleportPosition):getItemById(1949) if teleport then diff --git a/data-otservbr-global/scripts/movements/quests/dangerous_depth/boss_entrance.lua b/data-otservbr-global/scripts/movements/quests/dangerous_depth/boss_entrance.lua index 30af7f7676b..20300f3ac5f 100644 --- a/data-otservbr-global/scripts/movements/quests/dangerous_depth/boss_entrance.lua +++ b/data-otservbr-global/scripts/movements/quests/dangerous_depth/boss_entrance.lua @@ -1,4 +1,5 @@ local bossEntrance = MoveEvent() +local timeToFightAgain = 10 -- hours function bossEntrance.onStepIn(creature, item, position, fromPosition, toPosition) local player = creature:getPlayer() @@ -15,33 +16,35 @@ function bossEntrance.onStepIn(creature, item, position, fromPosition, toPositio local WarzoneVI = Position(33275, 32316, 15) local WarzoneVI_b = Position(33717, 32302, 15) + local bossName = "The Count of the Core" + local destination = WarzoneV_b + if item:getPosition() == WarzoneIV then -- Warzone IV - if player:getStorageValue(Storage.DangerousDepths.Bosses.TheBaronFromBelow) > os.time() then - player:teleportTo(fromPosition) - player:say("You have to wait to challenge this enemy again!", TALKTYPE_MONSTER_SAY) - else - player:teleportTo(WarzoneIV_b) - end + bossName = "The Baron from Below" + destination = WarzoneIV_b end if item:getPosition() == WarzoneV then -- Warzone V - if player:getStorageValue(Storage.DangerousDepths.Bosses.TheCountOfTheCore) > os.time() then - player:teleportTo(fromPosition) - player:say("You have to wait to challenge this enemy again!", TALKTYPE_MONSTER_SAY) - else - player:teleportTo(WarzoneV_b) - end + bossName = "The Count of the Core" + destination = WarzoneV_b end if item:getPosition() == WarzoneVI then -- Warzone VI - if player:getStorageValue(Storage.DangerousDepths.Bosses.TheDukeOfTheDepths) > os.time() then - player:teleportTo(fromPosition) - player:say("You have to wait to challenge this enemy again!", TALKTYPE_MONSTER_SAY) - else - player:teleportTo(WarzoneVI_b) - end + bossName = "The Duke of the Depths" + destination = WarzoneVI_b + end + local timeLeft = player:getBossCooldown(bossName) - os.time() + if timeLeft > 0 then + player:teleportTo(fromPosition, true) + player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have to wait " .. getTimeInWords(timeLeft) .. " to face " .. bossName .. " again!") + player:getPosition():sendMagicEffect(CONST_ME_POFF) + return true end + + player:teleportTo(destination) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) + player:setBossCooldown(bossName, os.time() + timeToFightAgain * 3600) return true end