Skip to content

Commit

Permalink
fix: convert forgotten knowledge boss levers to lib (#1783)
Browse files Browse the repository at this point in the history
Also adds a `/clearcooldown <boss-name>,<player-name>` to reset these cooldowns more easily.
  • Loading branch information
luan authored Nov 8, 2023
1 parent c7b582b commit a9c391b
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 466 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ monster.outfit = {
lookMount = 0,
}

monster.events = {
"scarlettThink",
"scarlettHealth",
}

monster.bosstiary = {
bossRaceId = 1804,
bossRace = RARITY_ARCHFOE,
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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),
Expand All @@ -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()
Original file line number Diff line number Diff line change
@@ -1,95 +1,27 @@
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),
},
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()
Original file line number Diff line number Diff line change
@@ -1,95 +1,29 @@
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 },
{ pos = Position(32657, 32879, 14), teleport = Position(32624, 32886, 14), effect = CONST_ME_TELEPORT },
{ 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),
},
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()
Loading

0 comments on commit a9c391b

Please sign in to comment.