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
using System;
using DiIiS_NA.Core.Logging;
using Nini.Config;
namespace DiIiS_NA.Core.Config
{
public class Config
{
private readonly Logger _logger;
private readonly string _sectionName;
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()
@ -17,14 +24,14 @@ namespace DiIiS_NA.Core.Config
ConfigurationManager.Save();
}
protected bool GetBoolean(string key, bool defaultValue) { return this._section.GetBoolean(key, defaultValue); }
protected double GetDouble(string key, double defaultValue) { return this._section.GetDouble(key, defaultValue); }
protected float GetFloat(string key, float defaultValue) { return this._section.GetFloat(key, defaultValue); }
protected int GetInt(string key, int defaultValue) { return this._section.GetInt(key, defaultValue); }
protected int GetInt(string key, int defaultValue, bool fromAlias) { return this._section.GetInt(key, defaultValue, fromAlias); }
protected long GetLong(string key, long defaultValue) { return this._section.GetLong(key, defaultValue); }
protected string GetString(string key, string defaultValue) { return this._section.Get(key, defaultValue); }
protected string[] GetEntryKeys() { return this._section.GetKeys(); }
protected void Set(string key, object value) { this._section.Set(key, value); }
protected bool GetBoolean(string key, bool defaultValue) => _section.GetBoolean(key, defaultValue);
protected double GetDouble(string key, double defaultValue) => _section.GetDouble(key, defaultValue);
protected float GetFloat(string key, float defaultValue) => _section.GetFloat(key, defaultValue);
protected int GetInt(string key, int defaultValue) => _section.GetInt(key, defaultValue);
protected int GetInt(string key, int defaultValue, bool fromAlias) => _section.GetInt(key, defaultValue, fromAlias);
protected long GetLong(string key, long defaultValue) => _section.GetLong(key, defaultValue);
protected string GetString(string key, string defaultValue) { return _section.Get(key, defaultValue); }
protected string[] GetEntryKeys() { return _section.GetKeys(); }
protected void Set(string key, object value) { _section.Set(key, value); }
}
}

View File

@ -17,7 +17,7 @@ namespace DiIiS_NA.Core.Config
{
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.
_fileExists = true;
}
@ -30,28 +30,28 @@ namespace DiIiS_NA.Core.Config
finally
{
// adds aliases so we can use On and Off directives in ini files.
Parser.Alias.AddAlias("On", true);
Parser.Alias.AddAlias("Off", false);
Parser!.Alias.AddAlias("On", true);
Parser!.Alias.AddAlias("Off", false);
// logger level aliases.
Parser.Alias.AddAlias("MinimumLevel", Logger.Level.Trace);
Parser.Alias.AddAlias("MaximumLevel", Logger.Level.Trace);
Parser!.Alias.AddAlias("MinimumLevel", Logger.Level.Trace);
Parser!.Alias.AddAlias("MaximumLevel", Logger.Level.Trace);
}
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];
}
static internal IConfig AddSection(string section) // Adds a config section.
internal static IConfig AddSection(string section) // Adds a config section.
{
return Parser.AddConfig(section);
}
static internal void Save() // Saves the settings.
internal static void Save() // Saves the settings.
{
if (_fileExists) Parser.Save();
else

View File

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

View File

@ -133,7 +133,7 @@ namespace DiIiS_NA.GameServer.CommandManager
if (line == string.Empty)
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;
line = line.Substring(1); // advance to actual command.
@ -153,9 +153,9 @@ namespace DiIiS_NA.GameServer.CommandManager
output =
invokerClient != null
? 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
.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.";
}

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;
Attributes[GameAttribute.using_Bossbar] = true;
Attributes[GameAttribute.InBossEncounter] = true;
Attributes[GameAttribute.Hitpoints_Max] *= Config.Instance.BossHealthMultiplier;
Attributes[GameAttribute.Damage_Weapon_Min, 0] *= Config.Instance.BossDamageMultiplier;
Attributes[GameAttribute.Damage_Weapon_Delta, 0] *= Config.Instance.BossDamageMultiplier;
Attributes[GameAttribute.Hitpoints_Max] *= GameServerConfig.Instance.BossHealthMultiplier;
Attributes[GameAttribute.Damage_Weapon_Min, 0] *= GameServerConfig.Instance.BossDamageMultiplier;
Attributes[GameAttribute.Damage_Weapon_Delta, 0] *= GameServerConfig.Instance.BossDamageMultiplier;
Attributes[GameAttribute.Hitpoints_Cur] = Attributes[GameAttribute.Hitpoints_Max_Total];
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_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)
Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative] = Attributes[GameAttribute.Hitpoints_Max_Percent_Bonus_Multiplicative];// / 2f;
var hpMax = Attributes[GameAttribute.Hitpoints_Max];
var hpTotal = Attributes[GameAttribute.Hitpoints_Max_Total];
float damageMin = monsterLevels.MonsterLevel[World.Game.MonsterLevel].Dmg * DmgMultiplier;// * 0.5f;
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;
if (monsterLevel > 30)
{
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;
}
if (monsterLevel > 60)
{
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;
}

View File

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

View File

@ -194,13 +194,16 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
if (!Game.Empty)
{
SaveQuestProgress(true);
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) =>
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) =>
{
if (Game.CurrentQuest == 312429) return; // open world quest
int xpReward = (int)(Quests[Game.CurrentQuest].RewardXp * Game.XpModifier);
int goldReward = (int)(Quests[Game.CurrentQuest].RewardGold * Game.GoldModifier);
int xpReward = (int)(Quests[Game.CurrentQuest].RewardXp *
Game.XpModifier);
int goldReward = (int)(Quests[Game.CurrentQuest].RewardGold *
Game.GoldModifier);
player.InGameClient.SendMessage(new QuestStepCompleteMessage()
{
QuestStepComplete = QuestStepComplete.CreateBuilder()
@ -213,28 +216,34 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
.SetIsQuestComplete(true)
.Build()
});
player.InGameClient.SendMessage(new GameServer.MessageSystem.Message.Definitions.Base.FloatingAmountMessage()
{
Place = new WorldPlace()
{
Position = player.Position,
WorldID = player.World.DynamicID(player),
},
player.InGameClient.SendMessage(
new GameServer.MessageSystem.Message.Definitions.Base.
FloatingAmountMessage()
{
Place = new WorldPlace()
{
Position = player.Position,
WorldID = player.World.DynamicID(player),
},
Amount = xpReward,
Type = GameServer.MessageSystem.Message.Definitions.Base.FloatingAmountMessage.FloatType.Experience,
});
player.InGameClient.SendMessage(new GameServer.MessageSystem.Message.Definitions.Base.FloatingAmountMessage()
{
Place = new WorldPlace()
{
Position = player.Position,
WorldID = player.World.DynamicID(player),
},
Amount = xpReward,
Type = GameServer.MessageSystem.Message.Definitions.Base
.FloatingAmountMessage.FloatType.Experience,
});
player.InGameClient.SendMessage(
new GameServer.MessageSystem.Message.Definitions.Base.
FloatingAmountMessage()
{
Place = new WorldPlace()
{
Position = player.Position,
WorldID = player.World.DynamicID(player),
},
Amount = goldReward,
Type = GameServer.MessageSystem.Message.Definitions.Base.FloatingAmountMessage.FloatType.Gold,
});
Amount = goldReward,
Type = GameServer.MessageSystem.Message.Definitions.Base
.FloatingAmountMessage.FloatType.Gold,
});
player.UpdateExp(xpReward);
player.Inventory.AddGoldAmount(goldReward);
player.AddAchievementCounter(74987243307173, (uint)goldReward);
@ -253,21 +262,25 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
{
Logger.WarnException(e, "Advance() exception caught:");
}
//Пока только для одного квеста
// if (this.Game.CurrentQuest != 72221)
// if (this.Game.CurrentStep != -1)
Advance();
// if (this.Game.CurrentQuest != 72221)
// if (this.Game.CurrentStep != -1)
Advance();
}
if (!Game.Empty)
{
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);
}
OnQuestProgress();
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()

View File

@ -104,11 +104,11 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
//445736 - p4_forest_snow_icecave_01
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.");
string DRLGVersion = "1.8";
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;
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>
/// 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.
/// Otherwise, it will have <see cref="Config.ChanceNormalUnidentified"/>% 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="GameServerConfig.ChanceNormalUnidentified"/>% chance to be unidentified.
/// </summary>
/// <param name="item">The item to set the flag</param>
private static void RandomSetUnidentified(Item item) => item.Unidentified =
FastRandom.Instance.Chance(item.Name.Contains("unique", StringComparison.InvariantCultureIgnoreCase)
|| item.ItemDefinition.Quality is ItemTable.ItemQuality.Legendary or ItemTable.ItemQuality.Special or ItemTable.ItemQuality.Set
? Config.Instance.ChanceHighQualityUnidentified
: Config.Instance.ChanceNormalUnidentified);
? GameServerConfig.Instance.ChanceHighQualityUnidentified
: GameServerConfig.Instance.ChanceNormalUnidentified);
// Allows cooking a custom item.
public static Item Cook(Player player, string name)

View File

@ -613,16 +613,16 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
switch (MonsterQuality)
{
case 0: //Normal
return new List<float> { 0.18f * Config.Instance.RateChangeDrop };
return new List<float> { 0.18f * GameServerConfig.Instance.RateChangeDrop };
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 4: //Unique
return new List<float> { 1f, 1f, 1f, 1f, 1f };
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:
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>
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)
amount += Min;
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
Attributes[GameAttribute.Corpse_Resurrection_Charges] = Config.Instance.ResurrectionCharges;
Attributes[GameAttribute.Corpse_Resurrection_Charges] = GameServerConfig.Instance.ResurrectionCharges;
#if DEBUG
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 DiIiS_NA.GameServer.GSSystem.PlayerSystem;
using DiIiS_NA.GameServer.GSSystem.TickerSystem;
using DiIiS_NA.LoginServer;
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()
{
if (User is Player player)
{
player.AddPercentageHP(60);
AddBuff(player, player, new CooldownBuff(30211, TickTimer.WaitSeconds(player.World.Game, 30f)));
}
yield break;
if (User is not Player player) yield break;
player.AddPercentageHP(GameServerConfig.Instance.HealthPotionRestorePercentage);
AddBuff(player, player, new CooldownBuff(30211, TickTimer.WaitSeconds(player.World.Game, GameServerConfig.Instance.HealthPotionCooldown)));
}
}
}

View File

@ -403,7 +403,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
{
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));
var a = (int)plr.Attributes[GameAttribute.Experience_Bonus];
@ -597,7 +597,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
//Nephalem Rift
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;
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 < rate * (1f
+ plr.Attributes[GameAttribute.Magic_Find])
* Config.Instance.RateDrop)
* GameServerConfig.Instance.RateDrop)
{
//Logger.Debug("rate: {0}", rate);
var lootQuality = Target.World.Game.IsHardcore

View File

@ -64,7 +64,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
catch (Exception ex)
{
#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
return AnimationSno._NONE;
}
@ -78,32 +78,18 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
}
public virtual float GetActionSpeed()
{
return EvalTag(PowerKeys.AttackSpeed);
}
public virtual float GetActionSpeed() => EvalTag(PowerKeys.AttackSpeed);
public virtual int GetCastEffectSNO()
{
return EvalTag(IsUserFemale ? PowerKeys.CastingEffectGroup_Female : PowerKeys.CastingEffectGroup_Male);
}
public virtual int GetCastEffectSNO() => EvalTag(IsUserFemale ? PowerKeys.CastingEffectGroup_Female : PowerKeys.CastingEffectGroup_Male);
public virtual int GetContactEffectSNO()
{
return EvalTag(IsUserFemale ? PowerKeys.ContactFrameEffectGroup_Female : PowerKeys.ContactFrameEffectGroup_Male);
}
public virtual int GetContactEffectSNO() => EvalTag(IsUserFemale ? PowerKeys.ContactFrameEffectGroup_Female : PowerKeys.ContactFrameEffectGroup_Male);
public virtual float GetContactDelay()
{
return 0f;
}
public virtual float GetContactDelay() => 0f;
public float GetCooldown()
{
if (EvalTag(PowerKeys.CooldownTime) > 0f)
return EvalTag(PowerKeys.CooldownTime);
else
return 1f;
var tag = EvalTag(PowerKeys.CooldownTime);
return tag > 0f ? tag : 1f;
}
private void PlayActionAnimation()
@ -112,10 +98,10 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
var animationSNO = GetActionAnimationSNO();
#region Патч анимаций
if(animationSNO == AnimationSno._NONE)
switch (this.User.SNO)
switch (User.SNO)
{
case ActorSno._x1_skeletonarcher_westmarch_a: //x1_SkeletonArcher_Westmarch_A
if (this.PowerSNO == 30334)
if (PowerSNO == 30334)
animationSNO = AnimationSno.x1_skeletonarcher_westmarch_attack_01;
break;
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
{
public sealed class Config : DiIiS_NA.Core.Config.Config
public sealed class GameServerConfig : DiIiS_NA.Core.Config.Config
{
public bool Enabled
{
@ -170,9 +170,26 @@ namespace DiIiS_NA.GameServer
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);
}
/// <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 Config() : base("Game-Server")
private GameServerConfig() : base("Game-Server")
{
}
}

View File

@ -62,14 +62,14 @@ namespace DiIiS_NA
public static Thread WatchdogThread;
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 PublicGameServerIp = DiIiS_NA.GameServer.NATConfig.Instance.PublicIP;
public static int Build => 30;
public static int Stage => 2;
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()
{