Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable party share range #2539

Merged
merged 1 commit into from
Apr 17, 2024
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
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ wheelAtelierRevealGreaterCost = 6000000
familiarTime = 30

partyAutoShareExperience = true
-- partyShareRangeMultiplier: the range of the party share experience, default 3/2 (1.5)
partyShareRangeMultiplier = 1.5
partyShareLootBoosts = false
partyShareLootBoostsDimishingFactor = 0.7

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 @@ -178,6 +178,7 @@ enum ConfigKey_t : uint16_t {
OWNER_NAME,
PARALLELISM,
PARTY_AUTO_SHARE_EXPERIENCE,
PARTY_SHARE_RANGE_MULTIPLIER,
PARTY_LIST_MAX_DISTANCE,
PARTY_SHARE_LOOT_BOOSTS_DIMINISHING_FACTOR,
PARTY_SHARE_LOOT_BOOSTS,
Expand Down
1 change: 1 addition & 0 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ bool ConfigManager::load() {
loadIntConfig(L, STAMINA_PZ_GAIN, "staminaPzGain", 1);
loadIntConfig(L, STAMINA_TRAINER_DELAY, "staminaTrainerDelay", 5);
loadIntConfig(L, STAMINA_TRAINER_GAIN, "staminaTrainerGain", 1);
loadFloatConfig(L, PARTY_SHARE_RANGE_MULTIPLIER, "partyShareRangeMultiplier", 1.5f);
loadIntConfig(L, START_STREAK_LEVEL, "startStreakLevel", 0);
loadIntConfig(L, STATUSQUERY_TIMEOUT, "statusTimeout", 5000);
loadIntConfig(L, STORE_COIN_PACKET, "coinPacketSize", 25);
Expand Down
9 changes: 6 additions & 3 deletions src/creatures/players/grouping/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ SharedExpStatus_t Party::getMemberSharedExperienceStatus(std::shared_ptr<Player>
return SHAREDEXP_OK;
}

float Party::shareRangeMultiplier() const {
return g_configManager().getFloat(PARTY_SHARE_RANGE_MULTIPLIER, __FUNCTION__);
}

uint32_t Party::getHighestLevel() {
auto leader = getLeader();
if (!leader) {
Expand All @@ -507,7 +511,7 @@ uint32_t Party::getHighestLevel() {
}

uint32_t Party::getMinLevel() {
return static_cast<uint32_t>(std::ceil((static_cast<float>(getHighestLevel()) * 2) / 3));
return static_cast<uint32_t>(std::ceil(static_cast<float>(getHighestLevel()) / shareRangeMultiplier()));
}

uint32_t Party::getLowestLevel() {
Expand All @@ -525,15 +529,14 @@ uint32_t Party::getLowestLevel() {
}

uint32_t Party::getMaxLevel() {
return static_cast<uint32_t>(std::floor((static_cast<float>(getLowestLevel()) * 3) / 2));
return static_cast<uint32_t>(std::floor(static_cast<float>(getLowestLevel()) * shareRangeMultiplier()));
}

bool Party::isPlayerActive(std::shared_ptr<Player> player) {
auto it = ticksMap.find(player->getID());
if (it == ticksMap.end()) {
return false;
}

uint64_t timeDiff = OTSYS_TIME() - it->second;
return timeDiff <= 2 * 60 * 1000;
}
Expand Down
1 change: 1 addition & 0 deletions src/creatures/players/grouping/party.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class Party : public SharedObject {
uint32_t getLowestLevel();
uint32_t getMinLevel();
uint32_t getMaxLevel();
float shareRangeMultiplier() const;

std::map<uint32_t, int64_t> ticksMap;

Expand Down
Loading