Skip to content

Commit

Permalink
fix: store UI exhaustion and improve bosslever messages (opentibiabr#…
Browse files Browse the repository at this point in the history
…2694)

Fixed the store exhaustion to work correctly.

Fixed the boss lever messages to better inform the participants.
  • Loading branch information
dudantas authored Jun 15, 2024
1 parent b682da7 commit 4af5b2d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
32 changes: 22 additions & 10 deletions data/libs/functions/boss_lever.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,24 +174,36 @@ function BossLever:onUse(player)
end

if creature:getLevel() < self.requiredLevel then
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All the players need to be level " .. self.requiredLevel .. " or higher.")
local message = "All players need to be level " .. self.requiredLevel .. " or higher."
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
return false
end

if self:lastEncounterTime(creature) > os.time() then
local info = lever:getInfoPositions()
for _, v in pairs(info) do
local newPlayer = v.creature
if newPlayer then
local timeLeft = self:lastEncounterTime(newPlayer) - os.time()
newPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. getTimeInWords(timeLeft) .. " to face " .. self.name .. " again!")
if self:lastEncounterTime(newPlayer) > os.time() then
newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
if creature:getGroup():getId() < GROUP_TYPE_GOD and self:lastEncounterTime(creature) > os.time() then
local infoPositions = lever:getInfoPositions()
for _, posInfo in pairs(infoPositions) do
local currentPlayer = posInfo.creature
if currentPlayer then
local lastEncounter = self:lastEncounterTime(currentPlayer)
local currentTime = os.time()
if lastEncounter and currentTime < lastEncounter then
local timeLeft = lastEncounter - currentTime
local timeMessage = getTimeInWords(timeLeft) .. " to face " .. monsterName .. " again!"
local message = "You have to wait " .. timeMessage

if currentPlayer ~= player then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A member in your team has to wait " .. timeMessage)
end

currentPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
currentPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
end
end
end
return false
end

self.onUseExtra(creature)
return true
end)
Expand Down
17 changes: 11 additions & 6 deletions data/modules/scripts/gamestore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ function onRecvbyte(player, msg, byte)
return player:sendCancelMessage("Store don't have offers for rookgaard citizen.")
end

if player:isUIExhausted(250) then
player:sendCancelMessage("You are exhausted.")
return
end

if byte == GameStore.RecivedPackets.C_StoreEvent then
elseif byte == GameStore.RecivedPackets.C_TransferCoins then
parseTransferableCoins(player:getId(), msg)
Expand All @@ -262,12 +267,6 @@ function onRecvbyte(player, msg, byte)
parseRequestTransactionHistory(player:getId(), msg)
end

if player:isUIExhausted(250) then
player:sendCancelMessage("You are exhausted.")
return false
end

player:updateUIExhausted()
return true
end

Expand Down Expand Up @@ -306,6 +305,7 @@ function parseTransferableCoins(playerId, msg)
GameStore.insertHistory(accountId, GameStore.HistoryTypes.HISTORY_TYPE_NONE, player:getName() .. " transferred you this amount.", amount, GameStore.CoinType.Transferable)
GameStore.insertHistory(player:getAccountId(), GameStore.HistoryTypes.HISTORY_TYPE_NONE, "You transferred this amount to " .. reciver, -1 * amount, GameStore.CoinType.Transferable)
openStore(playerId)
player:updateUIExhausted()
end

function parseOpenStore(playerId, msg)
Expand Down Expand Up @@ -396,6 +396,7 @@ function parseRequestStoreOffers(playerId, msg)

addPlayerEvent(sendShowStoreOffers, 250, playerId, searchResultsCategory)
end
player:updateUIExhausted()
end

function parseBuyStoreOffer(playerId, msg)
Expand Down Expand Up @@ -532,6 +533,8 @@ function parseBuyStoreOffer(playerId, msg)
sendUpdatedStoreBalances(playerId)
return addPlayerEvent(sendStorePurchaseSuccessful, 650, playerId, message)
end

player:updateUIExhausted()
return true
end

Expand All @@ -540,11 +543,13 @@ function parseOpenTransactionHistory(playerId, msg)
local page = 1
GameStore.DefaultValues.DEFAULT_VALUE_ENTRIES_PER_PAGE = msg:getByte()
sendStoreTransactionHistory(playerId, page, GameStore.DefaultValues.DEFAULT_VALUE_ENTRIES_PER_PAGE)
player:updateUIExhausted()
end

function parseRequestTransactionHistory(playerId, msg)
local page = msg:getU32()
sendStoreTransactionHistory(playerId, page + 1, GameStore.DefaultValues.DEFAULT_VALUE_ENTRIES_PER_PAGE)
player:updateUIExhausted()
end

local function getCategoriesRook()
Expand Down

0 comments on commit 4af5b2d

Please sign in to comment.