Skip to content

Commit

Permalink
fix: warzone IV-VI cooldown (#1851)
Browse files Browse the repository at this point in the history
  • Loading branch information
luan authored Nov 20, 2023
1 parent b6af793 commit e275455
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bossEntrance = MoveEvent()
local timeToFightAgain = 10 -- hours

function bossEntrance.onStepIn(creature, item, position, fromPosition, toPosition)
local player = creature:getPlayer()
Expand All @@ -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

Expand Down

0 comments on commit e275455

Please sign in to comment.