Skip to content

Commit

Permalink
* PvP Expert WalkThrough
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 10, 2025
1 parent 0870b81 commit a07888d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ rookSlotAmmo = 0
-- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced"
-- NOTE: removeBeginningWeaponAmmunition: spears, arrows, bolt have endless ammo (allows training for paladins)
-- NOTE: refundManaOnBeginningWeapons: wand of vortex and snakebite refund mana used (allows training for mages)
-- NOTE: toggleExpertPvp enables the PvP frames, similar to Tibia RL.
worldType = "pvp"
hotkeyAimbotEnabled = true
protectionLevel = 7
Expand All @@ -72,7 +71,11 @@ blackSkulledDeathHealth = 40
blackSkulledDeathMana = 0
fieldOwnershipDuration = 5 * 1000
loginProtectionPeriod = 10 * 1000

-- Expert PvP
-- NOTE: toggleExpertPvp enables the PvP frames, similar to Tibia RL.
toggleExpertPvp = true
pvpExpertCanWalkThroughOtherPlayers = false;

cleanProtectionZones = false

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 @@ -352,6 +352,7 @@ enum ConfigKey_t : uint16_t {
BEDS_ONLY_PREMIUM,
LOGIN_PROTECTION,
TOGGLE_EXPERT_PVP,
EXPERT_PVP_CANWALKTHROUGHOTHERPLAYERS,
SPELL_NAME_INSTEAD_WORDS,
LOG_PLAYERS_STATEMENTS,
TOGGLE_TEST_MODE,
Expand Down
1 change: 1 addition & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ bool ConfigManager::load() {
loadBoolConfig(L, CHAIN_SYSTEM_VIP_ONLY, "chainSystemVipOnly", false);
loadBoolConfig(L, BEDS_ONLY_PREMIUM, "bedsOnlyPremium", true);
loadBoolConfig(L, TOGGLE_EXPERT_PVP, "toggleExpertPvp", false);
loadBoolConfig(L, EXPERT_PVP_CANWALKTHROUGHOTHERPLAYERS, "pvpExpertCanWalkThroughOtherPlayers", false);
loadBoolConfig(L, SPELL_NAME_INSTEAD_WORDS, "spellNameInsteadOfWords", false);
loadBoolConfig(L, LOG_PLAYERS_STATEMENTS, "logPlayersStatements", false);
loadBoolConfig(L, TOGGLE_TEST_MODE, "toggleTestMode", false);
Expand Down
27 changes: 25 additions & 2 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,21 @@ bool Player::canWalkthrough(const std::shared_ptr<Creature> &creature) {
return true;
}

bool expertPvpWalkThrough = g_configManager().getBoolean(TOGGLE_EXPERT_PVP) && g_configManager().getBoolean(EXPERT_PVP_CANWALKTHROUGHOTHERPLAYERS);
const auto &player = creature->getPlayer();
if (!player) {
if (expertPvpWalkThrough) {
if (const auto &monster = creature->getMonster()) {
if (!monster->isSummon() || !monster->getMaster()->getPlayer()) {
return false;
}
const auto master = monster->getMaster()->getPlayer();
return master != getPlayer() && canWalkthrough(master);
}
}
return false;
}

const auto &monster = creature->getMonster();
const auto &npc = creature->getNpc();
if (monster) {
Expand Down Expand Up @@ -1208,7 +1222,11 @@ bool Player::canWalkthroughEx(const std::shared_ptr<Creature> &creature) const {
const auto &npc = creature->getNpc();
if (player) {
const auto &playerTile = player->getTile();
return playerTile && (playerTile->hasFlag(TILESTATE_NOPVPZONE) || playerTile->hasFlag(TILESTATE_PROTECTIONZONE) || player->getLevel() <= static_cast<uint32_t>(g_configManager().getNumber(PROTECTION_LEVEL)) || g_game().getWorldType() == WORLD_TYPE_NO_PVP);
if (g_configManager().getBoolean(TOGGLE_EXPERT_PVP) && g_configManager().getBoolean(EXPERT_PVP_CANWALKTHROUGHOTHERPLAYERS)) {
return playerTile != nullptr;
} else {
return playerTile && (playerTile->hasFlag(TILESTATE_NOPVPZONE) || playerTile->hasFlag(TILESTATE_PROTECTIONZONE) || player->getLevel() <= static_cast<uint32_t>(g_configManager().getNumber(PROTECTION_LEVEL)) || g_game().getWorldType() == WORLD_TYPE_NO_PVP);
}
} else if (npc) {
const auto &tile = npc->getTile();
const auto &houseTile = std::dynamic_pointer_cast<HouseTile>(tile);
Expand Down Expand Up @@ -2434,10 +2452,15 @@ void Player::onChangeZone(ZoneType_t zone) {
}
}

bool expertPvp = g_configManager().getBoolean(TOGGLE_EXPERT_PVP);
bool expertPvpWalkThrough = g_configManager().getBoolean(EXPERT_PVP_CANWALKTHROUGHOTHERPLAYERS);
if (!expertPvp || (expertPvp && !expertPvpWalkThrough)) {
g_game().updateCreatureWalkthrough(static_self_cast<Player>());
}

updateImbuementTrackerStats();
wheel()->onThink(true);
wheel()->sendGiftOfLifeCooldown();
g_game().updateCreatureWalkthrough(static_self_cast<Player>());
sendIcons();
g_events().eventPlayerOnChangeZone(static_self_cast<Player>(), zone);

Expand Down

0 comments on commit a07888d

Please sign in to comment.