From d16abb75b4476e8d4e13231abf0bb8c1237f3a12 Mon Sep 17 00:00:00 2001 From: CarlosEDev Date: Sun, 17 Mar 2024 21:38:56 -0300 Subject: [PATCH 1/6] feat:lost-brother-quest --- data-otservbr-global/lib/core/quests.lua | 14 +++- data-otservbr-global/lib/core/storages.lua | 3 +- data-otservbr-global/npc/tarun.lua | 65 +++++++++++++++++++ .../adventurers_guild/warrior_skeleton.lua | 5 ++ .../creaturescripts/customs/freequests.lua | 2 + .../movement-find-remains.lua | 19 ++++++ 6 files changed, 106 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..63f22996f50 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 69f1d7f7948..1f174aa7afd 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -1573,6 +1573,8 @@ Storage = { WarriorSkeleton = 52146, DragonCounter = 52147, }, + QuestLine = 52148, + TheLostBrother = 52149 }, DreamersChallenge = { -- Reserved storage from 52160 - 52199 @@ -2537,7 +2539,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..8ac9e74ec2d 100644 --- a/data-otservbr-global/npc/tarun.lua +++ b/data-otservbr-global/npc/tarun.lua @@ -51,6 +51,71 @@ npcType.onCloseChannel = function(npc, creature) npcHandler:onCloseChannel(npc, creature) end +local function creatureSayCallback(npc, creature, type, message) + local player = Player(creature) + local playerId = player:getId() + + if not npcHandler:checkInteraction(npc, creature) then + return false + end + + if MsgContains(message, "mission") then + if player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) < 1 then + npcHandler:setTopic(playerId, 1) + 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 + ) + elseif player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) == 1 then + npcHandler:say("I hope you will find my brother.", npc, creature) + elseif player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) == 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) + end + elseif MsgContains(message, "yes") then + if npcHandler:getTopic(playerId) == 1 then + npcHandler:say("I thank you! This is more than I could hope!", npc, creature) + if player:getStorageValue(Storage.AdventurersGuild.QuestLine) < 1 then + player:setStorageValue(Storage.AdventurersGuild.QuestLine, 1) + end + player:setStorageValue(Storage.AdventurersGuild.TheLostBrother, 1) + npcHandler:setTopic(playerId, 0) + end + elseif MsgContains(message, "no") then + if npcHandler:getTopic(playerId) == 1 then + npcHandler:say("As you wish.", npc, creature) + npcHandler:setTopic(playerId, 0) + end + end + + return true +end + +local function onTradeRequest(npc, creature) + local player = Player(creature) + 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..392a0b8438b --- /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() From 92bb4e8095fb6cae894322fdde999568c3f4876c Mon Sep 17 00:00:00 2001 From: CarlosEDev Date: Mon, 18 Mar 2024 18:30:21 -0300 Subject: [PATCH 2/6] applied dry for storage --- data-otservbr-global/npc/tarun.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/data-otservbr-global/npc/tarun.lua b/data-otservbr-global/npc/tarun.lua index 8ac9e74ec2d..6e9ad21dd1b 100644 --- a/data-otservbr-global/npc/tarun.lua +++ b/data-otservbr-global/npc/tarun.lua @@ -60,7 +60,9 @@ local function creatureSayCallback(npc, creature, type, message) end if MsgContains(message, "mission") then - if player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) < 1 then + local theLostBrotherStorage = player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) + + if theLostBrotherStorage < 1 then npcHandler:setTopic(playerId, 1) npcHandler:say( { @@ -70,9 +72,9 @@ local function creatureSayCallback(npc, creature, type, message) npc, creature ) - elseif player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) == 1 then + elseif theLostBrotherStorage == 1 then npcHandler:say("I hope you will find my brother.", npc, creature) - elseif player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) == 2 then + 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) @@ -83,7 +85,7 @@ local function creatureSayCallback(npc, creature, type, message) elseif MsgContains(message, "yes") then if npcHandler:getTopic(playerId) == 1 then npcHandler:say("I thank you! This is more than I could hope!", npc, creature) - if player:getStorageValue(Storage.AdventurersGuild.QuestLine) < 1 then + if theLostBrotherStorage < 1 then player:setStorageValue(Storage.AdventurersGuild.QuestLine, 1) end player:setStorageValue(Storage.AdventurersGuild.TheLostBrother, 1) From 87d9d8149c4cb09d90d6f1b9a7e6b47d48101ed0 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 18 Mar 2024 21:31:11 +0000 Subject: [PATCH 3/6] Lua code format - (Stylua) --- data-otservbr-global/lib/core/quests.lua | 22 +++++++++---------- data-otservbr-global/lib/core/storages.lua | 2 +- data-otservbr-global/npc/tarun.lua | 15 +++++-------- .../movement-find-remains.lua | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/data-otservbr-global/lib/core/quests.lua b/data-otservbr-global/lib/core/quests.lua index 63f22996f50..a35dcb15dea 100644 --- a/data-otservbr-global/lib/core/quests.lua +++ b/data-otservbr-global/lib/core/quests.lua @@ -5607,17 +5607,17 @@ if not Quests then 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.", - }, - } + 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 1f174aa7afd..a7358c83037 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -1574,7 +1574,7 @@ Storage = { DragonCounter = 52147, }, QuestLine = 52148, - TheLostBrother = 52149 + TheLostBrother = 52149, }, DreamersChallenge = { -- Reserved storage from 52160 - 52199 diff --git a/data-otservbr-global/npc/tarun.lua b/data-otservbr-global/npc/tarun.lua index 6e9ad21dd1b..f372afb18e6 100644 --- a/data-otservbr-global/npc/tarun.lua +++ b/data-otservbr-global/npc/tarun.lua @@ -64,20 +64,17 @@ local function creatureSayCallback(npc, creature, type, message) if theLostBrotherStorage < 1 then npcHandler:setTopic(playerId, 1) - 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: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) elseif theLostBrotherStorage == 1 then npcHandler:say("I hope you will find my brother.", npc, creature) 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) + "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) 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 index 392a0b8438b..c2ddb8efcb7 100644 --- 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 @@ -8,7 +8,7 @@ function findRemains.onStepIn(creature, item, position, fromPosition) 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:setStorageValue(Storage.AdventurersGuild.TheLostBrother, 2) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) end From eafa7474698645192731c825c220c55ebe6f421d Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Silva <104630060+CarlosE-Dev@users.noreply.github.com> Date: Mon, 18 Mar 2024 23:05:38 -0300 Subject: [PATCH 4/6] Update data-otservbr-global/npc/tarun.lua Co-authored-by: Luan Luciano --- data-otservbr-global/npc/tarun.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data-otservbr-global/npc/tarun.lua b/data-otservbr-global/npc/tarun.lua index f372afb18e6..c3702a3205c 100644 --- a/data-otservbr-global/npc/tarun.lua +++ b/data-otservbr-global/npc/tarun.lua @@ -53,6 +53,9 @@ 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 From cf2b9503f431e1b278ca475b5610729927d7ac22 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Silva <104630060+CarlosE-Dev@users.noreply.github.com> Date: Mon, 18 Mar 2024 23:05:46 -0300 Subject: [PATCH 5/6] Update data-otservbr-global/npc/tarun.lua Co-authored-by: Luan Luciano --- data-otservbr-global/npc/tarun.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data-otservbr-global/npc/tarun.lua b/data-otservbr-global/npc/tarun.lua index c3702a3205c..9adfc3e629b 100644 --- a/data-otservbr-global/npc/tarun.lua +++ b/data-otservbr-global/npc/tarun.lua @@ -103,6 +103,9 @@ 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 From 147d7fa51cd544f934839bf02802450d3f34202f Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Silva <104630060+CarlosE-Dev@users.noreply.github.com> Date: Mon, 18 Mar 2024 23:10:44 -0300 Subject: [PATCH 6/6] Update data-otservbr-global/npc/tarun.lua Co-authored-by: Luan Luciano --- data-otservbr-global/npc/tarun.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/data-otservbr-global/npc/tarun.lua b/data-otservbr-global/npc/tarun.lua index 9adfc3e629b..9f0b8be5883 100644 --- a/data-otservbr-global/npc/tarun.lua +++ b/data-otservbr-global/npc/tarun.lua @@ -62,17 +62,17 @@ local function creatureSayCallback(npc, creature, type, message) return false end + local theLostBrotherStorage = player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) if MsgContains(message, "mission") then - local theLostBrotherStorage = player:getStorageValue(Storage.AdventurersGuild.TheLostBrother) - if theLostBrotherStorage < 1 then - npcHandler:setTopic(playerId, 1) 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. ...", @@ -81,21 +81,19 @@ local function creatureSayCallback(npc, creature, type, message) player:addItem(3039, 1) player:addExperience(3000, true) player:setStorageValue(Storage.AdventurersGuild.TheLostBrother, 3) + npcHandler:setTopic(playerId, 0) end - elseif MsgContains(message, "yes") then - if npcHandler:getTopic(playerId) == 1 then + 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) - npcHandler:setTopic(playerId, 0) - end - elseif MsgContains(message, "no") then - if npcHandler:getTopic(playerId) == 1 then + elseif MsgContains(message, "no") then npcHandler:say("As you wish.", npc, creature) - npcHandler:setTopic(playerId, 0) end + npcHandler:setTopic(playerId, 0) end return true