From 56793a0a6514ad3fb09771f22cd3b5f452ea7c76 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Silva <104630060+CarlosE-Dev@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:54:10 -0300 Subject: [PATCH] feat: The Lost Brother Quest (#2454) Implementation of the quest "The Lost Brother". It's a small quest initiated with the NPC Tarun, with one of the rewards being able to negotiate with the NPC. So, this part was also modified so that the negotiation can only be done once this quest is complete. --- data-otservbr-global/lib/core/quests.lua | 14 +++- data-otservbr-global/lib/core/storages.lua | 3 +- data-otservbr-global/npc/tarun.lua | 68 +++++++++++++++++++ .../adventurers_guild/warrior_skeleton.lua | 5 ++ .../creaturescripts/customs/freequests.lua | 2 + .../movement-find-remains.lua | 19 ++++++ 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 data-otservbr-global/scripts/quests/the_lost_brother/movement-find-remains.lua diff --git a/data-otservbr-global/lib/core/quests.lua b/data-otservbr-global/lib/core/quests.lua index ef61ee2549b..a35dcb15dea 100644 --- a/data-otservbr-global/lib/core/quests.lua +++ b/data-otservbr-global/lib/core/quests.lua @@ -5592,7 +5592,7 @@ if not Quests then }, [41] = { name = "Adventurers Guild", - startStorageId = Storage.AdventurersGuild.GreatDragonHunt.WarriorSkeleton, + startStorageId = Storage.AdventurersGuild.QuestLine, startStorageValue = 1, missions = { [1] = { @@ -5606,6 +5606,18 @@ if not Quests then But the dragon hoards might justify the risks. You killed %d/50 dragons and dragon lords."):format(math.max(player:getStorageValue(Storage.AdventurersGuild.GreatDragonHunt.DragonCounter), 0)) end, }, + [2] = { + name = "The Lost Brother", + storageId = Storage.AdventurersGuild.TheLostBrother, + missionId = 11000, + startValue = 1, + endValue = 3, + states = { + [1] = "At the Kha'zeel Mountains you met the merchant Tarun. His brother has gone missing and was last seen following a beautiful woman into a palace. Tarun fears this woman might have been a demon.", + [2] = "You found the remains of Tarun's brother containing a message. Go back to Tarun and report his brother's last words.", + [3] = "You told Tarun about his brother's sad fate. He was very downhearted but gave you his sincere thanks. The beautiful asuri have taken a young man's life and the happiness of another one.", + }, + }, }, }, [42] = { diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index 6ce29967451..fce8059f7d1 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -1570,6 +1570,8 @@ Storage = { WarriorSkeleton = 52146, DragonCounter = 52147, }, + QuestLine = 52148, + TheLostBrother = 52149, }, DreamersChallenge = { -- Reserved storage from 52160 - 52199 @@ -2534,7 +2536,6 @@ Storage = { NightmareTeddy = {}, PoacherCavesMiniWorldChange = {}, TheGreatDragonHunt = {}, - TheLostBrother = {}, TheTaintedSouls = {}, }, U10_90 = { -- update 10.90 - Reserved Storages 45201 - 45350 diff --git a/data-otservbr-global/npc/tarun.lua b/data-otservbr-global/npc/tarun.lua index 31f56602f81..9f0b8be5883 100644 --- a/data-otservbr-global/npc/tarun.lua +++ b/data-otservbr-global/npc/tarun.lua @@ -51,6 +51,74 @@ npcType.onCloseChannel = function(npc, creature) npcHandler:onCloseChannel(npc, creature) end +local function creatureSayCallback(npc, creature, type, message) + local player = Player(creature) + if not player then + return false + end + local playerId = player:getId() + + if not npcHandler:checkInteraction(npc, creature) then + return false + end + + local theLostBrotherStorage = player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) + if MsgContains(message, "mission") then + if theLostBrotherStorage < 1 then + npcHandler:say({ + "My brother is missing. I fear, he went to this evil palace north of here. A place of great beauty, certainly filled with riches and luxury. But in truth it is a threshold to hell and demonesses are after his blood. ...", + "He is my brother, and I am deeply ashamed to admit but I don't dare to go there. Perhaps your heart is more courageous than mine. Would you go to see this place and search for my brother?", + }, npc, creature) + npcHandler:setTopic(playerId, 1) + elseif theLostBrotherStorage == 1 then + npcHandler:say("I hope you will find my brother.", npc, creature) + npcHandler:setTopic(playerId, 0) + elseif theLostBrotherStorage == 2 then + npcHandler:say({ + "So, he is dead as I feared. I warned him not to go with this woman, but he gave in to temptation. My heart darkens and moans. But you have my sincere thanks. ...", + "Without your help I would have stayed in the dark about his fate. Please, take this as a little recompense.", + }, npc, creature) + player:addItem(3039, 1) + player:addExperience(3000, true) + player:setStorageValue(Storage.AdventurersGuild.TheLostBrother, 3) + npcHandler:setTopic(playerId, 0) + end + elseif npcHandler:getTopic(playerId) == 1 then + if MsgContains(message, "yes") then + npcHandler:say("I thank you! This is more than I could hope!", npc, creature) + if theLostBrotherStorage < 1 then + player:setStorageValue(Storage.AdventurersGuild.QuestLine, 1) + end + player:setStorageValue(Storage.AdventurersGuild.TheLostBrother, 1) + elseif MsgContains(message, "no") then + npcHandler:say("As you wish.", npc, creature) + end + npcHandler:setTopic(playerId, 0) + end + + return true +end + +local function onTradeRequest(npc, creature) + local player = Player(creature) + if not player then + return false + end + local playerId = player:getId() + + if player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) ~= 3 then + return false + end + + return true +end + +npcHandler:setMessage(MESSAGE_GREET, "Greetings!") +npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell.") +npcHandler:setMessage(MESSAGE_SENDTRADE, "Of course, just have a look.") +npcHandler:setCallback(CALLBACK_ON_TRADE_REQUEST, onTradeRequest) +npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) +npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell.") npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true) npcConfig.shop = { diff --git a/data-otservbr-global/scripts/actions/quests/adventurers_guild/warrior_skeleton.lua b/data-otservbr-global/scripts/actions/quests/adventurers_guild/warrior_skeleton.lua index a1aec80aaee..73a5d3f8acb 100644 --- a/data-otservbr-global/scripts/actions/quests/adventurers_guild/warrior_skeleton.lua +++ b/data-otservbr-global/scripts/actions/quests/adventurers_guild/warrior_skeleton.lua @@ -3,6 +3,11 @@ function adventurersWarriorSkeleton.onUse(player, item, fromPosition, target, to if player:getStorageValue(Storage.AdventurersGuild.GreatDragonHunt.WarriorSkeleton) < 1 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have discovered a deceased warrior's skeleton. It seems he tried to hunt the dragons around here - and failed.") player:addItem(5882, 1) -- red dragon scale + + if player:getStorageValue(Storage.AdventurersGuild.QuestLine) < 1 then + player:setStorageValue(Storage.AdventurersGuild.QuestLine, 1) + end + player:setStorageValue(Storage.AdventurersGuild.GreatDragonHunt.WarriorSkeleton, 1) player:setStorageValue(Storage.AdventurersGuild.GreatDragonHunt.DragonCounter, 0) else diff --git a/data-otservbr-global/scripts/creaturescripts/customs/freequests.lua b/data-otservbr-global/scripts/creaturescripts/customs/freequests.lua index ac8f4506c70..ad0e8d49b73 100644 --- a/data-otservbr-global/scripts/creaturescripts/customs/freequests.lua +++ b/data-otservbr-global/scripts/creaturescripts/customs/freequests.lua @@ -275,8 +275,10 @@ local questTable = { { storage = Storage.Quest.U11_40.ThreatenedDreams.QuestLine, storageValue = 1 }, { storage = Storage.Quest.U11_40.ThreatenedDreams.Mission01[1], storageValue = 16 }, { storage = Storage.Quest.U11_40.ThreatenedDreams.Mission02.KroazurAccess, storageValue = 1 }, + { storage = Storage.AdventurersGuild.QuestLine, storageValue = 1 }, { storage = Storage.AdventurersGuild.GreatDragonHunt.WarriorSkeleton, storageValue = 1 }, { storage = Storage.AdventurersGuild.GreatDragonHunt.WarriorSkeleton, storageValue = 2 }, + { storage = Storage.AdventurersGuild.TheLostBrother, storageValue = 3 }, { storage = Storage.Quest.U10_55.Dawnport.Questline, storageValue = 1 }, { storage = Storage.Quest.U10_55.Dawnport.GoMain, storageValue = 1 }, { storage = Storage.ForgottenKnowledge.AccessDeath, storageValue = 1 }, diff --git a/data-otservbr-global/scripts/quests/the_lost_brother/movement-find-remains.lua b/data-otservbr-global/scripts/quests/the_lost_brother/movement-find-remains.lua new file mode 100644 index 00000000000..c2ddb8efcb7 --- /dev/null +++ b/data-otservbr-global/scripts/quests/the_lost_brother/movement-find-remains.lua @@ -0,0 +1,19 @@ +local findRemains = MoveEvent() + +function findRemains.onStepIn(creature, item, position, fromPosition) + local player = creature:getPlayer() + if not player then + return true + end + + if player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) == 1 then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You stumble over some old bones. Something is carved into the stone wall here: 'Tarun, my brother, you were right. She's evil.'") + player:setStorageValue(Storage.AdventurersGuild.TheLostBrother, 2) + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) + end + + return true +end + +findRemains:position(Position(32959, 32674, 4)) +findRemains:register()