Skip to content

Commit

Permalink
* Teleport player to a free town if they are inside special tiles.
Browse files Browse the repository at this point in the history
* Addd config freeTownId to config.lua
  • Loading branch information
jprzimba committed Feb 28, 2025
1 parent 7515f11 commit f93eeea
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
9 changes: 7 additions & 2 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ 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: Set `toggleSpecialTiles` to true if you want to use the system.
stashMoving = false
stashItemCount = 5000
depotChest = 4
Expand All @@ -314,7 +313,13 @@ enablePlayerPutItemInAmmoSlot = false
startStreakLevel = 0
showLootsInBestiary = false
minTownIdToBankTransferFromMain = 4
toggleSpecialTiles = false

-- Special tiles and Free Town
-- NOTE: Special tiles and free town ID are independent.
-- NOTE: Set toggleSpecialTiles to true if you want to use the system.
-- NOTE: freeTownId = 8 is Thais city.
freeTownId = 8
toggleSpecialTiles = true

-- Cosmetics
-- NOTE: enableSupportOutfit enable GODS and GMS to select support outfit (gamemaster, customer support or community manager)
Expand Down
1 change: 1 addition & 0 deletions src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,5 @@ enum ConfigKey_t : uint16_t {
UNLOCK_ALL_FAMILIARS,
LEAVE_PARTY_ON_DEATH,
TOGGLE_SPECIAL_TILES,
FREE_TOWN_ID,
};
1 change: 1 addition & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ bool ConfigManager::load() {
loadIntConfig(L, ROOK_SLOT_AMMO, "rookSlotAmmo", 0);
loadIntConfig(L, DAYS_TO_CLOSE_BID, "daysToCloseBid", 7);
loadIntConfig(L, ANIMUS_MASTERY_MONSTERS_TO_INCREASE_XP_MULTIPLIER, "animusMasteryMonstersToIncreaseXpMultiplier", 10);
loadIntConfig(L, FREE_TOWN_ID, "freeTownId", 8);

loadStringConfig(L, CORE_DIRECTORY, "coreDirectory", "data");
loadStringConfig(L, DATA_DIRECTORY, "dataPackDirectory", "data-global");
Expand Down
1 change: 1 addition & 0 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10309,6 +10309,7 @@ void Player::onCreatureAppear(const std::shared_ptr<Creature> &creature, bool is
}

g_game().changePlayerSpeed(static_self_cast<Player>(), 0);
g_game().checkPremiumArea(static_self_cast<Player>());
}
}

Expand Down
23 changes: 23 additions & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11324,3 +11324,26 @@ void Game::loadSpecialTiles() {
bool Game::isSpecialTile(const Position &pos) const {
return specialTiles.find(pos) != specialTiles.end();
}

void Game::checkPremiumArea(const std::shared_ptr<Player> &player) {
if (!player || player->isPremium() || player->isVip()) {
return;
}

const auto freeTownId = g_configManager().getNumber(FREE_TOWN_ID);
const auto &freeTown = g_game().map.towns.getTown(freeTownId);
if (!freeTown) {
return;
}

const auto &playerPos = player->getPosition();
const auto freeTownTemplePosition = freeTown->getTemplePosition();
if (isSpecialTile(playerPos)) {
player->sendTextMessage(MESSAGE_ADMINISTRATOR, "Your premium has expired. You are being teleported to a free town.");
Position freeTemplePosition(freeTownTemplePosition);
internalTeleport(player, freeTemplePosition, false);
player->loginPosition = freeTownTemplePosition;
player->setTown(freeTown);
g_saveManager().savePlayer(player);
}
}
1 change: 1 addition & 0 deletions src/game/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class Game {

void loadSpecialTiles();
bool isSpecialTile(const Position &pos) const;
void checkPremiumArea(const std::shared_ptr<Player> &player);

void addItemsClassification(ItemClassification* itemsClassification) {
itemsClassifications.push_back(itemsClassification);
Expand Down

0 comments on commit f93eeea

Please sign in to comment.