public void MaybeAddRoles(EPlayer player, bool is035 = false) { if (!rolesForClass.ContainsKey(player.Role)) { rolesForClass.Add(player.Role, Subclass.Instance.Classes.Values.Count(e => e.BoolOptions["Enabled"] && e.AffectsRoles.Contains(player.Role))); } if (rolesForClass[player.Role] > 0) { List <Team> teamsAlive = EPlayer.List.Select(p1 => p1.Team).ToList(); teamsAlive.RemoveAll(t => t == Team.RIP); foreach (var item in Tracking.PlayersWithSubclasses.Where(s => s.Value.EndsRoundWith != Team.RIP)) { teamsAlive.Remove(item.Key.Team); teamsAlive.Add(item.Value.EndsRoundWith); } teamsAlive.ForEach(t => { if (t == Team.CDP) { t = Team.CHI; } else if (t == Team.RSC) { t = Team.MTF; } else if (t == Team.TUT) { t = Team.SCP; } }); if (!Subclass.Instance.Config.AdditiveChance) { Log.Debug($"Evaluating possible subclasses for player with name {player.Nickname}", Subclass.Instance.Config.Debug); foreach (SubClass subClass in Subclass.Instance.Classes.Values.Where(e => e.BoolOptions["Enabled"] && e.AffectsRoles.Contains(player.Role) && (!e.IntOptions.ContainsKey("MaxSpawnPerRound") || Tracking.ClassesSpawned(e) < e.IntOptions["MaxSpawnPerRound"]) && (!e.BoolOptions.ContainsKey("OnlyAffectsSpawnWave") || !e.BoolOptions["OnlyAffectsSpawnWave"]))) { Log.Debug($"Evaluating possible subclass {subClass.Name} for player with name {player.Nickname}", Subclass.Instance.Config.Debug); if ((rnd.NextDouble() * 100) < subClass.FloatOptions["ChanceToGet"] && (!subClass.IntOptions.ContainsKey("MaxAlive") || Tracking.PlayersWithSubclasses.Where(e => e.Value.Name == subClass.Name).Count() < subClass.IntOptions["MaxAlive"]) && (subClass.EndsRoundWith == Team.RIP || teamsAlive.Contains(subClass.EndsRoundWith))) { Log.Debug($"{player.Nickname} attempting to be given subclass {subClass.Name}", Subclass.Instance.Config.Debug); Tracking.AddClass(player, subClass, is035); } else { Log.Debug($"Player with name {player.Nickname} did not get subclass {subClass.Name}", Subclass.Instance.Config.Debug); } } } else { Log.Debug($"Evaluating possible subclasses for player with name {player.Nickname}", Subclass.Instance.Config.Debug); double num = (rnd.NextDouble() * 100); if (!Subclass.Instance.ClassesAdditive.ContainsKey(player.Role)) { return; } foreach (var possibity in Subclass.Instance.ClassesAdditive[player.Role].Where(e => e.Key.BoolOptions["Enabled"] && e.Key.AffectsRoles.Contains(player.Role) && (!e.Key.BoolOptions.ContainsKey("OnlyAffectsSpawnWave") || !e.Key.BoolOptions["OnlyAffectsSpawnWave"]))) { Log.Debug($"Evaluating possible subclass {possibity.Key.Name} for player with name {player.Nickname}", Subclass.Instance.Config.Debug); if (num < possibity.Value && (!possibity.Key.IntOptions.ContainsKey("MaxAlive") || Tracking.PlayersWithSubclasses.Where(e => e.Value.Name == possibity.Key.Name).Count() < possibity.Key.IntOptions["MaxAlive"]) && (!possibity.Key.IntOptions.ContainsKey("MaxSpawnPerRound") || Tracking.ClassesSpawned(possibity.Key) < possibity.Key.IntOptions["MaxSpawnPerRound"]) && (possibity.Key.EndsRoundWith == Team.RIP || teamsAlive.Contains(possibity.Key.EndsRoundWith))) { Log.Debug($"{player.Nickname} attempting to be given subclass {possibity.Key.Name}", Subclass.Instance.Config.Debug); Tracking.AddClass(player, possibity.Key, is035); break; } else { Log.Debug($"Player with name {player.Nickname} did not get subclass {possibity.Key.Name}", Subclass.Instance.Config.Debug); } } } } else { Log.Debug($"No subclasses for {player.Role}", Subclass.Instance.Config.Debug); } }
public void OnRespawningTeam(RespawningTeamEventArgs ev) { Timing.CallDelayed(3f, () => // Clear them after the wave spawns instead. { Tracking.NextSpawnWave.Clear(); Tracking.NextSpawnWaveGetsRole.Clear(); Tracking.SpawnWaveSpawns.Clear(); }); bool ntfSpawning = ev.NextKnownTeam == Respawning.SpawnableTeamType.NineTailedFox; if (!Subclass.Instance.Config.AdditiveChance) { List <RoleType> hasRole = new List <RoleType>(); foreach (SubClass subClass in Subclass.Instance.Classes.Values.Where(e => e.BoolOptions["Enabled"] && (!e.IntOptions.ContainsKey("MaxSpawnPerRound") || Tracking.ClassesSpawned(e) < e.IntOptions["MaxSpawnPerRound"]) && (ntfSpawning ? (e.AffectsRoles.Contains(RoleType.NtfCadet) || e.AffectsRoles.Contains(RoleType.NtfCommander) || e.AffectsRoles.Contains(RoleType.NtfLieutenant)) : e.AffectsRoles.Contains(RoleType.ChaosInsurgency)) && ((e.BoolOptions.ContainsKey("OnlyAffectsSpawnWave") && e.BoolOptions["OnlyAffectsSpawnWave"]) || (e.BoolOptions.ContainsKey("AffectsSpawnWave") && e.BoolOptions["AffectsSpawnWave"])))) { if ((ntfSpawning ? (subClass.AffectsRoles.Contains(RoleType.NtfCadet) || subClass.AffectsRoles.Contains(RoleType.NtfCommander) || subClass.AffectsRoles.Contains(RoleType.NtfLieutenant)) : subClass.AffectsRoles.Contains(RoleType.ChaosInsurgency)) && (rnd.NextDouble() * 100) < subClass.FloatOptions["ChanceToGet"]) { if (ntfSpawning) { if (!hasRole.Contains(RoleType.NtfCadet) && subClass.AffectsRoles.Contains(RoleType.NtfCadet)) { Tracking.NextSpawnWaveGetsRole.Add(RoleType.NtfCadet, subClass); hasRole.Add(RoleType.NtfCadet); } if (!hasRole.Contains(RoleType.NtfLieutenant) && subClass.AffectsRoles.Contains(RoleType.NtfLieutenant)) { Tracking.NextSpawnWaveGetsRole.Add(RoleType.NtfLieutenant, subClass); hasRole.Add(RoleType.NtfLieutenant); } if (!hasRole.Contains(RoleType.NtfCommander) && subClass.AffectsRoles.Contains(RoleType.NtfCommander)) { Tracking.NextSpawnWaveGetsRole.Add(RoleType.NtfCommander, subClass); hasRole.Add(RoleType.NtfCommander); } if (hasRole.Count == 3) { break; } } else { if (subClass.AffectsRoles.Contains(RoleType.ChaosInsurgency)) { Tracking.NextSpawnWaveGetsRole.Add(RoleType.ChaosInsurgency, subClass); break; } } } } } else { double num = (rnd.NextDouble() * 100); if (!ntfSpawning && !Subclass.Instance.ClassesAdditive.ContainsKey(RoleType.ChaosInsurgency)) { return; } else if (ntfSpawning && !Subclass.Instance.ClassesAdditive.ContainsKey(RoleType.NtfCadet) && !Subclass.Instance.ClassesAdditive.ContainsKey(RoleType.NtfCommander) && !Subclass.Instance.ClassesAdditive.ContainsKey(RoleType.NtfLieutenant)) { return; } if (!ntfSpawning) { foreach (var possibity in Subclass.Instance.ClassesAdditive[RoleType.ChaosInsurgency].Where(e => e.Key.BoolOptions["Enabled"] && (!e.Key.IntOptions.ContainsKey("MaxSpawnPerRound") || Tracking.ClassesSpawned(e.Key) < e.Key.IntOptions["MaxSpawnPerRound"]) && ((e.Key.BoolOptions.ContainsKey("OnlyAffectsSpawnWave") && e.Key.BoolOptions["OnlyAffectsSpawnWave"]) || (e.Key.BoolOptions.ContainsKey("AffectsSpawnWave") && e.Key.BoolOptions["AffectsSpawnWave"])))) { Log.Debug($"Evaluating possible subclass {possibity.Key.Name} for next spawn wave", Subclass.Instance.Config.Debug); if (num < possibity.Value) { Tracking.NextSpawnWaveGetsRole.Add(RoleType.ChaosInsurgency, possibity.Key); break; } else { Log.Debug($"Next spawn wave did not get subclass {possibity.Key.Name}", Subclass.Instance.Config.Debug); } } } else { RoleType[] roles = { RoleType.NtfCommander, RoleType.NtfLieutenant, RoleType.NtfCadet }; foreach (RoleType role in roles) { foreach (var possibity in Subclass.Instance.ClassesAdditive[role].Where(e => e.Key.BoolOptions["Enabled"] && (!e.Key.IntOptions.ContainsKey("MaxSpawnPerRound") || Tracking.ClassesSpawned(e.Key) < e.Key.IntOptions["MaxSpawnPerRound"]) && ((e.Key.BoolOptions.ContainsKey("OnlyAffectsSpawnWave") && e.Key.BoolOptions["OnlyAffectsSpawnWave"]) || (e.Key.BoolOptions.ContainsKey("AffectsSpawnWave") && e.Key.BoolOptions["AffectsSpawnWave"])))) { Log.Debug($"Evaluating possible subclass {possibity.Key.Name} for next spawn wave", Subclass.Instance.Config.Debug); if (num < possibity.Value) { Tracking.NextSpawnWaveGetsRole.Add(role, possibity.Key); break; } else { Log.Debug($"Next spawn wave did not get subclass {possibity.Key.Name}", Subclass.Instance.Config.Debug); } } } } } Tracking.NextSpawnWave = ev.Players; }