Merge remote-tracking branch 'origin/community' into community

# Conflicts:
#	src/DiIiS-NA/D3-GameServer/GSSystem/PowerSystem/Implementations/HeroSkills/Necromancer.cs
This commit is contained in:
Lucca Faria Ferri 2023-01-29 18:34:23 -08:00
commit eeb49270f5
61 changed files with 566 additions and 583 deletions

View File

@ -33,7 +33,35 @@ RateDrop = 1
RateChangeDrop = 1
RateMonsterHP = 1
RateMonsterDMG = 1
ChanceHighQualityUnidentified = 30
ChanceNormalUnidentified = 5
ResurrectionCharges = 3
[NAT]
Enabled = False
PublicIP = 127.0.0.1
; Use Ansi Log if you want a cleaner log view, otherwise, use ConsoleLog, which keeps the screen logs.
[ConsoleLog]
Enabled = false
Target = Console
IncludeTimeStamps = true
MinimumLevel = Debug
MaximumLevel = Fatal
; Ansi Log - enabled by default - useful if you're not in a hard-debug mode. It's easier to view logs.
[AnsiLog]
Enabled = true
Target = Ansi
IncludeTimeStamps = true
MinimumLevel = Info
MaximumLevel = Fatal
; dumps everything from Debug to PacketDump (packet logs) to a file
[PacketLog]
Enabled = true
Target = file
FileName = packet.log
IncludeTimeStamps = true
MinimumLevel = Debug
MaximumLevel = PacketDump

View File

@ -14,6 +14,9 @@ RateDrop = 1
RateChangeDrop = 1
RateMonsterHP = 1
RateMonsterDMG = 1
ChanceHighQualityUnidentified = 30
ChanceNormalUnidentified = 5
ResurrectionCharges = 3
```
## Description
@ -26,4 +29,7 @@ RateMonsterDMG = 1
| `RateChangeDrop` | Drop quality multiplier |
| `RateMonsterHP` | Monsters HP multiplier |
| `RateMonsterDMG` | Monster damage multiplier |
| `ChanceHighQualityUnidentified` | Percentage that a unique, legendary, set or special item created is unidentified |
| `ChanceNormalUnidentified` | Percentage that normal item created is unidentified |
| `ResurrectionCharges` | Amount of times user can resurrect at corpse |

View File

@ -85,7 +85,7 @@ namespace DiIiS_NA.LoginServer.AccountsSystem
public static Account GetAccountByDiscordId(ulong discordId)
{
List<DBAccount> dbAcc = DBSessions.SessionQueryWhere<DBAccount>(dba => dba.DiscordId == discordId).ToList();
if (dbAcc.Count() == 0)
if (!dbAcc.Any())
{
Logger.Warn("GetAccountByDiscordId {0}: DBAccount is null!", discordId);
return null;

View File

@ -1197,7 +1197,7 @@ public class GameAccount : PersistentRPCObject
public uint AchievementPoints
{
get { return (uint)Achievements.Where(a => a.Completion != -1).Count() * 10U; }
get { return (uint)Achievements.Count(a => a.Completion != -1) * 10U; }
}
public bool IsLoggedIn { get; set; }

View File

@ -1,4 +1,6 @@
//Blizzless Project 2022
using System;
using DiIiS_NA.Core.Logging;
using DiIiS_NA.Core.Storage;
using DiIiS_NA.Core.Storage.AccountDataBase.Entities;
@ -14,10 +16,7 @@ namespace DiIiS_NA.LoginServer.AccountsSystem
public static readonly ConcurrentDictionary<ulong, GameAccount> LoadedGameAccounts = new();
public static int TotalAccounts
{
get { return DBSessions.SessionQuery<DBGameAccount>().Count(); }
}
public static int TotalAccounts => DBSessions.SessionQuery<DBGameAccount>().Count;
public static void PreLoadGameAccounts()
{
@ -170,7 +169,7 @@ namespace DiIiS_NA.LoginServer.AccountsSystem
crafting.DBGameAccount = dbGAcc;
crafting.isHardcore = hardcore;
crafting.isSeasoned = seasoned;
crafting.LearnedRecipes = new byte[0];
crafting.LearnedRecipes = Array.Empty<byte>();
crafting.Level = 1;
DBSessions.SessionSave(crafting);
}

View File

@ -70,7 +70,7 @@ namespace DiIiS_NA.LoginServer.FriendsSystem
Logger.MethodTrace($": owner {owner.PersistentID}, target {target.PersistentID}");
try
{
if (DBSessions.SessionQueryWhere<DBAccountLists>(dbl => dbl.ListOwner.Id == owner.PersistentID && dbl.ListTarget.Id == target.PersistentID && dbl.Type == "IGNORE").Count() > 0) return;
if (DBSessions.SessionQueryWhere<DBAccountLists>(dbl => dbl.ListOwner.Id == owner.PersistentID && dbl.ListTarget.Id == target.PersistentID && dbl.Type == "IGNORE").Any()) return;
var blockRecord = new DBAccountLists
{

View File

@ -7,6 +7,7 @@ using DiIiS_NA.LoginServer.ChannelSystem;
using System;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.LoginServer.GamesSystem
{
@ -19,7 +20,7 @@ namespace DiIiS_NA.LoginServer.GamesSystem
{
get
{
return GameCreators.Values.Where(game => game.PlayersCount > 0).Count();
return GameCreators.Values.Count(game => game.PlayersCount > 0);
}
set { }
}
@ -95,13 +96,12 @@ namespace DiIiS_NA.LoginServer.GamesSystem
GameDescriptor TagGame = null;
if (client.GameTeamTag != "") TagGame = FindTagGame(client.GameTeamTag);
var rand = new Random();
GameDescriptor gameDescriptor = null;
if(TagGame != null)
gameDescriptor = TagGame;
else if (request_type == "find" && matchingGames.Count > 0)
gameDescriptor = matchingGames[rand.Next(matchingGames.Count)];
gameDescriptor = matchingGames.PickRandom();
else
gameDescriptor = CreateGame(client, request.Options, requestId);

View File

@ -263,7 +263,7 @@ namespace DiIiS_NA.LoginServer.Toons
CurrentQuestId = 87700,
CurrentQuestStepId = -1,
CurrentDifficulty = 0,
Lore = new byte[0],
Lore = Array.Empty<byte>(),
Stats = "0;0;0;0;0;0",
DBGameAccount = dbGameAccount,
Cosmetic1 = -1,
@ -424,7 +424,7 @@ namespace DiIiS_NA.LoginServer.Toons
DBGameAccount = gaccount,
TimePlayed = 0,
Stats = "",
Lore = new byte[0],
Lore = Array.Empty<byte>(),
Deleted = false,
Archieved = false,
Cosmetic1 = -1,

View File

@ -9,6 +9,7 @@ using Discord;
using Discord.Commands;
using Discord.WebSocket;
using DiIiS_NA.Core.Discord.Services;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.LoginServer.AccountsSystem;
using DiIiS_NA.Core.Logging;
using DiIiS_NA.Core.Storage;
@ -224,10 +225,10 @@ namespace DiIiS_NA.Core.Discord
{
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 contestants = reactedUsers.Where(u => !u.IsBot).ToArray();
if (contestants.TryPickRandom(out var winner))
{
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);

View File

@ -33,11 +33,11 @@ namespace DiIiS_NA.Core.Discord.Modules
}
if (registerInfo.Count() == 3)
if (registerInfo.Length == 3)
{
if (!email.Contains('@'))
{
await ReplyAsync($"<@{Context.User.Id}> " + string.Format("'{0}' is not a valid email address.", email));
await ReplyAsync($"<@{Context.User.Id}> " + $"'{email}' is not a valid email address.");
return;
}
if (!IsValid(email))

View File

@ -1,61 +1,70 @@
//Blizzless Project 2022
using System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using DiIiS_NA.Core.Helpers.Math;
namespace DiIiS_NA.Core.Extensions
namespace DiIiS_NA.Core.Extensions;
public static class EnumerableExtensions
{
public static class EnumerableExtensions
public static string HexDump(this IEnumerable<byte> collection)
{
public static string HexDump(this IEnumerable<byte> collection)
var sb = new StringBuilder();
foreach (byte value in collection)
{
var sb = new StringBuilder();
foreach (byte value in collection)
{
sb.Append(value.ToString("X2"));
sb.Append(' ');
}
if (sb.Length > 0)
sb.Remove(sb.Length - 1, 1);
return sb.ToString();
sb.Append(value.ToString("X2"));
sb.Append(' ');
}
if (sb.Length > 0)
sb.Remove(sb.Length - 1, 1);
return sb.ToString();
}
public static string ToEncodedString(this IEnumerable<byte> collection, Encoding encoding)
{
return encoding.GetString(collection.ToArray());
}
public static string ToEncodedString(this IEnumerable<byte> collection, Encoding encoding)
{
return encoding.GetString(collection.ToArray());
}
public static string Dump(this IEnumerable<byte> collection)
public static string Dump(this IEnumerable<byte> collection)
{
var output = new StringBuilder();
var hex = new StringBuilder();
var text = new StringBuilder();
int i = 0;
foreach (byte value in collection)
{
var output = new StringBuilder();
var hex = new StringBuilder();
var text = new StringBuilder();
int i = 0;
foreach (byte value in collection)
if (i > 0 && ((i % 16) == 0))
{
if (i > 0 && ((i % 16) == 0))
{
output.Append(hex);
output.Append(' ');
output.Append(text);
output.Append(Environment.NewLine);
hex.Clear(); text.Clear();
}
hex.Append(value.ToString("X2"));
hex.Append(' ');
text.Append(string.Format("{0}", (char.IsWhiteSpace((char)value) && (char)value != ' ') ? '.' : (char)value)); // prettify text
++i;
output.Append(hex);
output.Append(' ');
output.Append(text);
output.Append(Environment.NewLine);
hex.Clear(); text.Clear();
}
var hexstring = hex.ToString();
if (text.Length < 16)
{
hexstring = hexstring.PadRight(48); // pad the hex representation in-case it's smaller than a regular 16 value line.
}
output.Append(hexstring);
output.Append(' ');
output.Append(text);
return output.ToString();
hex.Append(value.ToString("X2"));
hex.Append(' ');
text.Append($"{((char.IsWhiteSpace((char)value) && (char)value != ' ') ? '.' : (char)value)}"); // prettify text
++i;
}
var hexstring = hex.ToString();
if (text.Length < 16)
{
hexstring = hexstring.PadRight(48); // pad the hex representation in-case it's smaller than a regular 16 value line.
}
output.Append(hexstring);
output.Append(' ');
output.Append(text);
return output.ToString();
}
public static TItem PickRandom<TItem>(this IEnumerable<TItem> source)
{
return RandomHelper.RandomItem(source);
}
public static bool TryPickRandom<TItem>(this IEnumerable<TItem> source, out TItem randomItem)
{
return RandomHelper.TryGetRandomItem(source, out randomItem);
}
}

View File

@ -1,112 +1,122 @@
//Blizzless Project 2022
using System;
using System;
using System.Linq;
using System.Collections.Generic;
using DiIiS_NA.Core.Logging;
namespace DiIiS_NA.Core.Helpers.Math
namespace DiIiS_NA.Core.Helpers.Math;
public static class RandomHelper
{
public class RandomHelper
private static readonly Random Random = new();
public static int Next()
{
private readonly static Random _random;
static RandomHelper()
{
_random = new Random();
}
public static int Next()
{
return _random.Next();
}
public static int Next(Int32 maxValue)
{
return _random.Next(maxValue);
}
public static int Next(Int32 minValue, Int32 maxValue)
{
return _random.Next(minValue, maxValue);
}
public static void NextBytes(byte[] buffer)
{
_random.NextBytes(buffer);
}
public static double NextDouble()
{
return _random.NextDouble();
}
/*IEnumerable<TValue>*/
public static TValue RandomValue<TKey, TValue>(IDictionary<TKey, TValue> dictionary)
{
List<TValue> values = Enumerable.ToList(dictionary.Values);
int size = dictionary.Count;
/*while (true)
{
yield return values[_random.Next(size)];
}*/
return values[_random.Next(size)];
}
/// <summary>
/// Picks a random item from a list
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list"></param>
/// <param name="probability">A function that assigns each item a probability. If the probabilities dont sum up to 1, they are normalized</param>
/// <returns></returns>
public static T RandomItem<T>(IEnumerable<T> list, Func<T, float> probability)
{
int cumulative = (int)list.Select(x => probability(x)).Sum();
int randomRoll = RandomHelper.Next(cumulative);
float cumulativePercentages = 0;
foreach (T element in list)
{
cumulativePercentages += probability(element);
if (cumulativePercentages > randomRoll)
return element;
}
return list.First();
}
return Random.Next();
}
public class ItemRandomHelper
public static int Next(int maxValue)
{
private static readonly Logger Logger = LogManager.CreateLogger("RH");
uint a;
uint b;
public ItemRandomHelper(int seed)
return Random.Next(maxValue);
}
public static int Next(int minValue, int maxValue)
{
return Random.Next(minValue, maxValue);
}
public static void NextBytes(byte[] buffer)
{
Random.NextBytes(buffer);
}
public static double NextDouble()
{
return Random.NextDouble();
}
public static T RandomItem<T>(IEnumerable<T> source)
{
var collection = source as IReadOnlyCollection<T> ?? source?.ToArray();
if (collection == null || collection.Count == 0)
{
a = (uint)seed;
b = 666;
throw new ArgumentException("Cannot be null or empty", nameof(source));
}
public void ReinitSeed()
var randomIndex = Next(collection.Count);
return collection.ElementAt(randomIndex);
}
public static bool TryGetRandomItem<T>(IEnumerable<T> source, out T randomItem)
{
var collection = source as IReadOnlyCollection<T> ?? source?.ToArray();
if (collection == null)
{
b = 666;
throw new ArgumentException("Cannot be null", nameof(source));
}
public uint Next()
if (collection.Count == 0)
{
ulong temp = 1791398085UL * (ulong)a + (ulong)b;
a = (uint)temp;
b = (uint)(temp >> 32);
//Logger.MethodTrace("a {0}, b {1}", a, b);
return (uint)a;
randomItem = default;
return false;
}
public float Next(float min, float max)
var randomIndex = Next(collection.Count);
randomItem = collection.ElementAt(randomIndex);
return true;
}
/// <summary>
/// Picks a random item from a list
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="probability">A function that assigns each item a probability. If the probabilities dont sum up to 1, they are normalized</param>
/// <returns></returns>
public static T RandomItem<T>(IEnumerable<T> source, Func<T, float> probability)
{
var collection = source as IReadOnlyCollection<T> ?? source.ToArray();
int cumulative = (int)collection.Select(probability).Sum();
int randomRoll = Next(cumulative);
float cumulativePercentages = 0;
foreach (T element in collection)
{
return min + (Next() % (uint)(max - min + 1));
cumulativePercentages += probability(element);
if (cumulativePercentages > randomRoll)
return element;
}
return collection.First();
}
}
public class ItemRandomHelper
{
uint _a;
uint _b;
public ItemRandomHelper(int seed)
{
_a = (uint)seed;
_b = 666;
}
public void ReinitSeed()
{
_b = 666;
}
public uint Next()
{
ulong temp = 1791398085UL * _a + _b;
_a = (uint)temp;
_b = (uint)(temp >> 32);
return _a;
}
public float Next(float min, float max)
{
return min + (Next() % (uint)(max - min + 1));
}
}

View File

@ -7,6 +7,7 @@ using DiIiS_NA.Core.MPQ.FileFormats.Types;
using DiIiS_NA.GameServer.Core.Types.TagMap;
using System.Linq;
using System;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.Core.Helpers.Math;
using DiIiS_NA.D3_GameServer.Core.Types.SNO;
@ -102,7 +103,9 @@ namespace DiIiS_NA.Core.MPQ.FileFormats
{
return AnimationSno._NONE;
}
return deathTags.Select(x => GetAniSNO(x)).Where(x => x != AnimationSno._NONE).OrderBy(x => RandomHelper.Next()).First();
var possibleDeaths = deathTags.Select(GetAniSNO).Where(x => x != AnimationSno._NONE);
return possibleDeaths.PickRandom();
}
}
public enum AnimationTags

View File

@ -178,7 +178,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
lock (client.ServiceLock)
{
Logger.MethodTrace($"id {achievementId}");
if (client.Account.GameAccount.Achievements.Where(a => a.AchievementId == achievementId && a.Completion != -1).Count() > 0) return;
if (client.Account.GameAccount.Achievements.Any(a => a.AchievementId == achievementId && a.Completion != -1)) return;
DBAchievements achievement = null;
var achs = DBSessions.SessionQueryWhere<DBAchievements>(dbi =>
dbi.DBGameAccount.Id == client.Account.GameAccount.PersistentID);
@ -195,7 +195,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
{
DBGameAccount = client.Account.GameAccount.DBGameAccount,
AchievementId = achievementId,
Criteria = new byte[0],
Criteria = Array.Empty<byte>(),
IsHardcore = IsHardcore(achievementId),
CompleteTime = (int)DateTime.Now.ToUnixTime()
};
@ -218,7 +218,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
if (IsHardcore(achievementId))
{
if (achs.Where(a => a.CompleteTime != -1 && a.IsHardcore == true).Count() >= 30) //31 in total
if (achs.Count(a => a.CompleteTime != -1 && a.IsHardcore) >= 30) //31 in total
{
var toons = DBSessions.SessionQueryWhere<DBToon>(dbt => dbt.DBGameAccount.Id == client.Account.GameAccount.PersistentID && dbt.isHardcore == true && dbt.Archieved == false);
}
@ -308,7 +308,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
}
var ach_data = _achievements.AchievementList.Single(a => a.Id == definition.ParentAchievementId);
if (!ach_data.HasSupersedingAchievementId || client.Account.GameAccount.Achievements.Where(a => a.AchievementId == ach_data.SupersedingAchievementId && a.Completion > 0).Count() > 0)
if (!ach_data.HasSupersedingAchievementId || client.Account.GameAccount.Achievements.Any(a => a.AchievementId == ach_data.SupersedingAchievementId && a.Completion > 0))
UpdateSnapshot(client, 0, criteriaId);
}
else
@ -380,14 +380,14 @@ namespace DiIiS_NA.GameServer.AchievementSystem
{
if (additionalQuantity == 0) return;
Logger.MethodTrace($"id {achievementId}");
if (client.Account.GameAccount.Achievements.Where(a => a.AchievementId == achievementId && a.Completion != -1).Count() > 0) return;
if (client.Account.GameAccount.Achievements.Any(a => a.AchievementId == achievementId && a.Completion != -1)) return;
ulong mainCriteriaId = GetMainCriteria(achievementId);
var aa = client.Account.GameAccount.AchievementCriteria;
D3.Achievements.CriteriaUpdateRecord mainCriteria;
lock (client.Account.GameAccount.AchievementCriteria)
{
mainCriteria = client.Account.GameAccount.AchievementCriteria.Where(c => c.CriteriaId32AndFlags8 == (uint)mainCriteriaId).FirstOrDefault();
mainCriteria = client.Account.GameAccount.AchievementCriteria.FirstOrDefault(c => c.CriteriaId32AndFlags8 == (uint)mainCriteriaId);
}
if (mainCriteria == null)
mainCriteria = D3.Achievements.CriteriaUpdateRecord.CreateBuilder()
@ -531,7 +531,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
(c.AdvanceEvent.Id == 105 && c.AdvanceEvent.Comparand == actorId64)).ToList();
if (!isHardcore)
criterias = criterias.Where(c => c.AdvanceEvent.ModifierList.Where(m => m.NecessaryCondition == 306).Count() == 0).ToList();
criterias = criterias.Where(c => c.AdvanceEvent.ModifierList.All(m => m.NecessaryCondition != 306)).ToList();
criterias = criterias.Where(c => c.AdvanceEvent.ModifierList.Single(m => m.NecessaryCondition == 103).Comparand == type64).ToList();

View File

@ -13,14 +13,14 @@ namespace DiIiS_NA.GameServer.ClientSystem.Base
public ConnectionDataEventArgs(IConnection connection, IEnumerable<byte> data)
: base(connection)
{
Data = data ?? new byte[0];
Data = data ?? Array.Empty<byte>();
}
public override string ToString()
{
return Connection.RemoteEndPoint != null
? string.Format("{0}: {1} bytes", Connection.RemoteEndPoint, Data.Count())
: string.Format("Not Connected: {0} bytes", Data.Count());
? $"{Connection.RemoteEndPoint}: {Data.Count()} bytes"
: $"Not Connected: {Data.Count()} bytes";
}
}
}

View File

@ -54,7 +54,7 @@ namespace DiIiS_NA.GameServer.ClientSystem.Base
{
try
{
if (_newSockets.Count() == 0)
if (!_newSockets.Any())
return;
lock (_newSockets)

View File

@ -33,7 +33,7 @@ namespace DiIiS_NA.GameServer.CommandManager
[Command("add", "Allows you to add a new user account.\nUsage: account add <email> <password> <battletag> [userlevel]", Account.UserLevels.GM)]
public string Add(string[] @params, BattleClient invokerClient)
{
if (@params.Count() < 3)
if (@params.Length < 3)
return "Invalid arguments. Type 'help account add' to get help.";
var email = @params[0];
@ -41,7 +41,7 @@ namespace DiIiS_NA.GameServer.CommandManager
var battleTagName = @params[2];
var userLevel = Account.UserLevels.User;
if (@params.Count() == 4)
if (@params.Length == 4)
{
var level = @params[3].ToLower();
switch (level)
@ -88,7 +88,7 @@ namespace DiIiS_NA.GameServer.CommandManager
[Command("setpassword", "Allows you to set a new password for account\nUsage: account setpassword <email> <password>", Account.UserLevels.GM)]
public string SetPassword(string[] @params, BattleClient invokerClient)
{
if (@params.Count() < 2)
if (@params.Length < 2)
return "Invalid arguments. Type 'help account setpassword' to get help.";
var email = @params[0];
@ -109,7 +109,7 @@ namespace DiIiS_NA.GameServer.CommandManager
[Command("setbtag", "Allows you to change battle tag for account\nUsage: account setbtag <email> <newname>", Account.UserLevels.GM)]
public string SetBTag(string[] @params, BattleClient invokerClient)
{
if (@params.Count() < 2)
if (@params.Length < 2)
return "Invalid arguments. Type 'help account setbtag' to get help.";
var email = @params[0];
@ -127,7 +127,7 @@ namespace DiIiS_NA.GameServer.CommandManager
[Command("setuserlevel", "Allows you to set a new user level for account\nUsage: account setuserlevel <email> <user level>.\nAvailable user levels: owner, admin, gm, user.", Account.UserLevels.GM)]
public string SetLevel(string[] @params, BattleClient invokerClient)
{
if (@params.Count() < 2)
if (@params.Length < 2)
return "Invalid arguments. Type 'help account setuserlevel' to get help.";
var email = @params[0];
@ -170,7 +170,7 @@ namespace DiIiS_NA.GameServer.CommandManager
[DefaultCommand(Account.UserLevels.GM)]
public string Mute(string[] @params, BattleClient invokerClient)
{
if (@params.Count() < 2)
if (@params.Length < 2)
return "Invalid arguments. Type 'help mute' to get help.";
var bTagName = @params[0];
@ -196,7 +196,7 @@ namespace DiIiS_NA.GameServer.CommandManager
{
if(@params == null)
return "Wrong game tag. Example: !tag mytag";
if (@params.Count() != 1)
if (@params.Length != 1)
return "Invalid arguments. Enter one string tag.";
string Tag = @params[0];

View File

@ -175,7 +175,7 @@ namespace DiIiS_NA.GameServer.CommandManager
bool found = false;
var @params = parameters.Split(' ');
var group = @params[0];
var command = @params.Count() > 1 ? @params[1] : string.Empty;
var command = @params.Length > 1 ? @params[1] : string.Empty;
foreach (var pair in CommandGroups.Where(pair => group == pair.Key.Name))
{

View File

@ -301,7 +301,7 @@ public class SpawnCommand : CommandGroup
actorSNO = 6652;
if (@params.Count() > 1)
if (@params.Length > 1)
if (!int.TryParse(@params[1], out amount))
amount = 1;
if (amount > 100) amount = 100;
@ -563,7 +563,7 @@ public class ItemCommand : CommandGroup
return "You need to specify a valid item name!";
if (@params.Count() == 1 || !int.TryParse(@params[1], out amount))
if (@params.Length == 1 || !int.TryParse(@params[1], out amount))
amount = 1;
if (amount > 100) amount = 100;
@ -605,7 +605,7 @@ public class ItemCommand : CommandGroup
if (type == null)
return "The type given is not a valid item type.";
if (@params.Count() == 1 || !int.TryParse(@params[1], out amount))
if (@params.Length == 1 || !int.TryParse(@params[1], out amount))
amount = 1;
if (amount > 100) amount = 100;
@ -766,7 +766,7 @@ public class ConversationCommand : CommandGroup
if (invokerClient.InGameClient == null)
return "You can only invoke this command while in-game.";
if (@params.Count() != 1)
if (@params.Length != 1)
return "Invalid arguments. Type 'help conversation' to get help.";
try
@ -875,7 +875,7 @@ public class ModifySpeedCommand : CommandGroup
if (@params == null)
return Fallback();
if (@params.Count() != 1)
if (@params.Length != 1)
return "Invalid arguments. Type 'help text public' to get help.";
var questId = int.Parse(@params[0]);
@ -897,7 +897,7 @@ public class ModifySpeedCommand : CommandGroup
if (@params == null)
return Fallback();
if (@params.Count() != 2)
if (@params.Length != 2)
return "Invalid arguments. Type 'help text public' to get help.";
var eventId = int.Parse(@params[0]);

View File

@ -436,10 +436,10 @@ namespace DiIiS_NA.GameServer.Core
public Item GetItemByDynId(Player plr, uint dynId)
{
if (Items.Values.Where(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId).Count() > 0)
if (Items.Values.Any(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId))
return Items.Values.Single(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId);
else
return null;
return null;
}
}
}

View File

@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
{
@ -106,14 +107,10 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
protected virtual int PickPowerToUse()
{
if (PresetPowers.Count > 0)
{
int powerIndex = RandomHelper.Next(PresetPowers.Count);
if (PowerSystem.PowerLoader.HasImplementationForPowerSNO(PresetPowers[powerIndex]))
return PresetPowers[powerIndex];
}
return -1;
var implementedPowers = PresetPowers.Where(PowerSystem.PowerLoader.HasImplementationForPowerSNO);
return implementedPowers.TryPickRandom(out var randomPower)
? randomPower
: -1;
}
public void AddPresetPower(int powerSNO)

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.Core.Helpers.Math;
using DiIiS_NA.Core.MPQ;
using DiIiS_NA.GameServer.Core.Types.Math;
@ -149,16 +150,11 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
protected virtual int PickPowerToUse()
{
// randomly used an implemented power
if (PresetPowers.Count > 0)
{
int powerIndex = RandomHelper.Next(PresetPowers.Count);
if (PowerLoader.HasImplementationForPowerSNO(PresetPowers[powerIndex]))
return PresetPowers[powerIndex];
}
// no usable power
return -1;
// randomly used an implemented power
var implementedPowers = PresetPowers.Where(PowerLoader.HasImplementationForPowerSNO);
return implementedPowers.TryPickRandom(out var randomPower)
? randomPower
: -1;
}
public void AddPresetPower(int powerSNO)

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.Core.Helpers.Math;
using DiIiS_NA.Core.MPQ;
using DiIiS_NA.D3_GameServer.Core.Types.SNO;
@ -196,13 +197,12 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
// randomly used an implemented power
if (PresetPowers.Count > 0)
{
//int power = this.PresetPowers[RandomHelper.Next(this.PresetPowers.Count)].Key;
List<int> availablePowers = Enumerable.ToList(PresetPowers.Where(p => (p.Value.CooldownTimer == null || p.Value.CooldownTimer.TimedOut) && PowerLoader.HasImplementationForPowerSNO(p.Key)).Select(p => p.Key));
if (availablePowers.Where(p => p != 30592).Count() > 0)
return availablePowers.Where(p => p != 30592).ToList()[RandomHelper.Next(availablePowers.Where(p => p != 30592).ToList().Count())];
else
if (availablePowers.Contains(30592))
return 30592; //melee attack
// int power = this.PresetPowers[RandomHelper.Next(this.PresetPowers.Count)].Key;
List<int> availablePowers = PresetPowers.Where(p => (p.Value.CooldownTimer == null || p.Value.CooldownTimer.TimedOut) && PowerLoader.HasImplementationForPowerSNO(p.Key)).Select(p => p.Key).ToList();
if (availablePowers.Where(p => p != 30592).TryPickRandom(out var randomItem))
return randomItem;
if (availablePowers.Contains(30592))
return 30592; // melee attack
}
// no usable power

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.Core.Helpers.Math;
using DiIiS_NA.Core.Logging;
using DiIiS_NA.Core.MPQ;
@ -59,7 +60,7 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
}
var monsterData = (DiIiS_NA.Core.MPQ.FileFormats.Monster)MPQStorage.Data.Assets[SNOGroup.Monster][body.ActorData.MonsterSNO].Data;
_mpqPowerCount = monsterData.SkillDeclarations.Count(e => e.SNOPower != -1);
for (int i = 0; i < monsterData.SkillDeclarations.Count(); i++)
for (int i = 0; i < monsterData.SkillDeclarations.Length; i++)
{
if (monsterData.SkillDeclarations[i].SNOPower == -1) continue;
if (PowerLoader.HasImplementationForPowerSNO(monsterData.SkillDeclarations[i].SNOPower))
@ -435,16 +436,13 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
//int power = this.PresetPowers[RandomHelper.Next(this.PresetPowers.Count)].Key;
var availablePowers = PresetPowers.Where(p => (p.Value.CooldownTimer == null || p.Value.CooldownTimer.TimedOut) && PowerLoader.HasImplementationForPowerSNO(p.Key)).Select(p => p.Key).ToList();
if (availablePowers.Count(p => p != 30592) > 0)
if (availablePowers.Where(p => p != 30592).TryPickRandom(out var selectedPower))
{
int SelectedPower = availablePowers.Where(p => p != 30592).ToList()[RandomHelper.Next(availablePowers.Where(p => p != 30592).ToList().Count())];
//if(SelectedPower == 73824)
//if(SkeletonKingWhirlwind)
return SelectedPower;
return selectedPower;
}
if (availablePowers.Contains(30592))
return 30592; //melee attack
return 30592; // melee attack
// no usable power
return -1;

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.Core.Helpers.Math;
using DiIiS_NA.Core.MPQ;
using DiIiS_NA.GameServer.Core.Types.SNO;
@ -115,15 +116,10 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
protected virtual int PickPowerToUse()
{
// randomly used an implemented power
if (PresetPowers.Count > 0)
{
int powerIndex = RandomHelper.Next(PresetPowers.Count);
if (PowerLoader.HasImplementationForPowerSNO(PresetPowers[powerIndex]))
return PresetPowers[powerIndex];
}
// no usable power
return -1;
var implementedPowers = PresetPowers.Where(PowerLoader.HasImplementationForPowerSNO);
return implementedPowers.TryPickRandom(out var randomPower)
? randomPower
: -1;
}
public void AddPresetPower(int powerSNO)

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
{
@ -31,7 +32,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
_collapsed = true;
World.Game.SideQuestGizmo = this;
World.Game.QuestManager.LaunchSideQuest(eventIds[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, eventIds.Count())], true);
World.Game.QuestManager.LaunchSideQuest(eventIds.PickRandom(), true);
}
}
catch { }

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.GameServer.Core.Types.TagMap;
using DiIiS_NA.GameServer.MessageSystem;
using DiIiS_NA.GameServer.GSSystem.TickerSystem;
@ -35,7 +36,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
_collapsed = true;
World.Game.SideQuestGizmo = this;
World.Game.QuestManager.LaunchSideQuest(eventIds[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, eventIds.Count())], true);
World.Game.QuestManager.LaunchSideQuest(eventIds.PickRandom(), true);
}
}
catch { }

View File

@ -510,12 +510,12 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
UnequipItem(owner, slot, item);
}
public Item GetItemByDynId(Player player, uint DynamicId)
public Item GetItemByDynId(Player player, uint dynamicId)
{
if (_equipment[player].Values.Where(it => it.IsRevealedToPlayer(player) && it.DynamicID(player) == DynamicId).Count() > 0)
return _equipment[player].Values.Single(it => it.IsRevealedToPlayer(player) && it.DynamicID(player) == DynamicId);
else
return null;
if (_equipment[player].Values.Any(it => it.IsRevealedToPlayer(player) && it.DynamicID(player) == dynamicId))
return _equipment[player].Values.Single(it => it.IsRevealedToPlayer(player) && it.DynamicID(player) == dynamicId);
return null;
}
public void RefreshEquipment(Player player)
@ -530,18 +530,23 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
#region EqupimentStats
public List<Item> GetEquippedItems(Player player)
public IEnumerable<Item> GetEquippedItems(Player player)
{
return _equipment[player].Values.ToList();
return _equipment[player].Values;
}
public float GetItemBonus(GameAttributeF attributeF)
{
var stats = GetEquippedItems(owner).Where(item => item.Attributes[GameAttribute.Durability_Cur] > 0 || item.Attributes[GameAttribute.Durability_Max] == 0);
var stats = GetEquippedItems(owner)
.Where(item => item.Attributes[GameAttribute.Durability_Cur] > 0 ||
item.Attributes[GameAttribute.Durability_Max] == 0);
if (attributeF == GameAttribute.Attacks_Per_Second_Item)
return stats.Count() > 0 ? stats.Select(item => item.Attributes[attributeF]).Where(a => a > 0f).Aggregate(1f, (x, y) => x * y) : 0f;
{
return stats.Any()
? stats.Select(item => item.Attributes[attributeF]).Where(a => a > 0f).Aggregate(1f, (x, y) => x * y)
: 0f;
}
return stats.Sum(item => item.Attributes[attributeF]);
}
@ -552,7 +557,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Hirelings
public bool GetItemBonus(GameAttributeB attributeB)
{
return GetEquippedItems(owner).Where(item => item.Attributes[attributeB] == true).Count() > 0;
return GetEquippedItems(owner).Any(item => item.Attributes[attributeB]);
}
public float GetItemBonus(GameAttributeF attributeF, int attributeKey)

View File

@ -34,12 +34,12 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Minions
LifeTime = TickTimer.WaitSeconds(world.Game, lifetime);
if (Master != null && context.ScriptFormula(1) < (Master as Player).Followers.Values.Where(f => f == SNO).Count())
if (Master != null && context.ScriptFormula(1) < (Master as Player).Followers.Values.Count(f => f == SNO))
{
if (Master is Player)
{
var rem = new List<uint>();
foreach (var fol in (Master as Player).Followers.Where(f => f.Key != GlobalID).Take((Master as Player).Followers.Values.Where(f => f == SNO).Count() - (int)context.ScriptFormula(1)))
foreach (var fol in (Master as Player).Followers.Where(f => f.Key != GlobalID).Take((Master as Player).Followers.Values.Count(f => f == SNO) - (int)context.ScriptFormula(1)))
if (fol.Value == SNO)
rem.Add(fol.Key);
foreach (var rm in rem)

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Pet;
using DiIiS_NA.GameServer.GSSystem.PlayerSystem;
using DiIiS_NA.GameServer.MessageSystem;
@ -207,10 +208,10 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
{
if (ConversationList != null)
{
var suitable_entries = ConversationList.AmbientConversationListEntries.Where(entry => entry.SpecialEventFlag == World.Game.CurrentAct).ToList();
if (suitable_entries.Count() > 0)
var suitableEntries = ConversationList.AmbientConversationListEntries.Where(entry => entry.SpecialEventFlag == World.Game.CurrentAct).ToList();
if (suitableEntries.Count > 0)
{
var random_conv = suitable_entries[FastRandom.Instance.Next(suitable_entries.Count())];
var random_conv = suitableEntries.PickRandom();
player.Conversations.StartConversation(random_conv.SNOConversation);
if (ForceConversationSNO == Conversations[0].ConversationSNO) ForceConversationSNO = -1;
}

View File

@ -21,6 +21,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
{
@ -1126,16 +1127,16 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
var portals = GetActorsInRange<Portal>(5f).Where(p => p.Destination != null && p.Destination.DestLevelAreaSNO != -1).ToList();
if (portals.Count >= 2)
{
var random_portal = portals[FastRandom.Instance.Next(portals.Count)];
var randomPortal = portals.PickRandom();
var bounty_portals = World.Game.QuestManager.Bounties.Where(b => !b.PortalSpawned).SelectMany(b => b.LevelAreaChecks).Intersect(portals.Select(p => p.Destination.DestLevelAreaSNO));
if (bounty_portals.Any())
{
random_portal = portals.First(p => World.Game.QuestManager.Bounties.SelectMany(b => b.LevelAreaChecks).Where(w => w != -1).Contains(p.Destination.DestLevelAreaSNO));
World.Game.QuestManager.Bounties.First(b => b.LevelAreaChecks.Contains(random_portal.Destination.DestLevelAreaSNO)).PortalSpawned = true;
randomPortal = portals.First(p => World.Game.QuestManager.Bounties.SelectMany(b => b.LevelAreaChecks).Where(w => w != -1).Contains(p.Destination.DestLevelAreaSNO));
World.Game.QuestManager.Bounties.First(b => b.LevelAreaChecks.Contains(randomPortal.Destination.DestLevelAreaSNO)).PortalSpawned = true;
}
foreach (var portal in portals)
portal.randomed = false;
random_portal.randomed = true;
randomPortal.randomed = true;
}
}

View File

@ -151,7 +151,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
public void CheckKillMonsterCriteria(ulong gameAccountId, int actorId, int type, bool isHardcore)
{
Logger.MethodTrace($"gameAccountId {gameAccountId}, actorId {actorId}, type {type}, hc {isHardcore}");
BattleNetSocketSend($"ckmc|{gameAccountId}/{actorId}/{type}/{ (isHardcore ? "True" : "False")}");
BattleNetSocketSend($"ckmc|{gameAccountId}/{actorId}/{type}/{(isHardcore ? "True" : "False")}");
}
public void CheckSalvageItemCriteria(ulong gameAccountId, int itemId)

View File

@ -1716,7 +1716,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
public bool WorldCleared(WorldSno worldSno)
{
return _worlds[worldSno].Actors.Values.OfType<Monster>().Where(m => m.OriginalLevelArea != -1 && !m.Dead).Count() < 5;
return _worlds[worldSno].Actors.Values.OfType<Monster>().Count(m => m.OriginalLevelArea != -1 && !m.Dead) < 5;
}
/// <summary>

View File

@ -32,7 +32,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
public static GameUpdateThread FindWorker()
{
return UpdateWorkers.OrderBy(t => t.Games.Count()).First();
return UpdateWorkers.OrderBy(t => t.Games.Count).First();
}
}
}

View File

@ -940,7 +940,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
{
while (monsterCount < AdditionalTargetCounter + 20)
{
GameServer.Core.Types.Math.Vector3D scenePoint = Scenes[RandomHelper.Next(0, Scenes.Count)].Position;
GameServer.Core.Types.Math.Vector3D scenePoint = Scenes.PickRandom().Position;
GameServer.Core.Types.Math.Vector3D point = null;
while (true)
{
@ -948,7 +948,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
if (QuestManager.Game.GetWorld(world).CheckLocationForFlag(point, Scene.NavCellFlags.AllowWalk))
break;
}
QuestManager.Game.GetWorld(world).SpawnMonster((ActorSno)GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee[FastRandom.Instance.Next(GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee.Count())], point);
QuestManager.Game.GetWorld(world).SpawnMonster((ActorSno)GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee.PickRandom(), point);
monsterCount++;
}
} // Need additional monster spawn, there are few of them
@ -978,7 +978,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
scenes.Add(scene);
}
GameServer.Core.Types.Math.Vector3D scenePoint = scenes[RandomHelper.Next(0, scenes.Count - 1)].Position;
GameServer.Core.Types.Math.Vector3D scenePoint = scenes.PickRandom().Position;
GameServer.Core.Types.Math.Vector3D point = null;
while (true)
{

View File

@ -1,6 +1,7 @@
using DiIiS_NA.Core.Logging;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.GameServer.GSSystem.AISystem.Brains;
using static DiIiS_NA.Core.MPQ.FileFormats.GameBalance;
using Actor = DiIiS_NA.GameServer.GSSystem.ActorSystem.Actor;
@ -250,14 +251,14 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
public static int GeneratePrefixName()
{
var randomPrefix = NamesList.Where(n => n.AffixType == AffixType.Prefix).OrderBy(x => RandomHelper.Next()).ToList().First();
var randomPrefix = NamesList.Where(n => n.AffixType == AffixType.Prefix).PickRandom();
return randomPrefix.Hash;
}
public static int GenerateSuffixName()
{
var randomSuffix = NamesList.Where(n => n.AffixType == AffixType.Suffix).OrderBy(x => RandomHelper.Next()).ToList().First();
return randomSuffix.Hash;
var randomPrefix = NamesList.Where(n => n.AffixType == AffixType.Suffix).PickRandom();
return randomPrefix.Hash;
}
}
}

View File

@ -302,11 +302,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
else
{
var entries = clusterSelected[sceneChunk.SceneSpecification.ClusterID];
SubSceneEntry subSceneEntry = null;
if (entries.Count > 0)
if (entries.TryPickRandom(out var subSceneEntry))
{
subSceneEntry = RandomHelper.RandomItem<SubSceneEntry>(entries, entry => 1);
entries.Remove(subSceneEntry);
}
else
@ -566,8 +563,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
List<Scene> scenes = world.Scenes.Values.ToList();
if (levelArea != -1) scenes = scenes.Where(sc => sc.Specification.SNOLevelAreas[0] == levelArea && !sc.SceneSNO.Name.ToLower().Contains("filler")).ToList();
else scenes = scenes.Where(sc => !sc.SceneSNO.Name.ToLower().Contains("filler")).ToList();
int randomScene = RandomHelper.Next(0, scenes.Count - 1);
Vector3D SSV = scenes[randomScene].Position;
Vector3D SSV = scenes.PickRandom().Position;
Vector3D startingPoint = null;
while (true)
@ -586,10 +582,10 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
if (waypoints.Count > 1)
{
int RandomPoint = RandomHelper.Next(0, waypoints.Count - 1);
int randomPoint = RandomHelper.Next(0, waypoints.Count);
for (int i = 0; i < waypoints.Count; i++)
{
if (i != RandomPoint)
if (i != randomPoint)
waypoints[i].Destroy();
}
}
@ -638,7 +634,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
bool rift = world.SNO.IsGenerated();
//Getting Enter
var loadedScene = new SceneChunk();
currentScene = DRLGContainers[0][RandomHelper.Next(0, DRLGContainers[0].Count)];
currentScene = DRLGContainers[0].PickRandom();
loadedScene.SNOHandle = new SNOHandle(SNOGroup.Scene, currentScene.SnoID);
loadedScene.PRTransform = new PRTransform(new Quaternion(new Vector3D(0f, 0f, 0f), 1), new Vector3D(0, 0, 0));
loadedScene.SceneSpecification = new SceneSpecification(
@ -676,7 +672,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
{
if (prestScene.SNOHandle.Name.StartsWith("x1_Pand"))
positionOfNav = 3;
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way
break;
}
@ -715,7 +711,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
if (prestScene.SNOHandle.Name.StartsWith("x1_Pand"))
positionOfNav = 3;
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way
break;
}
@ -753,7 +749,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
if (prestScene.SNOHandle.Name.StartsWith("x1_Pand"))
positionOfNav = 3;
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way
break;
}
@ -793,7 +789,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
if (prestScene.SNOHandle.Name.StartsWith("x1_Pand"))
positionOfNav = 3;
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way
break;
}
@ -832,7 +828,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
currentNav = 'E';
while (true)
{
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way
break;
}
@ -865,7 +861,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
currentNav = 'W';
while (true)
{
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length > 1) //Way
break;
}
@ -919,7 +915,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
{
if (hasExit)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];
currentScene = DRLGContainers[3].PickRandom();
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //Way
{
@ -929,7 +925,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
}
else
{
currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)];
currentScene = DRLGContainers[1].PickRandom();
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav)) //Exit
{
@ -941,7 +937,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
}
else
{
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
#region проверка на будущее
toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray();
bool ForceStop = false;
@ -955,7 +951,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -972,7 +968,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -989,7 +985,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1006,7 +1002,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1067,7 +1063,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
{
if (hasExit)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];
currentScene = DRLGContainers[3].PickRandom();
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //Way
{
@ -1077,7 +1073,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
}
else
{
currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)];
currentScene = DRLGContainers[1].PickRandom();
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav)) //Exit
{
@ -1089,7 +1085,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
}
else
{
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
#region проверка на будущее
toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray();
bool forceStop = false;
@ -1103,7 +1099,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1119,7 +1115,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1135,7 +1131,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1151,7 +1147,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;// else PosOfNav = 3;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1212,7 +1208,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
{
if (hasExit)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];
currentScene = DRLGContainers[3].PickRandom();
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //Way
{
@ -1222,7 +1218,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
}
else
{
currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)];
currentScene = DRLGContainers[1].PickRandom();
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav)) //Exit
{
@ -1234,7 +1230,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
}
else
{
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
#region проверка на будущее
toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray();
bool ForceStop = false;
@ -1252,7 +1248,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom();//CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1267,7 +1263,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom();//CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1282,7 +1278,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1297,7 +1293,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1358,7 +1354,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
{
if (hasExit)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];
currentScene = DRLGContainers[3].PickRandom();
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //Way
{
@ -1368,7 +1364,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
}
else
{
currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)];
currentScene = DRLGContainers[1].PickRandom();
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav)) //Exit
{
@ -1380,7 +1376,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
}
else
{
currentScene = DRLGContainers[2][RandomHelper.Next(0, DRLGContainers[2].Count)];
currentScene = DRLGContainers[2].PickRandom();
#region проверка на будущее
toWaitChunks = currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray();
bool ForceStop = false;
@ -1398,7 +1394,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X + RangetoNext, placeToNewScene.Y, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1413,7 +1409,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X - RangetoNext, placeToNewScene.Y, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1428,7 +1424,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y + RangetoNext, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1443,7 +1439,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
(reservedChunks.Contains(new Vector3D(placeToNewScene.X, placeToNewScene.Y - RangetoNext, placeToNewScene.Z))))
while (true)
{
currentScene = DRLGContainers[3][RandomHelper.Next(0, DRLGContainers[3].Count)];//CurrentScene Switch
currentScene = DRLGContainers[3].PickRandom(); // CurrentScene Switch
if (currentScene.Asset.Name.ToLower().Contains("hexmaze_edge") || currentScene.Asset.Name.ToLower().Contains("hexmaze_exit")) positionOfNav = 4;
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(currentNav) & currentScene.Asset.Name.Split('_')[positionOfNav].ToCharArray().Length == 1) //End
{
@ -1540,7 +1536,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
char Nav = chunk.SNOHandle.Name.Split('_')[positionOfNav].ToCharArray()[0];
while (true)
{
currentScene = DRLGContainers[1][RandomHelper.Next(0, DRLGContainers[1].Count)];
currentScene = DRLGContainers[1].PickRandom();
if (currentScene.Asset.Name.Split('_')[positionOfNav].Contains(Nav)) //Exit
{
@ -1603,7 +1599,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
if (!busy)
{
currentScene = DRLGContainers[4][RandomHelper.Next(0, DRLGContainers[4].Count)];
currentScene = DRLGContainers[4].PickRandom();
var newscene = new SceneChunk
{
@ -1678,7 +1674,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
if (DRLGTemplate.Templates.ContainsKey(worldSNO))
{
DRLGTemplate.DRLGLayout world_layout = DRLGTemplate.Templates[worldSNO][FastRandom.Instance.Next(DRLGTemplate.Templates[worldSNO].Count)];
DRLGTemplate.DRLGLayout world_layout = DRLGTemplate.Templates[worldSNO].PickRandom();
int coordY = 0;
foreach (List<int> row in world_layout.map)
@ -1975,7 +1971,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
for (int i = 0; i < count; i++)
{
//Chose a random exit to test
Vector3D chosenExitPosition = RandomHelper.RandomValue(exitTypes);
Vector3D chosenExitPosition = exitTypes.PickRandom().Value;
var chosenExitDirection = (from pair in exitTypes
where pair.Value == chosenExitPosition
select pair.Key).FirstOrDefault();
@ -2077,7 +2073,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
//return filler
return GetTileInfo(tiles, TileTypes.Filler);
}
List<TileInfo> tilesWithRightDirection = (from pair in tiles where ((pair.Value.ExitDirectionBits & exitDirectionBits) > 0) select pair.Value).ToList<TileInfo>();
List<TileInfo> tilesWithRightDirection = (from pair in tiles where ((pair.Value.ExitDirectionBits & exitDirectionBits) > 0) select pair.Value).ToList();
if (tilesWithRightDirection.Count == 0)
{
@ -2087,7 +2083,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
return null;
}
return RandomHelper.RandomItem(tilesWithRightDirection, x => 1.0f);
return tilesWithRightDirection.PickRandom();
}
private TileInfo GetTile(Dictionary<int, TileInfo> tiles, int snoId)
@ -2100,12 +2096,12 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
/// Returns a tileinfo from a list of tiles that has a specific type
/// </summary>
/// <param name="tiles"></param>
/// <param name="exitDirectionBits"></param>
/// <param name="tileType"></param>
/// <returns></returns>
private TileInfo GetTileInfo(Dictionary<int, TileInfo> tiles, TileTypes tileType)
{
var tilesWithRightType = (from pair in tiles where (pair.Value.TileType == (int)tileType) select pair.Value);
return RandomHelper.RandomItem(tilesWithRightType, x => 1);
var tilesWithRightType = tiles.Values.Where(tile => tile.TileType == (int)tileType);
return tilesWithRightType.PickRandom();
}
private TileInfo GetTileInfo(Dictionary<int, TileInfo> tiles, TileTypes tileType, int exitDirectionBits)
@ -2274,7 +2270,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
{
var handle = new SNOHandle(207706);
if (handle == null || gizmoLocations.Count == 0) continue;
LazyLoadActor(handle, gizmoLocations[FastRandom.Instance.Next(gizmoLocations.Count)], world, ((DiIiS_NA.Core.MPQ.FileFormats.Actor)handle.Target).TagMap);
LazyLoadActor(handle, gizmoLocations.PickRandom(), world, ((DiIiS_NA.Core.MPQ.FileFormats.Actor)handle.Target).TagMap);
}
else
foreach (var location in gizmoLocations)
@ -2300,11 +2296,11 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
if (gizmoLocations.Count > 0 && world.Game.MonsterLevel >= Program.MaxLevel && FastRandom.Instance.Next(100) < 30)
{
var handle_chest = new SNOHandle(96993); //leg chest
if (handle_chest == null) continue;
var golden_chest = LoadActor(handle_chest, gizmoLocations[FastRandom.Instance.Next(0, gizmoLocations.Count - 1)], world, ((DiIiS_NA.Core.MPQ.FileFormats.Actor)handle_chest.Target).TagMap);
if (golden_chest > 0)
(world.GetActorByGlobalId(golden_chest) as LegendaryChest).ChestActive = true;
var handleChest = new SNOHandle(96993); //leg chest
if (handleChest == null) continue;
var goldenChest = LoadActor(handleChest, gizmoLocations.PickRandom(), world, ((DiIiS_NA.Core.MPQ.FileFormats.Actor)handleChest.Target).TagMap);
if (goldenChest > 0)
(world.GetActorByGlobalId(goldenChest) as LegendaryChest).ChestActive = true;
}
if (world.DRLGEmuActive)
@ -2326,8 +2322,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
//unique spawn
if (SpawnGenerator.Spawns.ContainsKey(wid) && SpawnGenerator.Spawns[wid].dangerous.Count > 0 && FastRandom.Instance.NextDouble() < 0.5)
{
var randomUnique = new SNOHandle(SpawnGenerator.Spawns[wid].dangerous[FastRandom.Instance.Next(SpawnGenerator.Spawns[wid].dangerous.Count)]);
var scene = levelAreas.First().Value[FastRandom.Instance.Next(levelAreas.First().Value.Count)];
var randomUnique = new SNOHandle(SpawnGenerator.Spawns[wid].dangerous.PickRandom());
var scene = levelAreas.First().Value.PickRandom();
int x = FastRandom.Instance.Next(scene.NavMesh.SquaresCountX);
int y = FastRandom.Instance.Next(scene.NavMesh.SquaresCountY);
int threshold = 0;
@ -2368,9 +2364,9 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
//goblin spawn
if (SpawnGenerator.Spawns.ContainsKey(wid) && SpawnGenerator.Spawns[wid].can_spawn_goblin && FastRandom.Instance.NextDouble() < 0.5)
{
var randomGoblin = new SNOHandle(Goblins[FastRandom.Instance.Next(Goblins.Count)]);
var randomGoblin = new SNOHandle(Goblins.PickRandom());
if (world.Game.IsHardcore) randomGoblin = new SNOHandle(3852);
var scene = levelAreas.First().Value[FastRandom.Instance.Next(levelAreas.First().Value.Count)];
var scene = levelAreas.First().Value.PickRandom();
int x = FastRandom.Instance.Next(scene.NavMesh.SquaresCountX);
int y = FastRandom.Instance.Next(scene.NavMesh.SquaresCountY);
int threshold = 0;
@ -2423,8 +2419,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
//unique spawn
if (SpawnGenerator.Spawns.ContainsKey(la) && SpawnGenerator.Spawns[la].dangerous.Count > 0 && FastRandom.Instance.NextDouble() < 0.5)
{
var randomUnique = new SNOHandle(SpawnGenerator.Spawns[la].dangerous[FastRandom.Instance.Next(SpawnGenerator.Spawns[la].dangerous.Count)]);
var scene = levelAreas[la][FastRandom.Instance.Next(levelAreas[la].Count)];
var randomUnique = new SNOHandle(SpawnGenerator.Spawns[la].dangerous.PickRandom());
var scene = levelAreas[la].PickRandom();
int x = FastRandom.Instance.Next(scene.NavMesh.SquaresCountX);
int y = FastRandom.Instance.Next(scene.NavMesh.SquaresCountY);
int threshold = 0;
@ -2465,9 +2461,9 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
//goblin spawn
if (SpawnGenerator.Spawns.ContainsKey(la) && SpawnGenerator.Spawns[la].can_spawn_goblin && FastRandom.Instance.NextDouble() < 0.5)
{
var randomGoblin = new SNOHandle(Goblins[FastRandom.Instance.Next(Goblins.Count)]);
var randomGoblin = new SNOHandle(Goblins.PickRandom());
if (world.Game.IsHardcore) randomGoblin = new SNOHandle(3852);
var scene = levelAreas[la][FastRandom.Instance.Next(levelAreas[la].Count)];
var scene = levelAreas[la].PickRandom();
int x = FastRandom.Instance.Next(scene.NavMesh.SquaresCountX);
int y = FastRandom.Instance.Next(scene.NavMesh.SquaresCountY);
int threshold = 0;
@ -2543,8 +2539,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
#region elite spawn
int randomMeleeMonsterId = -1;
int randomRangedMonsterId = -1;
if (SpawnGenerator.Spawns[la].melee.Count > 0) randomMeleeMonsterId = SpawnGenerator.Spawns[la].melee[FastRandom.Instance.Next(SpawnGenerator.Spawns[la].melee.Count)];
if (SpawnGenerator.Spawns[la].range.Count > 0) randomRangedMonsterId = SpawnGenerator.Spawns[la].range[FastRandom.Instance.Next(SpawnGenerator.Spawns[la].range.Count)];
if (SpawnGenerator.Spawns[la].melee.Count > 0) randomMeleeMonsterId = SpawnGenerator.Spawns[la].melee.PickRandom();
if (SpawnGenerator.Spawns[la].range.Count > 0) randomRangedMonsterId = SpawnGenerator.Spawns[la].range.PickRandom();
SNOHandle meleeMonsterHandle = (randomMeleeMonsterId == -1 ? null : new SNOHandle(randomMeleeMonsterId));
SNOHandle rangedMonsterHandle = (randomRangedMonsterId == -1 ? null : new SNOHandle(randomRangedMonsterId));
if (rangedMonsterHandle == null) rangedMonsterHandle = meleeMonsterHandle;
@ -2588,8 +2584,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
{
int randomMeleeMonsterId = -1;
int randomRangedMonsterId = -1;
if (SpawnGenerator.Spawns[la].melee.Count > 0) randomMeleeMonsterId = SpawnGenerator.Spawns[la].melee[FastRandom.Instance.Next(SpawnGenerator.Spawns[la].melee.Count)];
if (SpawnGenerator.Spawns[la].range.Count > 0) randomRangedMonsterId = SpawnGenerator.Spawns[la].range[FastRandom.Instance.Next(SpawnGenerator.Spawns[la].range.Count)];
if (SpawnGenerator.Spawns[la].melee.Count > 0) randomMeleeMonsterId = SpawnGenerator.Spawns[la].melee.PickRandom();
if (SpawnGenerator.Spawns[la].range.Count > 0) randomRangedMonsterId = SpawnGenerator.Spawns[la].range.PickRandom();
SNOHandle meleeMonsterHandle = (randomMeleeMonsterId == -1 ? null : new SNOHandle(randomMeleeMonsterId));
SNOHandle rangedMonsterHandle = (randomRangedMonsterId == -1 ? null : new SNOHandle(randomRangedMonsterId));
//int maxMobsInStack = (SpawnGenerator.IsMelee(la, randomMonsterId) ? 6 : (SpawnGenerator.IsDangerous(la, randomMonsterId) ? 1 : 3));
@ -2620,7 +2616,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem
else //spawn champions
#region champion spawn
{
SNOHandle championHandle = new SNOHandle(SpawnGenerator.Spawns[la].melee[FastRandom.Instance.Next(SpawnGenerator.Spawns[la].melee.Count)]);
SNOHandle championHandle = new SNOHandle(SpawnGenerator.Spawns[la].melee.PickRandom());
groupId = FastRandom.Instance.Next();
for (int n = 0; n < 4; n++)
{

View File

@ -171,30 +171,28 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
if (IsUnique)
{
var restrictedFamily = item.ItemDefinition.LegendaryAffixFamily.Where(af => af != -1);
filteredList = filteredList.Where(
a =>
!(restrictedFamily.Contains(a.AffixFamily0) || restrictedFamily.Contains(a.AffixFamily1))
);
var restrictedFamily = item.ItemDefinition.LegendaryAffixFamily.Where(af => af != -1).ToHashSet();
filteredList = filteredList
.Where(a => !(restrictedFamily.Contains(a.AffixFamily0) || restrictedFamily.Contains(a.AffixFamily1)));
if (restrictedFamily.Contains(1616088365) ||
restrictedFamily.Contains(-1461069734) ||
restrictedFamily.Contains(234326220) ||
restrictedFamily.Contains(1350281776) ||
restrictedFamily.Contains(-812845450) ||
restrictedFamily.Contains(1791554648) ||
restrictedFamily.Contains(125900958)) //MinMaxDam and ele damage
filteredList = filteredList.Where(
a =>
!a.Name.Contains("FireD") &&
!a.Name.Contains("PoisonD") &&
!a.Name.Contains("HolyD") &&
!a.Name.Contains("ColdD") &&
!a.Name.Contains("LightningD") &&
!a.Name.Contains("ArcaneD") &&
!a.Name.Contains("MinMaxDam") &&
isCrafting ? !a.Name.ToLower().Contains("socket") : !a.Name.Contains("ASDHUIOPASDHIOU")
);
restrictedFamily.Contains(-1461069734) ||
restrictedFamily.Contains(234326220) ||
restrictedFamily.Contains(1350281776) ||
restrictedFamily.Contains(-812845450) ||
restrictedFamily.Contains(1791554648) ||
restrictedFamily.Contains(125900958)) //MinMaxDam and ele damage
{
filteredList = filteredList
.Where(a => !a.Name.Contains("FireD") &&
!a.Name.Contains("PoisonD") &&
!a.Name.Contains("HolyD") &&
!a.Name.Contains("ColdD") &&
!a.Name.Contains("LightningD") &&
!a.Name.Contains("ArcaneD") &&
!a.Name.Contains("MinMaxDam") &&
isCrafting ? !a.Name.ToLower().Contains("socket") : !a.Name.Contains("ASDHUIOPASDHIOU"));
}
}
if (affixesCount <= 1)
@ -228,7 +226,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
if (item.AffixFamilies.Contains(affix_group.First().AffixFamily0)) continue;
int s = item.ItemDefinition.RequiredLevel;
bestDefinitions[affix_group.First().AffixFamily0] = affix_group.ToList()[FastRandom.Instance.Next(0, affix_group.Count())];
bestDefinitions[affix_group.First().AffixFamily0] = affix_group.PickRandom();
}
//if (bestDefinitions.Values.Where(a => a.Name.Contains("PoisonD")).Count() > 0) Logger.Debug("PoisonD in bestDefinitions");
@ -321,24 +319,28 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
public static int FindSuitableAffix(Item item, int affixGroup, int affixLevel, bool extendedFilter)
{
if (affixGroup == -1) return -1;
var all_group = LegendaryAffixList.Where(a => (a.AffixFamily0 == affixGroup || a.AffixFamily1 == affixGroup) && (Item.Is2H(item.ItemType) ? !a.Name.EndsWith("1h") : (!a.Name.Contains("Two-Handed") && !a.Name.EndsWith("2h"))));
var allGroup = LegendaryAffixList
.Where(a => (a.AffixFamily0 == affixGroup || a.AffixFamily1 == affixGroup) && (Item.Is2H(item.ItemType) ? !a.Name.EndsWith("1h") : (!a.Name.Contains("Two-Handed") && !a.Name.EndsWith("2h"))))
.ToArray();
if (all_group.Count() == 0) return -1;
if (!allGroup.Any()) return -1;
bool secondGroup = (all_group.First().AffixFamily1 == affixGroup);
bool secondGroup = allGroup.First().AffixFamily1 == affixGroup;
var suitable = all_group.Where(a => a.AffixLevel <= affixLevel || affixLevel <= 0);
var suitable = allGroup.Where(a => a.AffixLevel <= affixLevel || affixLevel <= 0).ToArray();
if (suitable.Count() == 0) return -1;
if (!suitable.Any()) return -1;
List<int> itemTypes = ItemGroup.HierarchyToHashList(item.ItemType);
suitable = suitable.Where(a => itemTypes.ContainsAtLeastOne(a.ItemGroup) || (extendedFilter ? itemTypes.ContainsAtLeastOne(a.LegendaryAllowedTypes) : false));
suitable = suitable.Where(a =>
itemTypes.ContainsAtLeastOne(a.ItemGroup) ||
(extendedFilter && itemTypes.ContainsAtLeastOne(a.LegendaryAllowedTypes))).ToArray();
if (suitable.Count() == 0) return -1;
if (!suitable.Any()) return -1;
int suitableAffixLevel = suitable.OrderByDescending(a => a.AffixLevel).First().AffixLevel;
suitable = suitable.Where(a => a.AffixLevel == suitableAffixLevel);
int suitableAffixLevel = suitable.MaxBy(a => a.AffixLevel).AffixLevel;
suitable = suitable.Where(a => a.AffixLevel == suitableAffixLevel).ToArray();
//if (i18 && !secondGroup)
// suitable = suitable.Where(a => a.MaxLevel <= (Program.MaxLevel + 4));
@ -347,8 +349,8 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
//else
//suitable = suitable.Where(a => itemTypes.ContainsAtLeastOne(a.I10));
if (suitable.Count() == 0)
suitable = all_group.Where(a => a.AffixLevel == 1);
if (!suitable.Any())
suitable = allGroup.Where(a => a.AffixLevel == 1).ToArray();
/*int suitableMaxLevel = suitable.OrderByDescending(a => a.AffixLevel).First().MaxLevel;
int suitableAffixLevel = suitable.OrderByDescending(a => a.AffixLevel).First().AffixLevel;
@ -361,36 +363,36 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
if (suitable.Count() > 1 && i18 && !secondGroup && suitable.Where(a => a.Name.Contains("Secondary")).Count() > 0)
suitable = suitable.Where(a => a.Name.Contains("Secondary"));*/
if (suitable.Count() > 0)
return suitable.ToList()[FastRandom.Instance.Next(0, suitable.Count())].Hash;
else
return -1;
if (suitable.TryPickRandom(out var randomAffix))
return randomAffix.Hash;
return -1;
}
public static void AddAffix(Item item, int AffixGbId, bool findFromTotal = false)
public static void AddAffix(Item item, int affixGbId, bool findFromTotal = false)
{
if (AffixGbId == -1) return;
if (affixGbId == -1) return;
AffixTable definition = null;
if (findFromTotal)
{
definition = AllAffix.Where(def => def.Hash == AffixGbId).FirstOrDefault();
var testc = AllAffix.Where(def => def.ItemGroup[0] == AffixGbId || def.ItemGroup[1] == AffixGbId).FirstOrDefault();
definition = AllAffix.FirstOrDefault(def => def.Hash == affixGbId);
var testc = AllAffix.FirstOrDefault(def => def.ItemGroup[0] == affixGbId || def.ItemGroup[1] == affixGbId);
}
else
{
definition = AffixList.Where(def => def.Hash == AffixGbId).FirstOrDefault();
definition = AffixList.FirstOrDefault(def => def.Hash == affixGbId);
if (definition == null)
{
definition = LegendaryAffixList.Where(def => def.Hash == AffixGbId).FirstOrDefault();
definition = LegendaryAffixList.FirstOrDefault(def => def.Hash == affixGbId);
}
}
if (definition == null)
{
Logger.Warn("Affix {0} was not found!", AffixGbId);
Logger.Warn("Affix {0} was not found!", affixGbId);
return;
}
@ -444,7 +446,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
}
}
}
var affix = new Affix(AffixGbId);
var affix = new Affix(affixGbId);
affix.Score = (Scores.Count == 0 ? 0 : Scores.Average());
item.AffixList.Add(affix);
//item.Attributes[GameAttribute.Item_Quality_Level]++;
@ -502,7 +504,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
bool itemIsPrefix = (FastRandom.Instance.Next(0, 2) > 0);
var randomName = D3.Items.RareItemName.CreateBuilder()
.SetItemNameIsPrefix(itemIsPrefix)
.SetSnoAffixStringList(itemIsPrefix ? SuffixAffixLists[FastRandom.Instance.Next(0, SuffixAffixLists.Count)] : PrefixAffixLists[FastRandom.Instance.Next(0, PrefixAffixLists.Count)])
.SetSnoAffixStringList(itemIsPrefix ? SuffixAffixLists.PickRandom() : PrefixAffixLists.PickRandom())
.SetAffixStringListIndex(FastRandom.Instance.Next(0, 6))
.SetItemStringListIndex(FastRandom.Instance.Next(0, 6));
return randomName.Build();

View File

@ -1088,7 +1088,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
break;
}
it = items[RandomHelper.Next(@base, @base + 1)];
it = items[RandomHelper.Next(@base, @base + 2)];
player.Inventory.PickUp(ItemGenerator.Cook(player, it));
break;
case -1249067448:
@ -1102,7 +1102,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
"Unique_Shoulder_Set_09_x1", "Unique_Boots_Set_09_x1",
"Unique_Shoulder_Set_06_x1", "Unique_Boots_Set_06_x1"
};
it = items[RandomHelper.Next(@base, @base + 1)];
it = items[RandomHelper.Next(@base, @base + 2)];
player.Inventory.PickUp(ItemGenerator.Cook(player, it));
break;
case -1249067447:
@ -1116,7 +1116,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
"Unique_Chest_Set_09_x1", "Unique_Pants_Set_09_x1",
"Unique_Chest_Set_06_x1", "Unique_Pants_Set_06_x1"
};
it = items[RandomHelper.Next(@base, @base + 1)];
it = items[RandomHelper.Next(@base, @base + 2)];
player.Inventory.PickUp(ItemGenerator.Cook(player, it));
break;

View File

@ -3,6 +3,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DiIiS_NA.Core.Extensions;
using NHibernate.Linq;
using DiIiS_NA.Core.Logging;
using DiIiS_NA.Core.Storage;
@ -335,7 +336,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
data.NumberOfCompletionSteps);
foreach (var step in data.QuestSteps)
{
int nextID = step.StepObjectiveSets.Count() > 0
int nextID = step.StepObjectiveSets.Any()
? step.StepObjectiveSets.First().FollowUpStepID
: -1;
Logger.Info("Step [{0}] {1} -> {2}", step.ID, step.Name, nextID);
@ -1143,7 +1144,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
public static Item GenerateRandomGem(ActorSystem.Actor player, int level, bool is_goblin)
{
string gemName = GemNames[FastRandom.Instance.Next(GemNames.Count)];
string gemName = GemNames.PickRandom();
int lvl = Math.Max(player.Attributes[GameAttribute.Level], 20);
int gem_grade = ((lvl - 10) / 8) + 1;
@ -1168,7 +1169,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
//var found = false;
//ItemTable itemDefinition = null;
if (pool.Count() == 0) return null;
if (pool.Count == 0) return null;
List<ItemTable> pool_filtered = pool.Where(it =>
it.SNOActor != -1 &&
it.WeaponDamageMin != 100.0f &&
@ -1222,10 +1223,10 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
).ToList();
//*/
if (pool_filtered.Count() == 0) return null;
if (pool_filtered.Count == 0) return null;
ItemTable selected = pool_filtered[FastRandom.Instance.Next(0, pool_filtered.Count() - 1)];
ItemTable selected = pool_filtered.PickRandom();
return selected;
}
@ -1234,7 +1235,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
//var found = false;
//ItemTable itemDefinition = null;
if (pool.Count() == 0) return null;
if (pool.Count == 0) return null;
List<ItemTable> pool_filtered = pool.Where(it =>
it.SNOActor != -1 &&
it.WeaponDamageMin != 100.0f &&
@ -1262,9 +1263,9 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
(it.Cost == 0)) && // i hope it catches all lore with npc spawned /xsochor
!(!GBIDHandlers.ContainsKey(it.Hash) && !AllowedItemTypes.Contains(it.ItemTypesGBID))
).ToList();
if (pool_filtered.Count() == 0) return null;
if (pool_filtered.Count == 0) return null;
ItemTable selected = pool_filtered[FastRandom.Instance.Next(0, pool_filtered.Count() - 1)];
ItemTable selected = pool_filtered.PickRandom();
return selected;
}

View File

@ -187,8 +187,8 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
Parent = parent;
Subscenes = new List<Scene>();
Scale = 1.0f;
AppliedLabels = new int[0];
Field8 = new int[0];
AppliedLabels = Array.Empty<int>();
Field8 = Array.Empty<int>();
Size = new Size(NavZone.V0.X * (int)NavZone.Float0, NavZone.V0.Y * (int)NavZone.Float0);
Position = position;
World.AddScene(this); // add scene to the world.

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.Core.Helpers.Hash;
using DiIiS_NA.Core.Helpers.Math;
using DiIiS_NA.Core.Logging;
@ -240,7 +241,7 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
var scenes = new List<int> { 265624, 265655, 265678, 265693 };
foreach (var scene in scenes)
{
var wld = worlds[FastRandom.Instance.Next(worlds.Count)];
var wld = worlds.PickRandom();
PortalOverrides.Add(scene, wld);
worlds.Remove(wld);
}
@ -282,7 +283,7 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
BuffManager.Update();
PowerManager.Update();
if (tickCounter % 6 == 0 && _flippyTimers.Count() > 0)
if (tickCounter % 6 == 0 && _flippyTimers.Any())
{
UpdateFlippy(tickCounter);
}
@ -1033,7 +1034,7 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
else
{
_flippyTimers.Dequeue().Dequeue().Invoke();
if (_flippyTimers.Count() > 0)
if (_flippyTimers.Any())
_flippyTimers.Peek().Dequeue().Invoke();
}
}

View File

@ -52,6 +52,7 @@ using DiIiS_NA.GameServer.Core.Types.Math;
using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Conversation;
//Blizzless Project 2022
using System.Collections.Concurrent;
using DiIiS_NA.Core.Extensions;
//Blizzless Project 2022
using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Quest;
//Blizzless Project 2022
@ -572,8 +573,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
}
if (asset.RootTreeNodes[lineIndex].ConvNodeType == 4)
currentLineNode = asset.RootTreeNodes[lineIndex]
.ChildNodes[RandomHelper.Next(asset.RootTreeNodes[lineIndex].ChildNodes.Count)];
currentLineNode = asset.RootTreeNodes[lineIndex].ChildNodes.PickRandom();
else
currentLineNode = asset.RootTreeNodes[lineIndex];

View File

@ -261,7 +261,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
public Item GetItemByDynId(Player plr, uint dynId)
{
if (Items.Values.Where(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId).Count() > 0)
if (Items.Values.Any(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId))
return Items.Values.Single(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId);
else
return null;

View File

@ -286,9 +286,9 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
{
string itemType = originalItem.ItemDefinition.Name.Substring(3);
if (itemType.Contains("1HWeapon"))
itemType = OneHandedWeapons[FastRandom.Instance.Next(OneHandedWeapons.Count())];
itemType = OneHandedWeapons.PickRandom();
if (itemType.Contains("2HWeapon"))
itemType = TwoHandedWeapons[FastRandom.Instance.Next(TwoHandedWeapons.Count())];
itemType = TwoHandedWeapons.PickRandom();
if (itemType.Contains("Pants"))
itemType = "Legs";
_inventoryGrid.AddItem(ItemGenerator.GetRandomItemOfType(_owner, ItemGroup.FromString(itemType)));
@ -739,15 +739,15 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
_owner.GrantAchievement(74987243307126);
var items = GetEquippedItems();
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "Belt_Barbarian")).Count() > 0 && (items.Where(item => ItemGroup.IsSubType(item.ItemType, "MightyWeapon1H")).Count() > 0 || items.Where(item => ItemGroup.IsSubType(item.ItemType, "MightyWeapon2H")).Count() > 0)) //barb
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "Belt_Barbarian")) && (items.Any(item => ItemGroup.IsSubType(item.ItemType, "MightyWeapon1H")) || items.Any(item => ItemGroup.IsSubType(item.ItemType, "MightyWeapon2H")))) //barb
_owner.GrantAchievement(74987243307046);
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "Cloak")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "HandXbow")).Count() > 0) //dh
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "Cloak")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "HandXbow"))) //dh
_owner.GrantAchievement(74987243307058);
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "SpiritStone_Monk")).Count() > 0 && (items.Where(item => ItemGroup.IsSubType(item.ItemType, "FistWeapon")).Count() > 0 || items.Where(item => ItemGroup.IsSubType(item.ItemType, "CombatStaff")).Count() > 0)) //monk
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "SpiritStone_Monk")) && (items.Any(item => ItemGroup.IsSubType(item.ItemType, "FistWeapon")) || items.Any(item => ItemGroup.IsSubType(item.ItemType, "CombatStaff")))) //monk
_owner.GrantAchievement(74987243307544);
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "VoodooMask")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "CeremonialDagger")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "Mojo")).Count() > 0) //wd
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "VoodooMask")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "CeremonialDagger")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "Mojo"))) //wd
_owner.GrantAchievement(74987243307561);
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "WizardHat")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "Wand")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "Orb")).Count() > 0) //wiz
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "WizardHat")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "Wand")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "Orb"))) //wiz
_owner.GrantAchievement(74987243307582);
}
@ -1099,23 +1099,23 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
{
if (client.Game.PvP) return;
if (_owner.IsCasting) _owner.StopCasting();
if (message is InventoryRequestMoveMessage) HandleInventoryRequestMoveMessage(message as InventoryRequestMoveMessage);
else if (message is InventoryRequestQuickMoveMessage) HandleInventoryRequestQuickMoveMessage(message as InventoryRequestQuickMoveMessage);
else if (message is InventorySplitStackMessage) OnInventorySplitStackMessage(message as InventorySplitStackMessage);
else if (message is InventoryStackTransferMessage) OnInventoryStackTransferMessage(message as InventoryStackTransferMessage);
else if (message is InventoryDropItemMessage) OnInventoryDropItemMessage(message as InventoryDropItemMessage);
else if (message is InventoryRequestUseMessage) OnInventoryRequestUseMessage(message as InventoryRequestUseMessage);
else if (message is InventoryRequestSocketMessage) OnSocketMessage(message as InventoryRequestSocketMessage);
else if (message is InventoryGemsExtractMessage) OnGemsExtractMessage(message as InventoryGemsExtractMessage);
else if (message is RequestBuySharedStashSlotsMessage) OnBuySharedStashSlots(message as RequestBuySharedStashSlotsMessage);
else if (message is InventoryIdentifyItemMessage) OnInventoryIdentifyItemMessage(message as InventoryIdentifyItemMessage);
else if (message is InventoryUseIdentifyItemMessage) OnInventoryUseIdentifyItemMessage(message as InventoryUseIdentifyItemMessage);
else if (message is TrySalvageMessage) OnTrySalvageMessage(message as TrySalvageMessage);
else if (message is TrySalvageAllMessage) OnTrySalvageAllMessage(message as TrySalvageAllMessage);
else if (message is CraftItemsMessage) OnCraftItemMessage(client, message as CraftItemsMessage);
else if (message is EnchantAffixMessage) OnEnchantAffixMessage(client, message as EnchantAffixMessage);
else if (message is TryTransmogItemMessage) OnTryTransmogItemMessage(client, message as TryTransmogItemMessage);
else if (message is DyeItemMessage) OnDyeItemMessage(client, message as DyeItemMessage);
if (message is InventoryRequestMoveMessage moveMessage) HandleInventoryRequestMoveMessage(moveMessage);
else if (message is InventoryRequestQuickMoveMessage quickMoveMessage) HandleInventoryRequestQuickMoveMessage(quickMoveMessage);
else if (message is InventorySplitStackMessage stackMessage) OnInventorySplitStackMessage(stackMessage);
else if (message is InventoryStackTransferMessage transferMessage) OnInventoryStackTransferMessage(transferMessage);
else if (message is InventoryDropItemMessage dropItemMessage) OnInventoryDropItemMessage(dropItemMessage);
else if (message is InventoryRequestUseMessage useMessage) OnInventoryRequestUseMessage(useMessage);
else if (message is InventoryRequestSocketMessage socketMessage) OnSocketMessage(socketMessage);
else if (message is InventoryGemsExtractMessage extractMessage) OnGemsExtractMessage(extractMessage);
else if (message is RequestBuySharedStashSlotsMessage slotsMessage) OnBuySharedStashSlots(slotsMessage);
else if (message is InventoryIdentifyItemMessage identifyItemMessage) OnInventoryIdentifyItemMessage(identifyItemMessage);
else if (message is InventoryUseIdentifyItemMessage itemMessage) OnInventoryUseIdentifyItemMessage(itemMessage);
else if (message is TrySalvageMessage salvageMessage) OnTrySalvageMessage(salvageMessage);
else if (message is TrySalvageAllMessage allMessage) OnTrySalvageAllMessage(allMessage);
else if (message is CraftItemsMessage itemsMessage) OnCraftItemMessage(client, itemsMessage);
else if (message is EnchantAffixMessage affixMessage) OnEnchantAffixMessage(client, affixMessage);
else if (message is TryTransmogItemMessage transmogItemMessage) OnTryTransmogItemMessage(client, transmogItemMessage);
else if (message is DyeItemMessage dyeItemMessage) OnDyeItemMessage(client, dyeItemMessage);
else if (message is InventoryRepairAllMessage) RepairAll();
else if (message is InventoryRepairEquippedMessage) RepairEquipment();
@ -1201,6 +1201,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
if (!ReloadAffix.Definition.Name.Contains("Secondary")) filteredList = filteredList.Where( a => !a.Name.Contains("Secondary") );
if (!ReloadAffix.Definition.Name.Contains("Experience")) filteredList = filteredList.Where(a => !a.Name.Contains("Experience"));
if (!ReloadAffix.Definition.Name.Contains("Archon")) filteredList = filteredList.Where(a => !a.Name.Contains("Archon"));
// FIXME: always true?
if (ReloadAffix.Definition.Hash == ReloadAffix.Definition.Hash) filteredList = filteredList.Where(a => a.Hash != ReloadAffix.Definition.Hash);
if (Item.GBHandle.GBID == -4139386) filteredList = filteredList.Where( a => !a.Name.Contains("Str") && !a.Name.Contains("Dex") && !a.Name.Contains("Int") && !a.Name.Contains("Vit" ));
@ -1211,22 +1212,27 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
if (Item.AffixFamilies.Contains(affix_group.First().AffixFamily0)) continue;
int s = Item.ItemDefinition.RequiredLevel;
bestDefinitions[affix_group.First().AffixFamily0] = affix_group.ToList()[FastRandom.Instance.Next(0, 1)];
bestDefinitions[affix_group.First().AffixFamily0] = affix_group.ToList()[FastRandom.Instance.Next(0, 1)]; // FIXME: random always returns 0
}
var SocketsAffixs = AffixGenerator.AllAffix.Where(a => a.Name.ToLower().Contains("1xx_socket") && itemTypes.ContainsAtLeastOne(a.ItemGroup)).ToList();
//if (bestDefinitions.Values.Where(a => a.Name.Contains("PoisonD")).Count() > 0) Logger.Debug("PoisonD in bestDefinitions");
List<AffixTable> selectedGroups = bestDefinitions.Values
.OrderBy(x => FastRandom.Instance.Next()) //random order
.GroupBy(x => (x.AffixFamily1 == -1) ? x.AffixFamily0 : x.AffixFamily1)
.Select(x => x.First()) //only one from group
.Take(1) //take needed amount
.OrderBy(_ => FastRandom.Instance.Next()) //random order
.GroupBy(x => x.AffixFamily1 == -1 ? x.AffixFamily0 : x.AffixFamily1)
.Select(x => x.First()) // only one from group
.Take(1) // take needed amount
.ToList();
if (selectedGroups.Count == 0)
if (ReloadAffix.Definition.Name.ToLower().Contains("socket"))
selectedGroups = SocketsAffixs.Where(x => x.OverrideLevelReq <= ReloadAffix.Definition.AffixLevelMax //&& x.AffixLevelMin == ReloadAffix.Definition.AffixLevelMin
).OrderBy(x => FastRandom.Instance.Next()).Take(1).ToList();
{
selectedGroups = SocketsAffixs
.Where(x => x.OverrideLevelReq <= ReloadAffix.Definition.AffixLevelMax) //&& x.AffixLevelMin == ReloadAffix.Definition.AffixLevelMin
.OrderBy(_ => FastRandom.Instance.Next())
.Take(1)
.ToList();
}
else
return;
@ -2196,10 +2202,10 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
public Item GetItemByDynId(Player plr, uint dynId)
{
if (_inventoryGrid.Items.Values.Union(_stashGrid.Items.Values).Union(_equipment.Items.Values).Where(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId).Count() > 0)
if (_inventoryGrid.Items.Values.Union(_stashGrid.Items.Values).Union(_equipment.Items.Values).Any(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId))
return _inventoryGrid.Items.Values.Union(_stashGrid.Items.Values).Union(_equipment.Items.Values).Single(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId);
else
return null;
return null;
}
public bool HasItem(int GBid)
@ -2612,7 +2618,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
public bool GetItemBonus(GameAttributeB attributeB)
{
return Loaded ? (GetEquippedItems().Where(item => item.Attributes[attributeB] == true).Count() > 0) : _owner.Attributes[attributeB];
return Loaded ? GetEquippedItems().Any(item => item.Attributes[attributeB]) : _owner.Attributes[attributeB];
}
public float GetItemBonus(GameAttributeF attributeF, int attributeKey)

View File

@ -1869,7 +1869,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
foreach (var oldp in World.GetActorsBySNO(ActorSno._x1_openworld_lootrunportal,
ActorSno._x1_openworld_tiered_rifts_portal)) oldp.Destroy();
map = maps[RandomHelper.Next(0, maps.Length)];
map = maps.PickRandom();
//map = 288823;
newTagMap.Add(new TagKeySNO(526850), new TagMapEntry(526850, (int)map, 0)); //World
newTagMap.Add(new TagKeySNO(526853), new TagMapEntry(526853, 288482, 0)); //Zone
@ -1878,7 +1878,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
while (true)
{
map = maps[RandomHelper.Next(0, maps.Length)];
map = maps.PickRandom();
if (map != InGameClient.Game.WorldOfPortalNephalem) break;
}
@ -2068,7 +2068,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
InGameClient.Game.NephalemGreater = true;
//disable banner while greater is active enable once boss is killed or portal is closed /advocaite
Attributes[GameAttribute.Banner_Usable] = false;
map = maps[RandomHelper.Next(0, maps.Length)];
map = maps.PickRandom();
newTagMap.Add(new TagKeySNO(526850), new TagMapEntry(526850, (int)map, 0)); //World
newTagMap.Add(new TagKeySNO(526853), new TagMapEntry(526853, 288482, 0)); //Zone
newTagMap.Add(new TagKeySNO(526851), new TagMapEntry(526851, 172, 0)); //Entry-Pointа
@ -4669,8 +4669,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public void GrantAchievement(ulong id)
{
if (_unlockedAchievements.Contains(id)) return;
if (InGameClient.BnetClient.Account.GameAccount.Achievements
.Where(a => a.AchievementId == id && a.Completion != -1).Count() > 0) return;
if (InGameClient.BnetClient.Account.GameAccount.Achievements.Any(a => a.AchievementId == id && a.Completion != -1)) return;
if (_unlockedAchievements.Contains(id)) return;
_unlockedAchievements.Add(id);
try
@ -5699,13 +5698,10 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public Actor SpawnNephalemBoss(World world)
{
var Boss = world.SpawnMonster(
ActorSnoExtensions.nephalemPortalBosses[
RandomHelper.Next(0, ActorSnoExtensions.nephalemPortalBosses.Length - 1)], Position);
Boss.Attributes[GameAttribute.Bounty_Objective] = true;
Boss.Attributes[GameAttribute.Is_Loot_Run_Boss] = true;
Boss.Attributes.BroadcastChangedIfRevealed();
var boss = world.SpawnMonster(ActorSnoExtensions.nephalemPortalBosses.PickRandom(), Position);
boss.Attributes[GameAttribute.Bounty_Objective] = true;
boss.Attributes[GameAttribute.Is_Loot_Run_Boss] = true;
boss.Attributes.BroadcastChangedIfRevealed();
foreach (var plr in world.Players.Values)
plr.InGameClient.SendMessage(new WorldSyncedDataMessage()
@ -5720,7 +5716,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
});
return Boss;
return boss;
}
public bool StartConversation(World world, int conversationId)
@ -6147,13 +6143,13 @@ public class Player : Actor, IMessageConsumer, IUpdateable
public int FindFollowerIndex(ActorSno sno)
{
if (HaveFollower(sno))
return _followerIndexes.Where(i => i.Value == sno).FirstOrDefault().Key;
else return 0;
return _followerIndexes.FirstOrDefault(i => i.Value == sno).Key;
return 0;
}
public int CountFollowers(ActorSno sno)
{
return Followers.Values.Where(f => f == sno).Count();
return Followers.Values.Count(f => f == sno);
}
public int CountAllFollowers()

View File

@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{
@ -127,7 +128,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (_tickTimer == null || _tickTimer.TimedOut)
{
var monster = ActorFactory.Create(Target.World, Monsters[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, Monsters.Count())], new TagMap());
var monster = ActorFactory.Create(Target.World, Monsters.PickRandom(), new TagMap());
monster.EnterWorld(RandomDirection(Target.Position, 5f, Radius));
monster.HasLoot = (Target.World.Game.CurrentAct == 3000);
monster.Unstuck();
@ -210,7 +211,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{
for (int i = 0; i < 10; i++)
{
var monster = ActorFactory.Create(Target.World, Monsters[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, Monsters.Count())], new TagMap());
var monster = ActorFactory.Create(Target.World, Monsters.PickRandom(), new TagMap());
monster.EnterWorld(RandomDirection(Target.Position, 5f, Radius));
monster.HasLoot = (Target.World.Game.CurrentAct == 3000);
monster.Unstuck();

View File

@ -16,6 +16,7 @@ using System.Collections.Generic;
using System.Linq;
//Blizzless Project 2022
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{
@ -1098,20 +1099,21 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
//once collision with target, RopeEffect up to ScriptFromula(5) times.
Actor curSource = hit;
var enemies = GetEnemiesInRadius(curSource.Position, ScriptFormula(12)).Actors.Where(actor => actor != curSource).ToList();
Actor curTarget = (enemies.Count > 0 ? enemies[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, enemies.Count)] : null);
enemies.TryPickRandom(out var curTarget);
for (int i = 0; i <= ScriptFormula(5); i++)
{
if (curTarget == null) break;
curSource.AddRopeEffect(166450, curTarget);
curSource = curTarget;
AttackPayload ricochet_attack = new AttackPayload(this);
ricochet_attack.AddWeaponDamage(ScriptFormula(15), DamageType.Physical);
ricochet_attack.SetSingleTarget(curTarget);
ricochet_attack.Apply();
AttackPayload ricochetAttack = new AttackPayload(this);
ricochetAttack.AddWeaponDamage(ScriptFormula(15), DamageType.Physical);
ricochetAttack.SetSingleTarget(curTarget);
ricochetAttack.Apply();
var next_enemies = GetEnemiesInRadius(curSource.Position, ScriptFormula(12)).Actors.Where(actor => actor != curSource).ToList();
curTarget = (next_enemies.Count > 0 ? next_enemies[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, next_enemies.Count)] : null);
var nextEnemies = GetEnemiesInRadius(curSource.Position, ScriptFormula(12)).Actors.Where(actor => actor != curSource).ToList();
nextEnemies.TryPickRandom(out curTarget);
}
}
if (Rune_D > 0)

View File

@ -15,6 +15,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{
@ -1544,7 +1545,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (!targets.Actors.Any()) return;
AttackPayload shock = new AttackPayload(this);
shock.SetSingleTarget(targets.Actors[Rand.Next(targets.Actors.Count())]);
shock.SetSingleTarget(targets.Actors.PickRandom());
shock.Targets.Actors.First().PlayEffectGroup(312568);
shock.AddWeaponDamage(ScriptFormula(21), DamageType.Lightning);
shock.OnHit = (hitPayload) =>

View File

@ -17,6 +17,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{
@ -300,10 +301,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
for (int i = 0; i < 8; i++)
{
var targets = GetEnemiesInRadius(User.Position, ScriptFormula(18)).Actors;
Actor target = null;
if (targets.Count() > 0)
target = targets[Rand.Next(targets.Count())];
targets.TryPickRandom(out var target);
var position = target == null ? RandomDirection(User.Position, 1f, 15f) : target.Position;
_CreateArrowPool(ActorSno._demonhunter_rainofarrows_indigo_buff, position, ScriptFormula(16), 2f);
@ -1650,7 +1648,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
Vector3D targetPosition = RandomDirection(Target.Position, ScriptFormula(2));
var enemies = GetEnemiesInRadius(Target.Position, ScriptFormula(2)).Actors;
if (enemies.Count > 0)
targetPosition = enemies[FastRandom.Instance.Next(0, enemies.Count)].Position;
targetPosition = enemies.PickRandom().Position;
if (_damageTimer == null || _damageTimer.TimedOut)
{
_damageTimer = WaitSeconds(1f / 4f);
@ -1700,11 +1698,11 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
var targets = GetEnemiesInRadius(Target.Position, ScriptFormula(2));
if (targets.Actors.Count > 0)
{
Vector3D nearby_position = targets.Actors[FastRandom.Instance.Next(0, targets.Actors.Count)].Position;
Vector3D nearbyPosition = targets.Actors.PickRandom().Position;
// TODO: check projectile actor
var rocket = new Projectile(this, ActorSno._dh_straferune_knives_knife, User.Position);
rocket.Position.Z += 6f;
rocket.Launch(nearby_position, ScriptFormula(10));
rocket.Launch(nearbyPosition, ScriptFormula(10));
rocket.OnCollision = (hit) =>
{
SpawnEffect(ActorSno._dh_strafe_sphereexplode, new Vector3D(hit.Position.X, hit.Position.Y, hit.Position.Z + 6f)); // impact effect (fix height)

View File

@ -1350,7 +1350,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (Rune_A > 0) //Barrage
{
if (dash.Targets.Actors.Count() > 0)
if (dash.Targets.Actors.Any())
AddBuff(dash.Targets.GetClosestTo(TargetPosition), new DashingBarrageDotBuff());
}
@ -3114,7 +3114,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
Target.Attributes[GameAttribute.Damage_Weapon_Percent_Bonus] -= _unityDamageBonus;
Target.Attributes[GameAttribute.Damage_Percent_All_From_Skills] -= _unityDamageBonus;
_unityDamageBonus = 0.05f * Target.GetActorsInRange<Player>(ScriptFormula(0)).Count();
_unityDamageBonus = 0.05f * Target.GetActorsInRange<Player>(ScriptFormula(0)).Count;
Target.Attributes[GameAttribute.Damage_Weapon_Percent_Bonus] += _unityDamageBonus;
Target.Attributes[GameAttribute.Damage_Percent_All_From_Skills] += _unityDamageBonus;
@ -3657,7 +3657,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (Rune_B > 0) //Water Ally
{
var targets = GetEnemiesInRadius(petAlly.Position, 20f, 7).Actors;
if (targets.Count() <= 0) yield break;
if (!targets.Any()) yield break;
foreach (var target in targets)
{

View File

@ -19,6 +19,7 @@ using System.Text;
using System.Threading.Tasks;
using DiIiS_NA.GameServer.GSSystem.PlayerSystem;
using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Pet;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{
@ -1985,42 +1986,14 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
User.PlayEffect(Effect.PlayEffectGroup, 466026);
if (Target != null)
{
DamageType damageType = DamageType.Physical;
bool greaterDamage = false;
// Enforcer
if (Rune_A > 0)
{
}
// Frenzy
else if (Rune_B > 0)
{
UsePrimaryResource(EvalTag(PowerKeys.ResourceCost));
}
// Dark Mending
else if (Rune_C > 0)
{
UsePrimaryResource(EvalTag(PowerKeys.ResourceCost));
damageType = DamageType.Cold;
}
// Freezing Grasp
else if (Rune_D > 0)
{
UsePrimaryResource(EvalTag(PowerKeys.ResourceCost));
damageType = DamageType.Poison;
}
else if (Rune_E > 0)
{
UsePrimaryResource(EvalTag(PowerKeys.ResourceCost));
greaterDamage = true;
damageType = DamageType.Poison;
Logger.Warn("Rune E not implemented for Necromancer's Command Skeletons");
}
UsePrimaryResource(EvalTag(PowerKeys.ResourceCost));
foreach (var skeleton in ((Player)User).NecroSkeletons)
foreach (var Skelet in (User as PlayerSystem.Player).NecroSkeletons)
{
//User.PlayEffectGroup(474172);
ActorMover mover = new ActorMover(skeleton);
ActorMover mover = new ActorMover(Skelet);
mover.MoveArc(Target.Position, 6, -0.1f, new ACDTranslateArcMessage
{
//Field3 = 303110, // used for male barb leap, not needed?
@ -2029,65 +2002,13 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
Gravity = 0.6f,
PowerSNO = PowerSNO
});
skeleton.Position = Target.Position;
skeleton.SetVisible(true);
skeleton.Hidden = false;
skeleton.PlayEffectGroup(474172);
Skelet.Position = Target.Position;
Skelet.PlayEffectGroup(474172);
AttackPayload attack = new AttackPayload(this)
{
Target = Target
};
attack.AddWeaponDamage(greaterDamage ? skeleton.Attributes[GameAttribute.Damage_Min, 0] * 2.15f : skeleton.Attributes[GameAttribute.Damage_Min, 0], damageType);
attack.OnHit = hit =>
{
if (Rune_C > 0)
{
if (!HasBuff<DebuffFrozen>(hit.Target))
{
AddBuff(hit.Target, new DebuffFrozen(WaitSeconds(3.0f)));
}
}
};
attack.Apply();
WeaponDamage(Target, 0.50f, DamageType.Physical);
//AddBuff(Target, new DebuffStunned(WaitSeconds(0.3f)));
}
// var player = (Player)User;
// if (player.ActiveSkeletons)
// {
// while (player.NecroSkeletons.Count < 7)
// {
// var skeleton = new NecromancerSkeleton_A(World, ActorSno._p6_necro_commandskeletons_a, player);
// skeleton.Brain.DeActivate();
// skeleton.Scale = 1.2f;
//
// skeleton.EnterWorld(PowerContext.RandomDirection(player.Position, 3f, 8f));
// player.NecroSkeletons.Add(skeleton);
// /*this.InGameClient.SendMessage(new PetMessage()
// {
// Owner = this.PlayerIndex,
// Index = this.CountFollowers(473147),
// PetId = Skeleton.DynamicID(this),
// Type = 70,
// });
// //*/
// skeleton.Brain.Activate();
// }
// }
// else
// {
// foreach (var skel in player.NecroSkeletons)
// {
// player.InGameClient.SendMessage(new PetDetachMessage()
// {
// PetId = skel.GlobalID
// });
// World.Leave(skel);
// }
//
// player.NecroSkeletons.Clear();
// }
}
yield break;
}

View File

@ -15,6 +15,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{
@ -236,7 +237,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
for (int i = 0; i < frogs.Length; ++i)
{
if (frogs[i] == null) continue;
var target = PowerMath.GenerateSpreadPositions(frogs[i].Position, PowerMath.TranslateDirection2D(User.Position, TargetPosition, frogs[i].Position, 10f), 30f, 3)[FastRandom.Instance.Next(0, 3)];
var target = PowerMath.GenerateSpreadPositions(frogs[i].Position, PowerMath.TranslateDirection2D(User.Position, TargetPosition, frogs[i].Position, 10f), 30f, 3).PickRandom();
//frogs[i].LaunchArc(new Vector3D(RandomDirection(frogs[i].Position, 5f, 10f)), 3f, -0.03f);
frogs[i].LaunchArc(target, 3f, -0.03f);
}
@ -1035,7 +1036,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
var targets = GetEnemiesInRadius(grenadeN.Position, ScriptFormula(11));
if (targets.Actors.Count > 0)
{
var target = targets.Actors[FastRandom.Instance.Next(0, targets.Actors.Count)];
var target = targets.Actors.PickRandom();
grenadeN.LaunchArc(PowerMath.TranslateDirection2D(grenadeN.Position, target.Position, grenadeN.Position, PowerMath.Distance2D(grenadeN.Position, target.Position)), height, ScriptFormula(2));
yield return grenadeN.ArrivalTime;
@ -2316,7 +2317,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (!HasBuff<GargantuanEnrageCDBuff>(Target))
{
var targets = GetEnemiesInRadius(Target.Position, 10f);
if (targets.Actors.Count >= 5 || targets.Actors.Where(a => a is Boss || a is Champion || a is Rare || a is Unique).Count() > 1)
if (targets.Actors.Count >= 5 || targets.Actors.Count(a => a is Boss or Champion or Rare or Unique) > 1)
{
AddBuff(Target, new GargantuanEnrageCDBuff());
AddBuff(Target, new GargantuanEnrageBuff());
@ -2704,7 +2705,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (payload is HitPayload && payload.Target == Target)
{
Player usr = (Target as Player);
float dmg = (payload as HitPayload).TotalDamage * ScriptFormula(9) / usr.Followers.Values.Where(a => a == ActorSno._wd_zombiedog).Count();
float dmg = (payload as HitPayload).TotalDamage * ScriptFormula(9) / usr.Followers.Values.Count(a => a == ActorSno._wd_zombiedog);
(payload as HitPayload).TotalDamage *= 1 - ScriptFormula(9);
//List<Actor> dogs = GetAlliesInRadius(Target.Position, 100f).Actors.Where(a => a.ActorSNO.Id == 51353).ToList();
foreach (var dog in GetAlliesInRadius(Target.Position, 100f).Actors.Where(a => a.SNO == ActorSno._wd_zombiedog))
@ -2738,7 +2739,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (payload is HitPayload && payload.Context.User == Target)
{
Player master = (Target as ZombieDog).Master as Player;
float heal = (payload as HitPayload).TotalDamage * ScriptFormula(8) / (master.Followers.Values.Where(a => a == ActorSno._wd_zombiedog).Count() + 1);
float heal = (payload as HitPayload).TotalDamage * ScriptFormula(8) / (master.Followers.Values.Count(a => a == ActorSno._wd_zombiedog) + 1);
(payload as HitPayload).TotalDamage *= 1 - ScriptFormula(9);
master.AddHP(heal);
foreach (var dog in GetAlliesInRadius(Target.Position, 100f).Actors.Where(a => a.SNO == ActorSno._wd_zombiedog))

View File

@ -17,6 +17,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
{
@ -724,7 +725,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
Vector3D[] spawnPoints = PowerMath.GenerateSpreadPositions(TgtPosition, TgtPosition + new Vector3D(3f, 0, 0), 120, 3);
for (int i = 0; i < spawnPoints.Count(); i++)
for (int i = 0; i < spawnPoints.Length; i++)
{
if (!User.World.CheckLocationForFlag(spawnPoints[i], DiIiS_NA.Core.MPQ.FileFormats.Scene.NavCellFlags.AllowWalk))
continue;
@ -801,7 +802,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
Actor curTarget = target;
Actor nextTarget = null;
var c = 0;
while (targets.Count() < 3)
while (targets.Count < 3)
{
nextTarget = GetEnemiesInRadius(curTarget.Position, 6f).Actors.FirstOrDefault(a => !targets.Contains(a));
if (nextTarget == null) break;
@ -1270,7 +1271,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
SnapFacing = true,
AnimationTag = 69728,
});
TargetPosition = PowerMath.GenerateSpreadPositions(Twister.Position, TargetPosition, 20f, 3)[FastRandom.Instance.Next(0, 3)];
TargetPosition = PowerMath.GenerateSpreadPositions(Twister.Position, TargetPosition, 20f, 3).PickRandom();
if (Rune_B > 0) //Raging Storm
{
@ -1299,7 +1300,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
SnapFacing = true,
AnimationTag = 69728,
});
TargetPosition = PowerMath.GenerateSpreadPositions(bigTwister.Position, TargetPosition, 20f, 3)[FastRandom.Instance.Next(0, 3)];
TargetPosition = PowerMath.GenerateSpreadPositions(bigTwister.Position, TargetPosition, 20f, 3).PickRandom();
WeaponDamage(GetEnemiesInRadius(bigTwister.Position, 12f), bigMultiplier, DamageType.Arcane);
};
Twister.Destroy();
@ -1980,7 +1981,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
AddBuff(hitPayload.Target, new ShatterDebuff(User, ScriptFormula(14), WaitSeconds(2f)));
}
if (Rune_E > 0) //Deep Freeze
if (nova.Targets.Actors.Count() > ScriptFormula(13))
if (nova.Targets.Actors.Count > ScriptFormula(13))
if (!HasBuff<DeepFreezeChCBuff>(User))
AddBuff(User, new DeepFreezeChCBuff(ScriptFormula(18), WaitSeconds(ScriptFormula(19))));
};
@ -2816,7 +2817,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
if (!(Rune_B > 0 || Rune_C > 0))
proj.Destroy();
};
var destination = ((Rune_B > 0 || Rune_C > 0) ? TargetPosition : PowerMath.GenerateSpreadPositions(User.Position, TargetPosition, 5f, 9)[FastRandom.Instance.Next(0, 9)]);
var destination = ((Rune_B > 0 || Rune_C > 0) ? TargetPosition : PowerMath.GenerateSpreadPositions(User.Position, TargetPosition, 5f, 9).PickRandom());
proj.Launch(destination, ScriptFormula(6));
//WaitSeconds(ScriptFormula(25));
}

View File

@ -141,7 +141,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
float additionalCritChance = chcBonus;
if (user is Player && (user as Player).SkillSet.HasPassive(338859)) //Single Out
if (target.GetMonstersInRange(20f).Where(m => m != target).Count() == 0)
if (target.GetMonstersInRange(20f).All(m => m == target))
additionalCritChance += 0.25f;
//Wizard -> Spectral Blade -> Ice Blades

View File

@ -256,7 +256,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
var targets = Context.GetEnemiesInRadius(ChainCurrent.Position, ChainRadius);
targets.Actors.Remove(ChainCurrent);
if (targets.Actors.Count() == 0)
if (!targets.Actors.Any())
{
Destroy();
return;
@ -266,7 +266,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
nextProj.Position.Z += 5f;
nextProj.ChainCurrent = ChainCurrent;
nextProj.ChainNextPos = targets.Actors[PowerContext.Rand.Next(targets.Actors.Count())].Position;
nextProj.ChainNextPos = targets.Actors[PowerContext.Rand.Next(targets.Actors.Count)].Position;
nextProj.ChainTargetsRemain = ChainTargetsRemain;
nextProj.ChainIteration = ChainIteration + 1;

View File

@ -9,6 +9,7 @@ using DiIiS_NA.GameServer.MessageSystem;
using System;
using System.Collections.Generic;
using System.Linq;
using DiIiS_NA.Core.Extensions;
namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
{
@ -380,7 +381,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
var world = Game.GetWorld(WorldSno.a2dun_aqd_oasis_randomfacepuzzle_large);
SetActorOperable(world, ActorSno._a2dun_aqd_godhead_door_largepuzzle, false);
var spots = world.GetActorsBySNO(ActorSno._boxtrigger__one_shot_);
world.SpawnMonster(ActorSno._a2dun_aqd_act_lever_facepuzzle_01, spots[FastRandom.Instance.Next(spots.Count)].Position);
world.SpawnMonster(ActorSno._a2dun_aqd_act_lever_facepuzzle_01, spots.PickRandom().Position);
ListenInteract(ActorSno._a2dun_aqd_act_lever_facepuzzle_01, 1, new SideAdvance());
})
});
@ -460,7 +461,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem
var world = Game.GetWorld(WorldSno.a2dun_aqd_oasis_randomfacepuzzle_small);
SetActorOperable(world, ActorSno._a2dun_aqd_godhead_door, false);
var spots = world.GetActorsBySNO(ActorSno._boxtrigger__one_shot_);
world.SpawnMonster(ActorSno._a2dun_aqd_act_lever_facepuzzle_01, spots[FastRandom.Instance.Next(spots.Count)].Position);
world.SpawnMonster(ActorSno._a2dun_aqd_act_lever_facepuzzle_01, spots.PickRandom().Position);
ListenInteract(ActorSno._a2dun_aqd_act_lever_facepuzzle_01, 1, new SideAdvance());
})
});

View File

@ -7,6 +7,7 @@ using DiIiS_NA.GameServer.MessageSystem;
using System.Linq;
using System;
using System.Collections.Generic;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.LoginServer.AccountsSystem;
using DiIiS_NA.GameServer.GSSystem.QuestSystem.QuestEvents;
using DiIiS_NA.GameServer.Core.Types.Math;
@ -47,10 +48,10 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem.QuestEvents.Implementations
if (portals.Count == 0) return;
foreach (var dest in PortalDests)
{
var random_portal = portals[FastRandom.Instance.Next(0, portals.Count - 1)];
random_portal.Destination = dest;
var randomPortal = portals.PickRandom();
randomPortal.Destination = dest;
//portal.EnterWorld(random_spot);
portals.Remove(random_portal);
portals.Remove(randomPortal);
}
}
}

View File

@ -7,6 +7,7 @@ using DiIiS_NA.GameServer.MessageSystem;
using System.Linq;
using System;
using System.Collections.Generic;
using DiIiS_NA.Core.Extensions;
using DiIiS_NA.LoginServer.AccountsSystem;
using DiIiS_NA.GameServer.GSSystem.QuestSystem.QuestEvents;
using DiIiS_NA.GameServer.Core.Types.Math;
@ -56,9 +57,9 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem.QuestEvents.Implementations
for (int i = 0; i < 6; i++)
{
var rand_pos = ActorsVector3D[FastRandom.Instance.Next(ActorsVector3D.Count())];
world.SpawnMonster(ActorSno._ghost_jail_prisoner, rand_pos);
ActorsVector3D.Remove(rand_pos);
var randPos = ActorsVector3D.PickRandom();
world.SpawnMonster(ActorSno._ghost_jail_prisoner, randPos);
ActorsVector3D.Remove(randPos);
}
}

View File

@ -106,7 +106,7 @@ namespace DiIiS_NA
var cpuTime = proc.TotalProcessorTime;
var text =
$"{name} | " +
$"{PlayerManager.OnlinePlayers.Count()} onlines in {PlayerManager.OnlinePlayers.Count(s => s.InGameClient?.Player?.World != null)} worlds | " +
$"{PlayerManager.OnlinePlayers.Count} onlines in {PlayerManager.OnlinePlayers.Count(s => s.InGameClient?.Player?.World != null)} worlds | " +
$"Memory: {totalMemory:0.000} GB | " +
$"CPU Time: {cpuTime.ToSmallText()} | " +
$"Uptime: {uptime.ToSmallText()}";

View File

@ -23,7 +23,7 @@ namespace DiIiS_NA.REST.Extensions
if (instance == null)
{
ConstructorInfo constructorInfo = typeof(T).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, null);
instance = (T)constructorInfo.Invoke(new object[0]);
instance = (T)constructorInfo.Invoke(Array.Empty<object>());
}
}
}