Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyx14 committed Nov 14, 2023
1 parent 0d986f9 commit 38626f8
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 52 deletions.
9 changes: 9 additions & 0 deletions data/XML/vocations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<vocation id="0" clientid="0" baseid="0" name="None" description="none" magicshield="0" gaincap="10" gainhp="5" gainmana="5" gainhpticks="12000" gainhpamount="1" gainmanaticks="6000" gainmanaamount="2" manamultiplier="4.0" attackspeed="2000" basespeed="110" soulmax="100" gainsoulticks="120000" fromvoc="0">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.3" primaryShield="2.05" secondaryShield="1.25" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.5" />
<skill id="1" multiplier="2.0" />
<skill id="2" multiplier="2.0" />
Expand All @@ -14,6 +15,7 @@
<vocation id="1" clientid="3" baseid="1" name="Sorcerer" description="a sorcerer" magicshield="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12000" gainhpamount="1" gainmanaticks="3000" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" basespeed="110" soulmax="100" gainsoulticks="120000" fromvoc="1">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.26" primaryShield="2.0" secondaryShield="1.2" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.5" />
<skill id="1" multiplier="2.0" />
<skill id="2" multiplier="2.0" />
Expand All @@ -25,6 +27,7 @@
<vocation id="2" clientid="4" baseid="2" name="Druid" description="a druid" magicshield="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12000" gainhpamount="1" gainmanaticks="3000" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" basespeed="110" soulmax="100" gainsoulticks="120000" fromvoc="2">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.26" primaryShield="2.0" secondaryShield="1.2" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.5" />
<skill id="1" multiplier="1.8" />
<skill id="2" multiplier="1.8" />
Expand All @@ -36,6 +39,7 @@
<vocation id="3" clientid="2" baseid="3" name="Paladin" description="a paladin" magicshield="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="8000" gainhpamount="1" gainmanaticks="4000" gainmanaamount="2" manamultiplier="1.4" attackspeed="2000" basespeed="110" soulmax="100" gainsoulticks="120000" fromvoc="3">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.28" primaryShield="2.08" secondaryShield="1.2" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.2" />
<skill id="1" multiplier="1.2" />
<skill id="2" multiplier="1.2" />
Expand All @@ -47,6 +51,7 @@
<vocation id="4" clientid="1" baseid="4" name="Knight" description="a knight" magicshield="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="6000" gainhpamount="1" gainmanaticks="6000" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" basespeed="110" soulmax="100" gainsoulticks="120000" fromvoc="4">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.3" primaryShield="2.05" secondaryShield="1.25" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.1" />
<skill id="1" multiplier="1.1" />
<skill id="2" multiplier="1.1" />
Expand All @@ -58,6 +63,7 @@
<vocation id="5" clientid="13" baseid="1" name="Master Sorcerer" description="a master sorcerer" magicshield="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12000" gainhpamount="1" gainmanaticks="2000" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" basespeed="110" soulmax="200" gainsoulticks="15000" fromvoc="1">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.26" primaryShield="2.0" secondaryShield="1.2" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.5" />
<skill id="1" multiplier="2.0" />
<skill id="2" multiplier="2.0" />
Expand All @@ -69,6 +75,7 @@
<vocation id="6" clientid="14" baseid="2" name="Elder Druid" description="an elder druid" magicshield="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12000" gainhpamount="1" gainmanaticks="2000" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" basespeed="110" soulmax="200" gainsoulticks="15000" fromvoc="2">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.26" primaryShield="2.0" secondaryShield="1.2" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.5" />
<skill id="1" multiplier="1.8" />
<skill id="2" multiplier="1.8" />
Expand All @@ -80,6 +87,7 @@
<vocation id="7" clientid="12" baseid="3" name="Royal Paladin" description="a royal paladin" magicshield="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="6000" gainhpamount="1" gainmanaticks="3000" gainmanaamount="2" manamultiplier="1.4" attackspeed="2000" basespeed="110" soulmax="200" gainsoulticks="15000" fromvoc="3">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.28" primaryShield="2.08" secondaryShield="1.2" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.2" />
<skill id="1" multiplier="1.2" />
<skill id="2" multiplier="1.2" />
Expand All @@ -91,6 +99,7 @@
<vocation id="8" clientid="11" baseid="4" name="Elite Knight" description="an elite knight" magicshield="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4000" gainhpamount="1" gainmanaticks="6000" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" basespeed="110" soulmax="200" gainsoulticks="15000" fromvoc="4">
<formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
<mitigation multiplier="1.3" primaryShield="2.05" secondaryShield="1.25" />
<pvp damageReceivedMultiplier="1.0" damageDealtMultiplier ="1.0"/>
<skill id="0" multiplier="1.1" />
<skill id="1" multiplier="1.1" />
<skill id="2" multiplier="1.1" />
Expand Down
4 changes: 2 additions & 2 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions data/libs/exercise_training.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 1 addition & 11 deletions data/libs/functions/bosslever.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
54 changes: 34 additions & 20 deletions data/libs/functions/container.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
6 changes: 1 addition & 5 deletions data/libs/functions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion data/libs/functions/game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions data/libs/functions/lever.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions data/libs/functions/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions data/libs/reward_boss/monster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 11 additions & 5 deletions data/libs/reward_boss/reward_boss.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions data/modules/scripts/gamestore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion data/scripts/talkactions/player/bank.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
3 changes: 2 additions & 1 deletion data/scripts/talkactions/player/reward.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit 38626f8

Please sign in to comment.