diff --git a/data/XML/vocations.xml b/data/XML/vocations.xml index 988075fd9..fd5ae77a3 100644 --- a/data/XML/vocations.xml +++ b/data/XML/vocations.xml @@ -3,6 +3,7 @@ + @@ -14,6 +15,7 @@ + @@ -25,6 +27,7 @@ + @@ -36,6 +39,7 @@ + @@ -47,6 +51,7 @@ + @@ -58,6 +63,7 @@ + @@ -69,6 +75,7 @@ + @@ -80,6 +87,7 @@ + @@ -91,6 +99,7 @@ + diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index c0284fafe..9141b5045 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -253,8 +253,8 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, return false end exhaust[playerId] = true - addEvent(function() - exhaust[playerId] = false + addEvent(function(id) + exhaust[id] = false end, 2000, playerId) return true end diff --git a/data/libs/exercise_training.lua b/data/libs/exercise_training.lua index 513c8ae04..3fcbf89dd 100644 --- a/data/libs/exercise_training.lua +++ b/data/libs/exercise_training.lua @@ -55,6 +55,7 @@ function ExerciseEvent(playerId, tilePosition, weaponId, dummyId) end if player:isTraining() == 0 then + player:sendTextMessage(MESSAGE_FAILURE, "You left training!") return LeaveTraining(playerId) end diff --git a/data/libs/functions/bosslever.lua b/data/libs/functions/bosslever.lua index 7e099ec91..648c25bed 100644 --- a/data/libs/functions/bosslever.lua +++ b/data/libs/functions/bosslever.lua @@ -178,17 +178,7 @@ function BossLever:onUse(player) 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 - newPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. self.timeToFightAgain / 60 / 60 .. " hours to face " .. self.name .. " again!") - if self:lastEncounterTime(newPlayer) > os.time() then - newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) - end - end - end + if not lever:canUseLever(player, self.name, self.timeToFightAgain / 60 / 60) then return false end self.onUseExtra(creature) diff --git a/data/libs/functions/container.lua b/data/libs/functions/container.lua index 6ec5897c5..30131fec9 100644 --- a/data/libs/functions/container.lua +++ b/data/libs/functions/container.lua @@ -7,32 +7,46 @@ end ---@param loot LootItems function Container:addLoot(loot) for itemId, item in pairs(loot) do - logger.debug("[Container:addLoot] - Adding loot item id: {} to container id: {}", itemId, self:getId()) - local tmpItem = self:addItem(itemId, item.count, INDEX_WHEREEVER, FLAG_NOLIMIT) - if tmpItem then - if tmpItem:isContainer() and item.childLoot then - if not tmpItem:addLoot(item.childLoot) then - tmpItem:remove() + local iType = ItemType(itemId) + if not iType then + logger.warn("Container:addLoot: invalid item type: {}", itemId) + goto continue + end + if iType:isStackable() or iType:getCharges() ~= 0 then + local tmpItem = self:addItem(itemId, item.count, INDEX_WHEREEVER, FLAG_NOLIMIT) + if not tmpItem then + logger.warn("Container:addLoot: failed to add item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId()) + goto continue + end + else + for i = 1, item.count do + local tmpItem = self:addItem(itemId, 1, INDEX_WHEREEVER, FLAG_NOLIMIT) + if not tmpItem then + logger.warn("Container:addLoot: failed to add item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId()) goto continue end - end - local iType = ItemType(itemId) - if item.subType ~= -1 then - tmpItem:transform(itemId, item.subType) - elseif iType:isFluidContainer() then - tmpItem:transform(itemId, 0) - end + if tmpItem:isContainer() and item.childLoot then + if not tmpItem:addLoot(item.childLoot) then + tmpItem:remove() + goto continue + end + end - if item.actionId ~= -1 then - tmpItem:setActionId(item.actionId) - end + if item.subType ~= -1 then + tmpItem:transform(itemId, item.subType) + elseif iType:isFluidContainer() then + tmpItem:transform(itemId, 0) + end + + if item.actionId ~= -1 then + tmpItem:setActionId(item.actionId) + end - if item.text and item.text ~= "" then - tmpItem:setText(item.text) + if item.text and item.text ~= "" then + tmpItem:setText(item.text) + end end - else - logger.warn("Container:addLoot: failed to add item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId()) end ::continue:: diff --git a/data/libs/functions/functions.lua b/data/libs/functions/functions.lua index 509893dbe..616d25b84 100644 --- a/data/libs/functions/functions.lua +++ b/data/libs/functions/functions.lua @@ -702,10 +702,6 @@ function isInRange(pos, fromPos, toPos) return pos.x >= fromPos.x and pos.y >= fromPos.y and pos.z >= fromPos.z and pos.x <= toPos.x and pos.y <= toPos.y and pos.z <= toPos.z end -function isInRangeIgnoreZ(pos, fromPos, toPos) - return pos.x >= fromPos.x and pos.y >= fromPos.y and pos.z >= fromPos.z and pos.x <= toPos.x -end - function isNumber(str) return tonumber(str) ~= nil end @@ -715,7 +711,7 @@ function isInteger(n) end -- Function for the reload talkaction -local logFormat = "[%s] %s %s" +local logFormat = "[%s] %s (params: %s)" function logCommand(player, words, param) local file = io.open(CORE_DIRECTORY .. "/logs/" .. player:getName() .. " commands.log", "a") diff --git a/data/libs/functions/game.lua b/data/libs/functions/game.lua index 4be079586..5682f5c58 100644 --- a/data/libs/functions/game.lua +++ b/data/libs/functions/game.lua @@ -138,7 +138,7 @@ function Game.setStorageValue(key, value) if value == -1 then if globalStorageTable[key] then - table.remove(globalStorageTable, key) + globalStorageTable[key] = nil end return end diff --git a/data/libs/functions/lever.lua b/data/libs/functions/lever.lua index 08c9f8e1d..54e6e5c49 100644 --- a/data/libs/functions/lever.lua +++ b/data/libs/functions/lever.lua @@ -176,3 +176,16 @@ function Lever.setCooldownAllPlayers(self, bossName, value) end end end + +function Lever.canUseLever(self, player, bossName, timeToFightAgain) + local info = self:getInfoPositions() + for _, v in pairs(info) do + local newPlayer = v.creature + if newPlayer and not newPlayer:canFightBoss(bossName) then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. timeToFightAgain .. " hours to face " .. bossName .. " again!") + newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) + return false + end + end + return true +end diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index 6c1d15697..ae4b21215 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -156,7 +156,9 @@ function Player:removeMoneyBank(amount) -- Removes player inventory money self:removeMoney(amount) - self:sendTextMessage(MESSAGE_TRADE, ("Paid %d gold from inventory."):format(amount)) + if amount > 0 then + self:sendTextMessage(MESSAGE_TRADE, ("Paid %d gold from inventory."):format(amount)) + end return true -- The player doens't have all the money with him @@ -170,7 +172,9 @@ function Player:removeMoneyBank(amount) -- Removes player bank money Bank.debit(self, remains) - self:sendTextMessage(MESSAGE_TRADE, ("Paid %s from inventory and %s gold from bank account. Your account balance is now %s gold."):format(FormatNumber(moneyCount), FormatNumber(amount - moneyCount), FormatNumber(self:getBankBalance()))) + if amount > 0 then + self:sendTextMessage(MESSAGE_TRADE, ("Paid %s from inventory and %s gold from bank account. Your account balance is now %s gold."):format(FormatNumber(moneyCount), FormatNumber(amount - moneyCount), FormatNumber(self:getBankBalance()))) + end return true end self:setBankBalance(bankCount - amount) diff --git a/data/libs/reward_boss/monster.lua b/data/libs/reward_boss/monster.lua index 84173fefd..028f325bb 100644 --- a/data/libs/reward_boss/monster.lua +++ b/data/libs/reward_boss/monster.lua @@ -21,7 +21,16 @@ function Monster:setRewardBoss() end end +local equipmentBags = { + BagYouCovetId, + BagYouDesireId, + PrimalBagId, +} + local function isEquipment(itemType) + if table.contains(equipmentBags, itemType:getId()) then + return true + end local t = itemType:getType() local equipmentTypes = { ITEM_TYPE_ARMOR, diff --git a/data/libs/reward_boss/reward_boss.lua b/data/libs/reward_boss/reward_boss.lua index 21e2c998b..fb7c75ec5 100644 --- a/data/libs/reward_boss/reward_boss.lua +++ b/data/libs/reward_boss/reward_boss.lua @@ -54,15 +54,21 @@ end function Container:addRewardBossItems(itemList) for itemId, lootInfo in pairs(itemList) do - local itemType = ItemType(itemId) - if itemType then + local iType = ItemType(itemId) + if iType then local itemCount = lootInfo.count - local charges = itemType:getCharges() + local charges = iType:getCharges() if charges > 0 then itemCount = charges - logger.debug("Adding item with 'id' to the reward container, item charges {}", itemType:getId(), charges) + logger.debug("Adding item with 'id' to the reward container, item charges {}", iType:getId(), charges) + end + if iType:isStackable() or iType:getCharges() ~= 0 then + self:addItem(itemId, itemCount, INDEX_WHEREEVER, FLAG_NOLIMIT) + else + for i = 1, itemCount do + self:addItem(itemId, 1, INDEX_WHEREEVER, FLAG_NOLIMIT) + end end - self:addItem(itemId, itemCount) end end end diff --git a/data/modules/scripts/gamestore/init.lua b/data/modules/scripts/gamestore/init.lua index 68a691216..7f0f2a80c 100644 --- a/data/modules/scripts/gamestore/init.lua +++ b/data/modules/scripts/gamestore/init.lua @@ -296,9 +296,9 @@ function parseTransferableCoins(playerId, msg) player:removeTransferableCoinsBalance(amount) addPlayerEvent(sendStorePurchaseSuccessful, 550, playerId, "You have transfered " .. amount .. " coins to " .. reciver .. " successfully") - -- Adding history for both reciver/sender - GameStore.insertHistory(accountId, GameStore.HistoryTypes.HISTORY_TYPE_NONE, player:getName() .. " transfered you this amount.", amount, GameStore.CoinType.Coin) - GameStore.insertHistory(player:getAccountId(), GameStore.HistoryTypes.HISTORY_TYPE_NONE, "You transfered this amount to " .. reciver, -1 * amount, GameStore.CoinType.Coin) + -- Adding history for both receiver/sender + GameStore.insertHistory(accountId, GameStore.HistoryTypes.HISTORY_TYPE_NONE, player:getName() .. " transferred you this amount.", amount, GameStore.CoinType.Coin) + GameStore.insertHistory(player:getAccountId(), GameStore.HistoryTypes.HISTORY_TYPE_NONE, "You transferred this amount to " .. reciver, -1 * amount, GameStore.CoinType.Coin) openStore(playerId) end @@ -1995,7 +1995,7 @@ function Player.makeCoinTransaction(self, offer, desc) op = self:removeTransferableCoinsBalance(offer.price) end - -- When the transaction is suscessfull add to the history + -- When the transaction is successful add to the history if op then GameStore.insertHistory(self:getAccountId(), GameStore.HistoryTypes.HISTORY_TYPE_NONE, desc, offer.price * -1, offer.coinType) end diff --git a/data/scripts/talkactions/player/bank.lua b/data/scripts/talkactions/player/bank.lua index 19acaf4a2..a9bb1967f 100644 --- a/data/scripts/talkactions/player/bank.lua +++ b/data/scripts/talkactions/player/bank.lua @@ -71,13 +71,18 @@ local transfer = TalkAction("!transfer") function transfer.onSay(player, words, param) local split = param:split(",") - local name = split[1]:trim() local amount = tonumber(split[2]) if not amount or amount <= 0 and isValidMoney(amount) then player:sendTextMessage(config.messageStyle, "Invalid amount.") return true end + local name = split[1] + if not name then + player:sendTextMessage(config.messageStyle, "Invalid name.") + return true + end + name = name:trim() local normalizedName = Game.getNormalizedPlayerName(name) if not normalizedName then player:sendTextMessage(config.messageStyle, "A player with name " .. name .. " does not exist.") diff --git a/data/scripts/talkactions/player/reward.lua b/data/scripts/talkactions/player/reward.lua index 7c2999a58..a1ad754a3 100644 --- a/data/scripts/talkactions/player/reward.lua +++ b/data/scripts/talkactions/player/reward.lua @@ -24,9 +24,10 @@ local function sendExerciseRewardModal(player) end local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX) - if inbox and inbox:getEmptySlots() > 0 then + if inbox and inbox:getEmptySlots() > 0 and player:getFreeCapacity() >= iType:getWeight() then local item = inbox:addItem(it.id, it.charges) if item then + item:setActionId(IMMOVABLE_ACTION_ID) item:setAttribute(ITEM_ATTRIBUTE_STORE, systemTime()) else player:sendTextMessage(MESSAGE_LOOK, "You need to have capacity and empty slots to receive.")