Skip to content

Commit

Permalink
Merge branch 'main' into feature/rotten-blood
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored Jul 19, 2024
2 parents 38b7c78 + 165a908 commit aa1626c
Show file tree
Hide file tree
Showing 45 changed files with 387 additions and 209 deletions.
8 changes: 8 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ onlyPremiumAccount = false

-- Customs
-- NOTE: stashMoving = true, stow an container inside your stash
-- NOTE: stashItemCount, the maximum items quantity in stash
-- NOTE: depotChest, the non-stackable items will be moved to the selected depot chest(I - XVIII).
-- NOTE: autoBank = true, the dropped coins from monsters will be automatically deposited to your bank account.
-- NOTE: toggleGoldPouchAllowAnything will allow players to move items or gold to gold pouch
Expand All @@ -254,7 +255,9 @@ onlyPremiumAccount = false
-- NOTE: startStreakLevel will make a reward streak level for new players who never logged in
-- NOTE: if showLootsInBestiary is true, will cause all loots to be shown in the bestiary even if the player has not reached the required number of kills
-- NOTE: minTownIdToBankTransfer blocks towns less than defined from receiving money transfers
-- NOTE: enableSupportOutfit enable GODS and GMS to select support outfit (gamemaster, customer support or community manager)
stashMoving = false
stashItemCount = 5000
depotChest = 4
autoLoot = false
autoBank = false
Expand All @@ -273,6 +276,7 @@ enablePlayerPutItemInAmmoSlot = false
startStreakLevel = 0
showLootsInBestiary = false
minTownIdToBankTransfer = 3
enableSupportOutfit = true

-- Teleport summon
-- Set to true will never remove the summon
Expand Down Expand Up @@ -502,6 +506,9 @@ rateMonsterHealth = 1.0
rateMonsterAttack = 1.0
rateMonsterDefense = 1.0

-- Npc rates
rateNpcHealth = 1.0

-- Boss rates
rateBossHealth = 1.0
rateBossAttack = 1.0
Expand Down Expand Up @@ -539,6 +546,7 @@ location = "South America"
-- Leave empty if you wish to disable.
discordWebhookURL = ""
discordSendFooter = true
discordWebhookDelayMs = 1000

-- Vip System (Get more info in: https://github.com/opentibiabr/canary/pull/1063)
-- NOTE: set vipSystemEnabled to true to enable the vip system functionalities (this overrides premium checks)
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/undeads/iks_ahpututu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ monster.outfit = {

monster.raceId = 2349
monster.Bestiary = {
class = "Iks",
class = "Undead",
race = BESTY_RACE_UNDEAD,
toKill = 5,
FirstUnlock = 1,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/undeads/iks_aucar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ monster.outfit = {

monster.raceId = 2344
monster.Bestiary = {
class = "Iks",
class = "Undead",
race = BESTY_RACE_UNDEAD,
toKill = 1000,
FirstUnlock = 50,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/undeads/iks_chuka.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ monster.outfit = {

monster.raceId = 2345
monster.Bestiary = {
class = "Iks",
class = "Undead",
race = BESTY_RACE_UNDEAD,
toKill = 1000,
FirstUnlock = 50,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/undeads/iks_churrascan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ monster.outfit = {

monster.raceId = 2350
monster.Bestiary = {
class = "Iks",
class = "Undead",
race = BESTY_RACE_UNDEAD,
toKill = 1000,
FirstUnlock = 50,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/undeads/iks_pututu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ monster.outfit = {

monster.raceId = 2343
monster.Bestiary = {
class = "Iks",
class = "Undead",
race = BESTY_RACE_UNDEAD,
toKill = 1000,
FirstUnlock = 50,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/obi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ npcConfig.shop = {
{ itemName = "hatchet", clientId = 3276, sell = 25 },
{ itemName = "katana", clientId = 3300, sell = 35 },
{ itemName = "mace", clientId = 3286, sell = 30 },
{ itemName = "machete", clientId = 3308, sell = 30 },
{ itemName = "machete", clientId = 3308, sell = 6 },
{ itemName = "rapier", clientId = 3272, buy = 15, sell = 5 },
{ itemName = "sabre", clientId = 3273, buy = 25, sell = 12 },
{ itemName = "scythe", clientId = 3453, buy = 12, sell = 3 },
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/npc/ramina.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ npcConfig.shop = {
{ itemName = "orange", clientId = 3586, buy = 12 },
{ itemName = "peas", clientId = 11683, buy = 5 },
{ itemName = "vial of fruit juice", clientId = 2874, buy = 10, count = 14 },
{ itemName = "vial of water", clientId = 2874, buy = 2, count = 1 },
{ itemName = "vial of water", clientId = 2874, buy = 6, count = 1 },
}
-- On buy npc shop message
npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost)
Expand Down
8 changes: 4 additions & 4 deletions data-otservbr-global/npc/sessek.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ npcConfig.shop = {
{ itemName = "peas", clientId = 11683, buy = 3 },
{ itemName = "pineapple", clientId = 11459, buy = 14 },
{ itemName = "roll", clientId = 3601, buy = 2 },
{ itemName = "vial of coconut milk", clientId = 2874, buy = 2, count = 15 },
{ itemName = "vial of coconut milk", clientId = 2874, buy = 6, count = 15 },
{ itemName = "vial of fruit juice", clientId = 2874, buy = 6, count = 14 },
{ itemName = "vial of tea", clientId = 2874, buy = 3, count = 17 },
{ itemName = "vial of water", clientId = 2874, buy = 2, count = 1 },
{ itemName = "vial of wine", clientId = 2874, buy = 3, count = 2 },
{ itemName = "vial of tea", clientId = 2874, buy = 6, count = 17 },
{ itemName = "vial of water", clientId = 2874, buy = 6, count = 1 },
{ itemName = "vial of wine", clientId = 2874, buy = 6, count = 2 },
}
-- On buy npc shop message
npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
local loginEvents = CreatureEvent("LoginEvents")
function loginEvents.onLogin(player)
local events = {
"AdvanceSave",
"RookgaardAdvance",
"FamiliarLogin",
"FamiliarAdvance",
--Quests
--Cults Of Tibia Quest
"HealthPillar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ function symbol.onStepIn(creature, item, position, fromPosition)
end

symbol:type("stepin")
symbol:position({ x = 33349, y = 31123, z = 5 })
symbol:position({ x = 33357, y = 31123, z = 5 })
symbol:register()
4 changes: 4 additions & 0 deletions data/libs/functions/revscriptsys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ do
self:type("periodchange")
self:onPeriodChange(value)
return
elseif key == "onSave" then
self:type("save")
self:onSave(value)
return
end
rawset(self, key, value)
end
Expand Down
1 change: 1 addition & 0 deletions data/scripts/creaturescripts/familiar/on_login.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function familiarOnLogin.onLogin(player)
return false
end

player:registerEvent("FamiliarAdvance")
local vocation = FAMILIAR_ID[player:getVocation():getBaseId()]

local familiarName
Expand Down
9 changes: 9 additions & 0 deletions data/scripts/creaturescripts/player/login.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,19 @@ function playerLoginGlobal.onLogin(player)
onMovementRemoveProtection(playerId, player:getPosition(), 10)
end

-- Change support outfit to a normal outfit to open customize character without crashes
local playerOutfit = player:getOutfit()
if table.contains({ 75, 266, 302 }, playerOutfit.lookType) then
playerOutfit.lookType = 136
playerOutfit.lookAddons = 0
player:setOutfit(playerOutfit)
end

player:initializeLoyaltySystem()
player:registerEvent("PlayerDeath")
player:registerEvent("DropLoot")
player:registerEvent("BossParticipation")
player:registerEvent("UpdatePlayerOnAdvancedLevel")
return true
end

Expand Down
7 changes: 1 addition & 6 deletions src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ enum ConfigKey_t : uint16_t {
ACTIONS_DELAY_INTERVAL,
ADVENTURERSBLESSING_LEVEL,
AIMBOT_HOTKEY_ENABLED,
ALLOW_BLOCK_SPAWN,
ALLOW_CHANGEOUTFIT,
ALLOW_RELOAD,
AUGMENT_INCREASED_DAMAGE_PERCENT,
Expand Down Expand Up @@ -63,11 +62,11 @@ enum ConfigKey_t : uint16_t {
DISCORD_WEBHOOK_URL,
EMOTE_SPELLS,
ENABLE_PLAYER_PUT_ITEM_IN_AMMO_SLOT,
ENABLE_SUPPORT_OUTFIT,
EX_ACTIONS_DELAY_INTERVAL,
EXP_FROM_PLAYERS_LEVEL_RANGE,
EXPERIENCE_FROM_PLAYERS,
FAMILIAR_TIME,
FORCE_MONSTERTYPE_LOAD,
FORGE_AMOUNT_MULTIPLIER,
FORGE_BASE_SUCCESS_RATE,
FORGE_BONUS_SUCCESS_RATE,
Expand Down Expand Up @@ -135,8 +134,6 @@ enum ConfigKey_t : uint16_t {
M_CONST,
MAINTAIN_MODE_MESSAGE,
MAP_AUTHOR,
MAP_CUSTOM_AUTHOR,
MAP_CUSTOM_NAME,
MAP_DOWNLOAD_URL,
MAP_NAME,
MARKET_OFFER_DURATION,
Expand Down Expand Up @@ -221,8 +218,6 @@ enum ConfigKey_t : uint16_t {
RATE_MONSTER_ATTACK,
RATE_MONSTER_DEFENSE,
RATE_MONSTER_HEALTH,
RATE_NPC_ATTACK,
RATE_NPC_DEFENSE,
RATE_NPC_HEALTH,
RATE_OFFLINE_TRAINING_SPEED,
RATE_SKILL,
Expand Down
21 changes: 14 additions & 7 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ bool ConfigManager::load() {
loadStringConfig(L, IP, "ip", "127.0.0.1");
loadStringConfig(L, MAINTAIN_MODE_MESSAGE, "maintainModeMessage", "");
loadStringConfig(L, MAP_AUTHOR, "mapAuthor", "Eduardo Dantas");
loadStringConfig(L, MAP_CUSTOM_AUTHOR, "mapCustomAuthor", "OTServBR");
loadStringConfig(L, MAP_CUSTOM_NAME, "mapCustomName", "");
loadStringConfig(L, MAP_DOWNLOAD_URL, "mapDownloadUrl", "");
loadStringConfig(L, MAP_NAME, "mapName", "canary");
loadStringConfig(L, MYSQL_DB, "mysqlDatabase", "canary");
Expand All @@ -84,7 +82,6 @@ bool ConfigManager::load() {
}

loadBoolConfig(L, AIMBOT_HOTKEY_ENABLED, "hotkeyAimbotEnabled", true);
loadBoolConfig(L, ALLOW_BLOCK_SPAWN, "allowBlockSpawn", true);
loadBoolConfig(L, ALLOW_CHANGEOUTFIT, "allowChangeOutfit", true);
loadBoolConfig(L, ALLOW_RELOAD, "allowReload", false);
loadBoolConfig(L, AUTOBANK, "autoBank", false);
Expand All @@ -97,8 +94,8 @@ bool ConfigManager::load() {
loadBoolConfig(L, DISCORD_SEND_FOOTER, "discordSendFooter", true);
loadBoolConfig(L, EMOTE_SPELLS, "emoteSpells", false);
loadBoolConfig(L, ENABLE_PLAYER_PUT_ITEM_IN_AMMO_SLOT, "enablePlayerPutItemInAmmoSlot", false);
loadBoolConfig(L, ENABLE_SUPPORT_OUTFIT, "enableSupportOutfit", true);
loadBoolConfig(L, EXPERIENCE_FROM_PLAYERS, "experienceByKillingPlayers", false);
loadBoolConfig(L, FORCE_MONSTERTYPE_LOAD, "forceMonsterTypesOnLoad", true);
loadBoolConfig(L, FREE_PREMIUM, "freePremium", false);
loadBoolConfig(L, GLOBAL_SERVER_SAVE_CLEAN_MAP, "globalServerSaveCleanMap", false);
loadBoolConfig(L, GLOBAL_SERVER_SAVE_CLOSE, "globalServerSaveClose", false);
Expand Down Expand Up @@ -193,8 +190,6 @@ bool ConfigManager::load() {
loadFloatConfig(L, RATE_MONSTER_ATTACK, "rateMonsterAttack", 1.0);
loadFloatConfig(L, RATE_MONSTER_DEFENSE, "rateMonsterDefense", 1.0);
loadFloatConfig(L, RATE_MONSTER_HEALTH, "rateMonsterHealth", 1.0);
loadFloatConfig(L, RATE_NPC_ATTACK, "rateNpcAttack", 1.0);
loadFloatConfig(L, RATE_NPC_DEFENSE, "rateNpcDefense", 1.0);
loadFloatConfig(L, RATE_NPC_HEALTH, "rateNpcHealth", 1.0);
loadFloatConfig(L, RATE_OFFLINE_TRAINING_SPEED, "rateOfflineTrainingSpeed", 1.0);
loadFloatConfig(L, RATE_SOUL_REGEN_SPEED, "rateSoulRegenSpeed", 1.0);
Expand Down Expand Up @@ -235,7 +230,7 @@ bool ConfigManager::load() {
loadIntConfig(L, FAMILIAR_TIME, "familiarTime", 30);
loadIntConfig(L, FORGE_BASE_SUCCESS_RATE, "forgeBaseSuccessRate", 50);
loadIntConfig(L, FORGE_BONUS_SUCCESS_RATE, "forgeBonusSuccessRate", 15);
loadIntConfig(L, FORGE_CONVERGENCE_FUSION_DUST_COST, "forgeConvergenceFusionCost", 130);
loadIntConfig(L, FORGE_CONVERGENCE_FUSION_DUST_COST, "forgeConvergenceFusionDustCost", 130);
loadIntConfig(L, FORGE_CONVERGENCE_TRANSFER_DUST_COST, "forgeConvergenceTransferCost", 160);
loadIntConfig(L, FORGE_CORE_COST, "forgeCoreCost", 50);
loadIntConfig(L, FORGE_COST_ONE_SLIVER, "forgeCostOneSliver", 20);
Expand Down Expand Up @@ -383,11 +378,17 @@ bool ConfigManager::reload() {
return result;
}

void ConfigManager::missingConfigWarning(const char* identifier) {
g_logger().warn("[{}]: Missing configuration for identifier: {}", __FUNCTION__, identifier);
}

std::string ConfigManager::loadStringConfig(lua_State* L, const ConfigKey_t &key, const char* identifier, const std::string &defaultValue) {
std::string value = defaultValue;
lua_getglobal(L, identifier);
if (lua_isstring(L, -1)) {
value = lua_tostring(L, -1);
} else {
missingConfigWarning(identifier);
}
configs[key] = value;
lua_pop(L, 1);
Expand All @@ -399,6 +400,8 @@ int32_t ConfigManager::loadIntConfig(lua_State* L, const ConfigKey_t &key, const
lua_getglobal(L, identifier);
if (lua_isnumber(L, -1)) {
value = static_cast<int32_t>(lua_tointeger(L, -1));
} else {
missingConfigWarning(identifier);
}
configs[key] = value;
lua_pop(L, 1);
Expand All @@ -410,6 +413,8 @@ bool ConfigManager::loadBoolConfig(lua_State* L, const ConfigKey_t &key, const c
lua_getglobal(L, identifier);
if (lua_isboolean(L, -1)) {
value = static_cast<bool>(lua_toboolean(L, -1));
} else {
missingConfigWarning(identifier);
}
configs[key] = value;
lua_pop(L, 1);
Expand All @@ -421,6 +426,8 @@ float ConfigManager::loadFloatConfig(lua_State* L, const ConfigKey_t &key, const
lua_getglobal(L, identifier);
if (lua_isnumber(L, -1)) {
value = static_cast<float>(lua_tonumber(L, -1));
} else {
missingConfigWarning(identifier);
}
configs[key] = value;
lua_pop(L, 1);
Expand Down
2 changes: 2 additions & 0 deletions src/config/configmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class ConfigManager {
bool load();
bool reload();

void missingConfigWarning(const char* identifier);

const std::string &setConfigFileLua(const std::string &what) {
configFileLua = { what };
return configFileLua;
Expand Down
29 changes: 16 additions & 13 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ CombatDamage Combat::getCombatDamage(std::shared_ptr<Creature> creature, std::sh
return damage;
}

void Combat::getCombatArea(const Position &centerPos, const Position &targetPos, const std::unique_ptr<AreaCombat> &area, std::forward_list<std::shared_ptr<Tile>> &list) {
void Combat::getCombatArea(const Position &centerPos, const Position &targetPos, const std::unique_ptr<AreaCombat> &area, std::vector<std::shared_ptr<Tile>> &list) {
if (targetPos.z >= MAP_MAX_LAYERS) {
return;
}

if (area) {
area->getList(centerPos, targetPos, list);
} else {
list.push_front(g_game().map.getOrCreateTile(targetPos));
list.emplace_back(g_game().map.getOrCreateTile(targetPos));
}
}

Expand Down Expand Up @@ -1119,7 +1119,7 @@ bool Combat::doCombat(std::shared_ptr<Creature> caster, const Position &position
}

void Combat::CombatFunc(std::shared_ptr<Creature> caster, const Position &origin, const Position &pos, const std::unique_ptr<AreaCombat> &area, const CombatParams &params, CombatFunction func, CombatDamage* data) {
std::forward_list<std::shared_ptr<Tile>> tileList;
std::vector<std::shared_ptr<Tile>> tileList;

if (caster) {
getCombatArea(caster->getPosition(), pos, area, tileList);
Expand Down Expand Up @@ -1827,26 +1827,29 @@ AreaCombat::AreaCombat(const AreaCombat &rhs) {
}
}

void AreaCombat::getList(const Position &centerPos, const Position &targetPos, std::forward_list<std::shared_ptr<Tile>> &list) const {
void AreaCombat::getList(const Position &centerPos, const Position &targetPos, std::vector<std::shared_ptr<Tile>> &list) const {
const std::unique_ptr<MatrixArea> &area = getArea(centerPos, targetPos);
if (!area) {
return;
}

uint32_t centerY, centerX;
uint32_t centerY;
uint32_t centerX;
area->getCenter(centerY, centerX);

const uint32_t rows = area->getRows();
const uint32_t cols = area->getCols();
list.reserve(rows * cols);

Position tmpPos(targetPos.x - centerX, targetPos.y - centerY, targetPos.z);
uint32_t cols = area->getCols();
for (uint32_t y = 0, rows = area->getRows(); y < rows; ++y) {
for (uint32_t x = 0; x < cols; ++x) {
if (area->getValue(y, x) != 0 && g_game().isSightClear(targetPos, tmpPos, true)) {
list.push_front(g_game().map.getOrCreateTile(tmpPos));
for (uint32_t y = 0; y < rows; ++y, ++tmpPos.y, tmpPos.x -= cols) {
for (uint32_t x = 0; x < cols; ++x, ++tmpPos.x) {
if (area->getValue(y, x) != 0) {
if (g_game().isSightClear(targetPos, tmpPos, true)) {
list.emplace_back(g_game().map.getOrCreateTile(tmpPos));
}
}
tmpPos.x++;
}
tmpPos.x -= cols;
tmpPos.y++;
}
}

Expand Down
Loading

0 comments on commit aa1626c

Please sign in to comment.