Skip to content

Commit

Permalink
migrate royal costume to kv
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires committed Mar 22, 2024
1 parent 9475fc4 commit 85e6518
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
17 changes: 9 additions & 8 deletions data-otservbr-global/npc/percybald.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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:kv():set("royal-costume-outfit-quest", 1)
else
npcHandler:say("You do not have enough tokens to donate that amount.", npc, creature)
end
Expand All @@ -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: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)
Expand All @@ -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: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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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:setStorageValue(goldeOutfitStorageValue, -1)
end
end

local migration = Migration("20241711122214_golden_outfit_to_kv_storage")

function migration:onExecute()
self:forEachPlayer(migrateGoldenOutfit)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 85e6518

Please sign in to comment.