public static int CountRoles(Smod2.API.Team team) { int count = 0; foreach (Player pl in PluginManager.Manager.Server.GetPlayers()) { if (pl.TeamRole.Team == team) { count++; } } return(count); }
private static Role GetClassID(Smod2.API.Team team, List <Role> enabledSCPs = null) { if (enabledSCPs == null) { enabledSCPs = new List <Role> { Role.SCP_049, Role.SCP_079, Role.SCP_096, Role.SCP_106, Role.SCP_173, Role.SCP_939_53, Role.SCP_939_89 }; } switch (team) { case Smod2.API.Team.SCP: if (enabledSCPs.Count == 0) { break; } Random fakeRandom = new Random(); return(enabledSCPs[fakeRandom.Next(0, enabledSCPs.Count)]); case Smod2.API.Team.NINETAILFOX: return(Role.FACILITY_GUARD); case Smod2.API.Team.CHAOS_INSURGENCY: return(Role.CHAOS_INSURGENCY); case Smod2.API.Team.SCIENTIST: return(Role.SCIENTIST); case Smod2.API.Team.CLASSD: return(Role.CLASSD); case Smod2.API.Team.SPECTATOR: return(Role.SPECTATOR); case Smod2.API.Team.TUTORIAL: return(Role.TUTORIAL); } return(Role.UNASSIGNED); }
public void ChangeSpyRole(Smod2.API.Team team, Player player) { List <Smod2.API.Item> Inventory = player.GetInventory(); Vector pos = player.GetPosition(); UnityEngine.GameObject pObj = (UnityEngine.GameObject)player.GetGameObject(); float rot = pObj.GetComponent <PlyMovementSync>().rotation; int health = player.GetHealth(); int ammo5 = player.GetAmmo(AmmoType.DROPPED_5); int ammo7 = player.GetAmmo(AmmoType.DROPPED_7); int ammo9 = player.GetAmmo(AmmoType.DROPPED_9); if (team.Equals(Smod2.API.Team.NINETAILFOX)) { player.ChangeRole(Smod2.API.Role.CHAOS_INSURGENCY); } else if (team.Equals(Smod2.API.Team.CHAOS_INSURGENCY)) { player.ChangeRole(sc.RoleDict[player.SteamId]); } foreach (Smod2.API.Item item in player.GetInventory()) { item.Remove(); } foreach (Smod2.API.Item item in Inventory) { player.GiveItem(item.ItemType); } player.SetAmmo(AmmoType.DROPPED_5, ammo5); player.SetAmmo(AmmoType.DROPPED_7, ammo7); player.SetAmmo(AmmoType.DROPPED_9, ammo9); player.Teleport(pos, false); player.SetHealth(health); Thread ChangeSpyRole = new Thread(new ThreadStart(() => new ChangeSpyRole(sc, player, false))); ChangeSpyRole.Start(); Thread SetRotation = new Thread(new ThreadStart(() => new SetRotation(sc, pObj, rot))); SetRotation.Start(); }
public Role SelectRole() { Smod2.API.Team team = this.RollTeam(); Role role = LJEventHandler.GetClassID(team, this.scpsToSpawn); role = this.MutateRoleByAvailability(role); int i = 0; while (role == Role.UNASSIGNED && i < 5) { team = this.RollTeam(); role = LJEventHandler.GetClassID(team, this.scpsToSpawn); role = this.MutateRoleByAvailability(role); i++; } return(role); }
private void CheckEscape(Player player, Smod2.API.Team team) { bool isDClass = team == Smod2.API.Team.CLASSD; Timing.RunCoroutine(GrantItemsDelay(player, player.GetInventory().Select(x => x.ItemType).ToList(), 0.2f)); player.ChangeRole(isDClass ? Role.CHAOS_INSURGENCY : Role.NTF_SCIENTIST, true, false, true, true); int min = instance.Server.Round.Duration / 60; int sec = instance.Server.Round.Duration % 60; player.PersonalBroadcast(10, $"You have escaped as a {(isDClass ? "<color=#ff8e00>Class-D</color>" : "<color=#f6f677>Scientist</color>")} in {min} minutes and {sec} seconds.", false); if (isDClass) { instance.Server.Round.Stats.ClassDEscaped++; } else { instance.Server.Round.Stats.ScientistsEscaped++; } }