disable EXP share during battle and challenge quests

This commit is contained in:
Martin Michelsen
2025-10-05 11:02:56 -07:00
parent 31eedd7e7e
commit 4074530a71
4 changed files with 33 additions and 44 deletions
-17
View File
@@ -146,26 +146,9 @@ Lobby::Lobby(shared_ptr<ServerState> s, uint32_t id, bool is_game)
: server_state(s), : server_state(s),
log(std::format("[{}:{:X}] ", is_game ? "Game" : "Lobby", id), lobby_log.min_level), log(std::format("[{}:{:X}] ", is_game ? "Game" : "Lobby", id), lobby_log.min_level),
lobby_id(id), lobby_id(id),
min_level(0),
max_level(0xFFFFFFFF),
next_game_item_id(0xCC000000),
allowed_versions(0x0000),
override_section_id(0xFF),
episode(Episode::NONE),
mode(GameMode::NORMAL),
difficulty(0),
base_exp_multiplier(1.0f),
exp_share_multiplier(0.5f),
challenge_exp_multiplier(1.0f),
random_seed(phosg::random_object<uint32_t>()), random_seed(phosg::random_object<uint32_t>()),
rand_crypt(make_shared<DisabledRandomGenerator>()), rand_crypt(make_shared<DisabledRandomGenerator>()),
drop_mode(ServerDropMode::CLIENT), drop_mode(ServerDropMode::CLIENT),
event(0),
block(0),
leader_id(0),
max_clients(12),
enabled_flags(0),
idle_timeout_usecs(0),
idle_timeout_timer(*s->io_context) { idle_timeout_timer(*s->io_context) {
this->log.info_f("Created"); this->log.info_f("Created");
if (is_game) { if (is_game) {
+21 -21
View File
@@ -96,12 +96,12 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
uint32_t lobby_id; uint32_t lobby_id;
uint32_t min_level; uint32_t min_level = 0;
uint32_t max_level; uint32_t max_level = 0xFFFFFFFF;
// Game state // Game state
std::array<uint32_t, 12> next_item_id_for_client; std::array<uint32_t, 12> next_item_id_for_client;
uint32_t next_game_item_id; uint32_t next_game_item_id = 0xCC000000;
std::vector<FloorItemManager> floor_item_managers; std::vector<FloorItemManager> floor_item_managers;
std::shared_ptr<const MapState::RareEnemyRates> rare_enemy_rates; std::shared_ptr<const MapState::RareEnemyRates> rare_enemy_rates;
std::shared_ptr<MapState> map_state; // Always null for lobbies, never null for games std::shared_ptr<MapState> map_state; // Always null for lobbies, never null for games
@@ -114,22 +114,22 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
// Bits in allowed_versions specify who is allowed to join this game. The // Bits in allowed_versions specify who is allowed to join this game. The
// bits are indexed as (1 << version), where version is a value from the // bits are indexed as (1 << version), where version is a value from the
// Version enum. // Version enum.
uint16_t allowed_versions; uint16_t allowed_versions = 0x0000;
uint8_t creator_section_id; uint8_t creator_section_id = 0xFF;
uint8_t override_section_id; uint8_t override_section_id = 0xFF;
Episode episode; Episode episode = Episode::NONE;
GameMode mode; GameMode mode = GameMode::NORMAL;
uint8_t difficulty; // 0-3 uint8_t difficulty = 0; // 0-3
float base_exp_multiplier; float base_exp_multiplier = 1.0f;
float exp_share_multiplier; float exp_share_multiplier = 0.5f;
float challenge_exp_multiplier; float challenge_exp_multiplier = 1.0f;
std::string password; std::string password;
std::string name; std::string name;
// This seed is also sent to the client for rare enemy generation // This seed is also sent to the client for rare enemy generation
uint32_t random_seed; uint32_t random_seed = 0;
std::shared_ptr<RandomGenerator> rand_crypt; std::shared_ptr<RandomGenerator> rand_crypt;
uint8_t allowed_drop_modes; uint8_t allowed_drop_modes = 0x1F;
ServerDropMode drop_mode; ServerDropMode drop_mode = ServerDropMode::CLIENT;
std::shared_ptr<ItemCreator> item_creator; // Always null for lobbies, never null for games std::shared_ptr<ItemCreator> item_creator; // Always null for lobbies, never null for games
struct ChallengeParameters { struct ChallengeParameters {
@@ -164,11 +164,11 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
std::shared_ptr<const G_SetEXResultValues_Ep3_6xB4x4B> ep3_ex_result_values; std::shared_ptr<const G_SetEXResultValues_Ep3_6xB4x4B> ep3_ex_result_values;
// Lobby stuff // Lobby stuff
uint8_t event; uint8_t event = 0;
uint8_t block; uint8_t block = 0;
uint8_t leader_id; uint8_t leader_id = 0;
uint8_t max_clients; uint8_t max_clients = 12;
uint32_t enabled_flags; uint32_t enabled_flags = 0;
std::shared_ptr<const Quest> quest; std::shared_ptr<const Quest> quest;
std::array<std::shared_ptr<Client>, 12> clients; std::array<std::shared_ptr<Client>, 12> clients;
// Keys in this map are client_id // Keys in this map are client_id
@@ -176,7 +176,7 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
// This is only used when the PERSISTENT flag is set and idle_timeout_usecs // This is only used when the PERSISTENT flag is set and idle_timeout_usecs
// is not zero // is not zero
uint64_t idle_timeout_usecs; uint64_t idle_timeout_usecs = 0;
asio::steady_timer idle_timeout_timer; asio::steady_timer idle_timeout_timer;
Lobby(std::shared_ptr<ServerState> s, uint32_t id, bool is_game); Lobby(std::shared_ptr<ServerState> s, uint32_t id, bool is_game);
+9 -5
View File
@@ -4029,15 +4029,19 @@ static asio::awaitable<void> on_enemy_exp_request_bb(shared_ptr<Client> c, Subco
if (base_exp != 0.0) { if (base_exp != 0.0) {
// If this player killed the enemy, they get full EXP; if they tagged the // If this player killed the enemy, they get full EXP; if they tagged the
// enemy, they get 80% EXP; if auto EXP share is enabled and they are // enemy, they get 80% EXP; if auto EXP share is enabled and they are
// close enough to the monster, they get a smaller share; if none of these // close enough to the monster, they get a smaller share; if none of
// situations apply, they get no EXP. // these situations apply, they get no EXP. In Battle and Challenge
// modes, if a quest is loaded, EXP share is disabled.
float exp_share_multiplier = (((l->mode == GameMode::BATTLE) || (l->mode == GameMode::CHALLENGE)) && l->quest)
? 0.0f
: l->exp_share_multiplier;
double rate_factor; double rate_factor;
if (ene_st->last_hit_by_client_id(client_id)) { if (ene_st->last_hit_by_client_id(client_id)) {
rate_factor = max<double>(1.0, l->exp_share_multiplier); rate_factor = max<double>(1.0, exp_share_multiplier);
} else if (ene_st->ever_hit_by_client_id(client_id)) { } else if (ene_st->ever_hit_by_client_id(client_id)) {
rate_factor = max<double>(0.8, l->exp_share_multiplier); rate_factor = max<double>(0.8, exp_share_multiplier);
} else if (lc->floor == ene_st->super_ene->floor) { } else if (lc->floor == ene_st->super_ene->floor) {
rate_factor = l->exp_share_multiplier; rate_factor = max<double>(0.0, exp_share_multiplier);
} else { } else {
rate_factor = 0.0; rate_factor = 0.0;
} }
+3 -1
View File
@@ -826,7 +826,9 @@
// (50% by default). // (50% by default).
// - If the player is not on the same floor as an enemy when it is killed and // - If the player is not on the same floor as an enemy when it is killed and
// never tagged it, they get no EXP. // never tagged it, they get no EXP.
// To disable EXP share in BB games, set this to zero. // To disable EXP share in BB games, set this to zero. EXP share is always
// disabled during battle and challenge quests (but not in free-play battle
// mode).
"BBEXPShareMultiplier": 0.5, "BBEXPShareMultiplier": 0.5,
// Drop rate multiplier for all server drop tables. This applies to server // Drop rate multiplier for all server drop tables. This applies to server
// drop modes in all game versions. If you want to scale the drop rates for // drop modes in all game versions. If you want to scale the drop rates for