Skip to content

Commit

Permalink
chore: remove unnecessary checking
Browse files Browse the repository at this point in the history
  • Loading branch information
omarcopires committed Mar 22, 2024
1 parent 82a7086 commit ba81b3e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 35 deletions.
11 changes: 4 additions & 7 deletions data-canary/npc/king_canary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 3 additions & 6 deletions data-otservbr-global/npc/emperor_kruzak.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
9 changes: 3 additions & 6 deletions data-otservbr-global/npc/king_tibianus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions data-otservbr-global/npc/queen_eloise.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down
19 changes: 10 additions & 9 deletions data/scripts/actions/objects/outfits_memorial.lua
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -23,7 +23,7 @@ local function updateGoldenOutfitCache()
result.free(resultId)
end

lastUpdated = os.time()
lastCacheUpdateTime = os.time()
end

local memorial = Action()
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit ba81b3e

Please sign in to comment.