From 4074530a714267b433595e15b21ab5eeef1782f8 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 5 Oct 2025 11:02:56 -0700 Subject: [PATCH] disable EXP share during battle and challenge quests --- src/Lobby.cc | 17 --------------- src/Lobby.hh | 42 +++++++++++++++++++------------------- src/ReceiveSubcommands.cc | 14 ++++++++----- system/config.example.json | 4 +++- 4 files changed, 33 insertions(+), 44 deletions(-) diff --git a/src/Lobby.cc b/src/Lobby.cc index 43388ebb..0102d45c 100644 --- a/src/Lobby.cc +++ b/src/Lobby.cc @@ -146,26 +146,9 @@ Lobby::Lobby(shared_ptr s, uint32_t id, bool is_game) : server_state(s), log(std::format("[{}:{:X}] ", is_game ? "Game" : "Lobby", id), lobby_log.min_level), 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()), rand_crypt(make_shared()), 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) { this->log.info_f("Created"); if (is_game) { diff --git a/src/Lobby.hh b/src/Lobby.hh index 36bdcbe7..86b7d22e 100644 --- a/src/Lobby.hh +++ b/src/Lobby.hh @@ -96,12 +96,12 @@ struct Lobby : public std::enable_shared_from_this { uint32_t lobby_id; - uint32_t min_level; - uint32_t max_level; + uint32_t min_level = 0; + uint32_t max_level = 0xFFFFFFFF; // Game state std::array next_item_id_for_client; - uint32_t next_game_item_id; + uint32_t next_game_item_id = 0xCC000000; std::vector floor_item_managers; std::shared_ptr rare_enemy_rates; std::shared_ptr map_state; // Always null for lobbies, never null for games @@ -114,22 +114,22 @@ struct Lobby : public std::enable_shared_from_this { // 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 // Version enum. - uint16_t allowed_versions; - uint8_t creator_section_id; - uint8_t override_section_id; - Episode episode; - GameMode mode; - uint8_t difficulty; // 0-3 - float base_exp_multiplier; - float exp_share_multiplier; - float challenge_exp_multiplier; + uint16_t allowed_versions = 0x0000; + uint8_t creator_section_id = 0xFF; + uint8_t override_section_id = 0xFF; + Episode episode = Episode::NONE; + GameMode mode = GameMode::NORMAL; + uint8_t difficulty = 0; // 0-3 + float base_exp_multiplier = 1.0f; + float exp_share_multiplier = 0.5f; + float challenge_exp_multiplier = 1.0f; std::string password; std::string name; // This seed is also sent to the client for rare enemy generation - uint32_t random_seed; + uint32_t random_seed = 0; std::shared_ptr rand_crypt; - uint8_t allowed_drop_modes; - ServerDropMode drop_mode; + uint8_t allowed_drop_modes = 0x1F; + ServerDropMode drop_mode = ServerDropMode::CLIENT; std::shared_ptr item_creator; // Always null for lobbies, never null for games struct ChallengeParameters { @@ -164,11 +164,11 @@ struct Lobby : public std::enable_shared_from_this { std::shared_ptr ep3_ex_result_values; // Lobby stuff - uint8_t event; - uint8_t block; - uint8_t leader_id; - uint8_t max_clients; - uint32_t enabled_flags; + uint8_t event = 0; + uint8_t block = 0; + uint8_t leader_id = 0; + uint8_t max_clients = 12; + uint32_t enabled_flags = 0; std::shared_ptr quest; std::array, 12> clients; // Keys in this map are client_id @@ -176,7 +176,7 @@ struct Lobby : public std::enable_shared_from_this { // This is only used when the PERSISTENT flag is set and idle_timeout_usecs // is not zero - uint64_t idle_timeout_usecs; + uint64_t idle_timeout_usecs = 0; asio::steady_timer idle_timeout_timer; Lobby(std::shared_ptr s, uint32_t id, bool is_game); diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index cf7aac09..0a33313c 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -4029,15 +4029,19 @@ static asio::awaitable on_enemy_exp_request_bb(shared_ptr c, Subco if (base_exp != 0.0) { // 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 - // close enough to the monster, they get a smaller share; if none of these - // situations apply, they get no EXP. + // close enough to the monster, they get a smaller share; if none of + // 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; if (ene_st->last_hit_by_client_id(client_id)) { - rate_factor = max(1.0, l->exp_share_multiplier); + rate_factor = max(1.0, exp_share_multiplier); } else if (ene_st->ever_hit_by_client_id(client_id)) { - rate_factor = max(0.8, l->exp_share_multiplier); + rate_factor = max(0.8, exp_share_multiplier); } else if (lc->floor == ene_st->super_ene->floor) { - rate_factor = l->exp_share_multiplier; + rate_factor = max(0.0, exp_share_multiplier); } else { rate_factor = 0.0; } diff --git a/system/config.example.json b/system/config.example.json index 07dcc81e..761c4f01 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -826,7 +826,9 @@ // (50% by default). // - If the player is not on the same floor as an enemy when it is killed and // 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, // 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