Skip to content

Commit

Permalink
The Secret Library Quest - The Path of Defiances
Browse files Browse the repository at this point in the history
  • Loading branch information
htc16 committed Oct 22, 2024
1 parent e8db3b3 commit e2a842c
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 27 deletions.
3 changes: 2 additions & 1 deletion data-otservbr-global/lib/core/quests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6600,7 +6600,7 @@ if not Quests then
storageId = Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline,
missionId = 10455,
startValue = 1,
endValue = 8,
endValue = 9,
states = {
[1] = "Go to Darashia and find out about the mysterious statue.",
[2] = "After you have been swallowed by a sand vortex you have entered a hidden desert area. A voice of unknown origin has informed you that you will have to face some challenges.",
Expand All @@ -6610,6 +6610,7 @@ if not Quests then
[6] = "Part VI",
[7] = "Part VII",
[8] = "You have found a book page in a chest. It seems to contain very useful information, but you are not capable to read it. At this point you have to speak with an expert.",
[9] = "Congratulations you completed this mission.",
},
},
[6] = {
Expand Down
10 changes: 8 additions & 2 deletions data-otservbr-global/npc/dedoras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,14 @@ local function creatureSayCallback(npc, creature, type, message)
startMission(player:getId(), Storage.Quest.U11_80.TheSecretLibrary.MoTA.Questline, 1)
end
elseif MsgContains(message, "desert") then
npcHandler:say("There are rumors of a mysterious statue in the desert next to Darashia. Nobody really knows the meaning of it.", npc, creature)
startMission(player:getId(), Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline, 1)
if player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline) == 8 then
npcHandler:say("That's simply a scientific sensation. It will provide me with lots of much needed knowledge!", npc, creature)
startMission(player:getId(), Storage.Quest.U11_80.TheSecretLibrary.LibraryPermission, currentStorage + 1)
startMission(player:getId(), Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline, 9)
elseif player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline) < 1 then
npcHandler:say("There are rumors of a mysterious statue in the desert next to Darashia. Nobody really knows the meaning of it.", npc, creature)
startMission(player:getId(), Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline, 1)
end
elseif MsgContains(message, "fishmen") then
if player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.LiquidDeath.Questline) == 7 then
npcHandler:say("You brought incredible news. This book proves an invaluable clue!", npc, creature)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local doors = {
[1] = { doorPosition = Position(32963, 32319, 9), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm, value = 40 },
[1] = { doorPosition = Position(32963, 32319, 9), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm, value = 39 },
[2] = { doorPosition = Position(32955, 32304, 9), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm, value = 40 },
[3] = { doorPosition = Position(32984, 32314, 9), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.SecondChest, value = 1 },
[3] = { doorPosition = Position(32984, 32314, 9), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.FirstChest, value = 1 },
[4] = { doorPosition = Position(32968, 32324, 9), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.SecondChest, value = 1 },
[5] = { doorPosition = Position(32978, 32290, 10), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.EatenFood, value = 1 },
[5] = { doorPosition = Position(32978, 32290, 10), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.EatenFood, value = 4 },
[6] = { doorPosition = Position(32963, 32297, 8), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline, value = 7 },
[7] = { doorPosition = Position(32963, 32299, 8), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline, value = 7 },
[8] = { doorPosition = Position(32963, 32301, 8), storage = Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline, value = 7 },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
local foods = {
3606, 3250, 3577, 21145, 21144, 21143, 3578, 3579, 23535, 23545, 3580, 3581, 3582,
3583, 3584, 3585, 3586, 3587, 3588, 3589, 3590, 3591, 3592, 904, 3593, 3594, 3595,
3596, 3597, 3598, 3599, 3600, 3601, 3602, 3607, 3723, 3724, 3725, 3726, 3727, 3728,
3729, 3730, 3731, 3732, 5096, 20310, 5678, 6125, 6277, 6278, 6392, 6393, 6500, 6541,
6542, 6543, 6544, 6545, 6569, 6574, 7158, 7159, 229, 7373, 7374, 7375, 7376, 7377,
836, 841, 901, 169, 8010, 8011, 8012, 8013, 8014, 8015, 8016, 8017, 8019, 8177, 8197,
9537, 10329, 10453, 10219, 11459, 11460, 11461, 11462, 11681, 11682, 11683, 12310,
13992, 14084, 14085, 14681, 15795, 16103, 17457, 17820, 17821, 21146, 22187, 22185,
24382, 24383, 24396, 24948, 25692, 30198, 30202, 31560, 32069, 37530, 37531, 37532, 37533
}

local pillars = {
{ position = Position(32963, 32280, 10), itemPosition = Position(32961, 32280, 10) },
{ position = Position(32963, 32282, 10), itemPosition = Position(32961, 32282, 10) },
{ position = Position(32963, 32284, 10), itemPosition = Position(32961, 32284, 10) },
{ position = Position(32963, 32286, 10), itemPosition = Position(32961, 32286, 10) }
}

local storageValue = Storage.Quest.U11_80.TheSecretLibrary.Darashia.EatenFood
local transformTime = 5 * 60 * 1000

local perimeter1Min = Position(32964, 32278, 10)
local perimeter1Max = Position(32966, 32290, 10)

local perimeter2Min = Position(32961, 32288, 10)
local perimeter2Max = Position(32963, 32290, 10)

local function isFood(itemid)
for _, foodid in ipairs(foods) do
if foodid == itemid then
return true
end
end
return false
end

local function findPlayerInPerimeter()
-- Verificar ambos os perímetros
for x = perimeter1Min.x, perimeter1Max.x do
for y = perimeter1Min.y, perimeter1Max.y do
local tile = Tile(Position(x, y, perimeter1Min.z))
if tile then
local player = tile:getTopCreature()
if player and player:isPlayer() then
return player
end
end
end
end
for x = perimeter2Min.x, perimeter2Max.x do
for y = perimeter2Min.y, perimeter2Max.y do
local tile = Tile(Position(x, y, perimeter2Min.z))
if tile then
local player = tile:getTopCreature()
if player and player:isPlayer() then
return player
end
end
end
end
return nil
end

local foodSacrifice = MoveEvent()

function foodSacrifice.onAddItem(moveitem, tileitem, position)
if not isFood(moveitem.itemid) then
return true
end

for _, pillar in ipairs(pillars) do
if position == pillar.position and tileitem:getActionId() == 4932 then

local itemToTransform = Tile(pillar.itemPosition):getItemById(27987)
if itemToTransform then
-- Transformar item 27987 em 27989
itemToTransform:transform(27989)

-- Remover o item de comida e adicionar o item 24490 em seu lugar
local foodPosition = moveitem:getPosition()
moveitem:remove()
Game.createItem(24490, 1, foodPosition)

addEvent(function()
local revertedTile = Tile(pillar.itemPosition)
if revertedTile then
local itemToRevert = revertedTile:getItemById(27989)
if itemToRevert then
itemToRevert:transform(27987)
end
end
-- Reverter o item 24490 de volta (remover)
local revertFoodItem = Tile(foodPosition):getItemById(24490)
if revertFoodItem then
revertFoodItem:remove()
end
end, transformTime)

local player = findPlayerInPerimeter()
if player then
local currentProgress = player:getStorageValue(storageValue)
if currentProgress < 0 then
currentProgress = 0
end
if currentProgress < 4 then
player:setStorageValue(storageValue, currentProgress + 1)
end
if player:getStorageValue(storageValue) == 4 then
if player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Questlog) < 6 then
player:setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.Questline, 6)
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have completed the food offering ritual!")
end
end

return true
end
end
end
return true
end

foodSacrifice:type("additem")
foodSacrifice:aid(4932)
foodSacrifice:register()
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ function movements_desert_teleportTo.onStepIn(creature, item, position, fromPosi
if position == lastTeleport then
if resetRoom(scorpionPosition, bossName) then
if player:getStorageValue(scorpionTimer) < os.time() then
player:setStorageValue(scorpionTimer, os.time() + 20 * 60 * 60)
startBattle(player:getId(), Position(32958, 32309, 8), bossName, scorpionPosition)
addEvent(function(cid)
local p = Player(cid)
Expand All @@ -114,6 +113,12 @@ function movements_desert_teleportTo.onStepIn(creature, item, position, fromPosi
end
end
end, 5 * 1000 * 60, player:getId())
addEvent(function(cid)
local p = Player(cid)
if p then
p:setStorageValue(scorpionTimer, os.time() + 20 * 60 * 60)
end
end, 1000, player:getId())
else
player:sendCancelMessage("You are still exhausted from your last battle.")
player:teleportTo(fromPosition, true)
Expand Down Expand Up @@ -142,20 +147,25 @@ function movements_desert_teleportTo.onStepIn(creature, item, position, fromPosi
end
end
elseif item.actionid == 4931 then
for _, k in pairs(puzzle) do
if position == k.position then
if player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm) < #puzzle then
if player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm) == k.value then
player:setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm, player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm) + 1)
local tileItem = Tile(position):getItemById(item.itemid)
if tileItem and (tileItem:getId() == 231 or tileItem:getId() == 28318 or tileItem:getId() == 28319 or tileItem:getId() == 28320 or tileItem:getId() == 28322 or tileItem:getId() == 28323) then
for _, k in pairs(puzzle) do
if position == k.position then
local currentStep = player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm)
if currentStep == -1 then
currentStep = 0
end
if currentStep == k.value - 1 then
player:setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm, currentStep + 1)
player:getPosition():sendMagicEffect(CONST_ME_SOUND_WHITE)

if currentStep + 1 == #puzzle then
player:say("Access granted!", TALKTYPE_MONSTER_SAY)
end
else
player:setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm, 1)
player:setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm, 0)
player:getPosition():sendMagicEffect(CONST_ME_SOUND_RED)
end
elseif player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm) == #puzzle then
player:say("Access granted!", TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_SOUND_WHITE)
player:setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm, player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.PuzzleSqm) + 1)
end
end
end
Expand Down
89 changes: 89 additions & 0 deletions data-otservbr-global/startup/tables/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,95 @@ ItemAction = {
{ x = 33297, y = 31289, z = 9 },
},
},
[4930] = {
itemId = false,
itemPos = {
{ x = 33110, y = 32385, z = 7 },
{ x = 32958, y = 32322, z = 8 },
{ x = 32955, y = 32288, z = 10 },
{ x = 32942, y = 32283, z = 10 },
{ x = 32945, y = 32313, z = 8 },
{ x = 32963, y = 32319, z = 9 },
{ x = 32955, y = 32304, z = 9 },
{ x = 32984, y = 32314, z = 9 },
{ x = 32968, y = 32324, z = 9 },
{ x = 32978, y = 32290, z = 10 },
{ x = 32963, y = 32297, z = 8 },
{ x = 32963, y = 32299, z = 8 },
{ x = 32963, y = 32301, z = 8 },
{ x = 32963, y = 32303, z = 8 },
{ x = 32963, y = 32312, z = 8 },
},
},
[4931] = {
itemId = false,
itemPos = {
{ x = 32965, y = 32310, z = 9 },
{ x = 32965, y = 32309, z = 9 },
{ x = 32964, y = 32309, z = 9 },
{ x = 32963, y = 32309, z = 9 },
{ x = 32962, y = 32309, z = 9 },
{ x = 32961, y = 32309, z = 9 },
{ x = 32960, y = 32309, z = 9 },
{ x = 32959, y = 32309, z = 9 },
{ x = 32959, y = 32310, z = 9 },
{ x = 32959, y = 32311, z = 9 },
{ x = 32958, y = 32311, z = 9 },
{ x = 32957, y = 32311, z = 9 },
{ x = 32956, y = 32311, z = 9 },
{ x = 32956, y = 32310, z = 9 },
{ x = 32955, y = 32310, z = 9 },
{ x = 32954, y = 32310, z = 9 },
{ x = 32953, y = 32310, z = 9 },
{ x = 32953, y = 32311, z = 9 },
{ x = 32953, y = 32312, z = 9 },
{ x = 32953, y = 32313, z = 9 },
{ x = 32953, y = 32314, z = 9 },
{ x = 32954, y = 32314, z = 9 },
{ x = 32955, y = 32314, z = 9 },
{ x = 32956, y = 32314, z = 9 },
{ x = 32956, y = 32315, z = 9 },
{ x = 32956, y = 32316, z = 9 },
{ x = 32956, y = 32317, z = 9 },
{ x = 32957, y = 32317, z = 9 },
{ x = 32957, y = 32318, z = 9 },
{ x = 32957, y = 32319, z = 9 },
{ x = 32958, y = 32319, z = 9 },
{ x = 32959, y = 32319, z = 9 },
{ x = 32960, y = 32319, z = 9 },
{ x = 32960, y = 32318, z = 9 },
{ x = 32960, y = 32317, z = 9 },
{ x = 32961, y = 32317, z = 9 },
{ x = 32962, y = 32317, z = 9 },
{ x = 32962, y = 32318, z = 9 },
{ x = 32962, y = 32319, z = 9 },
{ x = 32970, y = 32314, z = 9 },
{ x = 32980, y = 32308, z = 9 },
{ x = 32955, y = 32282, z = 10 },
{ x = 32983, y = 32289, z = 10 },
{ x = 32944, y = 32309, z = 8 },

},
},
[4932] = {
itemId = false,
itemPos = {
{ x = 32974, y = 32296, z = 9 },
{ x = 32967, y = 32319, z = 9 },
{ x = 32963, y = 32280, z = 10 },
{ x = 32963, y = 32282, z = 10 },
{ x = 32963, y = 32284, z = 10 },
{ x = 32963, y = 32286, z = 10 },
},
},
[4933] = {
itemId = false,
itemPos = {
{ x = 32945, y = 32288, z = 10 },
{ x = 32948, y = 32288, z = 10 },
{ x = 32951, y = 32288, z = 10 },
},
},
-- Cults of Tibia Quest
[5522] = {
itemId = 25687,
Expand Down
10 changes: 0 additions & 10 deletions data/scripts/actions/items/foods.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ function food.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return true
end

if IsRunningGlobalDatapack() then
-- The Secret Library Quest
if player:getStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.eatenFood) ~= 1 then
if player:getPosition():isInRange(Position(32961, 32280, 10), Position(32964, 32286, 10)) then
player:say("Fames est optimus coquus", TALKTYPE_MONSTER_SAY)
player:setStorageValue(Storage.Quest.U11_80.TheSecretLibrary.Darashia.eatenFood, 1)
end
end
end

player:feed(itemFood[1] * 12)
player:say(itemFood[2], TALKTYPE_MONSTER_SAY)
player:updateSupplyTracker(item)
Expand Down

0 comments on commit e2a842c

Please sign in to comment.