diff --git a/data-canary/npc/king_canary.lua b/data-canary/npc/king_canary.lua new file mode 100644 index 00000000000..92901e3da73 --- /dev/null +++ b/data-canary/npc/king_canary.lua @@ -0,0 +1,170 @@ +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() + local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0 + + 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 goldenOutfitQuest < 1 then + if player:removeMoneyBank(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:addOutfit(1211) + player:addOutfit(1210) + 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) + 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 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) + 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 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) + 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) + +-- npcType registering the npcConfig table +npcType:register(npcConfig) diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index 2b8d9a7783d..5514b5bbb4a 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -879,8 +879,7 @@ Storage = { AssassinBaseOutfit = 51012, AssassinFirstAddon = 51013, AssassinSecondAddon = 51014, - -- Golden Outfit - GoldenOutfit = 51015, + -- Nightmare Outfit NightmareOutfit = 51016, NightmareDoor = 51017, BrotherhoodOutfit = 51018, @@ -893,7 +892,6 @@ Storage = { DeeplingAnchor = 51023, FirstOrientalAddon = 51024, SecondOrientalAddon = 51025, - RoyalCostumeOutfit = 51026, }, TheAncientTombs = { -- Reserved storage from 50940 - 51059 @@ -2774,9 +2772,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/npc/emperor_kruzak.lua b/data-otservbr-global/npc/emperor_kruzak.lua index daf0742f615..8f46527dba7 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 @@ -62,37 +63,31 @@ 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 - if player:getMoney() + player:getBankBalance() >= 500000000 then + elseif npcHandler:getTopic(playerId) == 3 then + if goldenOutfitQuest < 1 then + if player:removeMoneyBank(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: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) player:addOutfit(1210) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 1) + 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) end @@ -103,18 +98,15 @@ 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:getMoney() + player:getBankBalance() >= 250000000 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:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 2) + 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) @@ -129,18 +121,15 @@ 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:getMoney() + player:getBankBalance() >= 250000000 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:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 3) + 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) @@ -154,22 +143,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: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) -- 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 d9968357fa1..317780925d2 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 @@ -71,20 +73,15 @@ 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 - if player:getMoney() + player:getBankBalance() >= 500000000 then + elseif npcHandler:getTopic(playerId) == 3 then + if goldenOutfitQuest < 1 then + if player:removeMoneyBank(500000000) then local inbox = player:getStoreInbox() local inboxItems = inbox:getItems() if inbox and #inboxItems < inbox:getMaxCapacity() then @@ -93,11 +90,10 @@ 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(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 1) + 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) end @@ -108,18 +104,15 @@ 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:getMoney() + player:getBankBalance() >= 250000000 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:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 2) + 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) @@ -134,18 +127,15 @@ 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:getMoney() + player:getBankBalance() >= 250000000 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:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 3) + 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) @@ -159,9 +149,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 +157,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: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) -- 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/percybald.lua b/data-otservbr-global/npc/percybald.lua index 5ecb521302e..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,13 +154,13 @@ 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 + 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 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) 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 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) 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/npc/queen_eloise.lua b/data-otservbr-global/npc/queen_eloise.lua index 0467bb6e74a..3d5cc7746f4 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 @@ -57,37 +58,31 @@ 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 - if player:getMoney() + player:getBankBalance() >= 500000000 then + elseif npcHandler:getTopic(playerId) == 3 then + if goldenOutfitQuest < 1 then + if player:removeMoneyBank(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: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) player:addOutfit(1210) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 1) + 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) end @@ -98,18 +93,15 @@ 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:getMoney() + player:getBankBalance() >= 250000000 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:removeMoneyBank(250000000) player:addOutfitAddon(1210, 1) player:addOutfitAddon(1211, 1) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 2) + 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) @@ -124,18 +116,15 @@ 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:getMoney() + player:getBankBalance() >= 250000000 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:removeMoneyBank(250000000) player:addOutfitAddon(1210, 2) player:addOutfitAddon(1211, 2) - player:getPosition():sendMagicEffect(171) - player:setStorageValue(Storage.OutfitQuest.GoldenOutfit, 3) + 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) @@ -149,22 +138,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: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) -- 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/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() 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/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