From e1c5f61a5cea7eefd6dcb2d00e5cb0322e55f57c Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 00:14:31 -0300 Subject: [PATCH 01/15] chore: convert golden outfit from storage to kv --- data-otservbr-global/npc/emperor_kruzak.lua | 37 ++++++------------ data-otservbr-global/npc/king_tibianus.lua | 38 ++++++------------- data-otservbr-global/npc/queen_eloise.lua | 37 ++++++------------ .../objects}/golden_outfit_display.lua | 2 +- 4 files changed, 37 insertions(+), 77 deletions(-) rename {data-otservbr-global/scripts/actions/object => data/scripts/actions/objects}/golden_outfit_display.lua (92%) diff --git a/data-otservbr-global/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index 4f838396df0..ade9333b6db 100644 --- a/data-otservbr-global/npc/emperor_kruzak.lua +++ b/data-otservbr-global/npc/emperor_kruzak.lua @@ -62,23 +62,18 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In exchange for a truly generous donation, I will offer a special outfit. Do you want to make a donation?", npc, creature) npcHandler:setTopic(playerId, 1) elseif MsgContains(message, "yes") then - -- vamos tratar todas condições para YES aqui if npcHandler:getTopic(playerId) == 1 then - -- para o primeiro Yes, o npc deve explicar como obter o outfit npcHandler:say({ "Excellent! Now, let me explain. If you donate 1.000.000.000 gold pieces, you will be entitled to wear a unique outfit. ...", "You will be entitled to wear the {armor} for 500.000.000 gold pieces, {helmet} for an additional 250.000.000 and the {boots} for another 250.000.000 gold pieces. ...", "What will it be?", }, npc, creature) npcHandler:setTopic(playerId, 2) - -- O NPC só vai oferecer os addons se o player já tiver escolhido. elseif npcHandler:getTopic(playerId) == 2 then - -- caso o player repita o yes, resetamos o tópico para começar de novo? npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) - -- Inicio do outfit - elseif npcHandler:getTopic(playerId) == 3 then -- ARMOR/OUTFIT - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 1 then + elseif npcHandler:getTopic(playerId) == 3 then + if player:kv():get("golden-outfit-quest") < 1 then if player:getMoney() + player:getBankBalance() >= 500000000 then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() @@ -92,7 +87,7 @@ local function creatureSayCallback(npc, creature, type, message) player:addOutfit(1211) player:addOutfit(1210) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 1) + player:kv():set("golden-outfit-quest", 1) else npcHandler:say("Please make sure you have free slots in your store inbox.", npc, creature) end @@ -103,18 +98,16 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("You alread have that addon.", npc, creature) end npcHandler:setTopic(playerId, 2) - -- Fim do outfit - -- Inicio do helmet elseif npcHandler:getTopic(playerId) == 4 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 1 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 2 then + if player:kv():get("golden-outfit-quest") == 1 then + if player:kv():get("golden-outfit-quest") < 2 then if player:getMoney() + player:getBankBalance() >= 250000000 then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 2) + player:kv():set("golden-outfit-quest", 2) npcHandler:setTopic(playerId, 2) else npcHandler:say("You do not have enough money to donate that amount.", npc, creature) @@ -129,18 +122,16 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 2) end npcHandler:setTopic(playerId, 2) - -- Fim do helmet - -- Inicio da boots elseif npcHandler:getTopic(playerId) == 5 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 2 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 3 then + if player:kv():get("golden-outfit-quest") == 2 then + if player:kv():get("golden-outfit-quest") < 3 then if player:getMoney() + player:getBankBalance() >= 250000000 then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 3) + player:kv():set("golden-outfit-quest", 3) npcHandler:setTopic(playerId, 2) else npcHandler:say("You do not have enough money to donate that amount.", npc, creature) @@ -154,22 +145,18 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("You need to donate {helmet} addon first.", npc, creature) npcHandler:setTopic(playerId, 2) end - -- Fim da boots npcHandler:setTopic(playerId, 2) end - --inicio das opções armor/helmet/boots - -- caso o player não diga YES, dirá alguma das seguintes palavras: elseif (MsgContains(message, "armor")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you wold like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) - npcHandler:setTopic(playerId, 3) -- alterando o tópico para que no próximo YES ele faça o outfit + npcHandler:setTopic(playerId, 3) elseif (MsgContains(message, "helmet")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear unique helmet?", npc, creature) - npcHandler:setTopic(playerId, 4) -- alterando o tópico para que no próximo YES ele faça o helmet + npcHandler:setTopic(playerId, 4) elseif (MsgContains(message, "boots")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear a unique boots?", npc, creature) - npcHandler:setTopic(playerId, 5) -- alterando o tópico para que no próximo YES ele faça a boots + npcHandler:setTopic(playerId, 5) end - -- fim das opções armor/helmet/boots end -- Promotion diff --git a/data-otservbr-global/npc/king_tibianus.lua b/data-otservbr-global/npc/king_tibianus.lua index de47e45acca..5850553a3df 100644 --- a/data-otservbr-global/npc/king_tibianus.lua +++ b/data-otservbr-global/npc/king_tibianus.lua @@ -71,19 +71,14 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In exchange for a truly generous donation, I will offer a special outfit. Do you want to make a donation?", npc, creature) npcHandler:setTopic(playerId, 1) elseif MsgContains(message, "yes") then - -- Vamos tratar todas condições para YES aqui if npcHandler:getTopic(playerId) == 1 then - -- Para o primeiro Yes, o npc deve explicar como obter o outfit npcHandler:say({ "Excellent! Now, let me explain. If you donate 1.000.000.000 gold pieces, you will be entitled to wear a unique outfit. ...", "You will be entitled to wear the {armor} for 500.000.000 gold pieces, {helmet} for an additional 250.000.000 and the {boots} for another 250.000.000 gold pieces. ...", "What will it be?" }, npc, creature) npcHandler:setTopic(playerId, 2) - -- O NPC só vai oferecer os addons se o player já tiver escolhido. elseif npcHandler:getTopic(playerId) == 2 then - -- caso o player repita o yes, resetamos o tópico para começar de novo? npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) - -- Inicio do outfit - elseif npcHandler:getTopic(playerId) == 3 then -- ARMOR/OUTFIT - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 1 then + elseif npcHandler:getTopic(playerId) == 3 then + if player:kv():get("golden-outfit-quest") < 1 then if player:getMoney() + player:getBankBalance() >= 500000000 then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() @@ -97,7 +92,7 @@ local function creatureSayCallback(npc, creature, type, message) player:addOutfit(1211) player:addOutfit(1210) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 1) + player:kv():set("golden-outfit-quest", 1) else npcHandler:say("Please make sure you have free slots in your store inbox.", npc, creature) end @@ -108,18 +103,16 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("You alread have that addon.", npc, creature) end npcHandler:setTopic(playerId, 2) - -- Fim do outfit - -- Inicio do helmet elseif npcHandler:getTopic(playerId) == 4 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 1 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 2 then + if player:kv():get("golden-outfit-quest") == 1 then + if player:kv():get("golden-outfit-quest") < 2 then if player:getMoney() + player:getBankBalance() >= 250000000 then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 2) + player:kv():set("golden-outfit-quest", 2) npcHandler:setTopic(playerId, 2) else npcHandler:say("You do not have enough money to donate that amount.", npc, creature) @@ -134,18 +127,16 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 2) end npcHandler:setTopic(playerId, 2) - -- Fim do helmet - -- Inicio da boots elseif npcHandler:getTopic(playerId) == 5 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 2 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 3 then + if player:kv():get("golden-outfit-quest") == 2 then + if player:kv():get("golden-outfit-quest") < 3 then if player:getMoney() + player:getBankBalance() >= 250000000 then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 3) + player:kv():set("golden-outfit-quest", 3) npcHandler:setTopic(playerId, 2) else npcHandler:say("You do not have enough money to donate that amount.", npc, creature) @@ -159,9 +150,7 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("You need to donate {helmet} addon first.", npc, creature) npcHandler:setTopic(playerId, 2) end - -- Fim da boots npcHandler:setTopic(playerId, 2) - -- Reseting word The New Frontier: Mission 5 elseif npcHandler:getTopic(playerId) == 6 then if player:getStorageValue(TheNewFrontier.Questline) == 14 and player:getStorageValue(TheNewFrontier.Mission05.KingTibianus) == 2 and player:removeItem(10009, 1) then npcHandler:say("Ah, I vaguely remember that our little allies were eager to build some base. So speak up, what do you want?", npc, creature) @@ -169,24 +158,21 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 10) end end - -- inicio das opções armor/helmet/boots - -- caso o player não diga YES, dirá alguma das seguintes palavras: elseif (MsgContains(message, "armor")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you wold like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) - npcHandler:setTopic(playerId, 3) -- alterando o tópico para que no próximo YES ele faça o outfit + npcHandler:setTopic(playerId, 3) elseif (MsgContains(message, "helmet")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear unique helmet?", npc, creature) - npcHandler:setTopic(playerId, 4) -- alterando o tópico para que no próximo YES ele faça o helmet + npcHandler:setTopic(playerId, 4) elseif (MsgContains(message, "boots")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear a unique boots?", npc, creature) - npcHandler:setTopic(playerId, 5) -- alterando o tópico para que no próximo YES ele faça a boots + npcHandler:setTopic(playerId, 5) else if player:getStorageValue(TheNewFrontier.Questline) == 14 and player:getStorageValue(TheNewFrontier.Mission05.KingTibianus) == 1 then npcHandler:say("Wrong Word.", npc, creature) player:setStorageValue(TheNewFrontier.Mission05.KingTibianus, 2) end end - -- fim das opções armor/helmet/boots end -- Promotion local node1 = keywordHandler:addKeyword({ "promot" }, StdModule.say, { diff --git a/data-otservbr-global/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index a9397061a56..cd11e37e1e7 100644 --- a/data-otservbr-global/npc/queen_eloise.lua +++ b/data-otservbr-global/npc/queen_eloise.lua @@ -57,23 +57,18 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In exchange for a truly generous donation, I will offer a special outfit. Do you want to make a donation?", npc, creature) npcHandler:setTopic(playerId, 1) elseif MsgContains(message, "yes") then - -- vamos tratar todas condições para YES aqui if npcHandler:getTopic(playerId) == 1 then - -- para o primeiro Yes, o npc deve explicar como obter o outfit npcHandler:say({ "Excellent! Now, let me explain. If you donate 1.000.000.000 gold pieces, you will be entitled to wear a unique outfit. ...", "You will be entitled to wear the {armor} for 500.000.000 gold pieces, {helmet} for an additional 250.000.000 and the {boots} for another 250.000.000 gold pieces. ...", "What will it be?", }, npc, creature) npcHandler:setTopic(playerId, 2) - -- O NPC só vai oferecer os addons se o player já tiver escolhido. elseif npcHandler:getTopic(playerId) == 2 then - -- caso o player repita o yes, resetamos o tópico para começar de novo? npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) - -- Inicio do outfit - elseif npcHandler:getTopic(playerId) == 3 then -- ARMOR/OUTFIT - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 1 then + elseif npcHandler:getTopic(playerId) == 3 then + if player:kv():get("golden-outfit-quest") < 1 then if player:getMoney() + player:getBankBalance() >= 500000000 then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() @@ -87,7 +82,7 @@ local function creatureSayCallback(npc, creature, type, message) player:addOutfit(1211) player:addOutfit(1210) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 1) + player:kv():set("golden-outfit-quest", 1) else npcHandler:say("Please make sure you have free slots in your store inbox.", npc, creature) end @@ -98,18 +93,16 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("You alread have that addon.", npc, creature) end npcHandler:setTopic(playerId, 2) - -- Fim do outfit - -- Inicio do helmet elseif npcHandler:getTopic(playerId) == 4 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 1 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 2 then + if player:kv():get("golden-outfit-quest") == 1 then + if player:kv():get("golden-outfit-quest") < 2 then if player:getMoney() + player:getBankBalance() >= 250000000 then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 2) + player:kv():set("golden-outfit-quest", 2) npcHandler:setTopic(playerId, 2) else npcHandler:say("You do not have enough money to donate that amount.", npc, creature) @@ -124,18 +117,16 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 2) end npcHandler:setTopic(playerId, 2) - -- Fim do helmet - -- Inicio da boots elseif npcHandler:getTopic(playerId) == 5 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 2 then - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) < 3 then + if player:kv():get("golden-outfit-quest") == 2 then + if player:kv():get("golden-outfit-quest") < 3 then if player:getMoney() + player:getBankBalance() >= 250000000 then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 3) + player:kv():set("golden-outfit-quest", 3) npcHandler:setTopic(playerId, 2) else npcHandler:say("You do not have enough money to donate that amount.", npc, creature) @@ -149,22 +140,18 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("You need to donate {helmet} addon first.", npc, creature) npcHandler:setTopic(playerId, 2) end - -- Fim da boots npcHandler:setTopic(playerId, 2) end - --inicio das opções armor/helmet/boots - -- caso o player não diga YES, dirá alguma das seguintes palavras: elseif (MsgContains(message, "armor")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you wold like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) - npcHandler:setTopic(playerId, 3) -- alterando o tópico para que no próximo YES ele faça o outfit + npcHandler:setTopic(playerId, 3) elseif (MsgContains(message, "helmet")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear unique helmet?", npc, creature) - npcHandler:setTopic(playerId, 4) -- alterando o tópico para que no próximo YES ele faça o helmet + npcHandler:setTopic(playerId, 4) elseif (MsgContains(message, "boots")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear a unique boots?", npc, creature) - npcHandler:setTopic(playerId, 5) -- alterando o tópico para que no próximo YES ele faça a boots + npcHandler:setTopic(playerId, 5) end - -- fim das opções armor/helmet/boots end -- Promotion diff --git a/data-otservbr-global/scripts/actions/object/golden_outfit_display.lua b/data/scripts/actions/objects/golden_outfit_display.lua similarity index 92% rename from data-otservbr-global/scripts/actions/object/golden_outfit_display.lua rename to data/scripts/actions/objects/golden_outfit_display.lua index 4301492a02a..47fcd610b83 100644 --- a/data-otservbr-global/scripts/actions/object/golden_outfit_display.lua +++ b/data/scripts/actions/objects/golden_outfit_display.lua @@ -25,7 +25,7 @@ function goldenOutfitDisplay.onUse(player, item, fromPosition, target, toPositio return true end - if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 3 then + if player:kv():get("golden-outfit-quest") == 3 then item:transform(newItemID) item:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) else From 540b8e4bb9b08bdf29eb62354b4682479900a34f Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 00:23:50 -0300 Subject: [PATCH 02/15] remove unused storage and old memorial --- data-otservbr-global/lib/core/storages.lua | 3 +- .../scripts/actions/other/outfit_memorial.lua | 64 ------------------- 2 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 data-otservbr-global/scripts/actions/other/outfit_memorial.lua diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index 69f1d7f7948..8b01ea39901 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -882,8 +882,7 @@ Storage = { AssassinBaseOutfit = 51012, AssassinFirstAddon = 51013, AssassinSecondAddon = 51014, - -- Golden Outfit - GoldenOutfit = 51015, + -- Nightmare Outfit NightmareOutfit = 51016, NightmareDoor = 51017, BrotherhoodOutfit = 51018, diff --git a/data-otservbr-global/scripts/actions/other/outfit_memorial.lua b/data-otservbr-global/scripts/actions/other/outfit_memorial.lua deleted file mode 100644 index 6061d5f11b9..00000000000 --- a/data-otservbr-global/scripts/actions/other/outfit_memorial.lua +++ /dev/null @@ -1,64 +0,0 @@ -local CACHE_UPDATE_INTERVAL = 60 -- 1 minute for update cache - -local goldenOutfitCache = { [1] = {}, [2] = {}, [3] = {} } -local royalOutfitCache = { [1] = {}, [2] = {}, [3] = {} } -local lastUpdatedGolden = 0 -local lastUpdatedRoyal = 0 - -local function updateOutfitCache(storageKey, cache, lastUpdated) - if os.time() < lastUpdated + CACHE_UPDATE_INTERVAL then - return cache, lastUpdated - end - - local newCache = { [1] = {}, [2] = {}, [3] = {} } - - local resultId = db.storeQuery("SELECT `name`, `value` FROM `player_storage` INNER JOIN `players` as `p` ON `p`.`id` = `player_id` WHERE `key` = " .. storageKey .. " AND `value` >= 1;") - if resultId then - repeat - table.insert(newCache[Result.getNumber(resultId, "value")], Result.getString(resultId, "name")) - until not Result.next(resultId) - Result.free(resultId) - end - - return newCache, os.time() -end - -local outfitMemorial = Action() - -function outfitMemorial.onUse(player, item, fromPosition, target, toPosition, isHotkey) - goldenOutfitCache, lastUpdatedGolden = updateOutfitCache(Storage.OutfitQuest.GoldenOutfit, goldenOutfitCache, lastUpdatedGolden) - royalOutfitCache, lastUpdatedRoyal = updateOutfitCache(Storage.OutfitQuest.RoyalCostumeOutfit, royalOutfitCache, lastUpdatedRoyal) - local response = NetworkMessage() - response:addByte(0xB0) - - -- Golden outfit bytes - response:addU32(500000000) -- Armor price - response:addU32(750000000) -- Armor + helmet price - response:addU32(1000000000) -- Armor + helmet + boots price - - for i = 1, 3 do - response:addU16(#goldenOutfitCache[i]) - for j = 1, #goldenOutfitCache[i] do - response:addString(goldenOutfitCache[i][j], "outfitMemorial.onUse - goldenOutfitCache[i][j]") - end - end - - -- Royal outfit bytes - for i = 1, 3 do - response:addU16(30000) -- price in silver tokens - response:addU16(25000) -- price in golden tokens - end - - for i = 1, 3 do - response:addU16(#royalOutfitCache[i]) - for j = 1, #royalOutfitCache[i] do - response:addString(royalOutfitCache[i][j], "outfitMemorial.onUse - royalOutfitCache[i][j]") - end - end - - response:sendToPlayer(player) - return true -end - -outfitMemorial:id(31518, 31519, 31520, 31521, 31522, 31523) -outfitMemorial:register() From eaace08f17f3ca8f031ea1c059fcef0cb6df7773 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 00:50:37 -0300 Subject: [PATCH 03/15] feat: outfit memorial --- data/scripts/actions/objects/memorial.lua | 66 +++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 data/scripts/actions/objects/memorial.lua diff --git a/data/scripts/actions/objects/memorial.lua b/data/scripts/actions/objects/memorial.lua new file mode 100644 index 00000000000..3894fa86fd0 --- /dev/null +++ b/data/scripts/actions/objects/memorial.lua @@ -0,0 +1,66 @@ +local lastUpdated = 0 +local goldenOutfitCache + +local function updateGoldenOutfitCache() + if os.time() < lastUpdated + 10 * 60 then + return + end + + goldenOutfitCache = {[1] = {}, [2] = {}, [3] = {}} + + local resultId = db.storeQuery("SELECT `key_name`, `timestamp`, `value` FROM `kv_store` WHERE `key_name` = '" .. "golden-outfit-quest" .. "'") + + if resultId ~= 0 then + repeat + local addons = result.getNumber(resultId, "value") + local name = result.getString(resultId, "name") + if not goldenOutfitCache[addons] then + goldenOutfitCache[addons] = {} + end + + table.insert(goldenOutfitCache[addons], name) + until not result.next(resultId) + result.free(resultId) + end + + lastUpdated = os.time() +end + +local memorial = Action() + +function memorial.onUse(player, item, fromPosition, target, toPosition, isHotkey) + updateGoldenOutfitCache() + + local msg = NetworkMessage() + msg:addByte(0xB0) + + local prices = {500000000, 750000000, 1000000000} + for i, price in ipairs(prices) do + msg:addU32(price) + end + + for i = 1, 3 do + msg:addU16(#goldenOutfitCache[i]) + + for j = 1, #goldenOutfitCache[i] do + msg:addString(goldenOutfitCache[i][j]) + end + end + + -- royal costume + for i = 1, 3 do + msg:addU16(0) -- price in silver tokens + msg:addU16(0) -- price in golden tokens + end + + for i = 1, 3 do + msg:addU16(0) -- list of spenders + end + + msg:sendToPlayer(player) + msg:delete() + return true +end + +memorial:id(31518, 31519, 31520, 31521, 31522, 31523) +memorial:register() From 0f49b47edfb867b57c034df2a109c0c18c9618a5 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 01:00:13 -0300 Subject: [PATCH 04/15] fix: custom attribute --- data-otservbr-global/npc/emperor_kruzak.lua | 2 +- data-otservbr-global/npc/queen_eloise.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data-otservbr-global/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index ade9333b6db..670421597dc 100644 --- a/data-otservbr-global/npc/emperor_kruzak.lua +++ b/data-otservbr-global/npc/emperor_kruzak.lua @@ -81,7 +81,7 @@ local function creatureSayCallback(npc, creature, type, message) local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1) local decoItemName = ItemType(31510):getName() decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".") - decoKit:setActionId(36345) + decoKit:setCustomAttribute("unWrapId", 31510) npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) player:removeMoneyBank(500000000) player:addOutfit(1211) diff --git a/data-otservbr-global/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index cd11e37e1e7..73484ef16e2 100644 --- a/data-otservbr-global/npc/queen_eloise.lua +++ b/data-otservbr-global/npc/queen_eloise.lua @@ -76,7 +76,7 @@ local function creatureSayCallback(npc, creature, type, message) local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1) local decoItemName = ItemType(31510):getName() decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".") - decoKit:setActionId(36345) + decoKit:setCustomAttribute("unWrapId", 31510) npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) player:removeMoneyBank(500000000) player:addOutfit(1211) From e8b5bef009c7988ead30a308d62213b1516458e9 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 12:54:14 -0300 Subject: [PATCH 05/15] feat: golden outfit migration --- .../20241711122214_golden_outfit_to_kv.lua | 17 +++++++++++++++++ .../{memorial.lua => outfits_memorial.lua} | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua rename data/scripts/actions/objects/{memorial.lua => outfits_memorial.lua} (92%) diff --git a/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua b/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua new file mode 100644 index 00000000000..67d0f5fb059 --- /dev/null +++ b/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua @@ -0,0 +1,17 @@ +local migration = Migration("20241711122214_golden_outfit_to_kv_storage") + +local function migrateGoldenOutfit(player) + local goldeOutfitStorageValue = 51015 + local value = player:getPlayerStorageValue(goldeOutfitStorageValue) + + if value > 0 then + player:kv():set("golden-outfit-quest", value) + player:setPlayerStorageValue(goldeOutfitStorageValue, -1) + end +end + +function migration:onExecute() + self:forEachPlayer(migrateGoldenOutfit) +end + +migration:register() diff --git a/data/scripts/actions/objects/memorial.lua b/data/scripts/actions/objects/outfits_memorial.lua similarity index 92% rename from data/scripts/actions/objects/memorial.lua rename to data/scripts/actions/objects/outfits_memorial.lua index 3894fa86fd0..ce4f536c5e4 100644 --- a/data/scripts/actions/objects/memorial.lua +++ b/data/scripts/actions/objects/outfits_memorial.lua @@ -6,7 +6,7 @@ local function updateGoldenOutfitCache() return end - goldenOutfitCache = {[1] = {}, [2] = {}, [3] = {}} + goldenOutfitCache = { [1] = {}, [2] = {}, [3] = {} } local resultId = db.storeQuery("SELECT `key_name`, `timestamp`, `value` FROM `kv_store` WHERE `key_name` = '" .. "golden-outfit-quest" .. "'") @@ -34,7 +34,7 @@ function memorial.onUse(player, item, fromPosition, target, toPosition, isHotkey local msg = NetworkMessage() msg:addByte(0xB0) - local prices = {500000000, 750000000, 1000000000} + local prices = { 500000000, 750000000, 1000000000 } for i, price in ipairs(prices) do msg:addU32(price) end From 9a70be227fbc7dd1556652dee32c0415096d5734 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 13:05:22 -0300 Subject: [PATCH 06/15] fix: writing correction --- data-otservbr-global/npc/emperor_kruzak.lua | 2 +- data-otservbr-global/npc/king_tibianus.lua | 2 +- data-otservbr-global/npc/queen_eloise.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data-otservbr-global/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index 670421597dc..9f45c60c1b6 100644 --- a/data-otservbr-global/npc/emperor_kruzak.lua +++ b/data-otservbr-global/npc/emperor_kruzak.lua @@ -148,7 +148,7 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 2) end elseif (MsgContains(message, "armor")) and npcHandler:getTopic(playerId) == 2 then - npcHandler:say("So you wold like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) + npcHandler:say("So you would like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) npcHandler:setTopic(playerId, 3) elseif (MsgContains(message, "helmet")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear unique helmet?", npc, creature) diff --git a/data-otservbr-global/npc/king_tibianus.lua b/data-otservbr-global/npc/king_tibianus.lua index 5850553a3df..143446cf5de 100644 --- a/data-otservbr-global/npc/king_tibianus.lua +++ b/data-otservbr-global/npc/king_tibianus.lua @@ -159,7 +159,7 @@ local function creatureSayCallback(npc, creature, type, message) end end elseif (MsgContains(message, "armor")) and npcHandler:getTopic(playerId) == 2 then - npcHandler:say("So you wold like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) + npcHandler:say("So you would like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) npcHandler:setTopic(playerId, 3) elseif (MsgContains(message, "helmet")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear unique helmet?", npc, creature) diff --git a/data-otservbr-global/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index 73484ef16e2..2934a86846d 100644 --- a/data-otservbr-global/npc/queen_eloise.lua +++ b/data-otservbr-global/npc/queen_eloise.lua @@ -143,7 +143,7 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 2) end elseif (MsgContains(message, "armor")) and npcHandler:getTopic(playerId) == 2 then - npcHandler:say("So you wold like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) + npcHandler:say("So you would like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) npcHandler:setTopic(playerId, 3) elseif (MsgContains(message, "helmet")) and npcHandler:getTopic(playerId) == 2 then npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear unique helmet?", npc, creature) From 12d7f2a48d1e673b515c78e405d663d18a62e760 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 13:10:57 -0300 Subject: [PATCH 07/15] chore: remove hardcode --- data-otservbr-global/npc/emperor_kruzak.lua | 6 +++--- data-otservbr-global/npc/king_tibianus.lua | 6 +++--- data-otservbr-global/npc/queen_eloise.lua | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/data-otservbr-global/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index 9f45c60c1b6..a080258fbf4 100644 --- a/data-otservbr-global/npc/emperor_kruzak.lua +++ b/data-otservbr-global/npc/emperor_kruzak.lua @@ -86,7 +86,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(500000000) player:addOutfit(1211) player:addOutfit(1210) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 1) else npcHandler:say("Please make sure you have free slots in your store inbox.", npc, creature) @@ -106,7 +106,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 2) npcHandler:setTopic(playerId, 2) else @@ -130,7 +130,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 3) npcHandler:setTopic(playerId, 2) else diff --git a/data-otservbr-global/npc/king_tibianus.lua b/data-otservbr-global/npc/king_tibianus.lua index 143446cf5de..acdd6c4b0ad 100644 --- a/data-otservbr-global/npc/king_tibianus.lua +++ b/data-otservbr-global/npc/king_tibianus.lua @@ -91,7 +91,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(500000000) player:addOutfit(1211) player:addOutfit(1210) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 1) else npcHandler:say("Please make sure you have free slots in your store inbox.", npc, creature) @@ -111,7 +111,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 2) npcHandler:setTopic(playerId, 2) else @@ -135,7 +135,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 3) npcHandler:setTopic(playerId, 2) else diff --git a/data-otservbr-global/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index 2934a86846d..ab0b04132c7 100644 --- a/data-otservbr-global/npc/queen_eloise.lua +++ b/data-otservbr-global/npc/queen_eloise.lua @@ -81,7 +81,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(500000000) player:addOutfit(1211) player:addOutfit(1210) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 1) else npcHandler:say("Please make sure you have free slots in your store inbox.", npc, creature) @@ -101,7 +101,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 2) npcHandler:setTopic(playerId, 2) else @@ -125,7 +125,7 @@ local function creatureSayCallback(npc, creature, type, message) player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) - player:getPosition():sendMagicEffect(171) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDERss) player:kv():set("golden-outfit-quest", 3) npcHandler:setTopic(playerId, 2) else From 82a7086a63d33e6b233833f35b2c6c5e48c15e27 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 13:11:21 -0300 Subject: [PATCH 08/15] feat: default promotion npc --- data-canary/npc/king_canary.lua | 174 ++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 data-canary/npc/king_canary.lua diff --git a/data-canary/npc/king_canary.lua b/data-canary/npc/king_canary.lua new file mode 100644 index 00000000000..edaafc482cb --- /dev/null +++ b/data-canary/npc/king_canary.lua @@ -0,0 +1,174 @@ +local internalNpcName = "King Canary" +local npcType = Game.createNpcType(internalNpcName) +local npcConfig = {} + +npcConfig.name = internalNpcName +npcConfig.description = internalNpcName + +npcConfig.health = 100 +npcConfig.maxHealth = npcConfig.health +npcConfig.walkInterval = 2000 +npcConfig.walkRadius = 2 + +npcConfig.outfit = { + lookType = 332, +} + +npcConfig.flags = { + floorchange = false, +} + +local keywordHandler = KeywordHandler:new() +local npcHandler = NpcHandler:new(keywordHandler) + +npcType.onThink = function(npc, interval) + npcHandler:onThink(npc, interval) +end + +npcType.onAppear = function(npc, creature) + npcHandler:onAppear(npc, creature) +end + +npcType.onDisappear = function(npc, creature) + npcHandler:onDisappear(npc, creature) +end + +npcType.onMove = function(npc, creature, fromPosition, toPosition) + npcHandler:onMove(npc, creature, fromPosition, toPosition) +end + +npcType.onSay = function(npc, creature, type, message) + npcHandler:onSay(npc, creature, type, message) +end + +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, "outfit")) or (MsgContains(message, "addon")) then + npcHandler:say("In exchange for a truly generous donation, I will offer a special outfit. Do you want to make a donation?", npc, creature) + npcHandler:setTopic(playerId, 1) + elseif MsgContains(message, "yes") then + if npcHandler:getTopic(playerId) == 1 then + npcHandler:say({ + "Excellent! Now, let me explain. If you donate 1.000.000.000 gold pieces, you will be entitled to wear a unique outfit. ...", + "You will be entitled to wear the {armor} for 500.000.000 gold pieces, {helmet} for an additional 250.000.000 and the {boots} for another 250.000.000 gold pieces. ...", + "What will it be?", + }, npc, creature) + npcHandler:setTopic(playerId, 2) + elseif npcHandler:getTopic(playerId) == 2 then + npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) + npcHandler:setTopic(playerId, 0) + elseif npcHandler:getTopic(playerId) == 3 then + if player:kv():get("golden-outfit-quest") < 1 then + if player:getMoney() + player:getBankBalance() >= 500000000 then + local inbox = player:getStoreInbox() + local inboxItems = inbox:getItems() + if inbox and #inboxItems <= inbox:getMaxCapacity() then + local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1) + local decoItemName = ItemType(31510):getName() + decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".") + decoKit:setCustomAttribute("unWrapId", 31510) + npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) + player:removeMoneyBank(500000000) + player:addOutfit(1211) + player:addOutfit(1210) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDERs) + player:kv():set("golden-outfit-quest", 1) + else + npcHandler:say("Please make sure you have free slots in your store inbox.", npc, creature) + end + else + npcHandler:say("You do not have enough money to donate that amount.", npc, creature) + end + else + npcHandler:say("You alread have that addon.", npc, creature) + end + npcHandler:setTopic(playerId, 2) + elseif npcHandler:getTopic(playerId) == 4 then + if player:kv():get("golden-outfit-quest") == 1 then + if player:kv():get("golden-outfit-quest") < 2 then + if player:getMoney() + player:getBankBalance() >= 250000000 then + npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) + player:removeMoneyBank(250000000) + player:addOutfitAddon(1210, 1) + player:addOutfitAddon(1211, 1) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) + player:kv():set("golden-outfit-quest", 2) + npcHandler:setTopic(playerId, 2) + else + npcHandler:say("You do not have enough money to donate that amount.", npc, creature) + npcHandler:setTopic(playerId, 2) + end + else + npcHandler:say("You alread have that outfit.", npc, creature) + npcHandler:setTopic(playerId, 2) + end + else + npcHandler:say("You need to donate {armor} outfit first.", npc, creature) + npcHandler:setTopic(playerId, 2) + end + npcHandler:setTopic(playerId, 2) + elseif npcHandler:getTopic(playerId) == 5 then + if player:kv():get("golden-outfit-quest") == 2 then + if player:kv():get("golden-outfit-quest") < 3 then + if player:getMoney() + player:getBankBalance() >= 250000000 then + npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) + player:removeMoneyBank(250000000) + player:addOutfitAddon(1210, 2) + player:addOutfitAddon(1211, 2) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) + player:kv():set("golden-outfit-quest", 3) + npcHandler:setTopic(playerId, 2) + else + npcHandler:say("You do not have enough money to donate that amount.", npc, creature) + npcHandler:setTopic(playerId, 2) + end + else + npcHandler:say("You alread have that outfit.", npc, creature) + npcHandler:setTopic(playerId, 2) + end + else + npcHandler:say("You need to donate {helmet} addon first.", npc, creature) + npcHandler:setTopic(playerId, 2) + end + npcHandler:setTopic(playerId, 2) + end + elseif (MsgContains(message, "armor")) and npcHandler:getTopic(playerId) == 2 then + npcHandler:say("So you would like to donate 500.000.000 gold pieces which in return will entitle you to wear a unique armor?", npc, creature) + npcHandler:setTopic(playerId, 3) + elseif (MsgContains(message, "helmet")) and npcHandler:getTopic(playerId) == 2 then + npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear unique helmet?", npc, creature) + npcHandler:setTopic(playerId, 4) + elseif (MsgContains(message, "boots")) and npcHandler:getTopic(playerId) == 2 then + npcHandler:say("So you would like to donate 250.000.000 gold pieces which in return will entitle you to wear a unique boots?", npc, creature) + npcHandler:setTopic(playerId, 5) + end +end + +-- Promotion +local node1 = keywordHandler:addKeyword({ "promot" }, StdModule.say, { npcHandler = npcHandler, onlyFocus = true, text = "I can promote you for 20000 gold coins. Do you want me to promote you?" }) +node1:addChildKeyword({ "yes" }, StdModule.promotePlayer, { npcHandler = npcHandler, cost = 20000, level = 20, text = "Congratulations! You are now promoted." }) +node1:addChildKeyword({ "no" }, StdModule.say, { npcHandler = npcHandler, onlyFocus = true, text = "Alright then, come back when you are ready.", reset = true }) + +-- Greeting message +keywordHandler:addGreetKeyword({ "hail king" }, { npcHandler = npcHandler, text = "Hiho, may fire and earth bless you, my child. Are you looking for a promotion?" }) +keywordHandler:addGreetKeyword({ "salutations king" }, { npcHandler = npcHandler, text = "Hiho, may fire and earth bless you, my child. Are you looking for a promotion?" }) + +npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, |PLAYERNAME|, my child!") + +npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) +npcHandler:setCallback(CALLBACK_GREET, greetCallback) + +npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true) + +-- npcType registering the npcConfig table +npcType:register(npcConfig) From ba81b3edf836082c205ada1021d4cfd628a497e4 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 13:20:23 -0300 Subject: [PATCH 09/15] chore: remove unnecessary checking --- data-canary/npc/king_canary.lua | 11 ++++------- data-otservbr-global/npc/emperor_kruzak.lua | 9 +++------ data-otservbr-global/npc/king_tibianus.lua | 9 +++------ data-otservbr-global/npc/queen_eloise.lua | 11 ++++------- .../actions/objects/outfits_memorial.lua | 19 ++++++++++--------- 5 files changed, 24 insertions(+), 35 deletions(-) diff --git a/data-canary/npc/king_canary.lua b/data-canary/npc/king_canary.lua index edaafc482cb..e24c80aa18f 100644 --- a/data-canary/npc/king_canary.lua +++ b/data-canary/npc/king_canary.lua @@ -69,7 +69,7 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then if player:kv():get("golden-outfit-quest") < 1 then - if player:getMoney() + player:getBankBalance() >= 500000000 then + if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() if inbox and #inboxItems <= inbox:getMaxCapacity() then @@ -78,10 +78,9 @@ local function creatureSayCallback(npc, creature, type, message) decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".") decoKit:setCustomAttribute("unWrapId", 31510) npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) - player:removeMoneyBank(500000000) player:addOutfit(1211) player:addOutfit(1210) - player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDERs) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 1) else npcHandler:say("Please make sure you have free slots in your store inbox.", npc, creature) @@ -96,9 +95,8 @@ local function creatureSayCallback(npc, creature, type, message) elseif npcHandler:getTopic(playerId) == 4 then if player:kv():get("golden-outfit-quest") == 1 then if player:kv():get("golden-outfit-quest") < 2 then - if player:getMoney() + player:getBankBalance() >= 250000000 then + if player:removeMoneyBank(250000000) then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) - player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) @@ -120,9 +118,8 @@ local function creatureSayCallback(npc, creature, type, message) elseif npcHandler:getTopic(playerId) == 5 then if player:kv():get("golden-outfit-quest") == 2 then if player:kv():get("golden-outfit-quest") < 3 then - if player:getMoney() + player:getBankBalance() >= 250000000 then + if player:removeMoneyBank(250000000) then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) - player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) diff --git a/data-otservbr-global/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index a080258fbf4..6568ba6f28f 100644 --- a/data-otservbr-global/npc/emperor_kruzak.lua +++ b/data-otservbr-global/npc/emperor_kruzak.lua @@ -74,7 +74,7 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then if player:kv():get("golden-outfit-quest") < 1 then - if player:getMoney() + player:getBankBalance() >= 500000000 then + if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() if inbox and #inboxItems <= inbox:getMaxCapacity() then @@ -83,7 +83,6 @@ local function creatureSayCallback(npc, creature, type, message) decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".") decoKit:setCustomAttribute("unWrapId", 31510) npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) - player:removeMoneyBank(500000000) player:addOutfit(1211) player:addOutfit(1210) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) @@ -101,9 +100,8 @@ local function creatureSayCallback(npc, creature, type, message) elseif npcHandler:getTopic(playerId) == 4 then if player:kv():get("golden-outfit-quest") == 1 then if player:kv():get("golden-outfit-quest") < 2 then - if player:getMoney() + player:getBankBalance() >= 250000000 then + if player:removeMoneyBank(250000000) then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) - player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) @@ -125,9 +123,8 @@ local function creatureSayCallback(npc, creature, type, message) elseif npcHandler:getTopic(playerId) == 5 then if player:kv():get("golden-outfit-quest") == 2 then if player:kv():get("golden-outfit-quest") < 3 then - if player:getMoney() + player:getBankBalance() >= 250000000 then + if player:removeMoneyBank(250000000) then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) - player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) diff --git a/data-otservbr-global/npc/king_tibianus.lua b/data-otservbr-global/npc/king_tibianus.lua index acdd6c4b0ad..5f84d81b2c8 100644 --- a/data-otservbr-global/npc/king_tibianus.lua +++ b/data-otservbr-global/npc/king_tibianus.lua @@ -79,7 +79,7 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then if player:kv():get("golden-outfit-quest") < 1 then - if player:getMoney() + player:getBankBalance() >= 500000000 then + if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() if inbox and #inboxItems <= inbox:getMaxCapacity() then @@ -88,7 +88,6 @@ local function creatureSayCallback(npc, creature, type, message) decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Unwrap it in your own house to create a " .. decoItemName .. ".") decoKit:setCustomAttribute("unWrapId", 31510) npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) - player:removeMoneyBank(500000000) player:addOutfit(1211) player:addOutfit(1210) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) @@ -106,9 +105,8 @@ local function creatureSayCallback(npc, creature, type, message) elseif npcHandler:getTopic(playerId) == 4 then if player:kv():get("golden-outfit-quest") == 1 then if player:kv():get("golden-outfit-quest") < 2 then - if player:getMoney() + player:getBankBalance() >= 250000000 then + if player:removeMoneyBank(250000000) then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) - player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) @@ -130,9 +128,8 @@ local function creatureSayCallback(npc, creature, type, message) elseif npcHandler:getTopic(playerId) == 5 then if player:kv():get("golden-outfit-quest") == 2 then if player:kv():get("golden-outfit-quest") < 3 then - if player:getMoney() + player:getBankBalance() >= 250000000 then + if player:removeMoneyBank(250000000) then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) - player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) diff --git a/data-otservbr-global/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index ab0b04132c7..f893361a7b9 100644 --- a/data-otservbr-global/npc/queen_eloise.lua +++ b/data-otservbr-global/npc/queen_eloise.lua @@ -69,7 +69,7 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then if player:kv():get("golden-outfit-quest") < 1 then - if player:getMoney() + player:getBankBalance() >= 500000000 then + if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() if inbox and #inboxItems <= inbox:getMaxCapacity() then @@ -78,7 +78,6 @@ local function creatureSayCallback(npc, creature, type, message) decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a " .. decoItemName .. ".") decoKit:setCustomAttribute("unWrapId", 31510) npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) - player:removeMoneyBank(500000000) player:addOutfit(1211) player:addOutfit(1210) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) @@ -96,9 +95,8 @@ local function creatureSayCallback(npc, creature, type, message) elseif npcHandler:getTopic(playerId) == 4 then if player:kv():get("golden-outfit-quest") == 1 then if player:kv():get("golden-outfit-quest") < 2 then - if player:getMoney() + player:getBankBalance() >= 250000000 then + if player:removeMoneyBank(250000000) then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) - player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) @@ -120,12 +118,11 @@ local function creatureSayCallback(npc, creature, type, message) elseif npcHandler:getTopic(playerId) == 5 then if player:kv():get("golden-outfit-quest") == 2 then if player:kv():get("golden-outfit-quest") < 3 then - if player:getMoney() + player:getBankBalance() >= 250000000 then + if player:removeMoneyBank(250000000) then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) - player:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) - player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDERss) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) player:kv():set("golden-outfit-quest", 3) npcHandler:setTopic(playerId, 2) else diff --git a/data/scripts/actions/objects/outfits_memorial.lua b/data/scripts/actions/objects/outfits_memorial.lua index ce4f536c5e4..ce200c5ab90 100644 --- a/data/scripts/actions/objects/outfits_memorial.lua +++ b/data/scripts/actions/objects/outfits_memorial.lua @@ -1,8 +1,8 @@ -local lastUpdated = 0 -local goldenOutfitCache +local lastCacheUpdateTime = 0 +local goldenOutfitCache = {} local function updateGoldenOutfitCache() - if os.time() < lastUpdated + 10 * 60 then + if os.time() < lastCacheUpdateTime + 10 * 60 then return end @@ -23,7 +23,7 @@ local function updateGoldenOutfitCache() result.free(resultId) end - lastUpdated = os.time() + lastCacheUpdateTime = os.time() end local memorial = Action() @@ -34,8 +34,8 @@ function memorial.onUse(player, item, fromPosition, target, toPosition, isHotkey local msg = NetworkMessage() msg:addByte(0xB0) - local prices = { 500000000, 750000000, 1000000000 } - for i, price in ipairs(prices) do + local goldenOutfitPrices = { 500000000, 750000000, 1000000000 } + for i, price in ipairs(goldenOutfitPrices) do msg:addU32(price) end @@ -47,10 +47,11 @@ function memorial.onUse(player, item, fromPosition, target, toPosition, isHotkey end end - -- royal costume + local royalOutfitPrices = { 30000, 25000 } for i = 1, 3 do - msg:addU16(0) -- price in silver tokens - msg:addU16(0) -- price in golden tokens + for j, price in ipairs(royalOutfitPrices) do + msg:addU16(price) + end end for i = 1, 3 do From 9475fc490393bb18000436ff2f4d6025bf030adc Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 14:18:20 -0300 Subject: [PATCH 10/15] fix: handle nil value returned by player:kv():get() --- data-canary/npc/king_canary.lua | 5 ++--- data-otservbr-global/npc/emperor_kruzak.lua | 3 ++- data-otservbr-global/npc/king_tibianus.lua | 3 ++- data-otservbr-global/npc/queen_eloise.lua | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/data-canary/npc/king_canary.lua b/data-canary/npc/king_canary.lua index e24c80aa18f..d1e872481ee 100644 --- a/data-canary/npc/king_canary.lua +++ b/data-canary/npc/king_canary.lua @@ -68,7 +68,8 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then - if player:kv():get("golden-outfit-quest") < 1 then + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 + if goldenOutfitQuest < 1 then if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() @@ -165,7 +166,5 @@ npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, |PLAYERNAME|, my child!") npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:setCallback(CALLBACK_GREET, greetCallback) -npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true) - -- npcType registering the npcConfig table npcType:register(npcConfig) diff --git a/data-otservbr-global/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index 6568ba6f28f..a2ad657703b 100644 --- a/data-otservbr-global/npc/emperor_kruzak.lua +++ b/data-otservbr-global/npc/emperor_kruzak.lua @@ -73,7 +73,8 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then - if player:kv():get("golden-outfit-quest") < 1 then + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 + if goldenOutfitQuest < 1 then if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() diff --git a/data-otservbr-global/npc/king_tibianus.lua b/data-otservbr-global/npc/king_tibianus.lua index 5f84d81b2c8..d952c0f3b9e 100644 --- a/data-otservbr-global/npc/king_tibianus.lua +++ b/data-otservbr-global/npc/king_tibianus.lua @@ -78,7 +78,8 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then - if player:kv():get("golden-outfit-quest") < 1 then + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 + if goldenOutfitQuest < 1 then if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() diff --git a/data-otservbr-global/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index f893361a7b9..2038ecfd3c8 100644 --- a/data-otservbr-global/npc/queen_eloise.lua +++ b/data-otservbr-global/npc/queen_eloise.lua @@ -68,7 +68,8 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then - if player:kv():get("golden-outfit-quest") < 1 then + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 + if goldenOutfitQuest < 1 then if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() From ab5fa95025b91c76d88921ddbdeb82f5dc1ff71d Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 14:33:24 -0300 Subject: [PATCH 11/15] migrate royal costume to kv --- data-otservbr-global/npc/percybald.lua | 23 ++++++++++--------- .../20241711122214_golden_outfit_to_kv.lua | 10 ++++---- ...41711128698_royal_costume_outfit_to_kv.lua | 17 ++++++++++++++ 3 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 data-otservbr-global/scripts/game_migrations/20241711128698_royal_costume_outfit_to_kv.lua diff --git a/data-otservbr-global/npc/percybald.lua b/data-otservbr-global/npc/percybald.lua index 5ecb521302e..02e8adaf0ce 100644 --- a/data-otservbr-global/npc/percybald.lua +++ b/data-otservbr-global/npc/percybald.lua @@ -153,13 +153,14 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("If you haven't made up your mind, please come back when you are ready.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 14 then - if player:getStorageValue(Storage.OutfitQuest.RoyalCostumeOutfit) < 1 then + local royalCostumeOutfitQuest = player:kv():get("royal-costume-outfit-quest") or 0 + if royalCostumeOutfitQuest < 1 then if player:removeItem(22516, 15000) and player:removeItem(22721, 12500) then npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) player:addOutfit(1457) player:addOutfit(1456) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.RoyalCostumeOutfit, 1) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) + player:kv():set("royal-costume-outfit-quest", 1) else npcHandler:say("You do not have enough tokens to donate that amount.", npc, creature) end @@ -168,14 +169,14 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 13) elseif npcHandler:getTopic(playerId) == 15 then - if player:getStorageValue(Storage.OutfitQuest.RoyalCostumeOutfit) == 1 then - if player:getStorageValue(Storage.OutfitQuest.RoyalCostumeOutfit) < 2 then + if player:kv():get("royal-costume-outfit-quest") == 1 then + if player:kv():get("royal-costume-outfit-quest") < 2 then if player:removeItem(22516, 7500) and player:removeItem(22721, 6250) then npcHandler:say("Take this sheild as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1457, 1) player:addOutfitAddon(1456, 1) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.RoyalCostumeOutfit, 2) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) + player:kv():set("royal-costume-outfit-quest", 2) npcHandler:setTopic(playerId, 13) else npcHandler:say("You do not have enough tokens to donate that amount.", npc, creature) @@ -191,14 +192,14 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 13) elseif npcHandler:getTopic(playerId) == 16 then - if player:getStorageValue(Storage.OutfitQuest.RoyalCostumeOutfit) == 2 then - if player:getStorageValue(Storage.OutfitQuest.RoyalCostumeOutfit) < 3 then + if player:kv():get("royal-costume-outfit-quest") == 2 then + if player:kv():get("royal-costume-outfit-quest") < 3 then if player:removeItem(22516, 7500) and player:removeItem(22721, 6250) then npcHandler:say("Take this crown as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1457, 2) player:addOutfitAddon(1456, 2) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.RoyalCostumeOutfit, 3) + player:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) + player:kv():set("royal-costume-outfit-quest", 3) npcHandler:setTopic(playerId, 13) else npcHandler:say("You do not have enough tokens to donate that amount.", npc, creature) diff --git a/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua b/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua index 67d0f5fb059..ed60c9c481b 100644 --- a/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua +++ b/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua @@ -1,15 +1,15 @@ -local migration = Migration("20241711122214_golden_outfit_to_kv_storage") - local function migrateGoldenOutfit(player) local goldeOutfitStorageValue = 51015 - local value = player:getPlayerStorageValue(goldeOutfitStorageValue) + local value = player:getStorageValue(goldeOutfitStorageValue) if value > 0 then - player:kv():set("golden-outfit-quest", value) - player:setPlayerStorageValue(goldeOutfitStorageValue, -1) + player:kv():set("royal-costume-outfit-quest", value) + player:setStorageValue(goldeOutfitStorageValue, -1) end end +local migration = Migration("20241711122214_golden_outfit_to_kv_storage") + function migration:onExecute() self:forEachPlayer(migrateGoldenOutfit) end diff --git a/data-otservbr-global/scripts/game_migrations/20241711128698_royal_costume_outfit_to_kv.lua b/data-otservbr-global/scripts/game_migrations/20241711128698_royal_costume_outfit_to_kv.lua new file mode 100644 index 00000000000..34d7cfd78fc --- /dev/null +++ b/data-otservbr-global/scripts/game_migrations/20241711128698_royal_costume_outfit_to_kv.lua @@ -0,0 +1,17 @@ +local function migrateRoyalCostumeOutfit(player) + local royalCostumeStorageValue = 51026 + local value = player:getStorageValue(royalCostumeStorageValue) + + if value > 0 then + player:kv():set("golden-outfit-quest", value) + player:setStorageValue(royalCostumeStorageValue, -1) + end +end + +local migration = Migration("20241711128698_royal_costume_outfit_to_kv") + +function migration:onExecute() + self:forEachPlayer(migrateRoyalCostumeOutfit) +end + +migration:register() From d0d02c6ccaef2a360334143da2f94ac6c972942a Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 14:37:32 -0300 Subject: [PATCH 12/15] fix: outfit memorial --- .../actions/objects/outfit_memorial.lua | 73 +++++++++++++++++++ .../actions/objects/outfits_memorial.lua | 67 ----------------- 2 files changed, 73 insertions(+), 67 deletions(-) create mode 100644 data/scripts/actions/objects/outfit_memorial.lua delete mode 100644 data/scripts/actions/objects/outfits_memorial.lua diff --git a/data/scripts/actions/objects/outfit_memorial.lua b/data/scripts/actions/objects/outfit_memorial.lua new file mode 100644 index 00000000000..4381110c2fd --- /dev/null +++ b/data/scripts/actions/objects/outfit_memorial.lua @@ -0,0 +1,73 @@ +local goldenOutfitCache = { [1] = {}, [2] = {}, [3] = {} } +local royalOutfitCache = { [1] = {}, [2] = {}, [3] = {} } +local lastUpdatedGolden = os.time() +local lastUpdatedRoyal = os.time() + +local function updateOutfitCache(storageKey, cache, lastUpdated) + local currentTime = os.time() + if currentTime < lastUpdated + 60 * 10 then + return cache, lastUpdated + end + + local newCache = { [1] = {}, [2] = {}, [3] = {} } + local resultId = db.storeQuery("SELECT `key_name`, `timestamp`, `value` FROM `kv_store` WHERE `key_name` LIKE '%" .. storageKey .. "%'") + + if resultId then + repeat + local value = Result.getNumber(resultId, "value") + local keyName = Result.getString(resultId, "key_name") + + if value and newCache[value] then + table.insert(newCache[value], keyName) + end + until not Result.next(resultId) + + Result.free(resultId) + end + return newCache, currentTime +end + +local outfitMemorial = Action() + +function outfitMemorial.onUse(player, item, fromPosition, target, toPosition, isHotkey) + goldenOutfitCache, lastUpdatedGolden = updateOutfitCache("golden-outfit-quest", goldenOutfitCache, lastUpdatedGolden) + royalOutfitCache, lastUpdatedRoyal = updateOutfitCache("royal-costume-outfit-quest", royalOutfitCache, lastUpdatedRoyal) + + local msg = NetworkMessage() + msg:addByte(0xB0) + + local goldenOutfitPrices = { 500000000, 750000000, 1000000000 } + for i, price in ipairs(goldenOutfitPrices) do + msg:addU32(goldenOutfitPrices) + end + + for i = 1, 3 do + msg:addU16(#goldenOutfitCache[i]) + + for j = 1, #goldenOutfitCache[i] do + msg:addString(goldenOutfitCache[i][j], "outfitMemorial.onUse - goldenOutfitCache[i][j]") + end + end + + local royalCostumePrices = { 30000, 25000 } + for i = 1, 3 do + for _, price in ipairs(royalCostumePrices) do + msg:addU16(price) + end + end + + for i = 1, 3 do + msg:addU16(#royalOutfitCache[i]) + + for j = 1, #royalOutfitCache[i] do + msg:addString(royalOutfitCache[i][j], "outfitMemorial.onUse - royalOutfitCache[i][j]") + end + end + + msg:sendToPlayer(player) + msg:delete() + return true +end + +outfitMemorial:id(31518, 31519, 31520, 31521, 31522, 31523) +outfitMemorial:register() diff --git a/data/scripts/actions/objects/outfits_memorial.lua b/data/scripts/actions/objects/outfits_memorial.lua deleted file mode 100644 index ce200c5ab90..00000000000 --- a/data/scripts/actions/objects/outfits_memorial.lua +++ /dev/null @@ -1,67 +0,0 @@ -local lastCacheUpdateTime = 0 -local goldenOutfitCache = {} - -local function updateGoldenOutfitCache() - if os.time() < lastCacheUpdateTime + 10 * 60 then - return - end - - goldenOutfitCache = { [1] = {}, [2] = {}, [3] = {} } - - local resultId = db.storeQuery("SELECT `key_name`, `timestamp`, `value` FROM `kv_store` WHERE `key_name` = '" .. "golden-outfit-quest" .. "'") - - if resultId ~= 0 then - repeat - local addons = result.getNumber(resultId, "value") - local name = result.getString(resultId, "name") - if not goldenOutfitCache[addons] then - goldenOutfitCache[addons] = {} - end - - table.insert(goldenOutfitCache[addons], name) - until not result.next(resultId) - result.free(resultId) - end - - lastCacheUpdateTime = os.time() -end - -local memorial = Action() - -function memorial.onUse(player, item, fromPosition, target, toPosition, isHotkey) - updateGoldenOutfitCache() - - local msg = NetworkMessage() - msg:addByte(0xB0) - - local goldenOutfitPrices = { 500000000, 750000000, 1000000000 } - for i, price in ipairs(goldenOutfitPrices) do - msg:addU32(price) - end - - for i = 1, 3 do - msg:addU16(#goldenOutfitCache[i]) - - for j = 1, #goldenOutfitCache[i] do - msg:addString(goldenOutfitCache[i][j]) - end - end - - local royalOutfitPrices = { 30000, 25000 } - for i = 1, 3 do - for j, price in ipairs(royalOutfitPrices) do - msg:addU16(price) - end - end - - for i = 1, 3 do - msg:addU16(0) -- list of spenders - end - - msg:sendToPlayer(player) - msg:delete() - return true -end - -memorial:id(31518, 31519, 31520, 31521, 31522, 31523) -memorial:register() From a36416216320cde6122c0be32510cdb45623bc01 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 22 Mar 2024 16:48:23 -0300 Subject: [PATCH 13/15] fix: migrations --- data-otservbr-global/lib/core/storages.lua | 4 --- ..._golden_and_royal_outfit_to_kv_storage.lua | 28 +++++++++++++++++++ .../20241711122214_golden_outfit_to_kv.lua | 17 ----------- ...41711128698_royal_costume_outfit_to_kv.lua | 17 ----------- 4 files changed, 28 insertions(+), 38 deletions(-) create mode 100644 data-otservbr-global/scripts/game_migrations/20241711122214_golden_and_royal_outfit_to_kv_storage.lua delete mode 100644 data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua delete mode 100644 data-otservbr-global/scripts/game_migrations/20241711128698_royal_costume_outfit_to_kv.lua diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index 8b01ea39901..50d4d409379 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -895,7 +895,6 @@ Storage = { DeeplingAnchor = 51023, FirstOrientalAddon = 51024, SecondOrientalAddon = 51025, - RoyalCostumeOutfit = 51026, }, TheAncientTombs = { -- Reserved storage from 50940 - 51059 @@ -2775,9 +2774,6 @@ Storage = { CitizenOfIssaviOutfits = {}, RoyalBounaceanAdvisorOutfits = {}, }, - U12_80 = { -- update 12.80 - Reserved Storages 47801 - 47850 - RoyalCostumeOutfits = {}, - }, U12_90 = { -- update 12.90 - Reserved Storages 47851 - 47900 PrimalOrdeal = { QuestLine = 47851, diff --git a/data-otservbr-global/scripts/game_migrations/20241711122214_golden_and_royal_outfit_to_kv_storage.lua b/data-otservbr-global/scripts/game_migrations/20241711122214_golden_and_royal_outfit_to_kv_storage.lua new file mode 100644 index 00000000000..88b0b39a57d --- /dev/null +++ b/data-otservbr-global/scripts/game_migrations/20241711122214_golden_and_royal_outfit_to_kv_storage.lua @@ -0,0 +1,28 @@ +local function migrateGoldenOutfit(player) + local goldeOutfitStorageValue = 51015 + local value = player:getStorageValue(goldeOutfitStorageValue) + + if value > 0 then + player:kv():set("golden-outfit-quest", value) + player:setStorageValue(goldeOutfitStorageValue, -1) + end +end + +local function migrateRoyalCostumeOutfit(player) + local royalCostumeStorageValue = 51026 + local value = player:getStorageValue(royalCostumeStorageValue) + + if value > 0 then + player:kv():set("royal-costume-outfit-quest", value) + player:setStorageValue(royalCostumeStorageValue, -1) + end +end + +local migration = Migration("20241711122214_golden_and_royal_outfit_to_kv_storage") + +function migration:onExecute() + self:forEachPlayer(migrateGoldenOutfit) + self:forEachPlayer(migrateRoyalCostumeOutfit) +end + +migration:register() diff --git a/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua b/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua deleted file mode 100644 index ed60c9c481b..00000000000 --- a/data-otservbr-global/scripts/game_migrations/20241711122214_golden_outfit_to_kv.lua +++ /dev/null @@ -1,17 +0,0 @@ -local function migrateGoldenOutfit(player) - local goldeOutfitStorageValue = 51015 - local value = player:getStorageValue(goldeOutfitStorageValue) - - if value > 0 then - player:kv():set("royal-costume-outfit-quest", value) - player:setStorageValue(goldeOutfitStorageValue, -1) - end -end - -local migration = Migration("20241711122214_golden_outfit_to_kv_storage") - -function migration:onExecute() - self:forEachPlayer(migrateGoldenOutfit) -end - -migration:register() diff --git a/data-otservbr-global/scripts/game_migrations/20241711128698_royal_costume_outfit_to_kv.lua b/data-otservbr-global/scripts/game_migrations/20241711128698_royal_costume_outfit_to_kv.lua deleted file mode 100644 index 34d7cfd78fc..00000000000 --- a/data-otservbr-global/scripts/game_migrations/20241711128698_royal_costume_outfit_to_kv.lua +++ /dev/null @@ -1,17 +0,0 @@ -local function migrateRoyalCostumeOutfit(player) - local royalCostumeStorageValue = 51026 - local value = player:getStorageValue(royalCostumeStorageValue) - - if value > 0 then - player:kv():set("golden-outfit-quest", value) - player:setStorageValue(royalCostumeStorageValue, -1) - end -end - -local migration = Migration("20241711128698_royal_costume_outfit_to_kv") - -function migration:onExecute() - self:forEachPlayer(migrateRoyalCostumeOutfit) -end - -migration:register() From b56d24178540e268e6d9898e7199ed76fc37ea47 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 18 Apr 2024 12:15:39 -0300 Subject: [PATCH 14/15] Delete outfit_memorial.lua --- .../actions/objects/outfit_memorial.lua | 73 ------------------- 1 file changed, 73 deletions(-) delete mode 100644 data/scripts/actions/objects/outfit_memorial.lua diff --git a/data/scripts/actions/objects/outfit_memorial.lua b/data/scripts/actions/objects/outfit_memorial.lua deleted file mode 100644 index 4381110c2fd..00000000000 --- a/data/scripts/actions/objects/outfit_memorial.lua +++ /dev/null @@ -1,73 +0,0 @@ -local goldenOutfitCache = { [1] = {}, [2] = {}, [3] = {} } -local royalOutfitCache = { [1] = {}, [2] = {}, [3] = {} } -local lastUpdatedGolden = os.time() -local lastUpdatedRoyal = os.time() - -local function updateOutfitCache(storageKey, cache, lastUpdated) - local currentTime = os.time() - if currentTime < lastUpdated + 60 * 10 then - return cache, lastUpdated - end - - local newCache = { [1] = {}, [2] = {}, [3] = {} } - local resultId = db.storeQuery("SELECT `key_name`, `timestamp`, `value` FROM `kv_store` WHERE `key_name` LIKE '%" .. storageKey .. "%'") - - if resultId then - repeat - local value = Result.getNumber(resultId, "value") - local keyName = Result.getString(resultId, "key_name") - - if value and newCache[value] then - table.insert(newCache[value], keyName) - end - until not Result.next(resultId) - - Result.free(resultId) - end - return newCache, currentTime -end - -local outfitMemorial = Action() - -function outfitMemorial.onUse(player, item, fromPosition, target, toPosition, isHotkey) - goldenOutfitCache, lastUpdatedGolden = updateOutfitCache("golden-outfit-quest", goldenOutfitCache, lastUpdatedGolden) - royalOutfitCache, lastUpdatedRoyal = updateOutfitCache("royal-costume-outfit-quest", royalOutfitCache, lastUpdatedRoyal) - - local msg = NetworkMessage() - msg:addByte(0xB0) - - local goldenOutfitPrices = { 500000000, 750000000, 1000000000 } - for i, price in ipairs(goldenOutfitPrices) do - msg:addU32(goldenOutfitPrices) - end - - for i = 1, 3 do - msg:addU16(#goldenOutfitCache[i]) - - for j = 1, #goldenOutfitCache[i] do - msg:addString(goldenOutfitCache[i][j], "outfitMemorial.onUse - goldenOutfitCache[i][j]") - end - end - - local royalCostumePrices = { 30000, 25000 } - for i = 1, 3 do - for _, price in ipairs(royalCostumePrices) do - msg:addU16(price) - end - end - - for i = 1, 3 do - msg:addU16(#royalOutfitCache[i]) - - for j = 1, #royalOutfitCache[i] do - msg:addString(royalOutfitCache[i][j], "outfitMemorial.onUse - royalOutfitCache[i][j]") - end - end - - msg:sendToPlayer(player) - msg:delete() - return true -end - -outfitMemorial:id(31518, 31519, 31520, 31521, 31522, 31523) -outfitMemorial:register() From ec68087e65326b3c6be1dfe2726d3e19d48382d0 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 18 Apr 2024 17:37:22 -0300 Subject: [PATCH 15/15] resolve conversation --- data-canary/npc/king_canary.lua | 10 +++++----- data-otservbr-global/npc/emperor_kruzak.lua | 10 +++++----- data-otservbr-global/npc/king_tibianus.lua | 11 ++++++----- data-otservbr-global/npc/percybald.lua | 10 +++++----- data-otservbr-global/npc/queen_eloise.lua | 10 +++++----- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/data-canary/npc/king_canary.lua b/data-canary/npc/king_canary.lua index d1e872481ee..92901e3da73 100644 --- a/data-canary/npc/king_canary.lua +++ b/data-canary/npc/king_canary.lua @@ -48,6 +48,7 @@ end local function creatureSayCallback(npc, creature, type, message) local player = Player(creature) local playerId = player:getId() + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 if not npcHandler:checkInteraction(npc, creature) then return false @@ -68,7 +69,6 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then - local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 if goldenOutfitQuest < 1 then if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() @@ -94,8 +94,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 2) elseif npcHandler:getTopic(playerId) == 4 then - if player:kv():get("golden-outfit-quest") == 1 then - if player:kv():get("golden-outfit-quest") < 2 then + if goldenOutfitQuest == 1 then + if goldenOutfitQuest < 2 then if player:removeMoneyBank(250000000) then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1210, 1) @@ -117,8 +117,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 2) elseif npcHandler:getTopic(playerId) == 5 then - if player:kv():get("golden-outfit-quest") == 2 then - if player:kv():get("golden-outfit-quest") < 3 then + if goldenOutfitQuest == 2 then + if goldenOutfitQuest < 3 then if player:removeMoneyBank(250000000) then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1210, 2) diff --git a/data-otservbr-global/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index a2ad657703b..16919048364 100644 --- a/data-otservbr-global/npc/emperor_kruzak.lua +++ b/data-otservbr-global/npc/emperor_kruzak.lua @@ -53,6 +53,7 @@ end local function creatureSayCallback(npc, creature, type, message) local player = Player(creature) local playerId = player:getId() + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 if not npcHandler:checkInteraction(npc, creature) then return false @@ -73,7 +74,6 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then - local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 if goldenOutfitQuest < 1 then if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() @@ -99,8 +99,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 2) elseif npcHandler:getTopic(playerId) == 4 then - if player:kv():get("golden-outfit-quest") == 1 then - if player:kv():get("golden-outfit-quest") < 2 then + if goldenOutfitQuest == 1 then + if goldenOutfitQuest < 2 then if player:removeMoneyBank(250000000) then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1210, 1) @@ -122,8 +122,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 2) elseif npcHandler:getTopic(playerId) == 5 then - if player:kv():get("golden-outfit-quest") == 2 then - if player:kv():get("golden-outfit-quest") < 3 then + if goldenOutfitQuest == 2 then + if goldenOutfitQuest < 3 then if player:removeMoneyBank(250000000) then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1210, 2) diff --git a/data-otservbr-global/npc/king_tibianus.lua b/data-otservbr-global/npc/king_tibianus.lua index d952c0f3b9e..f08339cd186 100644 --- a/data-otservbr-global/npc/king_tibianus.lua +++ b/data-otservbr-global/npc/king_tibianus.lua @@ -46,9 +46,11 @@ npcType.onCloseChannel = function(npc, creature) end local TheNewFrontier = Storage.Quest.U8_54.TheNewFrontier + local function creatureSayCallback(npc, creature, type, message) local player = Player(creature) local playerId = player:getId() + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 if not npcHandler:checkInteraction(npc, creature) then return false @@ -78,7 +80,6 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then - local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 if goldenOutfitQuest < 1 then if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() @@ -104,8 +105,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 2) elseif npcHandler:getTopic(playerId) == 4 then - if player:kv():get("golden-outfit-quest") == 1 then - if player:kv():get("golden-outfit-quest") < 2 then + if goldenOutfitQuest == 1 then + if goldenOutfitQuest < 2 then if player:removeMoneyBank(250000000) then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1210, 2) @@ -127,8 +128,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 2) elseif npcHandler:getTopic(playerId) == 5 then - if player:kv():get("golden-outfit-quest") == 2 then - if player:kv():get("golden-outfit-quest") < 3 then + if goldenOutfitQuest == 2 then + if goldenOutfitQuest < 3 then if player:removeMoneyBank(250000000) then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1210, 1) diff --git a/data-otservbr-global/npc/percybald.lua b/data-otservbr-global/npc/percybald.lua index 02e8adaf0ce..799801b3ad1 100644 --- a/data-otservbr-global/npc/percybald.lua +++ b/data-otservbr-global/npc/percybald.lua @@ -53,6 +53,7 @@ end local function creatureSayCallback(npc, creature, type, message) local player = Player(creature) local playerId = player:getId() + local royalCostumeOutfitQuest = player:kv():get("royal-costume-outfit-quest") or 0 if not npcHandler:checkInteraction(npc, creature) then return false @@ -153,7 +154,6 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("If you haven't made up your mind, please come back when you are ready.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 14 then - local royalCostumeOutfitQuest = player:kv():get("royal-costume-outfit-quest") or 0 if royalCostumeOutfitQuest < 1 then if player:removeItem(22516, 15000) and player:removeItem(22721, 12500) then npcHandler:say("Take this armor as a token of great gratitude. Let us forever remember this day, my friend!", npc, creature) @@ -169,8 +169,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 13) elseif npcHandler:getTopic(playerId) == 15 then - if player:kv():get("royal-costume-outfit-quest") == 1 then - if player:kv():get("royal-costume-outfit-quest") < 2 then + if royalCostumeOutfitQuest == 1 then + if royalCostumeOutfitQuest < 2 then if player:removeItem(22516, 7500) and player:removeItem(22721, 6250) then npcHandler:say("Take this sheild as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1457, 1) @@ -192,8 +192,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 13) elseif npcHandler:getTopic(playerId) == 16 then - if player:kv():get("royal-costume-outfit-quest") == 2 then - if player:kv():get("royal-costume-outfit-quest") < 3 then + if royalCostumeOutfitQuest == 2 then + if royalCostumeOutfitQuest < 3 then if player:removeItem(22516, 7500) and player:removeItem(22721, 6250) then npcHandler:say("Take this crown as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1457, 2) diff --git a/data-otservbr-global/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index 2038ecfd3c8..96eb187c71b 100644 --- a/data-otservbr-global/npc/queen_eloise.lua +++ b/data-otservbr-global/npc/queen_eloise.lua @@ -48,6 +48,7 @@ end local function creatureSayCallback(npc, creature, type, message) local player = Player(creature) local playerId = player:getId() + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 if not npcHandler:checkInteraction(npc, creature) then return false @@ -68,7 +69,6 @@ local function creatureSayCallback(npc, creature, type, message) npcHandler:say("In that case, return to me once you made up your mind.", npc, creature) npcHandler:setTopic(playerId, 0) elseif npcHandler:getTopic(playerId) == 3 then - local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 if goldenOutfitQuest < 1 then if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() @@ -94,8 +94,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 2) elseif npcHandler:getTopic(playerId) == 4 then - if player:kv():get("golden-outfit-quest") == 1 then - if player:kv():get("golden-outfit-quest") < 2 then + if goldenOutfitQuest == 1 then + if goldenOutfitQuest < 2 then if player:removeMoneyBank(250000000) then npcHandler:say("Take this helmet as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1210, 1) @@ -117,8 +117,8 @@ local function creatureSayCallback(npc, creature, type, message) end npcHandler:setTopic(playerId, 2) elseif npcHandler:getTopic(playerId) == 5 then - if player:kv():get("golden-outfit-quest") == 2 then - if player:kv():get("golden-outfit-quest") < 3 then + if goldenOutfitQuest == 2 then + if goldenOutfitQuest < 3 then if player:removeMoneyBank(250000000) then npcHandler:say("Take this boots as a token of great gratitude. Let us forever remember this day, my friend. ", npc, creature) player:addOutfitAddon(1210, 2)