Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ 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: minTownIdToBankTransferFromMain blocks towns less than defined from receiving money transfers
-- NOTE: allowLureCreatures if true monsters can be lured far from spawn, if false they will despawn
-- NOTE: blockRespawn if true players block monster respawns on their spot
-- NOTE: enableOfflineTraining if false will disable offline training from beds only, set false at skill_trainer.lua if you want to completly disable the system
-- NOTE: walkThroughPlayers if true players can pass through other players, if false they cannot, set allowWalkthrough same as you do here to avoid override or bug
autoLoot = false
autoBank = false
toggleGoldPouchAllowAnything = false
Expand All @@ -332,6 +336,10 @@ enablePlayerPutItemInAmmoSlot = false
startStreakLevel = 0
showLootsInBestiary = false
minTownIdToBankTransferFromMain = 4
allowLureCreatures = false
blockRespawn = false
enableOfflineTraining = true
walkThroughPlayers = true

-- Stash
-- NOTE: stashMoving = true, stow an container inside your stash
Expand Down Expand Up @@ -467,6 +475,7 @@ toggleMapCustom = false
-- Market
-- NOTE: marketRefreshPricesInterval (in minutes, minimum is 1 minute)
-- NOTE: set it to 0 for disable, is the time in which the task will run updating the prices of the items that will be sent to the client
enableMarket = true
marketOfferDuration = 30 * 24 * 60 * 60
marketRefreshPricesInterval = 30
premiumToCreateMarketOffer = true
Expand Down
6 changes: 4 additions & 2 deletions data/scripts/actions/objects/market.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
local market = Action()

function market.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not configManager.getBoolean(configKeys.ENABLE_MARKET) then
player:sendCancelMessage("Market is disabled.")
return true
end
player:openMarket()
return true
end

market:id(12903)
market:register()
11 changes: 5 additions & 6 deletions data/scripts/actions/objects/skill_trainer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ local setting = {
[16202] = SKILL_MAGLEVEL,
[50296] = SKILL_FIST,
}

local skillTrainer = Action()

function skillTrainer.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not configManager.getBoolean(configKeys.ENABLE_OFFLINE_TRAINING) then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Offline training is currently disabled.")
return true
end

local skill = setting[item:getId()]
if not player:isPremium() and player:getSkillLevel(skill) > 50 then
player:sendCancelMessage(RETURNVALUE_YOUNEEDPREMIUMACCOUNT)
return true
end

if player:isPzLocked() then
return false
end

player:setOfflineTrainingSkill(skill)
player:remove(false)
return true
end

for index, value in pairs(setting) do
skillTrainer:id(index)
end

skillTrainer:register()
5 changes: 5 additions & 0 deletions src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,5 +395,10 @@ enum ConfigKey_t : uint16_t {
INGAME_GUILD_MANAGEMENT,
LEVEL_TO_FORM_GUILD,
CREATE_GUILD_ONLY_PREMIUM,
WALK_THROUGH_PLAYERS,
ALLOW_LURE_CREATURES,
BLOCK_RESPAWN,
ENABLE_OFFLINE_TRAINING,
ENABLE_MARKET,
ADVANCED_PARTY_PROTECTION,
};
5 changes: 5 additions & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ bool ConfigManager::load() {
loadBoolConfig(L, PREY_ENABLED, "preySystemEnabled", true);
loadBoolConfig(L, PREY_FREE_THIRD_SLOT, "preyFreeThirdSlot", false);
loadBoolConfig(L, PUSH_WHEN_ATTACKING, "pushWhenAttacking", false);
loadBoolConfig(L, WALK_THROUGH_PLAYERS, "walkThroughPlayers", true);
loadBoolConfig(L, ALLOW_LURE_CREATURES, "allowLureCreatures", true);
loadBoolConfig(L, BLOCK_RESPAWN, "blockRespawn", true);
loadBoolConfig(L, ENABLE_OFFLINE_TRAINING, "enableOfflineTraining", true);
loadBoolConfig(L, ENABLE_MARKET, "enableMarket", true);
loadBoolConfig(L, ADVANCED_PARTY_PROTECTION, "advancedPartyProtection", true);
loadBoolConfig(L, RATE_USE_STAGES, "rateUseStages", false);
loadBoolConfig(L, REFUND_BEGINNING_WEAPON_MANA, "refundBeginningWeaponMana", false);
Expand Down
4 changes: 4 additions & 0 deletions src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,10 @@ bool Monster::isInSpawnRange(const Position &pos) const {
return true;
}

if (g_configManager().getBoolean(ALLOW_LURE_CREATURES)) {
return true;
}

if (Monster::despawnRadius == 0) {
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions src/creatures/monsters/spawns/spawn_monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ void SpawnMonster::checkSpawnMonster() {
if (!mType) {
continue;
}
bool spawnBlockedByPlayer = false;
if (g_configManager().getBoolean(BLOCK_RESPAWN)) {
spawnBlockedByPlayer = findPlayer(sb.pos);
} else {
spawnBlockedByPlayer = mType->info.isBlockable && findPlayer(sb.pos);
}

if (!mType->canSpawn(sb.pos) || (mType->info.isBlockable && findPlayer(sb.pos))) {
sb.lastSpawn = OTSYS_TIME();
continue;
Expand Down
6 changes: 5 additions & 1 deletion src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6866,7 +6866,11 @@ void Player::setSpecialMenuAvailable(bool stashBool, bool marketMenuBool, bool d
// Menu option 'show in market'
// Menu option to open depot search
stashMenuAvailable = stashBool;
marketMenu = marketMenuBool;
if (g_configManager().getBoolean(ENABLE_MARKET)) {
marketMenu = marketMenuBool;
} else {
marketMenu = false;
}
depotSearch = depotSearchBool;
if (client) {
client->sendSpecialContainersAvailable();
Expand Down
9 changes: 9 additions & 0 deletions src/items/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,15 @@ ReturnValue Tile::queryAdd(int32_t, const std::shared_ptr<Thing> &thing, uint32_
const CreatureVector* creatures = getCreatures();
if (const auto &player = creature->getPlayer()) {
if (creatures && !creatures->empty() && !hasBitSet(FLAG_IGNOREBLOCKCREATURE, tileFlags) && !player->isAccessPlayer()) {

if (!g_configManager().getBoolean(WALK_THROUGH_PLAYERS)) {
for (const auto &tileCreature : *creatures) {
if (tileCreature->getPlayer()) {
return RETURNVALUE_NOTENOUGHROOM;
}
}
}

for (const auto &tileCreature : *creatures) {
if (!player->canWalkthrough(tileCreature)) {
return RETURNVALUE_NOTPOSSIBLE;
Expand Down
8 changes: 7 additions & 1 deletion src/lua/creature/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,13 @@ ReturnValue Actions::internalUseItem(const std::shared_ptr<Player> &player, cons

if (bed->trySleep(player)) {
player->setBedItem(bed);
g_game().sendOfflineTrainingDialog(player);

if (g_configManager().getBoolean(ENABLE_OFFLINE_TRAINING)) {
g_game().sendOfflineTrainingDialog(player);
} else {
bed->sleep(player);
player->setBedItem(nullptr);
}
}

return RETURNVALUE_NOERROR;
Expand Down
6 changes: 5 additions & 1 deletion src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8780,7 +8780,11 @@ void ProtocolGame::sendSpecialContainersAvailable() {
NetworkMessage msg;
msg.addByte(0x2A);
msg.addByte(player->isStashMenuAvailable() ? 0x01 : 0x00);
msg.addByte(player->isMarketMenuAvailable() ? 0x01 : 0x00);
if (g_configManager().getBoolean(ENABLE_MARKET)) {
msg.addByte(player->isMarketMenuAvailable() ? 0x01 : 0x00);
} else {
msg.addByte(0x00);
}
writeToOutputBuffer(msg);
}

Expand Down
Loading