Changed config files to their own name;

DrinkHealthPotion.cs configurable;
Cleanup
This commit is contained in:
Lucca Faria Ferri 2023-02-06 04:08:12 -08:00
parent f54f91cfad
commit d670871a4f
20 changed files with 171 additions and 150 deletions

View File

@ -1,15 +1,22 @@
//Blizzless Project 2022 //Blizzless Project 2022
using System;
using DiIiS_NA.Core.Logging;
using Nini.Config; using Nini.Config;
namespace DiIiS_NA.Core.Config namespace DiIiS_NA.Core.Config
{ {
public class Config public class Config
{ {
private readonly Logger _logger;
private readonly string _sectionName;
private readonly IConfig _section; private readonly IConfig _section;
public Config(string sectionName) protected Config(string sectionName)
{ {
this._section = ConfigurationManager.Section(sectionName) ?? ConfigurationManager.AddSection(sectionName); _sectionName = sectionName;
_logger = LogManager.CreateLogger($"{GetType().Name}:{sectionName}");
_section = ConfigurationManager.Section(sectionName) ?? ConfigurationManager.AddSection(sectionName);
} }
public void Save() public void Save()
@ -17,14 +24,14 @@ namespace DiIiS_NA.Core.Config
ConfigurationManager.Save(); ConfigurationManager.Save();
} }
protected bool GetBoolean(string key, bool defaultValue) { return this._section.GetBoolean(key, defaultValue); } protected bool GetBoolean(string key, bool defaultValue) => _section.GetBoolean(key, defaultValue);
protected double GetDouble(string key, double defaultValue) { return this._section.GetDouble(key, defaultValue); } protected double GetDouble(string key, double defaultValue) => _section.GetDouble(key, defaultValue);
protected float GetFloat(string key, float defaultValue) { return this._section.GetFloat(key, defaultValue); } protected float GetFloat(string key, float defaultValue) => _section.GetFloat(key, defaultValue);
protected int GetInt(string key, int defaultValue) { return this._section.GetInt(key, defaultValue); } protected int GetInt(string key, int defaultValue) => _section.GetInt(key, defaultValue);
protected int GetInt(string key, int defaultValue, bool fromAlias) { return this._section.GetInt(key, defaultValue, fromAlias); } protected int GetInt(string key, int defaultValue, bool fromAlias) => _section.GetInt(key, defaultValue, fromAlias);
protected long GetLong(string key, long defaultValue) { return this._section.GetLong(key, defaultValue); } protected long GetLong(string key, long defaultValue) => _section.GetLong(key, defaultValue);
protected string GetString(string key, string defaultValue) { return this._section.Get(key, defaultValue); } protected string GetString(string key, string defaultValue) { return _section.Get(key, defaultValue); }
protected string[] GetEntryKeys() { return this._section.GetKeys(); } protected string[] GetEntryKeys() { return _section.GetKeys(); }
protected void Set(string key, object value) { this._section.Set(key, value); } protected void Set(string key, object value) { _section.Set(key, value); }
} }
} }

View File

@ -17,7 +17,7 @@ namespace DiIiS_NA.Core.Config
{ {
try try
{ {
ConfigFile = string.Format("{0}/{1}", FileHelpers.AssemblyRoot, "config.ini"); // the config file's location. ConfigFile = $"{FileHelpers.AssemblyRoot}/{"config.ini"}"; // the config file's location.
Parser = new IniConfigSource(ConfigFile); // see if the file exists by trying to parse it. Parser = new IniConfigSource(ConfigFile); // see if the file exists by trying to parse it.
_fileExists = true; _fileExists = true;
} }
@ -30,28 +30,28 @@ namespace DiIiS_NA.Core.Config
finally finally
{ {
// adds aliases so we can use On and Off directives in ini files. // adds aliases so we can use On and Off directives in ini files.
Parser.Alias.AddAlias("On", true); Parser!.Alias.AddAlias("On", true);
Parser.Alias.AddAlias("Off", false); Parser!.Alias.AddAlias("Off", false);
// logger level aliases. // logger level aliases.
Parser.Alias.AddAlias("MinimumLevel", Logger.Level.Trace); Parser!.Alias.AddAlias("MinimumLevel", Logger.Level.Trace);
Parser.Alias.AddAlias("MaximumLevel", Logger.Level.Trace); Parser!.Alias.AddAlias("MaximumLevel", Logger.Level.Trace);
} }
Parser.ExpandKeyValues(); Parser.ExpandKeyValues();
} }
static internal IConfig Section(string section) // Returns the asked config section. internal static IConfig Section(string section) // Returns the asked config section.
{ {
return Parser.Configs[section]; return Parser.Configs[section];
} }
static internal IConfig AddSection(string section) // Adds a config section. internal static IConfig AddSection(string section) // Adds a config section.
{ {
return Parser.AddConfig(section); return Parser.AddConfig(section);
} }
static internal void Save() // Saves the settings. internal static void Save() // Saves the settings.
{ {
if (_fileExists) Parser.Save(); if (_fileExists) Parser.Save();
else else

View File

@ -5,11 +5,11 @@ namespace DiIiS_NA.Core.Logging
{ {
public string LoggingRoot public string LoggingRoot
{ {
get { return this.GetString("Root", @"logs"); } get => GetString("Root", @"logs");
set { this.Set("Root", value); } set => Set("Root", value);
} }
public LogTargetConfig[] Targets = new[] public LogTargetConfig[] Targets { get; } = new[]
{ {
new LogTargetConfig("ConsoleLog"), new LogTargetConfig("ConsoleLog"),
new LogTargetConfig("AnsiLog"), new LogTargetConfig("AnsiLog"),
@ -20,57 +20,55 @@ namespace DiIiS_NA.Core.Logging
}; };
private LogConfig() : private LogConfig() :
base("Logging") base(nameof(Logging))
{ } { }
public static LogConfig Instance { get { return _instance; } } public static LogConfig Instance = new();
private static readonly LogConfig _instance = new LogConfig();
} }
public class LogTargetConfig : Config.Config public class LogTargetConfig : Config.Config
{ {
public bool Enabled public bool Enabled
{ {
get { return this.GetBoolean("Enabled", true); } get => GetBoolean(nameof(Enabled), true);
set { this.Set("Enabled", value); } set => Set(nameof(Enabled), value);
} }
public string Target public string Target
{ {
get { return this.GetString("Target", "Console"); } get => GetString(nameof(Target), "Console");
set { this.GetString("Target", value); } set => GetString(nameof(Target), value);
} }
public bool IncludeTimeStamps public bool IncludeTimeStamps
{ {
get { return this.GetBoolean("IncludeTimeStamps", false); } get => GetBoolean(nameof(IncludeTimeStamps), false);
set { this.Set("IncludeTimeStamps", value); } set => Set(nameof(IncludeTimeStamps), value);
} }
public string FileName public string FileName
{ {
get { return this.GetString("FileName", ""); } get => GetString(nameof(FileName), "");
set { this.GetString("FileName", value); } set => GetString(nameof(FileName), value);
} }
public Logger.Level MinimumLevel public Logger.Level MinimumLevel
{ {
get { return (Logger.Level)(this.GetInt("MinimumLevel", (int)Logger.Level.Info, true)); } get => (Logger.Level)(GetInt(nameof(MinimumLevel), (int)Logger.Level.Info, true));
set { this.Set("MinimumLevel", (int)value); } set => Set(nameof(MinimumLevel), (int)value);
} }
public Logger.Level MaximumLevel public Logger.Level MaximumLevel
{ {
get { return (Logger.Level)(this.GetInt("MaximumLevel", (int)Logger.Level.Fatal, true)); } get => (Logger.Level)(GetInt(nameof(MaximumLevel), (int)Logger.Level.Fatal, true));
set { this.Set("MaximumLevel", (int)value); } set => Set(nameof(MaximumLevel), (int)value);
} }
public bool ResetOnStartup public bool ResetOnStartup
{ {
get { return this.GetBoolean("ResetOnStartup", false); } get => GetBoolean(nameof(ResetOnStartup), false);
set { this.Set("ResetOnStartup", value); } set => Set(nameof(ResetOnStartup), value);
} }
public LogTargetConfig(string loggerName) public LogTargetConfig(string loggerName) : base(loggerName) { }
: base(loggerName) { }
} }
} }

View File

@ -133,7 +133,7 @@ namespace DiIiS_NA.GameServer.CommandManager
if (line == string.Empty) if (line == string.Empty)
return false; return false;
if (line[0] != Config.Instance.CommandPrefix) // if line does not start with command-prefix if (line[0] != CommandsConfig.Instance.CommandPrefix) // if line does not start with command-prefix
return false; return false;
line = line.Substring(1); // advance to actual command. line = line.Substring(1); // advance to actual command.
@ -153,9 +153,9 @@ namespace DiIiS_NA.GameServer.CommandManager
output = output =
invokerClient != null invokerClient != null
? CommandGroups.Where(pair => pair.Key.MinUserLevel > invokerClient?.Account.UserLevel) ? CommandGroups.Where(pair => pair.Key.MinUserLevel > invokerClient?.Account.UserLevel)
.Aggregate(output, (current, pair) => current + ($"{Config.Instance.CommandPrefix}{pair.Key.Name}: {pair.Key.Help}\n\n")) .Aggregate(output, (current, pair) => current + ($"{CommandsConfig.Instance.CommandPrefix}{pair.Key.Name}: {pair.Key.Help}\n\n"))
: CommandGroups : CommandGroups
.Aggregate(output, (current, pair) => current + (($"$[underline green]${Config.Instance.CommandPrefix}{pair.Key.Name}$[/]$: {pair.Key.Help}\n\n"))); .Aggregate(output, (current, pair) => current + (($"$[underline green]${CommandsConfig.Instance.CommandPrefix}{pair.Key.Name}$[/]$: {pair.Key.Help}\n\n")));
return output + "Type 'help <command>' to get help about a specific command."; return output + "Type 'help <command>' to get help about a specific command.";
} }

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiIiS_NA.GameServer.CommandManager
{
public sealed class CommandsConfig : DiIiS_NA.Core.Config.Config
{
public char CommandPrefix
{
get => GetString(nameof(CommandPrefix), "!")[0];
set => Set(nameof(CommandPrefix), value);
}
public static CommandsConfig Instance = new();
private CommandsConfig() : base("Commands") { }
}
}

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiIiS_NA.GameServer.CommandManager
{
public sealed class Config : DiIiS_NA.Core.Config.Config
{
public char CommandPrefix { get { return GetString("CommandPrefix", "!")[0]; } set { Set("CommandPrefix", value); } }
private static readonly Config _instance = new Config();
public static Config Instance { get { return _instance; } }
private Config() : base("Commands") { }
}
}

View File

@ -78,9 +78,9 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
//this.Attributes[GameAttribute.Immune_To_Charm] = true; //this.Attributes[GameAttribute.Immune_To_Charm] = true;
Attributes[GameAttribute.using_Bossbar] = true; Attributes[GameAttribute.using_Bossbar] = true;
Attributes[GameAttribute.InBossEncounter] = true; Attributes[GameAttribute.InBossEncounter] = true;
Attributes[GameAttribute.Hitpoints_Max] *= Config.Instance.BossHealthMultiplier; Attributes[GameAttribute.Hitpoints_Max] *= GameServerConfig.Instance.BossHealthMultiplier;
Attributes[GameAttribute.Damage_Weapon_Min, 0] *= Config.Instance.BossDamageMultiplier; Attributes[GameAttribute.Damage_Weapon_Min, 0] *= GameServerConfig.Instance.BossDamageMultiplier;
Attributes[GameAttribute.Damage_Weapon_Delta, 0] *= Config.Instance.BossDamageMultiplier; Attributes[GameAttribute.Damage_Weapon_Delta, 0] *= GameServerConfig.Instance.BossDamageMultiplier;
Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total]; Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total];
Attributes[GameAttribute.TeamID] = 10; Attributes[GameAttribute.TeamID] = 10;

View File

@ -97,26 +97,26 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
Attributes[GameAttribute.Hitpoints_Max] = (int)((int)monsterLevels.MonsterLevel[monsterLevel].HPMin + DiIiS_NA.Core.Helpers.Math.RandomHelper.Next(0, (int)monsterLevels.MonsterLevel[monsterLevel].HPDelta) * HpMultiplier * World.Game.HpModifier); Attributes[GameAttribute.Hitpoints_Max] = (int)((int)monsterLevels.MonsterLevel[monsterLevel].HPMin + DiIiS_NA.Core.Helpers.Math.RandomHelper.Next(0, (int)monsterLevels.MonsterLevel[monsterLevel].HPDelta) * HpMultiplier * World.Game.HpModifier);
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = ((int)World.Game.ConnectedPlayers.Length + 1) * 1.5f; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = ((int)World.Game.ConnectedPlayers.Length + 1) * 1.5f;
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] *= Config.Instance.RateMonsterHP; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] *= GameServerConfig.Instance.RateMonsterHP;
if (World.Game.ConnectedPlayers.Length > 1) if (World.Game.ConnectedPlayers.Length > 1)
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// / 2f; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// / 2f;
var hpMax = Attributes[GameAttribute.Hitpoints_Max]; var hpMax = Attributes[GameAttribute.Hitpoints_Max];
var hpTotal = Attributes[GameAttribute.Hitpoints_Max_Total]; var hpTotal = Attributes[GameAttribute.Hitpoints_Max_Total];
float damageMin = monsterLevels.MonsterLevel[World.Game.MonsterLevel].Dmg * DmgMultiplier;// * 0.5f; float damageMin = monsterLevels.MonsterLevel[World.Game.MonsterLevel].Dmg * DmgMultiplier;// * 0.5f;
float damageDelta = damageMin; float damageDelta = damageMin;
Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG; Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * GameServerConfig.Instance.RateMonsterDMG;
Attributes[GameAttribute.Damage_Weapon_Delta, 0] = damageDelta; Attributes[GameAttribute.Damage_Weapon_Delta, 0] = damageDelta;
if (monsterLevel > 30) if (monsterLevel > 30)
{ {
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// * 0.5f; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// * 0.5f;
Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG;// * 0.2f; Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * GameServerConfig.Instance.RateMonsterDMG;// * 0.2f;
Attributes[GameAttribute.Damage_Weapon_Delta, 0] = damageDelta; Attributes[GameAttribute.Damage_Weapon_Delta, 0] = damageDelta;
} }
if (monsterLevel > 60) if (monsterLevel > 60)
{ {
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// * 0.7f; Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// * 0.7f;
Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * Config.Instance.RateMonsterDMG;// * 0.15f; Attributes[GameAttribute.Damage_Weapon_Min, 0] = damageMin * World.Game.DmgModifier * GameServerConfig.Instance.RateMonsterDMG;// * 0.15f;
//this.Attributes[GameAttribute.Damage_Weapon_Delta, 0] = DamageDelta * 0.5f; //this.Attributes[GameAttribute.Damage_Weapon_Delta, 0] = DamageDelta * 0.5f;
} }

View File

@ -71,8 +71,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
{ {
Logger.Info("GameServer connected to BattleNet."); Logger.Info("GameServer connected to BattleNet.");
System.Threading.Thread.Sleep(3000); System.Threading.Thread.Sleep(3000);
string backEndIp = Config.Instance.BindIP; string backEndIp = GameServerConfig.Instance.BindIP;
int backEndPort = Config.Instance.Port; int backEndPort = GameServerConfig.Instance.Port;
bool pvp = false; bool pvp = false;
if (!pvp) if (!pvp)
RegisterGameServer(backEndIp, backEndPort); RegisterGameServer(backEndIp, backEndPort);

View File

@ -194,13 +194,16 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
if (!Game.Empty) if (!Game.Empty)
{ {
SaveQuestProgress(true); SaveQuestProgress(true);
Logger.Trace($"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/]$, completed $[underline white]${Quests[Game.CurrentQuest].Completed}$[/]$"); Logger.Trace(
$"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/]$, completed $[underline white]${Quests[Game.CurrentQuest].Completed}$[/]$");
Game.BroadcastPlayers((client, player) => Game.BroadcastPlayers((client, player) =>
{ {
if (Game.CurrentQuest == 312429) return; // open world quest if (Game.CurrentQuest == 312429) return; // open world quest
int xpReward = (int)(Quests[Game.CurrentQuest].RewardXp * Game.XpModifier); int xpReward = (int)(Quests[Game.CurrentQuest].RewardXp *
int goldReward = (int)(Quests[Game.CurrentQuest].RewardGold * Game.GoldModifier); Game.XpModifier);
int goldReward = (int)(Quests[Game.CurrentQuest].RewardGold *
Game.GoldModifier);
player.InGameClient.SendMessage(new QuestStepCompleteMessage() player.InGameClient.SendMessage(new QuestStepCompleteMessage()
{ {
QuestStepComplete = QuestStepComplete.CreateBuilder() QuestStepComplete = QuestStepComplete.CreateBuilder()
@ -213,7 +216,9 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
.SetIsQuestComplete(true) .SetIsQuestComplete(true)
.Build() .Build()
}); });
player.InGameClient.SendMessage(new GameServer.MessageSystem.Message.Definitions.Base.FloatingAmountMessage() player.InGameClient.SendMessage(
new GameServer.MessageSystem.Message.Definitions.Base.
FloatingAmountMessage()
{ {
Place = new WorldPlace() Place = new WorldPlace()
{ {
@ -222,9 +227,12 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
}, },
Amount = xpReward, Amount = xpReward,
Type = GameServer.MessageSystem.Message.Definitions.Base.FloatingAmountMessage.FloatType.Experience, Type = GameServer.MessageSystem.Message.Definitions.Base
.FloatingAmountMessage.FloatType.Experience,
}); });
player.InGameClient.SendMessage(new GameServer.MessageSystem.Message.Definitions.Base.FloatingAmountMessage() player.InGameClient.SendMessage(
new GameServer.MessageSystem.Message.Definitions.Base.
FloatingAmountMessage()
{ {
Place = new WorldPlace() Place = new WorldPlace()
{ {
@ -233,7 +241,8 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
}, },
Amount = goldReward, Amount = goldReward,
Type = GameServer.MessageSystem.Message.Definitions.Base.FloatingAmountMessage.FloatType.Gold, Type = GameServer.MessageSystem.Message.Definitions.Base
.FloatingAmountMessage.FloatType.Gold,
}); });
player.UpdateExp(xpReward); player.UpdateExp(xpReward);
player.Inventory.AddGoldAmount(goldReward); player.Inventory.AddGoldAmount(goldReward);
@ -253,6 +262,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
{ {
Logger.WarnException(e, "Advance() exception caught:"); Logger.WarnException(e, "Advance() exception caught:");
} }
//Пока только для одного квеста //Пока только для одного квеста
// if (this.Game.CurrentQuest != 72221) // if (this.Game.CurrentQuest != 72221)
// if (this.Game.CurrentStep != -1) // if (this.Game.CurrentStep != -1)
@ -262,12 +272,15 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
if (!Game.Empty) if (!Game.Empty)
{ {
RevealQuestProgress(); RevealQuestProgress();
if ((Game.CurrentActEnum != ActEnum.OpenWorld && Config.Instance.AutoSaveQuests) || Quests[Game.CurrentQuest].Steps[Game.CurrentStep].Saveable) if ((Game.CurrentActEnum != ActEnum.OpenWorld && GameServerConfig.Instance.AutoSaveQuests) ||
Quests[Game.CurrentQuest].Steps[Game.CurrentStep].Saveable)
SaveQuestProgress(false); SaveQuestProgress(false);
} }
OnQuestProgress(); OnQuestProgress();
AutoSetQuestMarker(); AutoSetQuestMarker();
Logger.Trace($"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/]$, step $[underline white]${Game.CurrentStep}$[/]$"); Logger.Trace(
$"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/]$, step $[underline white]${Game.CurrentStep}$[/]$");
} }
public void SideAdvance() public void SideAdvance()

View File

@ -104,11 +104,11 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
//445736 - p4_forest_snow_icecave_01 //445736 - p4_forest_snow_icecave_01
if (world.worldData.DynamicWorld && !worldSNO.IsNotDynamicWorld()) //Gardens of Hope - 2 lvl is NOT random if (world.worldData.DynamicWorld && !worldSNO.IsNotDynamicWorld()) //Gardens of Hope - 2 lvl is NOT random
{ {
if (!Config.Instance.DRLGemu) if (!GameServerConfig.Instance.DRLGemu)
Logger.Warn("DRLG-Emu is Disabled."); Logger.Warn("DRLG-Emu is Disabled.");
string DRLGVersion = "1.8"; string DRLGVersion = "1.8";
var WorldContainer = DBSessions.WorldSession.Query<DRLG_Container>().Where(dbt => dbt.WorldSNO == (int)worldSNO).ToList(); var WorldContainer = DBSessions.WorldSession.Query<DRLG_Container>().Where(dbt => dbt.WorldSNO == (int)worldSNO).ToList();
if (WorldContainer.Count > 0 && worldSNO != WorldSno.a1trdun_level05_templar && Config.Instance.DRLGemu) if (WorldContainer.Count > 0 && worldSNO != WorldSno.a1trdun_level05_templar && GameServerConfig.Instance.DRLGemu)
{ {
DRLGEmuActive = true; DRLGEmuActive = true;
Logger.Warn("World - {0} [{1}] is dynamic! Found container, DRLG-Emu v{2} Activated!", worldAsset.Name, worldAsset.SNOId, DRLGVersion); Logger.Warn("World - {0} [{1}] is dynamic! Found container, DRLG-Emu v{2} Activated!", worldAsset.Name, worldAsset.SNOId, DRLGVersion);

View File

@ -1353,15 +1353,15 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
/// <summary> /// <summary>
/// Randomly sets unidentified flag on item. /// Randomly sets unidentified flag on item.
/// If the item is unique, legendary, special or set, it will have <see cref="Config.ChanceHighQualityUnidentified"/>% chance to be unidentified. /// If the item is unique, legendary, special or set, it will have <see cref="GameServerConfig.ChanceHighQualityUnidentified"/>% chance to be unidentified.
/// Otherwise, it will have <see cref="Config.ChanceNormalUnidentified"/>% chance to be unidentified. /// Otherwise, it will have <see cref="GameServerConfig.ChanceNormalUnidentified"/>% chance to be unidentified.
/// </summary> /// </summary>
/// <param name="item">The item to set the flag</param> /// <param name="item">The item to set the flag</param>
private static void RandomSetUnidentified(Item item) => item.Unidentified = private static void RandomSetUnidentified(Item item) => item.Unidentified =
FastRandom.Instance.Chance(item.Name.Contains("unique", StringComparison.InvariantCultureIgnoreCase) FastRandom.Instance.Chance(item.Name.Contains("unique", StringComparison.InvariantCultureIgnoreCase)
|| item.ItemDefinition.Quality is ItemTable.ItemQuality.Legendary or ItemTable.ItemQuality.Special or ItemTable.ItemQuality.Set || item.ItemDefinition.Quality is ItemTable.ItemQuality.Legendary or ItemTable.ItemQuality.Special or ItemTable.ItemQuality.Set
? Config.Instance.ChanceHighQualityUnidentified ? GameServerConfig.Instance.ChanceHighQualityUnidentified
: Config.Instance.ChanceNormalUnidentified); : GameServerConfig.Instance.ChanceNormalUnidentified);
// Allows cooking a custom item. // Allows cooking a custom item.
public static Item Cook(Player player, string name) public static Item Cook(Player player, string name)

View File

@ -613,16 +613,16 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
switch (MonsterQuality) switch (MonsterQuality)
{ {
case 0: //Normal case 0: //Normal
return new List<float> { 0.18f * Config.Instance.RateChangeDrop }; return new List<float> { 0.18f * GameServerConfig.Instance.RateChangeDrop };
case 1: //Champion case 1: //Champion
return new List<float> { 1f, 1f, 1f, 1f, 0.75f * Config.Instance.RateChangeDrop }; return new List<float> { 1f, 1f, 1f, 1f, 0.75f * GameServerConfig.Instance.RateChangeDrop };
case 2: //Rare (Elite) case 2: //Rare (Elite)
case 4: //Unique case 4: //Unique
return new List<float> { 1f, 1f, 1f, 1f, 1f }; return new List<float> { 1f, 1f, 1f, 1f, 1f };
case 7: //Boss case 7: //Boss
return new List<float> { 1f, 1f, 1f, 1f, 1f, 0.75f * Config.Instance.RateChangeDrop, 0.4f * Config.Instance.RateChangeDrop }; return new List<float> { 1f, 1f, 1f, 1f, 1f, 0.75f * GameServerConfig.Instance.RateChangeDrop, 0.4f * GameServerConfig.Instance.RateChangeDrop };
default: default:
return new List<float> { 0.12f * Config.Instance.RateChangeDrop }; return new List<float> { 0.12f * GameServerConfig.Instance.RateChangeDrop };
} }
} }

View File

@ -934,7 +934,7 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
/// <param name="position">The position for drop.</param> /// <param name="position">The position for drop.</param>
public void SpawnGold(Actor source, Player player, int Min = -1) public void SpawnGold(Actor source, Player player, int Min = -1)
{ {
int amount = (int)(LootManager.GetGoldAmount(player.Attributes[GameAttribute.Level]) * Game.GoldModifier * Config.Instance.RateMoney); int amount = (int)(LootManager.GetGoldAmount(player.Attributes[GameAttribute.Level]) * Game.GoldModifier * GameServerConfig.Instance.RateMoney);
if (Min != -1) if (Min != -1)
amount += Min; amount += Min;
var item = ItemGenerator.CreateGold(player, amount); // somehow the actual ammount is not shown on ground /raist. var item = ItemGenerator.CreateGold(player, amount); // somehow the actual ammount is not shown on ground /raist.

View File

@ -2740,7 +2740,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
} }
} }
// Reset resurrection charges on zone change - TODO: do not reset charges on reentering the same zone // Reset resurrection charges on zone change - TODO: do not reset charges on reentering the same zone
Attributes[GameAttribute.Corpse_Resurrection_Charges] = Config.Instance.ResurrectionCharges; Attributes[GameAttribute.Corpse_Resurrection_Charges] = GameServerConfig.Instance.ResurrectionCharges;
#if DEBUG #if DEBUG
Logger.Warn($"Player Location {Toon.Name}, Scene: {CurrentScene.SceneSNO.Name} SNO: {CurrentScene.SceneSNO.Id} LevelArea: {CurrentScene.Specification.SNOLevelAreas[0]}"); Logger.Warn($"Player Location {Toon.Name}, Scene: {CurrentScene.SceneSNO.Name} SNO: {CurrentScene.SceneSNO.Id} LevelArea: {CurrentScene.Specification.SNOLevelAreas[0]}");

View File

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using DiIiS_NA.GameServer.GSSystem.PlayerSystem; using DiIiS_NA.GameServer.GSSystem.PlayerSystem;
using DiIiS_NA.GameServer.GSSystem.TickerSystem; using DiIiS_NA.GameServer.GSSystem.TickerSystem;
using DiIiS_NA.LoginServer;
namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations.General namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations.General
{ {
@ -10,13 +11,9 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations.General
{ {
public override IEnumerable<TickTimer> Run() public override IEnumerable<TickTimer> Run()
{ {
if (User is Player player) if (User is not Player player) yield break;
{ player.AddPercentageHP(GameServerConfig.Instance.HealthPotionRestorePercentage);
player.AddPercentageHP(60); AddBuff(player, player, new CooldownBuff(30211, TickTimer.WaitSeconds(player.World.Game, GameServerConfig.Instance.HealthPotionCooldown)));
AddBuff(player, player, new CooldownBuff(30211, TickTimer.WaitSeconds(player.World.Game, 30f)));
}
yield break;
} }
} }
} }

View File

@ -403,7 +403,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
{ {
grantedExp = (int)(grantedExp * plr.World.Game.XpModifier); grantedExp = (int)(grantedExp * plr.World.Game.XpModifier);
float tempExp = grantedExp * Config.Instance.RateExp; float tempExp = grantedExp * GameServerConfig.Instance.RateExp;
plr.UpdateExp(Math.Max((int)tempExp, 1)); plr.UpdateExp(Math.Max((int)tempExp, 1));
var a = (int)plr.Attributes[GameAttribute.Experience_Bonus]; var a = (int)plr.Attributes[GameAttribute.Experience_Bonus];
@ -597,7 +597,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
//Nephalem Rift //Nephalem Rift
if ((Target.CurrentScene.Specification.SNOLevelAreas[0] is 332339 or 288482) && Target.World.Game.ActiveNephalemTimer && Target.World.Game.ActiveNephalemKilledMobs == false) if ((Target.CurrentScene.Specification.SNOLevelAreas[0] is 332339 or 288482) && Target.World.Game.ActiveNephalemTimer && Target.World.Game.ActiveNephalemKilledMobs == false)
{ {
Target.World.Game.ActiveNephalemProgress += Config.Instance.NephalemRiftProgressMultiplier * (Target.Quality + 1); Target.World.Game.ActiveNephalemProgress += GameServerConfig.Instance.NephalemRiftProgressMultiplier * (Target.Quality + 1);
Player master = null; Player master = null;
foreach (var plr in Target.World.Game.Players.Values) foreach (var plr in Target.World.Game.Players.Values)
{ {
@ -878,7 +878,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
// if seed is less than the drop rate, drop the item // if seed is less than the drop rate, drop the item
if (seed < rate * (1f if (seed < rate * (1f
+ plr.Attributes[GameAttribute.Magic_Find]) + plr.Attributes[GameAttribute.Magic_Find])
* Config.Instance.RateDrop) * GameServerConfig.Instance.RateDrop)
{ {
//Logger.Debug("rate: {0}", rate); //Logger.Debug("rate: {0}", rate);
var lootQuality = Target.World.Game.IsHardcore var lootQuality = Target.World.Game.IsHardcore

View File

@ -64,7 +64,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
catch (Exception ex) catch (Exception ex)
{ {
#if DEBUG #if DEBUG
Logger.Error(ex.Message, "GetActionAnimationSNO: Please don't take this error seriously, it's just a workaround for a bug in the game."); Logger.ErrorException(ex, "GetActionAnimationSNO throws error");
#endif #endif
return AnimationSno._NONE; return AnimationSno._NONE;
} }
@ -78,32 +78,18 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
} }
public virtual float GetActionSpeed() public virtual float GetActionSpeed() => EvalTag(PowerKeys.AttackSpeed);
{
return EvalTag(PowerKeys.AttackSpeed);
}
public virtual int GetCastEffectSNO() public virtual int GetCastEffectSNO() => EvalTag(IsUserFemale ? PowerKeys.CastingEffectGroup_Female : PowerKeys.CastingEffectGroup_Male);
{
return EvalTag(IsUserFemale ? PowerKeys.CastingEffectGroup_Female : PowerKeys.CastingEffectGroup_Male);
}
public virtual int GetContactEffectSNO() public virtual int GetContactEffectSNO() => EvalTag(IsUserFemale ? PowerKeys.ContactFrameEffectGroup_Female : PowerKeys.ContactFrameEffectGroup_Male);
{
return EvalTag(IsUserFemale ? PowerKeys.ContactFrameEffectGroup_Female : PowerKeys.ContactFrameEffectGroup_Male);
}
public virtual float GetContactDelay() public virtual float GetContactDelay() => 0f;
{
return 0f;
}
public float GetCooldown() public float GetCooldown()
{ {
if (EvalTag(PowerKeys.CooldownTime) > 0f) var tag = EvalTag(PowerKeys.CooldownTime);
return EvalTag(PowerKeys.CooldownTime); return tag > 0f ? tag : 1f;
else
return 1f;
} }
private void PlayActionAnimation() private void PlayActionAnimation()
@ -112,10 +98,10 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
var animationSNO = GetActionAnimationSNO(); var animationSNO = GetActionAnimationSNO();
#region Патч анимаций #region Патч анимаций
if(animationSNO == AnimationSno._NONE) if(animationSNO == AnimationSno._NONE)
switch (this.User.SNO) switch (User.SNO)
{ {
case ActorSno._x1_skeletonarcher_westmarch_a: //x1_SkeletonArcher_Westmarch_A case ActorSno._x1_skeletonarcher_westmarch_a: //x1_SkeletonArcher_Westmarch_A
if (this.PowerSNO == 30334) if (PowerSNO == 30334)
animationSNO = AnimationSno.x1_skeletonarcher_westmarch_attack_01; animationSNO = AnimationSno.x1_skeletonarcher_westmarch_attack_01;
break; break;
case ActorSno._p6_necro_skeletonmage_f_archer: //p6_necro_skeletonMage_F_archer case ActorSno._p6_necro_skeletonmage_f_archer: //p6_necro_skeletonMage_F_archer

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace DiIiS_NA.GameServer namespace DiIiS_NA.GameServer
{ {
public sealed class Config : DiIiS_NA.Core.Config.Config public sealed class GameServerConfig : DiIiS_NA.Core.Config.Config
{ {
public bool Enabled public bool Enabled
{ {
@ -170,9 +170,26 @@ namespace DiIiS_NA.GameServer
set => Set(nameof(NephalemRiftProgressMultiplier), value); set => Set(nameof(NephalemRiftProgressMultiplier), value);
} }
public static Config Instance { get; } = new(); /// <summary>
/// How much a health potion heals in percentage
/// </summary>
public float HealthPotionRestorePercentage
{
get => GetFloat(nameof(HealthPotionRestorePercentage), 60f);
set => Set(nameof(HealthPotionRestorePercentage), value);
}
private Config() : base("Game-Server") /// <summary>
/// Cooldown (in seconds) to use a health potion again.
/// </summary>
public float HealthPotionCooldown
{
get => GetFloat(nameof(HealthPotionCooldown), 30f);
set => Set(nameof(HealthPotionCooldown), value);
}
public static GameServerConfig Instance { get; } = new();
private GameServerConfig() : base("Game-Server")
{ {
} }
} }

View File

@ -62,14 +62,14 @@ namespace DiIiS_NA
public static Thread WatchdogThread; public static Thread WatchdogThread;
public static string LoginServerIp = DiIiS_NA.LoginServer.Config.Instance.BindIP; public static string LoginServerIp = DiIiS_NA.LoginServer.Config.Instance.BindIP;
public static string GameServerIp = DiIiS_NA.GameServer.Config.Instance.BindIP; public static string GameServerIp = DiIiS_NA.GameServer.GameServerConfig.Instance.BindIP;
public static string RestServerIp = REST.Config.Instance.IP; public static string RestServerIp = REST.Config.Instance.IP;
public static string PublicGameServerIp = DiIiS_NA.GameServer.NATConfig.Instance.PublicIP; public static string PublicGameServerIp = DiIiS_NA.GameServer.NATConfig.Instance.PublicIP;
public static int Build => 30; public static int Build => 30;
public static int Stage => 2; public static int Stage => 2;
public static TypeBuildEnum TypeBuild => TypeBuildEnum.Beta; public static TypeBuildEnum TypeBuild => TypeBuildEnum.Beta;
private static bool DiabloCoreEnabled = DiIiS_NA.GameServer.Config.Instance.CoreActive; private static bool DiabloCoreEnabled = DiIiS_NA.GameServer.GameServerConfig.Instance.CoreActive;
static async Task LoginServer() static async Task LoginServer()
{ {