diff --git a/src/Blizzless-D3.sln b/src/Blizzless-D3.sln index fd3870b..e0bbba5 100644 --- a/src/Blizzless-D3.sln +++ b/src/Blizzless-D3.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.1.32210.238 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31410.357 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blizzless", "DiIiS-NA\Blizzless.csproj", "{535AC91E-54D1-4044-B4A5-B78AE1570EE3}" EndProject @@ -10,15 +10,20 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + github|Any CPU = github|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {535AC91E-54D1-4044-B4A5-B78AE1570EE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {535AC91E-54D1-4044-B4A5-B78AE1570EE3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {535AC91E-54D1-4044-B4A5-B78AE1570EE3}.github|Any CPU.ActiveCfg = github|Any CPU + {535AC91E-54D1-4044-B4A5-B78AE1570EE3}.github|Any CPU.Build.0 = github|Any CPU {535AC91E-54D1-4044-B4A5-B78AE1570EE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {535AC91E-54D1-4044-B4A5-B78AE1570EE3}.Release|Any CPU.Build.0 = Release|Any CPU {73D9E87F-1F75-4D94-A47B-29354B9BCF13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {73D9E87F-1F75-4D94-A47B-29354B9BCF13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {73D9E87F-1F75-4D94-A47B-29354B9BCF13}.github|Any CPU.ActiveCfg = github|Any CPU + {73D9E87F-1F75-4D94-A47B-29354B9BCF13}.github|Any CPU.Build.0 = github|Any CPU {73D9E87F-1F75-4D94-A47B-29354B9BCF13}.Release|Any CPU.ActiveCfg = Release|Any CPU {73D9E87F-1F75-4D94-A47B-29354B9BCF13}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/src/DiIiS-NA/BGS-Server/AccountsSystem/AccountManager.cs b/src/DiIiS-NA/BGS-Server/AccountsSystem/AccountManager.cs index 186435f..0f132f4 100644 --- a/src/DiIiS-NA/BGS-Server/AccountsSystem/AccountManager.cs +++ b/src/DiIiS-NA/BGS-Server/AccountsSystem/AccountManager.cs @@ -75,6 +75,35 @@ namespace DiIiS_NA.LoginServer.AccountsSystem Logger.Warn("Created account {0}", email); return GetAccountByEmail(email); } + public static bool BindDiscordAccount(string email, ulong discordId, string discordTag) + { + try + { + if (DBSessions.SessionQueryWhere(dba => dba.DiscordId == discordId).Count() > 0) + return false; + + var account = GetAccountByEmail(email); + account.DBAccount.DiscordTag = discordTag; + account.DBAccount.DiscordId = discordId; + DBSessions.SessionUpdate(account.DBAccount); + return true; + } + catch (Exception e) + { + Logger.DebugException(e, "BindDiscordAccount() exception: "); + return false; + } + } + public static Account GetAccountByDiscordId(ulong discordId) + { + List dbAcc = DBSessions.SessionQueryWhere(dba => dba.DiscordId == discordId).ToList(); + if (dbAcc.Count() == 0) + { + Logger.Warn("GetAccountByDiscordId {0}: DBAccount is null!", discordId); + return null; + } + return GetAccountByDBAccount(dbAcc.First()); + } public static bool GenerateReferralCode(string email) { diff --git a/src/DiIiS-NA/Blizzless.csproj b/src/DiIiS-NA/Blizzless.csproj index 1dc558c..154bfb6 100644 --- a/src/DiIiS-NA/Blizzless.csproj +++ b/src/DiIiS-NA/Blizzless.csproj @@ -10,6 +10,7 @@ 3.0.0.0 DiIiS_NA.Program full + Debug;Release;github @@ -27,6 +28,10 @@ true + + true + + @@ -64,6 +69,7 @@ + @@ -85,6 +91,7 @@ + @@ -95,7 +102,7 @@ Always - Never + PreserveNewest Always diff --git a/src/DiIiS-NA/Core/Discord/Bot.cs b/src/DiIiS-NA/Core/Discord/Bot.cs new file mode 100644 index 0000000..00f421d --- /dev/null +++ b/src/DiIiS-NA/Core/Discord/Bot.cs @@ -0,0 +1,284 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Discord; +using Discord.Commands; +using Discord.WebSocket; +using DiIiS_NA.Core.Discord.Services; +using DiIiS_NA.LoginServer.AccountsSystem; +using DiIiS_NA.Core.Logging; +using DiIiS_NA.Core.Storage; +using DiIiS_NA.Core.Storage.AccountDataBase.Entities; + +namespace DiIiS_NA.Core.Discord +{ + public class Bot + { + private static readonly Logger Logger = LogManager.CreateLogger(); + + public static void Init() + => new Bot().MainAsync().GetAwaiter().GetResult(); + + public DiscordSocketClient Client = null; + private DiscordSocketConfig _config = new DiscordSocketConfig{MessageCacheSize = 100}; + + public async Task MainAsync() + { + var services = ConfigureServices(); + this.Client = services.GetService(); + await services.GetService().InitializeAsync(); + + await this.Client.LoginAsync(TokenType.Bot, Config.Instance.Token); + await this.Client.StartAsync(); + + this.Client.ReactionAdded += HandleReactionAsync;// ReactionAdded; + + //await Task.Delay(-1); + } + + private IServiceProvider ConfigureServices() + { + return new ServiceCollection() + // Base + .AddSingleton(new DiscordSocketClient(_config)) + .AddSingleton() + .AddSingleton() + // Add additional services here... + .BuildServiceProvider(); + } + private async Task HandleReactionAsync(Cacheable message, Cacheable channel, SocketReaction reaction) + { + if (this.Client.GetUser(reaction.UserId).IsBot) return; + + // If the message was not in the cache, downloading it will result in getting a copy of it. + var msg = await message.GetOrDownloadAsync(); + if (channel.Id == (ulong)DiIiS_NA.Core.Discord.Config.Instance.EventsChannelId) + { + var user = reaction.User.Value; + var guild_user = this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetUser(user.Id); + + if (!guild_user.Roles.Select(r => r.Id).Contains((ulong)DiIiS_NA.Core.Discord.Config.Instance.BaseRoleId) && !guild_user.IsBot) + { + await msg.RemoveReactionAsync(reaction.Emote, reaction.User.Value); + await user.SendMessageAsync("**Your #💎events entry has been removed because your Blizzless account isn't linked to Discord!**\nYou can do that if you send me:\n\n`!email my_d3r_email@something.com`\n\n**(Replace** `my_d3r_email@something.com` **with your D3 Reflection email)**"); + } + } + + } + + public async Task AddCollectorRole(ulong userId) + { + try + { + var user = this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetUser(userId); + await user.AddRoleAsync(this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetRole((ulong)DiIiS_NA.Core.Discord.Config.Instance.CollectorRoleId)); + await user.SendMessageAsync("Congratulations! You are now a **Collector**."); + } + catch (Exception e) + { + Logger.WarnException(e, "AddCollectorRole() exception: "); + } + } + + public async Task AddPremiumRole(ulong userId) + { + try + { + var user = this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetUser(userId); + await user.AddRoleAsync(this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetRole((ulong)DiIiS_NA.Core.Discord.Config.Instance.PremiumRoleId)); + await user.SendMessageAsync("Congratulations! You are now a **Premium** user."); + } + catch (Exception e) + { + Logger.WarnException(e, "AddPremiumRole() exception: "); + } + } + + public async Task UpdateBattleTag(ulong userId, string btag) + { + try + { + var user = this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetUser(userId); + await user.AddRoleAsync(this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetRole((ulong)DiIiS_NA.Core.Discord.Config.Instance.PremiumRoleId)); + await user.ModifyAsync(x => {x.Nickname = btag;}); + } + catch (Exception e) + { + Logger.WarnException(e, "UpdateBattleTag() exception: "); + } + } + + public async Task ClearPremiumRoles(List userIds) + { + try + { + var guild = this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId); + var role = guild.GetRole((ulong)DiIiS_NA.Core.Discord.Config.Instance.PremiumRoleId); + foreach (var userId in userIds) + { + try + { + var user = guild.GetUser(userId); + await user.RemoveRoleAsync(role); + } catch {} + } + } + catch (Exception e) + { + Logger.WarnException(e, "ClearPremiumRoles() exception: "); + } + } + + public async Task ShowServerStats() + { + try + { + var guild = this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId); + var channelId = (ulong)DiIiS_NA.Core.Discord.Config.Instance.StatsChannelId; + string opened = DBSessions.SessionQueryWhere(dbgp => dbgp.Name == "ServerOpened").First().Value > 0 ? "ENABLED" : "DISABLED"; + // int gs_count = Program.MooNetServer.MooNetBackend.GameServers.Count; + // int ccu = DiIiS_NA.Core.MooNet.Online.PlayerManager.OnlinePlayers.Count; + // int games = DiIiS_NA.Core.MooNet.Games.GameFactoryManager.GamesOnline; + var messages = await guild.GetTextChannel(channelId).GetMessagesAsync(10).FlattenAsync(); + await guild.GetTextChannel(channelId).DeleteMessagesAsync(messages); + // await guild.GetTextChannel(channelId).SendMessageAsync($"Login availability: **{opened}**\nGame servers available: {gs_count}\nPlayers online: {ccu}\nGames online: {games}"); + } + catch (Exception e) + { + Logger.WarnException(e, "ShowStats() exception: "); + } + } + + + public async Task StartGiveaway() + { + try + { + var guild = this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId); + var channelId = (ulong)DiIiS_NA.Core.Discord.Config.Instance.EventsChannelId; + var param_message = DBSessions.SessionQueryWhere(dbgp => dbgp.Name == "DiscordGiveawayPostId"); + if (param_message.Count < 1) + { + var messages = await guild.GetTextChannel(channelId).GetMessagesAsync(10).FlattenAsync(); + await guild.GetTextChannel(channelId).DeleteMessagesAsync(messages); + } + else + { + await guild.GetTextChannel(channelId).DeleteMessageAsync(param_message.First().Value); + } + + var eb = new EmbedBuilder(); + eb.WithTitle("Reward: 7 days of Premium"); + eb.WithDescription("Click <:wolfRNG:607868292979490816> to join.\nEnds at 18:00 UTC"); + eb.WithFooter("You must bind your D3R account email to be able to join!"); + eb.WithColor(Color.Blue); + var mes = await guild.GetTextChannel(channelId).SendMessageAsync("@here \n <:wolfRNG:607868292979490816> **GIVEAWAY ROULETTE!** <:wolfRNG:607868292979490816>", false, eb.Build()); + + //var giveaway_message = await guild.GetTextChannel(channelId).GetMessagesAsync(1).FlattenAsync(); + //foreach (var mes in giveaway_message) + //{ + var param = DBSessions.SessionQueryWhere(dbgp => dbgp.Name == "DiscordGiveawayPostId"); + if (param.Count < 1) + { + var new_param = new DBGlobalParams{ + Name = "DiscordGiveawayPostId", + Value = mes.Id + }; + DBSessions.SessionSave(new_param); + } + else + { + var postId = param.First(); + postId.Value = mes.Id; + DBSessions.SessionUpdate(postId); + } + await (mes as IUserMessage).AddReactionAsync(Emote.Parse("<:wolfRNG:607868292979490816>")); + //} + } + catch (Exception e) + { + Logger.WarnException(e, "StartGiveaway() exception: "); + } + } + + public async Task FinishGiveaway() + { + try + { + var guild = this.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId); + var channelId = (ulong)DiIiS_NA.Core.Discord.Config.Instance.EventsChannelId; + bool haveWinner = true; + string winnerName = ""; + var param = DBSessions.SessionQueryWhere(dbgp => dbgp.Name == "DiscordGiveawayPostId"); + if (param.Count < 1) + { + haveWinner = false; + } + else + { + if (param.First().Value > 0) + { + var message = await guild.GetTextChannel(channelId).GetMessageAsync(param.First().Value); + var reactedUsers = await (message as IUserMessage).GetReactionUsersAsync(Emote.Parse("<:wolfRNG:607868292979490816>"), 100).FlattenAsync(); + var contestants = reactedUsers.Where(u => !u.IsBot).ToList(); + if (contestants.Count() > 0) + { + var winner = reactedUsers.Where(u => !u.IsBot).ToList()[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, reactedUsers.Count() - 1)]; + winnerName = guild.GetUser(winner.Id).Nickname; + await winner.SendMessageAsync("Congratulations! You have won **7 days of D3 Reflection Premium**!.\nYour account has already had its Premium prolonged. Have a nice game!"); + var acc = AccountManager.GetAccountByDiscordId(winner.Id); + if (acc != null) { + //acc.UpdatePremiumTime(7); + } + } + else + haveWinner = false; + } + else + haveWinner = false; + } + + if (param.Count < 1) + { + var messages = await guild.GetTextChannel(channelId).GetMessagesAsync(10).FlattenAsync(); + await guild.GetTextChannel(channelId).DeleteMessagesAsync(messages); + } + else + { + await guild.GetTextChannel(channelId).DeleteMessageAsync(param.First().Value); + } + + var eb = new EmbedBuilder(); + eb.WithTitle("Giveaway ended"); + eb.WithDescription(haveWinner ? string.Format("Winner: {0}", winnerName) : "We have no winner this time :("); + eb.WithFooter("Free Premium giveaways - starts every Friday and Saturday!"); + eb.WithColor(Color.Red); + var mes = await guild.GetTextChannel(channelId).SendMessageAsync("<:wolfRNG:607868292979490816> **GIVEAWAY ROULETTE!** <:wolfRNG:607868292979490816>", false, eb.Build()); + + var db_param = DBSessions.SessionQueryWhere(dbgp => dbgp.Name == "DiscordGiveawayPostId"); + if (db_param.Count < 1) + { + var new_param = new DBGlobalParams{ + Name = "DiscordGiveawayPostId", + Value = mes.Id + }; + DBSessions.SessionSave(new_param); + } + else + { + var postId = db_param.First(); + postId.Value = mes.Id; + DBSessions.SessionUpdate(postId); + } + } + catch (Exception e) + { + Logger.WarnException(e, "FinishGiveaway() exception: "); + } + } + } +} \ No newline at end of file diff --git a/src/DiIiS-NA/Core/Discord/Config.cs b/src/DiIiS-NA/Core/Discord/Config.cs new file mode 100644 index 0000000..eb9cb04 --- /dev/null +++ b/src/DiIiS-NA/Core/Discord/Config.cs @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2011 - 2012 DiIiS_NA project - http://www.DiIiS_NA.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * + */ + +namespace DiIiS_NA.Core.Discord +{ + public sealed class Config : Core.Config.Config + { + public bool Enabled { get { return this.GetBoolean("Enabled", false); } set { this.Set("Enabled", value); } } + public bool MonitorEnabled { get { return this.GetBoolean("MonitorEnabled", true); } set { this.Set("MonitorEnabled", value); } } + public string Token { get { return this.GetString("Token", ""); } set { this.Set("Token", value); } } + public long GuildId { get { return this.GetLong("GuildId", 0); } set { this.Set("GuildId", value); } } + public long AnnounceChannelId { get { return this.GetLong("AnnounceChannelId", 0); } set { this.Set("AnnounceChannelId", value); } } + public long StatsChannelId { get { return this.GetLong("StatsChannelId", 0); } set { this.Set("StatsChannelId", value); } } + public long EventsChannelId { get { return this.GetLong("EventsChannelId", 0); } set { this.Set("EventsChannelId", value); } } + public long BaseRoleId { get { return this.GetLong("BaseRoleId", 0); } set { this.Set("BaseRoleId", value); } } + public long PremiumRoleId { get { return this.GetLong("PremiumRoleId", 0); } set { this.Set("PremiumRoleId", value); } } + public long CollectorRoleId { get { return this.GetLong("CollectorRoleId", 0); } set { this.Set("CollectorRoleId", value); } } + + private static readonly Config _instance = new Config(); + public static Config Instance { get { return _instance; } } + private Config() : base("Discord") { } + } +} diff --git a/src/DiIiS-NA/Core/Discord/Modules/AuthModule.cs b/src/DiIiS-NA/Core/Discord/Modules/AuthModule.cs new file mode 100644 index 0000000..52297aa --- /dev/null +++ b/src/DiIiS-NA/Core/Discord/Modules/AuthModule.cs @@ -0,0 +1,115 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Net.Mail; +using DiIiS_NA.LoginServer.AccountsSystem; +using DiIiS_NA.Core.Storage; +using DiIiS_NA.Core.Storage.AccountDataBase.Entities; +using Discord; +using Discord.Commands; + +namespace DiIiS_NA.Core.Discord.Modules +{ + public class AuthModule : ModuleBase + { + [Command("register")] + public async Task Register([Remainder] string args) + { + string dtag = Context.User.Username + "#" + Context.User.Discriminator; + string[] registerInfo = args.Split(null); + + var email = registerInfo[0]; + var password = registerInfo[1]; + var battleTagName = registerInfo[2]; + var userLevel = Account.UserLevels.User; + + if (!(Context.Channel is IDMChannel)) + { + await Context.Guild.GetTextChannel(Context.Channel.Id).DeleteMessageAsync(Context.Message); + await ReplyAsync($"<@{Context.User.Id}> that command could be used only via direct message!\nDon't show your e-mail to anyone, don't be a fool! <:200iq:538833204421984286>"); + return; + } + + + if (registerInfo.Count() == 3) + { + if (!email.Contains('@')) + { + await ReplyAsync($"<@{Context.User.Id}> " + string.Format("'{0}' is not a valid email address.", email)); + return; + } + if (!IsValid(email)) + { + await ReplyAsync("Your e-mail address is invalid!"); + return; + } + if (battleTagName.Contains('#')) + { + await ReplyAsync($"<@{Context.User.Id}> BattleTag must not contain '#' or HashCode."); + return; + } + + + if (password.Length < 8 || password.Length > 16) + { + await ReplyAsync($"<@{Context.User.Id}> Password should be a minimum of 8 and a maximum of 16 characters."); + return; + } + + if (AccountManager.GetAccountByEmail(email) != null) + { + await ReplyAsync($"<@{Context.User.Id}> " + string.Format("An account already exists for email address {0}.", email)); + return; + } + + var account = AccountManager.CreateAccount(email, password, battleTagName, userLevel); + var gameAccount = GameAccountManager.CreateGameAccount(account); + + var guild_user = Context.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetUser(Context.User.Id); + + if (guild_user == null) + { + await ReplyAsync("Your Discord account is not participated channel!"); + return; + } + + if (AccountManager.BindDiscordAccount(email, Context.User.Id, dtag)) + { + var accountcheck = AccountManager.GetAccountByEmail(email); + string battle_tag = account.DBAccount.BattleTagName + "#" + account.DBAccount.HashCode; + await ReplyAsync($"Account registered.\nYour Discord account has been successfully bound to {battle_tag}!"); + await guild_user.AddRoleAsync(Context.Client.GetGuild((ulong)DiIiS_NA.Core.Discord.Config.Instance.GuildId).GetRole((ulong)DiIiS_NA.Core.Discord.Config.Instance.BaseRoleId)); + await ReplyAsync("You are now **DemonSlayer**!"); + try + { + await guild_user.ModifyAsync(x => { x.Nickname = battle_tag; }); + } + catch + { } + } + else + await ReplyAsync("An error occured: make sure your Discord account hasn't already been bound to another account.!"); + } + else + { + await ReplyAsync("Incorrect usage: !register .!"); + } + } + + private bool IsValid(string emailaddress) + { + try + { + MailAddress m = new MailAddress(emailaddress); + + return true; + } + catch (FormatException) + { + return false; + } + } + } +} diff --git a/src/DiIiS-NA/Core/Discord/Modules/EventsModule.cs b/src/DiIiS-NA/Core/Discord/Modules/EventsModule.cs new file mode 100644 index 0000000..1360d99 --- /dev/null +++ b/src/DiIiS-NA/Core/Discord/Modules/EventsModule.cs @@ -0,0 +1,39 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Discord; +using Discord.Commands; +using DiIiS_NA.Core.Storage; +using DiIiS_NA.Core.Storage.AccountDataBase.Entities; + +namespace DiIiS_NA.Core.Discord.Modules +{ + public class EventsModule : ModuleBase + { + private ulong EventsChannelId + { + get + { + return (ulong)DiIiS_NA.Core.Discord.Config.Instance.EventsChannelId; + } + set{} + } + + + [Command("announce_event")] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.Administrator)] + public async Task SalesAnnounce() + { + var eb = new EmbedBuilder(); + eb.WithTitle("New Event"); + eb.WithDescription("Event Description."); + eb.WithFooter("Ends 4th Dec 2022.\nStay at home!"); + eb.WithColor(Color.Green); + await Context.Guild.GetTextChannel(EventsChannelId).SendMessageAsync("<:party:> **NEW EVENT!** <:party:>", false, eb.Build()); + } + + } +} diff --git a/src/DiIiS-NA/Core/Discord/Modules/InfoModule.cs b/src/DiIiS-NA/Core/Discord/Modules/InfoModule.cs new file mode 100644 index 0000000..02055cd --- /dev/null +++ b/src/DiIiS-NA/Core/Discord/Modules/InfoModule.cs @@ -0,0 +1,116 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Discord; +using Discord.Commands; +using DiIiS_NA.Core.Extensions; +using DiIiS_NA.Core.Storage; +using DiIiS_NA.Core.Storage.AccountDataBase.Entities; +using DiIiS_NA.Core.Storage; +using DiIiS_NA.Core.Storage.AccountDataBase.Entities; +using DiIiS_NA.LoginServer.Battle; +using DiIiS_NA.LoginServer.GamesSystem; + +namespace DiIiS_NA.Core.Discord.Modules +{ + public class InfoModule : ModuleBase + { + private ulong AnnounceChannelId + { + get + { + return (ulong)DiIiS_NA.Core.Discord.Config.Instance.AnnounceChannelId; + } + set{} + } + + private ulong StatsChannelId + { + get + { + return (ulong)DiIiS_NA.Core.Discord.Config.Instance.StatsChannelId; + } + set{} + } + + [Command("about")] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.Administrator)] + public async Task Info() + { + await ReplyAsync($"Hello, I am a bot called {Context.Client.CurrentUser.Username} written for Blizzless Server\nSpecial Thanks to those who want it."); + } + + [Command("ping")] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.Administrator)] + public async Task PingAsync() + { + await ReplyAsync("pong!"); + } + + [Command("list_online")] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.Administrator)] + public async Task ListOnline() + { + int ccu = PlayerManager.OnlinePlayers.Count; + string players = ""; + foreach (var plr in PlayerManager.OnlinePlayers) + { + players += plr.Account.BattleTag; + players += "\n"; + } + + await ReplyAsync(string.Format("Total players online: {0}\n{1}", ccu, players)); + } + + [Command("lock")] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.Administrator)] + public async Task Lock() + { + var param = DBSessions.SessionQueryWhere(dbgp => dbgp.Name == "ServerOpened").First(); + param.Value = 0; + DBSessions.SessionUpdate(param); + await ReplyAsync("Login availability now **DISABLED**"); + } + + [Command("unlock")] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.Administrator)] + public async Task Unlock() + { + var param = DBSessions.SessionQueryWhere(dbgp => dbgp.Name == "ServerOpened").First(); + param.Value = 1; + DBSessions.SessionUpdate(param); + await ReplyAsync("Login availability now **ENABLED**"); + } + + [Command("maintenance")] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.Administrator)] + public async Task MaintenanceAnnounce([Remainder]int minutes) + { + //notify players maintenance is enabled + var messages = await Context.Guild.GetTextChannel(AnnounceChannelId).GetMessagesAsync(10).FlattenAsync(); + await Context.Guild.GetTextChannel(AnnounceChannelId).DeleteMessagesAsync(messages); + await Context.Guild.GetTextChannel(AnnounceChannelId).SendMessageAsync("Servers status: :tools: **PLANNED MAINTENANCE**."); + await Context.Guild.GetTextChannel(AnnounceChannelId).SendMessageAsync($"@here Servers will be restarted in **{minutes}** minutes for a planned maintenance.\n----\nСерверы будут перезагружены через **{minutes}** минут для плановых профилактических работ."); + } + + [Command("online")] + [RequireContext(ContextType.Guild)] + [RequireUserPermission(GuildPermission.Administrator)] + public async Task OnlineAnnounce() + { + var messages = await Context.Guild.GetTextChannel(AnnounceChannelId).GetMessagesAsync(10).FlattenAsync(); + await Context.Guild.GetTextChannel(AnnounceChannelId).DeleteMessagesAsync(messages); + await Context.Guild.GetTextChannel(AnnounceChannelId).SendMessageAsync("Servers status: :white_check_mark: **ONLINE**."); + await Context.Guild.GetTextChannel(AnnounceChannelId).SendMessageAsync("@here Servers are up and running.\n"); + } + + } +} diff --git a/src/DiIiS-NA/Core/Discord/Services/CommandHandlingService.cs b/src/DiIiS-NA/Core/Discord/Services/CommandHandlingService.cs new file mode 100644 index 0000000..41d765c --- /dev/null +++ b/src/DiIiS-NA/Core/Discord/Services/CommandHandlingService.cs @@ -0,0 +1,84 @@ +using System; +using System.Reflection; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Discord; +using Discord.Commands; +using Discord.WebSocket; +using DiIiS_NA.Core.Logging; + +namespace DiIiS_NA.Core.Discord.Services +{ + public class CommandHandlingService + { + private static readonly Logger Logger = LogManager.CreateLogger(); + private readonly CommandService _commands; + private readonly DiscordSocketClient _discord; + private readonly IServiceProvider _services; + + public CommandHandlingService(IServiceProvider services) + { + _commands = services.GetService(); + _discord = services.GetService(); + _services = services; + + // Hook CommandExecuted to handle post-command-execution logic. + _commands.CommandExecuted += CommandExecutedAsync; + // Hook MessageReceived so we can process each message to see + // if it qualifies as a command. + _discord.MessageReceived += MessageReceivedAsync; + } + + public async Task InitializeAsync() + { + // Register modules that are public and inherit ModuleBase. + await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services); + } + + public async Task MessageReceivedAsync(SocketMessage rawMessage) + { + try + { + // Ignore system messages, or messages from other bots + if (!(rawMessage is SocketUserMessage message)) return; + if (message.Source != MessageSource.User) return; + + //if (!(message.Channel is SocketTextChannel textChannel)) return; + //if (textChannel.Name != DiIiS_NA.Core.Discord.Config.Instance.ConsoleChannel) return; + // This value holds the offset where the prefix ends + var argPos = 0; + // Perform prefix check. You may want to replace this with + if (!message.HasCharPrefix('!', ref argPos)) return; + // for a more traditional command format like !help. + //if (!message.HasMentionPrefix(_discord.CurrentUser, ref argPos)) return; + + var context = new SocketCommandContext(_discord, message); + // Perform the execution of the command. In this method, + // the command service will perform precondition and parsing check + // then execute the command if one is matched. + Logger.BotCommand("[{0}]: {1}", message.Author.Username, message.Content); + await _commands.ExecuteAsync(context, argPos, _services); + // Note that normally a result will be returned by this format, but here + // we will handle the result in CommandExecutedAsync, + } + catch (Exception e) + { + Logger.DebugException(e, "Discord exception: "); + } + } + + public async Task CommandExecutedAsync(Optional command, ICommandContext context, IResult result) + { + // command is unspecified when there was a search failure (command not found); we don't care about these errors + if (!command.IsSpecified) + return; + + // the command was successful, we don't care about this result, unless we want to log that a command succeeded. + if (result.IsSuccess) + return; + + // the command failed, let's notify the user that something happened. + await context.Channel.SendMessageAsync($"error: {result}"); + } + } +} diff --git a/src/DiIiS-NA/Core/Storage/AccountDataBase/Entities/DBAccount.cs b/src/DiIiS-NA/Core/Storage/AccountDataBase/Entities/DBAccount.cs index c05f164..a26344f 100644 --- a/src/DiIiS-NA/Core/Storage/AccountDataBase/Entities/DBAccount.cs +++ b/src/DiIiS-NA/Core/Storage/AccountDataBase/Entities/DBAccount.cs @@ -23,5 +23,7 @@ namespace DiIiS_NA.Core.Storage.AccountDataBase.Entities public virtual ulong LastOnline { get; set; } public virtual bool HasRename { get; set; } public virtual ulong RenameCooldown { get; set; } - } + public virtual ulong DiscordId { get; set; } + public virtual string DiscordTag { get; set; } + } } diff --git a/src/DiIiS-NA/Core/Storage/AccountDataBase/Mapper/DBAccountMapper.cs b/src/DiIiS-NA/Core/Storage/AccountDataBase/Mapper/DBAccountMapper.cs index a968d4f..c2eb73e 100644 --- a/src/DiIiS-NA/Core/Storage/AccountDataBase/Mapper/DBAccountMapper.cs +++ b/src/DiIiS-NA/Core/Storage/AccountDataBase/Mapper/DBAccountMapper.cs @@ -12,6 +12,8 @@ namespace DiIiS_NA.Core.Storage.AccountDataBase.Mapper Table("accounts"); Id(e => e.Id).CustomType().GeneratedBy.Sequence("accounts_seq").UnsavedValue(null); Map(e => e.Email); + Map(e => e.DiscordTag); + Map(e => e.DiscordId).CustomType().Default("0"); Map(e => e.Banned).Not.Nullable().Default("false"); Map(e => e.Salt)/*.CustomSqlType("VarBinary(32)")*/.Length(32); Map(e => e.PasswordVerifier)/*.CustomSqlType("VarBinary")*/.Length(128); diff --git a/src/DiIiS-NA/D3-GameServer/ClientSystem/ClientManager.cs b/src/DiIiS-NA/D3-GameServer/ClientSystem/ClientManager.cs index 208a929..8161c42 100644 --- a/src/DiIiS-NA/D3-GameServer/ClientSystem/ClientManager.cs +++ b/src/DiIiS-NA/D3-GameServer/ClientSystem/ClientManager.cs @@ -1,28 +1,28 @@ -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Extensions; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Logging; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.GameSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.PlayerSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Act; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Connection; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Game; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Misc; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Portal; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.LoginServer.Toons; -//Blizzless Project 2022 +//Blizzless Project 2022 using System; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Linq; namespace DiIiS_NA.GameServer.ClientSystem @@ -92,7 +92,7 @@ namespace DiIiS_NA.GameServer.ClientSystem }*/ // Set references between MooNetClient and GameClient. - if (//Mooege.Net.MooNet.Config.Instance.Enabled && + if (//Mooege.Net.MooNet.Config.Instance.Enabled && toon.GameAccount.LoggedInClient != null) { client.BnetClient = toon.GameAccount.LoggedInClient; @@ -134,10 +134,14 @@ namespace DiIiS_NA.GameServer.ClientSystem }); if (client.Player.PlayerIndex > 0) + { + //make sure toons Difficulty is set + toon.CurrentDifficulty = (uint)game.Difficulty; client.SendMessage(new HandicapMessage(Opcodes.HandicapMessage) { Difficulty = (uint)game.Difficulty }); + } toon.LoginTime = DateTimeExtensions.ToUnixTime(DateTime.UtcNow); @@ -145,7 +149,7 @@ namespace DiIiS_NA.GameServer.ClientSystem game.Enter(client.Player); - + } } diff --git a/src/DiIiS-NA/D3-GameServer/ClientSystem/GameServer.cs b/src/DiIiS-NA/D3-GameServer/ClientSystem/GameServer.cs index d88ac0e..d7f495c 100644 --- a/src/DiIiS-NA/D3-GameServer/ClientSystem/GameServer.cs +++ b/src/DiIiS-NA/D3-GameServer/ClientSystem/GameServer.cs @@ -1,4 +1,5 @@ //Blizzless Project 2022 +using DiIiS_NA.Core.Discord; using DiIiS_NA.Core.Logging; //Blizzless Project 2022 using DiIiS_NA.GameServer.ClientSystem.Base; @@ -24,7 +25,7 @@ namespace DiIiS_NA.GameServer.ClientSystem public static GSBackend GSBackend { get; set; } public static int MaintenanceTime = -1; - + public Bot DiscordBot { get; set; } public GameServer() { this.OnConnect += ClientManager.Instance.OnConnect; diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Implementations/Banner.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Implementations/Banner.cs index dd1daf5..9603b1d 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Implementations/Banner.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Implementations/Banner.cs @@ -1,15 +1,15 @@ -//Blizzless Project 2022 +//Blizzless Project 2022 using System; using System.Collections.Generic; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Linq; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.MapSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.Core.Types.TagMap; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.PlayerSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.World; using DiIiS_NA.D3_GameServer.Core.Types.SNO; @@ -70,6 +70,12 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations return; } + //if banner has been disabled for events like active greater active swarm /advocaite + if(!player.Attributes[GameAttributeB.Banner_Usable]) + { + return; + } + player.ShowConfirmation(this.DynamicID(player), (() => { player.StartCasting(150, new Action(() => { if (banner_player.PlayerDirectBanner == null) diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/ConversationManager.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/ConversationManager.cs index d7f94cf..78d10d5 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/ConversationManager.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/ConversationManager.cs @@ -1,60 +1,60 @@ -//Blizzless Project 2022 +//Blizzless Project 2022 using System; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Collections.Generic; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Linq; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Threading.Tasks; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Logging; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Helpers.Math; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Storage.AccountDataBase.Entities; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.MPQ; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.MPQ.FileFormats; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.Core.Types.SNO; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ItemsSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Inventory; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.ACD; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Artisan; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Misc; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ObjectsSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.Core; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Fields; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Effect; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.ClientSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Base; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.PowerSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.Core.Types.Math; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Conversation; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Collections.Concurrent; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Quest; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Platinum; using DiIiS_NA.D3_GameServer.Core.Types.SNO; @@ -399,8 +399,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem Field1 = 0 }); //RiftEndScreenInfoBlobMessage - 524 - - + + plr.InGameClient.SendMessage(new GenericBlobMessage(Opcodes.RiftEndScreenInfoBlobMessage) { Data = D3.GameMessage.RiftEndScreenInfo.CreateBuilder() @@ -414,7 +414,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem .SetCompletionTimeMs(900 * 1000 - plr.InGameClient.Game.LastTieredRiftTimeout * 1000) .SetBannerConfiguration(plr.Toon.GameAccount.BannerConfigurationField.Value) .Build().ToByteArray() - + }); player.InGameClient.SendMessage(new PlatinumAwardedMessage @@ -470,10 +470,10 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem { player.GrantCriteria(74987250579270); if(player.InGameClient.Game.Difficulty >= 3) - player.GrantCriteria(74987247265988); + player.GrantCriteria(74987247265988); } } - //Таймер до закрытия + //Таймер до закрытия /* plr.InGameClient.SendMessage(new DungeonFinderClosingMessage() { @@ -499,7 +499,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem this.player.InGameClient.Game.ActiveNephalemPortal = false; this.player.InGameClient.Game.ActiveNephalemTimer = false; this.player.InGameClient.Game.ActiveNephalemProgress = 0; - + //Enabled banner /advocaite + this.player.Attributes[GameAttributeB.Banner_Usable] = true; var HubWorld = this.player.InGameClient.Game.GetWorld(WorldSno.x1_tristram_adventure_mode_hub); var NStone = HubWorld.GetActorBySNO(ActorSno._x1_openworld_lootrunobelisk_b); bool Activated = true; @@ -582,11 +583,11 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem Gender = (player.Toon.Gender == 0) ? VoiceGender.Male : VoiceGender.Female, TextClass = currentLineNode.LineSpeaker == Speaker.Player ? (GameBalance.Class)player.Toon.VoiceClassID : GameBalance.Class.None, SNOSpeakerActor = (int)GetSpeaker(currentLineNode.LineSpeaker).SNO, - LineFlags = 0x00000000, + LineFlags = 0x00000000, AnimationTag = currentLineNode.AnimationTag, Duration = duration, Id = currentUniqueLineID, - Priority = 0x00000000 + Priority = 0x00000000 }, Duration = duration, });//, true); @@ -650,7 +651,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem { case 198199: //Task.Delay(1000).Wait(); - + break; } #endregion @@ -740,7 +741,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem var LeoricGhost = player.World.GetActorBySNO(ActorSno._skeletonking_leoricghost); var LachdananGhost = player.World.GetActorBySNO(ActorSno._ghostknight3); var SwordPlace = player.World.GetActorBySNO(ActorSno._trdun_crypt_deathoftheking_sword_clickable); - + LachdananGhost.Move(SwordPlace.Position, ActorSystem.Movement.MovementHelpers.GetFacingAngle(LachdananGhost, SwordPlace.Position)); var ListenerA1Q4Event1 = Task.Delay(4000).ContinueWith(delegate diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs index 49fa3e6..42116df 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs @@ -1,121 +1,121 @@ -//Blizzless Project 2022 +//Blizzless Project 2022 using System; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Collections.Generic; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Linq; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Logging; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.LoginServer.Toons; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.ClientSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ObjectsSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using GameBalance = DiIiS_NA.Core.MPQ.FileFormats.GameBalance; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Storage; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.MapSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Threading; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Storage.AccountDataBase.Entities; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Extensions; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.Core.Types.Math; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Fields; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.ACD; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Text; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Player; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Skill; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Misc; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.World; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.MPQ; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.Core.Types.SNO; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Quest; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Base; -//Blizzless Project 2022 -using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Effect; -//Blizzless Project 2022 +//Blizzless Project 2022 +using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Effect; +//Blizzless Project 2022 using DiIiS_NA.LoginServer.AccountsSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Drawing; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.TickerSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.SkillsSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.Core.Types.TagMap; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.PowerSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.AISystem.Brains; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ItemsSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Fields.BlizzLess.Net.GS.Message.Fields; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.GameSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using Google.ProtocolBuffers; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Animation; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Waypoint; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Trade; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Inventory; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Helpers.Math; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Connection; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Artisan; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Portal; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Camera; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Minions; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Pet; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Game; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Combat; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Hireling; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Helpers.Hash; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Encounter; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.UI; using DiIiS_NA.D3_GameServer.Core.Types.SNO; @@ -412,6 +412,11 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem else this.Attributes[GameAttribute.TeamID] = 2; + //make sure if greater is not active enable banner. + if (!this.World.Game.NephalemGreater) + { + this.Attributes[GameAttributeB.Banner_Usable] = true; + } SetAllStatsInCorrectOrder(); // Enabled stone of recall if (!this.World.Game.PvP & this.Toon.StoneOfPortal) @@ -467,7 +472,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem Attributes[GameAttribute.Buff_Icon_Count0, 0x0006B48E] = 1; Attributes[GameAttribute.Buff_Icon_Count0, 0x0004601B] = 1; Attributes[GameAttribute.Buff_Icon_Count0, 0x00033C40] = 1; - + Attributes[GameAttribute.Currencies_Discovered] = 0x0011FFF8; this.Attributes[GameAttribute.Skill, 30592] = 1; @@ -1256,7 +1261,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem break; } - SetAttributesSkillSets(); //reapply synergy passives (laws, mantras, summons) + SetAttributesSkillSets(); //reapply synergy passives (laws, mantras, summons) } public void SetAttributesSkillSets() @@ -1567,7 +1572,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem //Type - 0 - Новое свойство //Type - 1 - Преобразование - //Type - 2 - + //Type - 2 - if (ItemPortalToCows != null) { @@ -1650,7 +1655,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem NewTagMap.Add(new TagKeySNO(526853), new TagMapEntry(526853, 288482, 0)); //Зона NewTagMap.Add(new TagKeySNO(526851), new TagMapEntry(526851, 172, 0)); //Точка входа this.InGameClient.Game.WorldOfPortalNephalem = map; - + while (true) { map = Maps[RandomHelper.Next(0, Maps.Length)]; @@ -1822,7 +1827,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem this.InGameClient.Game.ActiveNephalemPortal = true; this.InGameClient.Game.NephalemGreater = true; - + //disable banner while greater is active enable once boss is killed or portal is closed /advocaite + this.Attributes[GameAttributeB.Banner_Usable] = false; map = Maps[RandomHelper.Next(0, Maps.Length)]; NewTagMap.Add(new TagKeySNO(526850), new TagMapEntry(526850, (int)map, 0)); //Мир NewTagMap.Add(new TagKeySNO(526853), new TagMapEntry(526853, 288482, 0)); //Зона @@ -1971,7 +1977,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem private void OnTutorialShown(GameClient client, TutorialShownMessage message) { - + // Server has to save what tutorials are shown, so the player // does not have to see them over and over... int index = ItemGenerator.Tutorials.IndexOf(message.SNOTutorial); @@ -2143,7 +2149,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem this.World.BuffManager.AddBuff(this, this, new PowerSystem.Implementations.P6_Necro_Frailty_Aura()); else this.World.BuffManager.RemoveBuffs(this, 473992); - + //_StartSkillCooldown((cooldownskill as ActiveSkillSavedData).snoSkill, SkillChangeCooldownLength); } @@ -2187,7 +2193,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem this.SetAttributesByPassives(); this.SetAttributesByParagon(); this.SetAttributesSkillSets(); - this.Inventory.CheckWeapons(); //Handles removal of Heavenly Strength + this.Inventory.CheckWeapons(); //Handles removal of Heavenly Strength this.Attributes.BroadcastChangedIfRevealed(); this.UpdateHeroState(); UpdatePercentageHP(PercHPbeforeChange); @@ -2277,14 +2283,14 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem #if DEBUG Logger.Warn("OnTargetedActor ID: {0}, Name: {1}, NumInWorld: {2}", actor.SNO, actor.Name, actor.NumberInWorld); #else - + #endif if ((actor.GBHandle.Type == 1) && (actor.Attributes[GameAttribute.TeamID] == 10)) { this.ExpBonusData.MonsterAttacked(this.InGameClient.Game.TickCounter); } actor.OnTargeted(this, message); - + } @@ -2308,8 +2314,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem { this.Attributes.BroadcastChangedIfRevealed(); var a = this.GetActorsInRange(15f); - - #region + + #region //UpdateExp(5000000); /* this.Attributes[GameAttribute.Jewel_Upgrades_Max] = 3; @@ -2709,7 +2715,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem { int AnimByLevel = 0; int IdleByLevel = 0; - + if (this.ArtisanInteraction == "Blacksmith") { if (blacksmith_data.Level > 55) return; @@ -2773,8 +2779,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem client.SendMessage(new CrafterLevelUpMessage { Type = 0, - AnimTag = AnimByLevel, - NewIdle = IdleByLevel, + AnimTag = AnimByLevel, + NewIdle = IdleByLevel, Level = blacksmith_data.Level }); @@ -2814,7 +2820,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem this.GrantCriteria(74987245845978); } if (jeweler_data.Level == 12) - { + { this.GrantAchievement(74987257153995); if (blacksmith_data.Level == 12 && mystic_data.Level == 12) { @@ -2911,7 +2917,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem } this.LoadCrafterData(); - + /**/ } public void UnlockTransmog(int transmogGBID) @@ -3141,7 +3147,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem ActiveSkeletons = switchertobool; EnableGolem = switchertoboolTwo; - + PowerContext Killer = new PowerContext(); Killer.User = this; @@ -3319,7 +3325,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem int Rune_C = this.Attributes[GameAttribute.Rune_C, PowerSNO]; int Rune_D = this.Attributes[GameAttribute.Rune_D, PowerSNO]; int Rune_E = this.Attributes[GameAttribute.Rune_E, PowerSNO]; - + if (Rune_A > 0) return runeA; else if (Rune_B > 0) return runeB; else if (Rune_C > 0) return runeC; @@ -3396,7 +3402,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem (actor as Portal).Destination.WorldSNO = (int)WorldSno.x1_tristram_adventure_mode_hub; (actor as Portal).Destination.StartingPointActorTag = 483; } - + if (actor.ActorType != ActorType.ClientEffect && actor.ActorType != ActorType.AxeSymbol && actor.ActorType != ActorType.CustomBrain) { actor.Reveal(this); @@ -3407,7 +3413,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem { if ((actor is Player && (!this.World.IsPvP || actor == this)) || actors_around.Contains(actor)) // if the actors is already revealed, skip it. continue; - + actor.Unreveal(this); } } @@ -3470,14 +3476,14 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem public override void OnEnter(World world) { - + world.Reveal(this); this.Unreveal(this); if (this._CurrentHPValue == -1f) this.DefaultQueryProximityRadius = 60; - + this.InGameClient.SendMessage(new EnterWorldMessage() { EnterPosition = this.Position, @@ -3687,7 +3693,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem } this.World.Game.QuestManager.SetBountyMarker(this); - + //System.Threading.Tasks.Task.Delay(1000).ContinueWith(a => {this.BetweenWorlds = false;}); } @@ -4033,7 +4039,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem private PlayerSavedData GetSavedData() { var item = StringHashHelper.HashItemName("HealthPotionBottomless"); - + return new PlayerSavedData() { HotBarButtons = this.SkillSet.HotBarSkills, @@ -4060,7 +4066,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem ActiveSkills = this.SkillSet.ActiveSkills, snoTraits = this.SkillSet.PassiveSkills, GBIDLegendaryPowers = new int[4] { -1, -1, -1, -1 }, - + SavePointData = new SavePointData { snoWorld = -1, SavepointId = -1, }, EventFlags = 0 }; @@ -4325,7 +4331,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem Logger.Trace("Learning recipe #{0}, Artisan type: {1}", recipe, artisan); /*var query = this.World.Game.GameDBSession.SessionQuerySingle( dbi => - dbi.DBGameAccount.Id == this.Toon.GameAccount.PersistentID && + dbi.DBGameAccount.Id == this.Toon.GameAccount.PersistentID && dbi.Artisan == artisan && dbi.isHardcore == this.World.Game.IsHardcore);*/ if (artisan == "Blacksmith") @@ -4399,7 +4405,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem .SetLevel(this.InGameClient.Game.CurrentAct == 3000 ? this.MysticUnlocked == false && mystic_data.Level < 1 ? 1 : mystic_data.Level : mystic_data.Level) .SetCooldownEnd(0) .Build(); - + D3.ItemCrafting.CrafterSavedData transmog = D3.ItemCrafting.CrafterSavedData.CreateBuilder() .SetTransmogData(D3.GameBalance.BitPackedGbidArray.CreateBuilder().SetBitfield(ByteString.CopyFrom(mystic_data.LearnedRecipes))) //.AddRangeUnlockedTransmogs(this.UnserializeBytes(mystic_data.LearnedRecipes)) @@ -4408,10 +4414,10 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem if (this.BlacksmithUnlocked || this.InGameClient.Game.CurrentAct == 3000) this.InGameClient.SendMessage(new GenericBlobMessage(Opcodes.CraftingDataBlacksmithInitialMessage) { Data = blacksmith.ToByteArray() }); - + if (this.JewelerUnlocked || this.InGameClient.Game.CurrentAct == 3000) this.InGameClient.SendMessage(new GenericBlobMessage(Opcodes.CraftingDataJewelerInitialMessage) { Data = jeweler.ToByteArray() }); - + if (this.MysticUnlocked || this.InGameClient.Game.CurrentAct == 3000) { this.InGameClient.SendMessage(new GenericBlobMessage(Opcodes.CraftingDataMysticInitialMessage) { Data = mystic.ToByteArray() }); @@ -4430,7 +4436,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem this.Inventory.UpdateCurrencies(); } - + public void LoadMailData() { List mail_data = this.World.Game.GameDBSession.SessionQueryWhere(dbm => dbm.DBToon.Id == this.Toon.PersistentID && dbm.Claimed == false); @@ -4539,7 +4545,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem this.Inventory.UpdateCurrencies(); } ClientSystem.GameServer.GSBackend.GrantAchievement(this.Toon.GameAccount.PersistentID, id); - + } catch (Exception e) { @@ -5087,7 +5093,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem PlayerIndex = this.PlayerIndex, Level = this.Level }); - + //Test Update Monster Level if (this.PlayerIndex == 0) @@ -5337,7 +5343,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem else if (item.ItemDefinition.Name == "Platinum") { - + this.InGameClient.SendMessage(new FloatingAmountMessage() { Place = new WorldPlace() @@ -5486,7 +5492,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem }); } - + plr.InGameClient.SendMessage(new PlayMusicMessage(Opcodes.PlayMusicMessage) { SNO = 0x0005BBD8 @@ -5818,7 +5824,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem GeneratePrimaryResource(Math.Max(tickSeconds * this.Attributes[GameAttribute.Resource_Regen_Total, this.Attributes[GameAttribute.Resource_Type_Primary] - 1], 0)); GenerateSecondaryResource(Math.Max(tickSeconds * this.Attributes[GameAttribute.Resource_Regen_Total, this.Attributes[GameAttribute.Resource_Type_Secondary] - 1], 0)); - float totalHPregen = //(this.Attributes[GameAttribute.Hitpoints_Regen_Per_Second] + + float totalHPregen = //(this.Attributes[GameAttribute.Hitpoints_Regen_Per_Second] + this.Attributes[GameAttribute.Hitpoints_Regen_Per_Second_Bonus]//) * (1 + this.Attributes[GameAttribute.Hitpoints_Regen_Bonus_Percent]); if (!this.Dead && !this.World.Game.PvP) AddHP(Math.Max(tickSeconds * totalHPregen, 0)); @@ -5923,7 +5929,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem minion.Attributes[GameAttribute.Pet_Creator] = 1; minion.Attributes[GameAttribute.Pet_Owner] = 1; minion.Attributes[GameAttribute.Pet_Type] = 25; - + //*/ minion.Attributes[GameAttribute.Effect_Owner_ANN] = (int)this.DynamicID(this); minion.EnterWorld(minion.Position); diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/DeathPayload.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/DeathPayload.cs index 11f24a6..e95812e 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/DeathPayload.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Payloads/DeathPayload.cs @@ -1,60 +1,60 @@ -//Blizzless Project 2022 +//Blizzless Project 2022 using System; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Collections.Generic; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Linq; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Text; -//Blizzless Project 2022 +//Blizzless Project 2022 using System.Threading.Tasks; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Logging; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Misc; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Animation; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.PlayerSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Effect; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Combat; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.Core.Helpers.Math; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.LoginServer.Toons; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.Core.Types.TagMap; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.GeneratorsSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ItemsSystem; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Minions; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Player; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.ACD; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Base; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Text; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Quest; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.World; -//Blizzless Project 2022 +//Blizzless Project 2022 using DiIiS_NA.GameServer.MessageSystem.Message.Fields; using DiIiS_NA.D3_GameServer.Core.Types.SNO; @@ -199,7 +199,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads if (this.Target is Monster) { - + Monster mon = (Monster)this.Target; if (mon.Brain != null) mon.Brain.Kill(); @@ -246,7 +246,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads ActorId = this.Target.DynamicID(plr), Effect = Effect.Unknown12, }, this.Target); - + this.Target.World.BroadcastIfRevealed(plr => new ANNDataMessage(Opcodes.PlayIdleAnimationMessage) { ActorID = this.Target.DynamicID(plr) @@ -281,7 +281,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads } break; } - + this.Target.World.BroadcastIfRevealed(plr => new ANNDataMessage(Opcodes.CancelACDTargetMessage) { ActorID = this.Target.DynamicID(plr), @@ -295,7 +295,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads this.Target.Attributes[GameAttribute.Deleted_On_Server] = true; this.Target.Attributes[GameAttribute.Could_Have_Ragdolled] = true; this.Target.Attributes.BroadcastChangedIfRevealed(); - + this.Target.World.BroadcastIfRevealed(plr => new DeathFadeTimeMessage() { Field0 = this.Target.DynamicID(plr), @@ -303,7 +303,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads Field2 = 200, Field3 = true }, this.Target); - + if (this.Context != null) if (this.Context.User.Attributes[GameAttribute.Item_Power_Passive, 247640] == 1 || this.Context.User.Attributes[GameAttribute.Item_Power_Passive, 249963] == 1 || @@ -334,7 +334,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads //(this.Context.User as Player).Attributes[_Buff_Icon_End_TickN, PowerSNO] } } - + if (this.Target.SNO == ActorSno._a4dun_garden_corruption_monster) //Сады надежды { @@ -569,7 +569,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads } Logger.Trace("Killed monster, id: {0}, level {1}", this.Target.SNO, this.Target.Attributes[GameAttribute.Level]); - + //handling quest triggers if (this.Target.World.Game.QuestProgress.QuestTriggers.ContainsKey((int)this.Target.SNO)) { @@ -613,9 +613,9 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads { if (plr.PlayerIndex == 0) Master = plr; - plr.InGameClient.SendMessage(new SimpleMessage(Opcodes.KillCounterRefresh) + plr.InGameClient.SendMessage(new SimpleMessage(Opcodes.KillCounterRefresh) { - + }); plr.InGameClient.SendMessage(new FloatDataMessage(Opcodes.DungeonFinderProgressMessage) @@ -623,7 +623,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads Field0 = this.Target.World.Game.ActiveNephalemProgress }); - + if (this.Target.World.Game.ActiveNephalemProgress > 650) { @@ -710,7 +710,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads this.Target.World.Game.ActiveNephalemKilledBoss = true; foreach (var plr in this.Target.World.Game.Players.Values) { - + //Enable banner /advocaite + plr.Attributes[GameAttributeB.Banner_Usable] = true; if (this.Target.World.Game.NephalemGreater) { plr.InGameClient.SendMessage(new QuestCounterMessage() @@ -762,7 +763,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads NewTagMap.Add(new TagKeySNO(526850), new TagMapEntry(526850, 332336, 0)); //Мир NewTagMap.Add(new TagKeySNO(526853), new TagMapEntry(526853, 332339, 0)); //Зона NewTagMap.Add(new TagKeySNO(526851), new TagMapEntry(526851, 24, 0)); //Точка входа - + var portal = new Portal(this.Target.World, ActorSno._x1_openworld_lootrunportal, NewTagMap); portal.EnterWorld(new Core.Types.Math.Vector3D(this.Target.Position.X + 10f, this.Target.Position.Y + 10f, this.Target.Position.Z)); @@ -1007,8 +1008,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads //114917 if (this.Target.Quality == 7 || this.Target.Quality == 2 || this.Target.Quality == 4) - { - + { + } if (this.Target is Boss) @@ -1146,7 +1147,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads { var tomb = new Headstone(this.Target.World, ActorSno._playerheadstone, new TagMap(), player.PlayerIndex); tomb.EnterWorld(player.Position); - + player.Inventory.DecreaseDurability(0.1f); if (player.World.Game.IsHardcore) { diff --git a/src/DiIiS-NA/Program.cs b/src/DiIiS-NA/Program.cs index 95390be..55faf82 100644 --- a/src/DiIiS-NA/Program.cs +++ b/src/DiIiS-NA/Program.cs @@ -1,5 +1,6 @@ //Blizzless Project 2022 //Blizzless Project 2022 +using DiIiS_NA.Core.Discord.Modules; using DiIiS_NA.Core.Logging; //Blizzless Project 2022 using DiIiS_NA.Core.MPQ; @@ -165,6 +166,7 @@ namespace DiIiS_NA Logger.Info("REST server started - " + REST.Config.Instance.IP + ":{0}", REST.Config.Instance.PORT); } + //BGS ServerBootstrap b = new ServerBootstrap(); IEventLoopGroup boss = new MultithreadEventLoopGroup(1); @@ -269,7 +271,16 @@ namespace DiIiS_NA GameServer = new DiIiS_NA.GameServer.ClientSystem.GameServer(); GameServerThread = new Thread(GameServer.Run) { Name = "GameServerThread", IsBackground = true }; GameServerThread.Start(); - + if (DiIiS_NA.Core.Discord.Config.Instance.Enabled) + { + Logger.Info("Starting Discord bot handler.."); + GameServer.DiscordBot = new Core.Discord.Bot(); + GameServer.DiscordBot.MainAsync().GetAwaiter().GetResult(); + } + else + { + Logger.Info("Discord bot Disabled.."); + } DiIiS_NA.GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.RegenerateDensity(); DiIiS_NA.GameServer.ClientSystem.GameServer.GSBackend = new GSBackend(DiIiS_NA.LoginServer.Config.Instance.BindIP, DiIiS_NA.LoginServer.Config.Instance.WebPort); return true; diff --git a/src/DiIiS-NA/config.ini b/src/DiIiS-NA/config.ini new file mode 100644 index 0000000..ca3d80a --- /dev/null +++ b/src/DiIiS-NA/config.ini @@ -0,0 +1,153 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; ; +; blizzless Configuration File ; +; ; +;-----------------------------------------------------------------------------------------------------------------; +; ; +; This file is an example configuration and may require modification to suit your needs. ; +; ; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Settings for Bnet +[Battle-Server] +Enabled = true +BindIP = 127.0.0.1 +WebPort = 9800 +Port = 1119 +BindIPv6 = ::1 +MOTD = Welcome to Diablo 3! + +[IWServer] +IWServer = false + +; Settings for REST +[REST] +IP = 127.0.0.1 +Public = true +PublicIP = 127.0.0.1 +PORT = 8081 + +; Settings for game +[Game-Server] +Enabled = true +CoreActive = true +BindIP = 127.0.0.1 +WebPort = 9100 +Port = 2001 +BindIPv6 = ::1 +DRLGemu = true +;Modding of game +RateExp = 1 +RateMoney = 1 +RateDrop = 1 +RateChangeDrop = 1 +RateMonsterHP = 1 +RateMonsterDMG = 1 + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Authentication settings +[Authentication] +DisablePasswordChecks=true + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Discord bot settings +[Discord] +Enabled=true +MonitorEnabled=false +Token=sectret token +GuildId=0 +AnnounceChannelId=0 +StatsChannelId=0 +EventsChannelId=0 +BaseRoleId=0 +PremiumRoleId=0 +CollectorRoleId=0 + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; You can set here the command-prefix. Note: You can't use slash as a prefix. +[Commands] +CommandPrefix = ! + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Networking settings. +[Networking] +EnableIPv6 = false ; experimental!! + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; Network address translation settings. +; You only need to change this if you're running behind a dsl router or so. +; Important: If you enable NAT, LAN-clients will not able to connect in gs. +; (Will be fixed later with a proper implementation similar to one in pvpgn). +[NAT] +Enabled = false +PublicIP = 101.185.137.121 ; You need to change this to your router's public interface IP if you'd like to use NAT. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; General logging settings +[Logging] +Root=logs + +; Settings for console logger +[ConsoleLog] +Enabled=true +Target=Console +IncludeTimeStamps=true +MinimumLevel=Trace +MaximumLevel=Fatal + +; Settings for server log file. +[ServerLog] +Enabled=true +Target=File +FileName="blizzless.log" +IncludeTimeStamps=true +MinimumLevel=Trace +MaximumLevel=Fatal +ResetOnStartup=true + +; Settings for chat log file. +[ChatLog] +Enabled=true +Target=File +FileName="blizzless-chat.log" +IncludeTimeStamps=true +MinimumLevel=ChatMessage +MaximumLevel=ChatMessage +ResetOnStartup=true + +; Settings for discord log file. +[DiscordLog] +Enabled=false +Target=File +FileName="discord-bot.log" +IncludeTimeStamps=true +MinimumLevel=BotCommand +MaximumLevel=BotCommand +ResetOnStartup=true + +; Settings for renames log file. +[RenameAccountLog] +Enabled=true +Target=File +FileName="blizzless-btag-rename.log" +IncludeTimeStamps=true +MinimumLevel=RenameAccountLog +MaximumLevel=RenameAccountLog +ResetOnStartup=true + +; Settings for packet logger, only recommended for developers! +[PacketLog] +Enabled=true +Target=File +FileName="packet-dump.log" +IncludeTimeStamps=true +MinimumLevel=PacketDump +MaximumLevel=PacketDump +ResetOnStartup=true diff --git a/src/DiIiSNet/BZNET.csproj b/src/DiIiSNet/BZNET.csproj index cc1ad99..36800f1 100644 --- a/src/DiIiSNet/BZNET.csproj +++ b/src/DiIiSNet/BZNET.csproj @@ -2,6 +2,7 @@ net5.0 + Debug;Release;github