diff --git a/src/Domain/Entities/GameServers/GameServerConfig.cs b/src/Domain/Entities/GameServers/GameServerConfig.cs index 3ccb768e8..2cc22cb1a 100644 --- a/src/Domain/Entities/GameServers/GameServerConfig.cs +++ b/src/Domain/Entities/GameServers/GameServerConfig.cs @@ -48,5 +48,6 @@ public class GameServerConfig : AuditableEntity public int? Crpg_reward_tick { get; set; } // Sets the reward tick duration in seconds for Conquest/Siege/Team Deatmatch. public bool? Crpg_team_balance_once { get; set; } // Sets if the team balancer should balance only after warmup. public TimeSpan? Crpg_happy_hours { get; set; } // Sets the happy hours. Format: HH:MM-HH:MM,TZ + public float? Crpg_happy_hours_experience_multiplier { get; set; } // Sets the happy hours experience multipliers. public bool? Crpg_apply_harmony_patches { get; set; } // Apply Harmony patches } diff --git a/src/Module.Server/Common/CrpgServerConfiguration.cs b/src/Module.Server/Common/CrpgServerConfiguration.cs index c7209deec..d03fe3eaf 100644 --- a/src/Module.Server/Common/CrpgServerConfiguration.cs +++ b/src/Module.Server/Common/CrpgServerConfiguration.cs @@ -33,6 +33,7 @@ public static void Init() public static int ControlledBotsCount { get; private set; } = 0; public static int BaseNakedEquipmentValue { get; private set; } = 10000; public static Tuple? HappyHours { get; private set; } + public static float HappyHoursExperienceMultiplier { get; private set; } = 0.5f; [UsedImplicitly] [ConsoleCommandMethod("crpg_team_balancer_clan_group_size_penalty", "Apply a rating increase to members of the same clan that are playing in the same team")] @@ -166,6 +167,23 @@ private static void SetHappyHours(string? happHoursStr) Debug.Print($"Set happy hours from {startTime} to {endTime} in time zone {timeZone.Id}"); } + [UsedImplicitly] + [ConsoleCommandMethod("crpg_happy_hours_experience_multiplier", "Sets the happy hours experience multiplier. Range: 0f - 2f")] + private static void SetHappyHoursExperienceMultiplier(string? happyMultiplierStr) + { + if (happyMultiplierStr == null + || !float.TryParse(happyMultiplierStr, out float happyMultiplier) + || happyMultiplier < 0f + || happyMultiplier > 2f) + { + Debug.Print($"Invalid happy hours experience multiplier: {happyMultiplierStr}"); + return; + } + + HappyHoursExperienceMultiplier = happyMultiplier; + Debug.Print($"Set happy hours experience multiplier to {happyMultiplier}"); + } + [UsedImplicitly] [ConsoleCommandMethod("crpg_apply_harmony_patches", "Apply Harmony patches")] private static void ApplyHarmonyPatches() diff --git a/src/Module.Server/ModuleData/Languages/CNs/std_module_strings_xml-zho-CN.xml b/src/Module.Server/ModuleData/Languages/CNs/std_module_strings_xml-zho-CN.xml index cce6b220d..1962c0a05 100644 --- a/src/Module.Server/ModuleData/Languages/CNs/std_module_strings_xml-zho-CN.xml +++ b/src/Module.Server/ModuleData/Languages/CNs/std_module_strings_xml-zho-CN.xml @@ -51,7 +51,7 @@ - + diff --git a/src/Module.Server/ModuleData/Languages/RU/std_module_strings_xml-rus.xml b/src/Module.Server/ModuleData/Languages/RU/std_module_strings_xml-rus.xml index 46745dea6..4e458871c 100644 --- a/src/Module.Server/ModuleData/Languages/RU/std_module_strings_xml-rus.xml +++ b/src/Module.Server/ModuleData/Languages/RU/std_module_strings_xml-rus.xml @@ -51,7 +51,7 @@ - + diff --git a/src/Module.Server/Rewards/CrpgRewardClient.cs b/src/Module.Server/Rewards/CrpgRewardClient.cs index 5e09df04b..a2e8a0bc4 100644 --- a/src/Module.Server/Rewards/CrpgRewardClient.cs +++ b/src/Module.Server/Rewards/CrpgRewardClient.cs @@ -138,7 +138,10 @@ private void HandleRewardError(CrpgRewardError message) private void HandleRewardHappyHour(CrpgRewardHappyHour message) { var textObject = message.Started - ? new TextObject("{=TWpiAeFe}It's happy hours time! Experience gain is increased by 50%.") + ? new TextObject("{=TWpiAeFe}It's happy hours time! Experience gain is increased by {XPMULTIPLIER}.", new Dictionary + { + ["XPMULTIPLIER"] = $"{message.ExpMultiplier * 100:F0}%", + }) : new TextObject("{=KoqNpPLa}Happy hours ended!"); InformationManager.AddSystemNotification(textObject.ToString()); } diff --git a/src/Module.Server/Rewards/CrpgRewardHappyHour.cs b/src/Module.Server/Rewards/CrpgRewardHappyHour.cs index a38f30203..e9e60d1b8 100644 --- a/src/Module.Server/Rewards/CrpgRewardHappyHour.cs +++ b/src/Module.Server/Rewards/CrpgRewardHappyHour.cs @@ -7,16 +7,19 @@ namespace Crpg.Module.Rewards; internal sealed class CrpgRewardHappyHour : GameNetworkMessage { public bool Started { get; set; } + public float ExpMultiplier { get; set; } protected override void OnWrite() { WriteBoolToPacket(Started); + WriteFloatToPacket(ExpMultiplier, new CompressionInfo.Float(0f, 2f, 8)); } protected override bool OnRead() { bool bufferReadValid = true; Started = ReadBoolFromPacket(ref bufferReadValid); + ExpMultiplier = ReadFloatFromPacket(new CompressionInfo.Float(0f, 2f, 8), ref bufferReadValid); return bufferReadValid; } @@ -27,6 +30,6 @@ protected override MultiplayerMessageFilter OnGetLogFilter() protected override string OnGetLogFormat() { - return nameof(CrpgRewardHappyHour); + return $"{nameof(CrpgRewardHappyHour)}: Started={Started}, ExpMultiplier={ExpMultiplier}"; } } diff --git a/src/Module.Server/Rewards/CrpgRewardServer.cs b/src/Module.Server/Rewards/CrpgRewardServer.cs index 5270ac694..1fb46306c 100644 --- a/src/Module.Server/Rewards/CrpgRewardServer.cs +++ b/src/Module.Server/Rewards/CrpgRewardServer.cs @@ -518,7 +518,7 @@ private void SetRewardForConnectedPlayer( int? constantMultiplier) { float serverXpMultiplier = CrpgServerConfiguration.ServerExperienceMultiplier; - serverXpMultiplier *= IsHappyHour() ? 1.5f : 1f; + serverXpMultiplier *= (IsHappyHour() ? CrpgServerConfiguration.HappyHoursExperienceMultiplier : 0f) + 1f; userUpdate.Reward = new CrpgUserReward { Experience = (int)(serverXpMultiplier * durationRewarded * (_constants.BaseExperienceGainPerSecond @@ -562,7 +562,7 @@ private bool IsHappyHour() if (_lastRewardDuringHappyHours) { GameNetwork.BeginBroadcastModuleEvent(); - GameNetwork.WriteMessage(new CrpgRewardHappyHour { Started = false }); + GameNetwork.WriteMessage(new CrpgRewardHappyHour { Started = false, ExpMultiplier = CrpgServerConfiguration.HappyHoursExperienceMultiplier }); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None); } @@ -573,7 +573,7 @@ private bool IsHappyHour() if (!_lastRewardDuringHappyHours) { GameNetwork.BeginBroadcastModuleEvent(); - GameNetwork.WriteMessage(new CrpgRewardHappyHour { Started = true }); + GameNetwork.WriteMessage(new CrpgRewardHappyHour { Started = true, ExpMultiplier = CrpgServerConfiguration.HappyHoursExperienceMultiplier }); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None); }