Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: convert golden and royal costume outfit from storage to kv #2477

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e1c5f61
chore: convert golden outfit from storage to kv
omarcopires Mar 22, 2024
540b8e4
remove unused storage and old memorial
omarcopires Mar 22, 2024
eaace08
feat: outfit memorial
omarcopires Mar 22, 2024
0f49b47
fix: custom attribute
omarcopires Mar 22, 2024
e8b5bef
feat: golden outfit migration
omarcopires Mar 22, 2024
9a70be2
fix: writing correction
omarcopires Mar 22, 2024
12d7f2a
chore: remove hardcode
omarcopires Mar 22, 2024
82a7086
feat: default promotion npc
omarcopires Mar 22, 2024
ba81b3e
chore: remove unnecessary checking
omarcopires Mar 22, 2024
9475fc4
fix: handle nil value returned by player:kv():get()
omarcopires Mar 22, 2024
ab5fa95
migrate royal costume to kv
omarcopires Mar 22, 2024
d0d02c6
fix: outfit memorial
omarcopires Mar 22, 2024
a364162
fix: migrations
omarcopires Mar 22, 2024
b56d241
Delete outfit_memorial.lua
omarcopires Apr 18, 2024
bbe3701
Merge branch 'main' into golden-outfit-to-kv
omarcopires Apr 18, 2024
ec68087
resolve conversation
omarcopires Apr 18, 2024
6843b95
Merge remote-tracking branch 'upstream/main' into golden-outfit-to-kv
omarcopires Apr 25, 2024
35661d8
Merge branch 'main' into golden-outfit-to-kv
omarcopires May 16, 2024
291fd2c
Merge branch 'main' into golden-outfit-to-kv
omarcopires Jun 3, 2024
ce0ce79
Merge branch 'main' into golden-outfit-to-kv
omarcopires Jun 5, 2024
aa197e9
Merge branch 'main' into golden-outfit-to-kv
omarcopires Jun 14, 2024
0484dd6
Merge branch 'main' into golden-outfit-to-kv
omarcopires Jul 9, 2024
ba1904c
Merge branch 'main' into golden-outfit-to-kv
omarcopires Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions data-canary/npc/king_canary.lua
Original file line number Diff line number Diff line change
@@ -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()

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
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()
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 player:kv():get("golden-outfit-quest") == 1 then
if player:kv():get("golden-outfit-quest") < 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 player:kv():get("golden-outfit-quest") == 2 then
if player:kv():get("golden-outfit-quest") < 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)
7 changes: 1 addition & 6 deletions data-otservbr-global/lib/core/storages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,7 @@ Storage = {
AssassinBaseOutfit = 51012,
AssassinFirstAddon = 51013,
AssassinSecondAddon = 51014,
-- Golden Outfit
GoldenOutfit = 51015,
-- Nightmare Outfit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- Nightmare Outfit
-- GoldenOutfit = 51015, (moved to kv)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need, as it is free storage, it was set to -1 in the migration

NightmareOutfit = 51016,
NightmareDoor = 51017,
BrotherhoodOutfit = 51018,
Expand All @@ -893,7 +892,6 @@ Storage = {
DeeplingAnchor = 51023,
FirstOrientalAddon = 51024,
SecondOrientalAddon = 51025,
RoyalCostumeOutfit = 51026,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RoyalCostumeOutfit = 51026,
-- RoyalCostumeOutfit = 51026, (moved to kv)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need, as it is free storage, it was set to -1 in the migration

},
TheAncientTombs = {
-- Reserved storage from 50940 - 51059
Expand Down Expand Up @@ -2773,9 +2771,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,
Expand Down
57 changes: 21 additions & 36 deletions data-otservbr-global/npc/emperor_kruzak.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,32 @@ 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
local goldenOutfitQuest = player:kv():get("golden-outfit-quest") or 0
omarcopires marked this conversation as resolved.
Show resolved Hide resolved
omarcopires marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -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 player:kv():get("golden-outfit-quest") == 1 then
if player:kv():get("golden-outfit-quest") < 2 then
omarcopires marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand All @@ -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 player:kv():get("golden-outfit-quest") == 2 then
if player:kv():get("golden-outfit-quest") < 3 then
omarcopires marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand All @@ -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
Expand Down
Loading
Loading