Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: some scripts #1784

Merged
merged 24 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b67b317
fixes in levers and other fixes.
elsongabriel Oct 24, 2023
6c08e40
bosses: fixes.
elsongabriel Nov 6, 2023
fb2169b
bank: fixes.
elsongabriel Nov 6, 2023
dd39e4d
reward: fixes.
elsongabriel Nov 6, 2023
febdc3f
fixes.
elsongabriel Nov 6, 2023
f19bec7
save_interval.lua: commented broadcast message function.
elsongabriel Nov 11, 2023
ef2fa22
items.xml: removed wrong indentation.
elsongabriel Nov 11, 2023
6d32940
fixed addEvent parameters.
elsongabriel Nov 11, 2023
d23eab1
exercise_training: created message when player starts training or alr…
elsongabriel Nov 11, 2023
834c4c3
adventurers_stone: fixed validation to enable the usage of adventurer…
elsongabriel Nov 11, 2023
0ae5f44
quests e bosses: fixed events name and fixed variables. removed 'rewa…
elsongabriel Nov 11, 2023
e68d079
logCommand improvement.
elsongabriel Nov 11, 2023
4a9deb6
Lua code format - (Stylua)
github-actions[bot] Nov 11, 2023
e2a1bcb
adventurers_stone: fixed validations.
elsongabriel Nov 12, 2023
880fc6f
functions: removed unused function.
elsongabriel Nov 12, 2023
be8f3bf
ssa exhaust fixes.
elsongabriel Nov 13, 2023
f3a80c3
feat: custom pvp system (#1403)
sebbesiren Nov 12, 2023
c1db9e6
fix: the outlaw camp quest (#1809)
Leshyah Nov 13, 2023
8ce6e17
fix: charge house rent (#1814)
luan Nov 13, 2023
0964cdb
fix: bestiary kills and boss boost (#1813)
luan Nov 13, 2023
def2251
feat: random monsters spawn (#1802)
Schiffers Nov 13, 2023
a763dd0
fix: table.remove function does not work with random indexes (#1801)
luanluciano93 Nov 13, 2023
d5155fa
Merge branch 'main' into hotfix/fix-scripts
dudantas Nov 13, 2023
7d8545c
Update data-otservbr-global/scripts/globalevents/customs/save_interva…
luan Nov 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data-otservbr-global/monster/bosses/custodian.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ monster.loot = {
{ id = 281, chance = 28000 }, -- giant shimmering pearl (green)
{ name = "cobra crest", chance = 11000 },
{ name = "skull helmet", chance = 7500 },
{ name = "cobra club", chance = 100 },
}

monster.attacks = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ monster.flags = {
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = true,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ monster.outfit = {
lookMount = 0,
}

monster.events = {
"SoulwarsBossDeath",
}

monster.health = 300000
monster.maxHealth = 300000
monster.race = "undead"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ monster.flags = {
hostile = true,
convinceable = false,
pushable = false,
rewardBoss = true,
rewardBoss = false,
illusionable = false,
canPushItems = true,
canPushCreatures = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ local config = {
enableDepots = false,

Temples = {
{ fromPos = Position(32718, 31628, 7), toPos = Position(32736, 31639, 7), townId = TOWNS_LIST.AB_DENDRIEL },
{ fromPos = Position(32356, 31775, 7), toPos = Position(32364, 31787, 7), townId = TOWNS_LIST.CARLIN },
{ fromPos = Position(32727, 31632, 7), toPos = Position(32736, 31639, 7), townId = TOWNS_LIST.AB_DENDRIEL },
{ fromPos = Position(32358, 31777, 7), toPos = Position(32364, 31787, 7), townId = TOWNS_LIST.CARLIN },
{ fromPos = Position(32642, 31921, 11), toPos = Position(32656, 31929, 11), townId = TOWNS_LIST.KAZORDOON },
{ fromPos = Position(32364, 32231, 7), toPos = Position(32374, 32243, 7), townId = TOWNS_LIST.THAIS },
{ fromPos = Position(32365, 32231, 7), toPos = Position(32374, 32243, 7), townId = TOWNS_LIST.THAIS },
{ fromPos = Position(32953, 32072, 7), toPos = Position(32963, 32081, 7), townId = TOWNS_LIST.VENORE },
{ fromPos = Position(33188, 32844, 8), toPos = Position(33201, 32857, 8), townId = TOWNS_LIST.ANKRAHMUN },
{ fromPos = Position(33208, 31803, 8), toPos = Position(33225, 31819, 8), townId = TOWNS_LIST.EDRON },
{ fromPos = Position(33018, 31514, 11), toPos = Position(33032, 31531, 11), townId = TOWNS_LIST.FARMINE },
{ fromPos = Position(33210, 32450, 1), toPos = Position(33217, 32457, 1), townId = TOWNS_LIST.DARASHIA },
{ fromPos = Position(32313, 32818, 7), toPos = Position(32322, 32830, 7), townId = TOWNS_LIST.LIBERTY_BAY },
{ fromPos = Position(32590, 32740, 7), toPos = Position(32600, 32750, 7), townId = TOWNS_LIST.PORT_HOPE },
{ fromPos = Position(32207, 31127, 7), toPos = Position(32218, 31138, 7), townId = TOWNS_LIST.SVARGROND },
{ fromPos = Position(32785, 31274, 7), toPos = Position(32789, 31279, 7), townId = TOWNS_LIST.YALAHAR },
{ fromPos = Position(33442, 31312, 9), toPos = Position(33454, 31326, 9), townId = TOWNS_LIST.GRAY_BEACH },
{ fromPos = Position(33586, 31895, 6), toPos = Position(33603, 31903, 6), townId = TOWNS_LIST.RATHLETON },
{ fromPos = Position(33510, 32360, 6), toPos = Position(33516, 32366, 6), townId = TOWNS_LIST.ROSHAMUUL },
{ fromPos = Position(33916, 31474, 5), toPos = Position(33927, 31484, 5), townId = TOWNS_LIST.ISSAVI },
{ fromPos = Position(32209, 31130, 7), toPos = Position(32215, 31136, 7), townId = TOWNS_LIST.SVARGROND },
{ fromPos = Position(32785, 31275, 7), toPos = Position(32789, 31279, 7), townId = TOWNS_LIST.YALAHAR },
{ fromPos = Position(33444, 31313, 9), toPos = Position(33452, 31324, 9), townId = TOWNS_LIST.GRAY_BEACH },
{ fromPos = Position(33586, 31895, 6), toPos = Position(33602, 31902, 6), townId = TOWNS_LIST.RATHLETON },
{ fromPos = Position(33510, 32360, 6), toPos = Position(33516, 32365, 6), townId = TOWNS_LIST.ROSHAMUUL },
{ fromPos = Position(33916, 31474, 5), toPos = Position(33926, 31480, 5), townId = TOWNS_LIST.ISSAVI },
},

Depots = {
Expand All @@ -45,11 +45,31 @@ local config = {

local adventurersStone = Action()

local function doNotTeleport(player)
local enabledLocations = {}
if config.enableTemples then
table.insert(enabledLocations, "temple")
end
if config.enableDepots then
table.insert(enabledLocations, "depot")
end
local message = "Try to move more to the center of a " .. table.concat(enabledLocations, " or ") .. " to use the spiritual energy for a teleport."
player:getPosition():sendMagicEffect(CONST_ME_POFF)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
end

function adventurersStone.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local playerPos, allowed, townId = player:getPosition(), false
local tile = Tile(player:getPosition())
if not tile:hasFlag(TILESTATE_PROTECTIONZONE) or tile:hasFlag(TILESTATE_HOUSE) or player:isPzLocked() or player:getCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT) then
doNotTeleport(player)
return false
end

local playerPos, allowed, townId = player:getPosition(), false, player:getTown():getId()

if config.enableTemples then
for _, temple in ipairs(config.Temples) do
if isInRangeIgnoreZ(playerPos, temple.fromPos, temple.toPos) then
if isInRange(playerPos, temple.fromPos, temple.toPos) then
allowed, townId = true, temple.townId
break
end
Expand All @@ -58,24 +78,16 @@ function adventurersStone.onUse(player, item, fromPosition, target, toPosition,

if config.enableDepots then
for _, depot in ipairs(config.Depots) do
if isInRangeIgnoreZ(playerPos, depot.fromPos, depot.toPos) then
if isInRange(playerPos, depot.fromPos, depot.toPos) then
allowed, townId = true, depot.townId
break
end
end
end

if not allowed then
local enabledLocations = {}
if config.enableTemples then
table.insert(enabledLocations, "temple")
end
if config.enableDepots then
table.insert(enabledLocations, "depot")
end
local message = "Try to move more to the center of a " .. table.concat(enabledLocations, " or ") .. " to use the spiritual energy for a teleport."
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
return true
doNotTeleport(player)
return false
end

player:setStorageValue(Storage.AdventurersGuild.Stone, townId)
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/scripts/actions/other/cask_kegs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function flasks.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return false
end

local charges = target:getCharges()
local charges = item:getCharges()
local itemCount = item:getCount()
local recharged = itemCount

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local function isDummy(id)
return dummies[id] and dummies[id] > 0
end

local cooldown = 2
local cooldown = 10

function exerciseTraining.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target then
Expand All @@ -17,8 +17,7 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,

if target:isItem() and isDummy(targetId) then
if onExerciseTraining[playerId] then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This exercise dummy can only be used after a " .. cooldown .. " second cooldown.")
LeaveTraining(playerId)
player:sendTextMessage(MESSAGE_FAILURE, "You are already training!")
return true
end

Expand Down Expand Up @@ -56,7 +55,7 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,
end

if player:getStorageValue(Storage.IsTraining) > os.time() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This exercise dummy can only be used after a " .. cooldown .. " second cooldown.")
player:sendTextMessage(MESSAGE_FAILURE, "You are already training!")
return true
end

Expand All @@ -66,6 +65,7 @@ function exerciseTraining.onUse(player, item, fromPosition, target, toPosition,
onExerciseTraining[playerId].dummyPos = targetPos
player:setTraining(true)
player:setStorageValue(Storage.IsTraining, os.time() + cooldown)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have started training on an exercise dummy.")
end
return true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function dangerousDepthPesticide.onUse(player, item, fromPosition, target, toPos
return true
end

if not target or not target:isItem() then
if not (target or target:isItem()) then
return false
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,7 @@ function dreamCourtsLever.onUse(player, item, fromPosition, target, toPosition,
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All the players need to be level " .. config.requiredLevel .. " or higher.")
return false
end
if creature:getStorageValue(config.storage) > 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 " .. config.timeToFightAgain .. " hours to face " .. bossToday .. " again!")
if newPlayer:getStorageValue(config.storage) > os.time() then
newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF)
end
end
end
if not lever:canUseLever(player, bossToday, config.timeToFightAgain) then
return false
end
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local bosses = {

-- This will set the status of warzone (killing 1, 2 and 3 wz bosses in order you can open the chest and get "some golden fruits") and the reward chest storages
local bossesWarzone = CreatureEvent("BossesWarzoneDeath")
function bossesWarzone.onDeath(target)
function bossesWarzone.onDeath(creature)
local bossConfig = bosses[creature:getName():lower()]
if not bossConfig then
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ local bosses = {

local bossesCults = CreatureEvent("CultsOfTibiaBossDeath")
function bossesCults.onDeath(creature)
if not player:isPlayer() then
return true
end

if not creature:isMonster() or creature:getMaster() then
-- Deny summons and players
if not creature or creature:isPlayer() or creature:getMaster() then
return true
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lostExileKill:register()

local wormKill = CreatureEvent("WarzoneWormDeath")
function wormKill.onDeath(creature, _corpse, _lastHitKiller, mostDamageKiller)
local storage = player:getStorageValue(Storage.DangerousDepths.Dwarves.Organisms)
local storage = mostDamageKiller:getStorageValue(Storage.DangerousDepths.Dwarves.Organisms)
onDeathForParty(creature, mostDamageKiller, function(creature, player)
if player:getStorageValue(Storage.DangerousDepths.Dwarves.Subterranean) ~= 1 then
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local function revertTeleport(position, itemId, transformId, destination)
end
end

local ascendantBossesKill = CreatureEvent("AscendantBossesKill")
local ascendantBossesKill = CreatureEvent("AscendantBossesDeath")
function ascendantBossesKill.onDeath(creature)
local bossConfig = bosses[creature:getName():lower()]
if not bossConfig then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ end

local azerus = CreatureEvent("AzerusDeath")
function azerus.onDeath(creature)
local targetMonster = creature:getMonster()
local position = targetMonster:getPosition()
position:sendMagicEffect(CONST_ME_TELEPORT)
local item = Game.createItem(1949, 1, position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ local function serverSave(interval)
end

saveServer()
local message = "Server save complete. Next save in %d %ss!"
local messageSingle = "Server save complete. Next save in %d %s!"
local message = string.format(SAVE_INTERVAL_CONFIG_TIME > 1 and "Server save complete. Next save in %d %ss!" or "Server save complete. Next save in %d %s!", SAVE_INTERVAL_CONFIG_TIME, SAVE_INTERVAL_TYPE)
Game.broadcastMessage(message, MESSAGE_GAME_HIGHLIGHT)
logger.info(message)
Webhook.sendMessage("Server save", message, WEBHOOK_COLOR_WARNING)
elsongabriel marked this conversation as resolved.
Show resolved Hide resolved
if SAVE_INTERVAL_CONFIG_TIME > 1 then
Game.broadcastMessage(string.format(message, SAVE_INTERVAL_CONFIG_TIME, SAVE_INTERVAL_TYPE), MESSAGE_GAME_HIGHLIGHT)
logger.info(string.format(message, SAVE_INTERVAL_CONFIG_TIME, SAVE_INTERVAL_TYPE))
else
Game.broadcastMessage(string.format(messageSingle, SAVE_INTERVAL_CONFIG_TIME, SAVE_INTERVAL_TYPE), MESSAGE_GAME_HIGHLIGHT)
logger.info(string.format(messageSingle, SAVE_INTERVAL_CONFIG_TIME, SAVE_INTERVAL_TYPE))
end
end

local save = GlobalEvent("save")
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)
elsongabriel marked this conversation as resolved.
Show resolved Hide resolved
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!")
elsongabriel marked this conversation as resolved.
Show resolved Hide resolved
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
6 changes: 1 addition & 5 deletions data/libs/functions/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,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 @@ -730,7 +726,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
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 @@ -224,7 +224,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 @@ -238,7 +240,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
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
Loading