Skip to content

Commit

Permalink
feat: configurable party share range (#2539)
Browse files Browse the repository at this point in the history
Pretty small yet useful configuration feature to allow one to easily change party share ranges.

The configuration is a float, default to 1.5 which is the same as cipbia.
  • Loading branch information
luan authored Apr 17, 2024
1 parent 533e9d6 commit d2d44cd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
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

0 comments on commit d2d44cd

Please sign in to comment.