Skip to content

Commit

Permalink
[Enhancement] rework for enable choosing of a custom datapack name (#572
Browse files Browse the repository at this point in the history
)

With this modification, we will be able to focus on just one repository (the canary), and archive otservbr-global repository.

The intention is that we can have two datapacks in the same repository, being able to easily switch from one to the other, just change in config.lua the "dataPackDirectory" from "data-otservbr-global" to "data-canary" or vice versa.

The main purpose is to facilitate our development, at the same time that the community will be able to contribute in a single repository, but keeping the choice of using a "clean" datapack.

I made some more modifications, such as removing the unused C++ gamestore, I also removed the "allowPickupable" tag, which was duplicated, and I made some other adjustments.

Folder structure changes
Now we have the following structure:
• data = this will be the "core" folder, it is where the files that are absolutely necessary for the executable to open correctly, such as libs, xmls, etc. Here we will have files that both the global and the canary datapack will share with each other
• data-otservbr-global = here will be the global datapack files, some libs and folders that are only for the global server, such as scripts, monsters, npcs, world.
• data-canary = a "clean" datapack as far as possible, with only the scripts and files necessary for the server to work.

• NOTE: The "data" folder is actually the "core" of the server, we didn't rename it to avoid having to make changes to the sites and login.php, since they read the "data/xml". The other two folders, data-otservbr-global and data-canary can be changed in config.lua, which one you want the executable to read, by default we'll point to the global one, as that's what most use. If you want to start a custom server with "as few files and scripts as possible", then switch to "data-canary".

We also added a boolean in config.lua that allows choosing another name for the datapack, by default we will also keep this disabled, since we will only maintain support for these two datapacks, it is up to each one to know what they are doing in case they want to change it.

So, in the end, we have the reorganization in the folders:
![58855](https://user-images.githubusercontent.com/8551443/202463807-c0902611-4d6e-493d-b72d-8d85d5009d55.jpg)

Note that we made few real changes to the files, the abundance of modified files is due to moving from one folder to another and also adding the global datapack to this repository (with an abundance of files). If you want to migrate your datapack to the global one, you should know what you're doing, if you don't know, just pass your modifications to the "new files" or get in touch on our discord group so we can help you: https://discord.gg/X3mSnMH8jg
  • Loading branch information
dudantas committed Nov 19, 2022
1 parent d39401a commit 6c924eb
Show file tree
Hide file tree
Showing 5,159 changed files with 616,037 additions and 13,543 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
39 changes: 23 additions & 16 deletions config.lua.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-- Core settings
-- Note: If you want to use datapack folder canary (custom), put only "data-canary"
-- If you want to use the global datapack folder, put "data-otservbr-global"
-- If "useAnyDatapackFolder" is set to true then you can choose any datapack folder for your server
useAnyDatapackFolder = false
dataPackDirectory = "data-otservbr-global"
-- Don't change this unless you know what you're doing
coreDirectory = "data"

-- Combat settings
-- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced"
worldType = "pvp"
Expand Down Expand Up @@ -32,10 +41,10 @@ loginProtocolPort = 7171
gameProtocolPort = 7172
statusProtocolPort = 7171
maxPlayers = 0
motd = "Welcome to the Canary!"
serverName = "OTServBR-Global"
motd = "Welcome to the OTServBR-Global!"
onePlayerOnlinePerAccount = true
allowClones = false
serverName = "Canary"
statusTimeout = 5 * 1000
replaceKickOnLogin = true
maxPacketsPerSecond = 25
Expand All @@ -52,9 +61,6 @@ freeDepotLimit = 2000
premiumDepotLimit = 10000
depotBoxes = 20

-- GameStore
gamestoreByModules = true

-- Prey system
-- NOTE: preyRerollPricePerLevel: Price multiplier in gold coin for rerolling prey list.
-- NOTE: preySelectListPrice: Price to manually select creature on list and to lock prey slot.
Expand Down Expand Up @@ -99,8 +105,9 @@ autoLoot = false
-- autoBank = true, the dropped coins from monsters will be automatically
-- deposited to your bank account.
autoBank = false
-- teleporte summon
-- true will never remove the summon

-- Teleport summon
-- Set to true will never remove the summon
teleportSummons = false

-- Stamina in Trainers
Expand Down Expand Up @@ -165,9 +172,9 @@ pushWhenAttacking = false
-- NOTE: set mapName WITHOUT .otbm at the end
-- NOTE: If toggleDownloadMap if false, then the mapDownloadUrl will not be used
-- NOTE: If a map with the name already exists in the world folder, the map will not be downloaded even if the toggleDownloadMap is true
toggleDownloadMap = false
mapName = "canary"
mapDownloadUrl = ""
toggleDownloadMap = true
mapName = "otservbr"
mapDownloadUrl = "https://github.com/opentibiabr/otservbr-global/releases/download/v1.5.0/otservbr.otbm"
mapAuthor = "OpenTibiaBR"

-- Party List limitations
Expand All @@ -176,9 +183,9 @@ mapAuthor = "OpenTibiaBR"
partyListMaxDistance = 30

-- Custom Map
-- NOTE: mapCustomEnabled: true = activate the map, false = disable the map
toggleMapCustom = false
mapCustomName = "canary-custom"
-- NOTE: mapCustomEnabled = activate the map, false = disable the map
toggleMapCustom = true
mapCustomName = "otservbr-custom"
mapCustomAuthor = "OpenTibiaBR"

-- Market
Expand All @@ -190,8 +197,8 @@ maxMarketOffersAtATimePerPlayer = 100
-- MySQL
mysqlHost = "127.0.0.1"
mysqlUser = "root"
mysqlPass = ""
mysqlDatabase = "canary"
mysqlPass = "root"
mysqlDatabase = "otservbr-global"
mysqlPort = 3306
mysqlSock = ""
passwordType = "sha1"
Expand Down Expand Up @@ -230,7 +237,7 @@ globalServerSaveTime = "06:00:00"
sortLootByChance = false

-- Rates
-- NOTE: rateExp, rateSkill and rateMagic are only used when 'rateUseStages = false'
-- NOTE: rateExp, rateSkill and rateMagic is used when 'rateUseStages = false' - or a fallback only
-- To configure rates see file data/stages.lua
rateUseStages = false
rateExp = 1
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions data-canary/lib/core/load.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dofile(DATA_DIRECTORY.. '/lib/core/storages.lua')
dofile(DATA_DIRECTORY.. '/lib/core/constants.lua')
dofile(DATA_DIRECTORY.. '/lib/core/quests.lua')
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions data-canary/lib/lib.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Core API functions implemented in Lua
dofile(DATA_DIRECTORY.. '/lib/core/load.lua')


-- Tables library
dofile(DATA_DIRECTORY.. '/lib/tables/load.lua')
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions data-canary/lib/tables/load.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dofile(DATA_DIRECTORY.. '/lib/tables/vocation.lua')
dofile(DATA_DIRECTORY.. '/lib/tables/door.lua')
dofile(DATA_DIRECTORY.. '/lib/tables/exercise_training.lua')
dofile(DATA_DIRECTORY.. '/lib/tables/familiar.lua')
dofile(DATA_DIRECTORY.. '/lib/tables/npc_spells.lua')
dofile(DATA_DIRECTORY.. '/lib/tables/window.lua')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions data-canary/migrations/1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- return true = There are others migrations file
-- return false = This is the last migration file
function onUpdateDatabase()
return false
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions data-canary/npclib/load.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dofile(DATA_DIRECTORY .. "/npclib/npc.lua")
dofile(DATA_DIRECTORY .. "/npclib/npc_system/npc_handler.lua")
dofile(DATA_DIRECTORY .. "/npclib/npc_system/keyword_handler.lua")
dofile(DATA_DIRECTORY .. "/npclib/npc_system/modules.lua")
dofile(DATA_DIRECTORY .. "/npclib/npc_system/custom_modules.lua")
dofile(DATA_DIRECTORY .. "/npclib/npc_system/bank_system.lua")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions data-canary/scripts/actions/other/blessing_charms.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dofile(CORE_DIRECTORY .. "/modules/scripts/blessings/blessings.lua")

local blessingCharms = Action()

function blessingCharms.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return Blessings.useCharm(player, item)
end

for blessingId = 10341, 10345 do
blessingCharms:id(blessingId)
end

blessingCharms:register()
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions data-canary/scripts/actions/other/check_bless.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dofile(CORE_DIRECTORY .. "/modules/scripts/blessings/blessings.lua")

local checkBless = Action()

function checkBless.onUse(player, item, fromPosition, target, toPosition, isHotkey)
return Blessings.checkBless(player)
end

checkBless:id(6561, 11468)
checkBless:register()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
107 changes: 107 additions & 0 deletions data-canary/scripts/creaturescripts/login.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
local login = CreatureEvent("PlayerLogin")

function login.onLogin(player)
local loginStr = "Welcome to " .. configManager.getString(configKeys.SERVER_NAME) .. "!"
if player:getLastLoginSaved() <= 0 then
loginStr = loginStr .. " Please choose your outfit."
player:sendOutfitWindow()
else
if loginStr ~= "" then
player:sendTextMessage(MESSAGE_LOGIN, loginStr)
end

player:sendTextMessage(MESSAGE_LOGIN, string.format("Your last visit in ".. SERVER_NAME ..": %s.", os.date("%d. %b %Y %X", player:getLastLoginSaved())))
end

-- Stamina
nextUseStaminaTime[player.uid] = 0

-- Promotion
local vocation = player:getVocation()
local promotion = vocation:getPromotion()
if player:isPremium() then
local value = player:getStorageValue(Storage.Promotion)
if not promotion and value ~= 1 then
player:setStorageValue(STORAGEVALUE_PROMOTION, 1)
elseif value == 1 then
player:setVocation(promotion)
end
elseif not promotion then
player:setVocation(vocation:getDemotion())
end

-- Events
player:registerEvent("PlayerDeath")
player:registerEvent("DropLoot")
player:registerEvent("BossParticipation")


if onExerciseTraining[player:getId()] then -- onLogin & onLogout
stopEvent(onExerciseTraining[player:getId()].event)
onExerciseTraining[player:getId()] = nil
player:setTraining(false)
end

-- Boosted creature
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Today's boosted creature: " .. Game.getBoostedCreature() .. " \
Boosted creatures yield more experience points, carry more loot than usual and respawn at a faster rate.")

if SCHEDULE_EXP_RATE ~= 100 then
if SCHEDULE_EXP_RATE > 100 then
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Exp Rate Event! Monsters yield more experience points than usual \
Happy Hunting!")
else
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Exp Rate Decreased! Monsters yield less experience points than usual.")
end
end

if SCHEDULE_SPAWN_RATE ~= 100 then
if SCHEDULE_SPAWN_RATE > 100 then
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Spawn Rate Event! Monsters respawn at a faster rate \
Happy Hunting!")
else
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Spawn Rate Decreased! Monsters respawn at a slower rate.")
end
end

if SCHEDULE_LOOT_RATE ~= 100 then
if SCHEDULE_LOOT_RATE > 100 then
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Loot Rate Event! Monsters carry more loot than usual \
Happy Hunting!")
else
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Loot Rate Decreased! Monsters carry less loot than usual.")
end
end

if SCHEDULE_SKILL_RATE ~= 100 then
if SCHEDULE_SKILL_RATE > 100 then
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Skill Rate Event! Your skills progresses at a higher rate \
Happy Hunting!")
else
player:sendTextMessage(MESSAGE_BOOSTED_CREATURE, "Skill Rate Decreased! Your skills progresses at a lower rate.")
end
end

local playerId = player:getId()

-- Stamina
nextUseStaminaTime[playerId] = 1

-- EXP Stamina
nextUseXpStamina[playerId] = 1

-- Set Client XP Gain Rate --
local rateExp = 1
if Game.getStorageValue(GlobalStorage.XpDisplayMode) > 0 then
rateExp = getRateFromTable(experienceStages, player:getLevel(), configManager.getNumber(configKeys.RATE_EXPERIENCE))
if SCHEDULE_EXP_RATE ~= 100 then
rateExp = math.max(0, (rateExp * SCHEDULE_EXP_RATE)/100)
end
end

player:setBaseXpGain(rateExp * 100)

return true
end

login:register()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6c924eb

Please sign in to comment.