Skip to content

Commit

Permalink
Merge branch 'main' into rework-targetlist
Browse files Browse the repository at this point in the history
  • Loading branch information
mehah committed Oct 25, 2023
2 parents 7a8c4bf + c3dc39c commit 36968b2
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 61 deletions.
6 changes: 3 additions & 3 deletions data-otservbr-global/npc/percybald.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ local function creatureSayCallback(npc, creature, type, message)
end

-- Handle options for armor, shield, and crown
elseif (MsgContains(message, "armor")) and npcHandler:getTopic(playerId) == 13 then
elseif MsgContains(message, "armor") and npcHandler:getTopic(playerId) == 13 then
npcHandler:say("Would you like to donate 15,000 silver tokens and 12,500 gold tokens for a unique red armor?", npc, creature)
npcHandler:setTopic(playerId, 14)
elseif (MsgContains(message, "shield")) and npcHandler:getTopic(playerId) == 13 then
elseif MsgContains(message, "shield") and npcHandler:getTopic(playerId) == 13 then
npcHandler:say("Would you like to donate 7,500 silver tokens and 6,250 gold tokens for a unique shield?", npc, creature)
npcHandler:setTopic(playerId, 15)
elseif (MsgContains(message, "crown")) and npcHandler:getTopic(playerId) == 13 then
elseif MsgContains(message, "crown") and npcHandler:getTopic(playerId) == 13 then
npcHandler:say("Would you like to donate 7,500 silver tokens and 6,250 gold tokens for a unique crown?", npc, creature)
npcHandler:setTopic(playerId, 16)
end
Expand Down
18 changes: 18 additions & 0 deletions data-otservbr-global/npc/yonan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,24 @@ local function creatureSayCallback(npc, creature, type, message)
npcHandler:say({ "Sorry." }, npc, creature) -- It needs to be revised, it's not the same as the global
end
end

if MsgContains(message, "regalia of suon") then
npcHandler:say({ "You have all parts of the famous Regalia of Suon! Only a few of them were ever forged, back in the times of the old empire. You are holding a very rare and precious treasure, my friend. ... As you have all four pieces, I could combine them into the full insignia. Shall I do this for you?" }, npc, creature)
npcHandler:setTopic(playerId, 5)
elseif MsgContains(message, "yes") and npcHandler:getTopic(playerId) == 5 then
if player:getItemById(31572, 1) and player:getItemById(31573, 1) and player:getItemById(31574, 1) and player:getItemById(31575, 1) then
if player:addItem(31576, 1) then -- regalia of suon
player:removeItem(31572, 1) -- blue and golden cordon
player:removeItem(31573, 1) -- sun medal
player:removeItem(31574, 1) -- sunray emblem
player:removeItem(31575, 1) -- golden bijou
npcHandler:say({ "Well then, let me have a look." }, npc, creature)
end
else
npcHandler:say({ "Sorry, you dont have the necessary items." }, npc, creature) -- It needs to be revised, it's not the same as the global
end
end

return true
end

Expand Down

This file was deleted.

64 changes: 64 additions & 0 deletions data-otservbr-global/scripts/actions/other/outfit_memorial.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
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])
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])
end
end

response:sendToPlayer(player)
return true
end

outfitMemorial:id(31518, 31519, 31520, 31521, 31522, 31523)
outfitMemorial:register()

0 comments on commit 36968b2

Please sign in to comment.