Exemplo n.º 1
0
 public void cassieMessage(string message)
 {
     if (CASSIE == null)
     {
         CASSIE = PlayerManager.localPlayer.GetComponent <MTFRespawn>();
     }
     CASSIE.RpcPlayCustomAnnouncement(message, false, CassieMakeNoise);
 }
Exemplo n.º 2
0
 public static void TriggerEvent(MTFRespawn ccm)
 {
     foreach (var type in types_update)
     {
         if (LabMod.GetObjectOfType(type) == null)
         {
             continue;
         }
         ((ILabModCISpawn)LabMod.GetObjectOfType(type)).Event(ccm);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Does the whole recontainment process the same way as main game does.
        /// </summary>
        public static IEnumerator <float> Fake5Gens()
        {
            // People complained about it being "easy to be told apart". Not anymore.
            MTFRespawn             mtf  = PlayerManager.localPlayer.GetComponent <MTFRespawn>();
            NineTailedFoxAnnouncer annc = NineTailedFoxAnnouncer.singleton;

            while (annc.queue.Count > 0 || AlphaWarheadController.Host.inProgress)
            {
                yield return(0f);
            }
            mtf.CallRpcPlayCustomAnnouncement("SCP079RECON5", false, false);
            // This massive for loop jank is what the main game does. Go complain to them.
            for (int i = 0; i < 2750; i++)
            {
                yield return(0f);
            }
            while (annc.queue.Count > 0 || AlphaWarheadController.Host.inProgress)
            {
                yield return(0f);
            }
            mtf.CallRpcPlayCustomAnnouncement("SCP079RECON6", true, false);
            mtf.CallRpcPlayCustomAnnouncement("SCP 0 7 9 CONTAINEDSUCCESSFULLY", false, false);
            for (int j = 0; j < 350; j++)
            {
                yield return(0f);
            }
            Generator079.generators[0].CallRpcOvercharge();
            foreach (Door door in UnityEngine.Object.FindObjectsOfType <Door>())
            {
                Scp079Interactable component = door.GetComponent <Scp079Interactable>();
                if (component.currentZonesAndRooms[0].currentZone == "HeavyRooms" && door.isOpen && !door.locked)
                {
                    door.ChangeState(true);
                }
            }
            Recontainer079.isLocked = true;
            for (int k = 0; k < 500; k++)
            {
                yield return(0f);
            }
            Recontainer079.isLocked = false;
        }
Exemplo n.º 4
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            if (args.Length > 0)
            {
                if (args[0] == "reload")
                {
                    if (plugin.data_enabled)
                    {
                        plugin.LoadPlayersData();
                        return(new string[] { "Player Data Reload!" });
                    }
                    else
                    {
                        return(new string[] { "Player Data Disabled, not load." });
                    }
                }
                else if (args[0] == "prune")
                {
                    if (plugin.data_enabled)
                    {
                        foreach (var tar in plugin.playersData.ToArray())
                        {
                            if (tar.level == 1 && tar.exp == 0)
                            {
                                plugin.playersData.Remove(tar);
                            }
                        }

                        plugin.SavePlayersData();

                        return(new string[] { "database pruned." });
                    }
                    else
                    {
                        return(new string[] { "Player Data Disabled" });
                    }
                }
                else if (args[0] == "blackout")
                {
                    List <Room> rooms = new List <Room>(plugin.Server.Map.Get079InteractionRooms(Scp079InteractionType.CAMERA)).FindAll(x => x.ZoneType == ZoneType.LCZ);
                    foreach (Room r in rooms)
                    {
                        r.FlickerLights();
                    }
                    Generator079.mainGenerator.CallRpcOvercharge();

                    return(new string[] { "blackout success." });
                }
                else if (args[0] == "lcza")
                {
                    DecontaminationLCZ lcz = GameObject.Find("Host").GetComponent <DecontaminationLCZ>();

                    int anm;
                    if (args.Length > 1 && int.TryParse(args[1], out anm))
                    {
                        lcz.CallRpcPlayAnnouncement(Mathf.Clamp(anm, 0, 5), true);
                        return(new string[] { $"lcz announcement:{Mathf.Clamp(anm, 0, 5)}" });
                    }
                }
                else if (args[0] == "amb")
                {
                    int amb;
                    if (args.Length > 1 && int.TryParse(args[1], out amb))
                    {
                        SanyaPlugin.CallAmbientSound(Mathf.Clamp(amb, 0, 31));

                        return(new string[] { $"ambient:{Mathf.Clamp(amb, 0, 31)}" });
                    }
                }
                else if (args[0] == "airbomb")
                {
                    if (SanyaPlugin.isAirBombGoing)
                    {
                        SanyaPlugin.isAirBombGoing = false;
                        return(new string[] { "airbomb force stopped." });
                    }
                    else
                    {
                        Timing.RunCoroutine(SanyaPlugin._AirSupportBomb(5, 10, true, true, true), Segment.Update);
                        return(new string[] { "airbomb started!" });
                    }
                }
                else if (args[0] == "gen")
                {
                    if (args.Length > 1)
                    {
                        if (args[1] == "unlock")
                        {
                            foreach (Generator items in plugin.Server.Map.GetGenerators())
                            {
                                items.Unlock();
                            }
                            return(new string[] { "gen unlock." });
                        }
                        else if (args[1] == "open")
                        {
                            foreach (Generator items in plugin.Server.Map.GetGenerators())
                            {
                                if (!items.Engaged)
                                {
                                    items.Open = true;
                                }
                            }
                            return(new string[] { "gen open." });
                        }
                        else if (args[1] == "close")
                        {
                            foreach (Generator items in plugin.Server.Map.GetGenerators())
                            {
                                items.Open = false;
                            }
                            return(new string[] { "gen close." });
                        }
                        else if (args[1] == "act")
                        {
                            float engagecount = 6.0f;
                            foreach (Generator items in plugin.Server.Map.GetGenerators())
                            {
                                if (!items.Engaged)
                                {
                                    items.TimeLeft  = engagecount--;
                                    items.HasTablet = true;
                                }
                            }
                            return(new string[] { "gen activate." });
                        }
                    }
                }
                else if (args[0] == "ev")
                {
                    foreach (Elevator ev in plugin.Server.Map.GetElevators())
                    {
                        ev.Use();
                    }
                    return(new string[] { "EV used." });
                }
                else if (args[0] == "tesla")
                {
                    bool isInstant = false;

                    if (args.Length > 1)
                    {
                        if (args[1] == "i")
                        {
                            isInstant = true;
                        }
                    }

                    foreach (Smod2.API.TeslaGate tesla in plugin.Server.Map.GetTeslaGates())
                    {
                        tesla.Activate(isInstant);
                    }
                    return(new string[] { "tesla activated." });
                }
                else if (args[0] == "shake")
                {
                    plugin.Server.Map.Shake();

                    return(new string[] { "map shaking." });
                }
                else if (args[0] == "femur")
                {
                    SanyaPlugin.Call106Scream();

                    return(new string[] { "Screaming!" });
                }
                else if (args[0] == "heli")
                {
                    SanyaPlugin.CallVehicle(false);

                    return(new string[] { "heli moved." });
                }
                else if (args[0] == "van")
                {
                    SanyaPlugin.CallVehicle(true);

                    return(new string[] { "van spawned." });
                }
                else if (args[0] == "next")
                {
                    if (args.Length > 1)
                    {
                        GameObject host    = GameObject.Find("Host");
                        MTFRespawn respawn = host.GetComponent <MTFRespawn>();
                        if (args[1] == "ci")
                        {
                            respawn.nextWaveIsCI = true;
                            return(new string[] { $"nextIsCi:{respawn.nextWaveIsCI}" });
                        }
                        else if (args[1] == "mtf" || args[1] == "ntf")
                        {
                            respawn.nextWaveIsCI = false;
                            return(new string[] { $"nextisCi:{respawn.nextWaveIsCI}" });
                        }
                    }
                }
                else if (args[0] == "spawn")
                {
                    GameObject host    = GameObject.Find("Host");
                    MTFRespawn respawn = host.GetComponent <MTFRespawn>();

                    if (respawn.nextWaveIsCI)
                    {
                        respawn.timeToNextRespawn = 14f;
                        return(new string[] { $"SpawnSet. nextIsCi:{respawn.nextWaveIsCI}" });
                    }
                    else
                    {
                        respawn.timeToNextRespawn = 19f;
                        return(new string[] { $"SpawnSet. nextIsCi:{respawn.nextWaveIsCI}" });
                    }
                }
                else if (args[0] == "override")
                {
                    Player ply = sender as Player;
                    if (ply != null)
                    {
                        SanyaPlugin.scp_override_steamid = ply.SteamId;
                    }

                    return(new string[] { $"set ok:{SanyaPlugin.scp_override_steamid}" });
                }
                else if (args[0] == "ammo")
                {
                    Player ply = sender as Player;
                    if (ply != null)
                    {
                        ply.SetAmmo(AmmoType.DROPPED_5, 999);
                        ply.SetAmmo(AmmoType.DROPPED_7, 999);
                        ply.SetAmmo(AmmoType.DROPPED_9, 999);
                    }

                    return(new string[] { $"Ammo set full." });
                }
                else if (args[0] == "106")
                {
                    foreach (PocketDimensionExit pde in plugin.Server.Map.GetPocketDimensionExits())
                    {
                        pde.ExitType = PocketDimensionExitType.Exit;
                    }

                    return(new string[] { $"All set to [Exit]." });
                }
                else if (args[0] == "914")
                {
                    if (args.Length > 1)
                    {
                        if (args[1] == "use")
                        {
                            SanyaPlugin.Call914Use();
                            return(new string[] { "914 used." });
                        }
                        else if (args[1] == "change")
                        {
                            SanyaPlugin.Call914Change();
                            return(new string[] { "914 changed." });
                        }
                    }
                }
                else if (args[0] == "939")
                {
                    SanyaPlugin.Call939CanSee();

                    return(new string[] { "939 can all see." });
                }
                else if (args[0] == "096")
                {
                    Scp096PlayerScript.instance.IncreaseRage(1f);

                    return(new string[] { "096 has Raged." });
                }
                else if (args[0] == "079")
                {
                    if (args.Length > 2)
                    {
                        if (args[1] == "level")
                        {
                            foreach (Player player in plugin.Server.GetPlayers(Role.SCP_079))
                            {
                                player.Scp079Data.Level = Mathf.Clamp(int.Parse(args[2]) - 1, 0, 4);
                                player.Scp079Data.ShowLevelUp(Mathf.Clamp(int.Parse(args[2]) - 1, 0, 4));
                            }
                            return(new string[] { $"079 Level Set to:{Mathf.Clamp(int.Parse(args[2]), 1, 5)}" });
                        }
                    }
                    else if (args.Length > 1)
                    {
                        if (args[1] == "ap")
                        {
                            foreach (Player player in plugin.Server.GetPlayers(Role.SCP_079))
                            {
                                player.Scp079Data.AP = player.Scp079Data.MaxAP;
                            }
                            return(new string[] { "079 AP MAX." });
                        }
                    }
                }
                else if (args[0] == "flagtest")
                {
                    if (SanyaPlugin.test)
                    {
                        SanyaPlugin.test = false;
                    }
                    else
                    {
                        SanyaPlugin.test = true;
                    }
                    plugin.Error($"test:{SanyaPlugin.test}");

                    return(new string[] { $"test:{SanyaPlugin.test}" });
                }
                else if (args[0] == "ping")
                {
                    List <string> pinglist = new List <string>();
                    byte          b;

                    foreach (Player player in plugin.Server.GetPlayers())
                    {
                        UnityEngine.Networking.NetworkConnection conn = (player.GetGameObject() as GameObject).GetComponent <NicknameSync>().connectionToClient;
                        pinglist.Add($"Name: {player.Name} IP: {player.IpAddress} Ping: {UnityEngine.Networking.NetworkTransport.GetCurrentRTT(conn.hostId, conn.connectionId, out b)}ms");
                    }

                    return(pinglist.ToArray());
                }
                else if (args[0] == "now")
                {
                    return(new string[] { TimeBehaviour.CurrentTimestamp().ToString() });
                }
                else if (args[0] == "randomitem")
                {
                    List <string>     returned = new List <string>();
                    RandomItemSpawner rnde     = UnityEngine.GameObject.FindObjectOfType <RandomItemSpawner>();
                    foreach (var i in rnde.posIds)
                    {
                        returned.Add($"{i.index}:{i.posID}:{i.position.position}");
                    }
                    returned.Add($"-----");
                    foreach (var i in rnde.pickups)
                    {
                        returned.Add($"{i.itemID}:{i.posID}:{(ItemType)i.itemID}");
                    }
                    return(returned.ToArray());
                }
                else if (args[0] == "namechange")
                {
                    Player ply = sender as Player;
                    if (ply != null)
                    {
                        if (args.Length > 1)
                        {
                            GameObject gameObject = ply.GetGameObject() as GameObject;
                            if (gameObject != null)
                            {
                                plugin.Warn($"[NameChanger] {ply.Name} -> {args[1]}");

                                gameObject.GetComponent <NicknameSync>().NetworkmyNick           = args[1];
                                gameObject.GetComponent <CharacterClassManager>().NetworkSteamId = string.Empty;
                                if (plugin.level_enabled)
                                {
                                    ply.SetRank("default", $"Level{UnityEngine.Random.Range(1, 50)}", null);
                                }
                                else
                                {
                                    Timing.RunCoroutine(SanyaPlugin._DelayedRefreshTag(ply), Segment.Update);
                                }
                                if (plugin.score_summary_inround)
                                {
                                    PlayerScoreInfo target = SanyaPlugin.eventhandler.scoredb.Find(x => x.player.PlayerId == ply.PlayerId);
                                    if (target != null)
                                    {
                                        SanyaPlugin.eventhandler.scoredb.Remove(target);
                                        SanyaPlugin.eventhandler.scoredb.Add(new PlayerScoreInfo(plugin.Server.GetPlayer(ply.PlayerId)));
                                    }
                                }

                                return(new string[] { $"Change to : {ply.Name} -> {args[1]}" });
                            }
                            else
                            {
                                return(new string[] { "Error. (GameObject cast error)" });
                            }
                        }
                        else
                        {
                            return(new string[] { "param \"Name\" not found." });
                        }
                    }
                    else
                    {
                        return(new string[] { "only can use player." });
                    }
                }
                else if (args[0] == "test")
                {
                    Player        ply        = sender as Player;
                    GameObject    gameObject = null;
                    GameObject    host       = GameObject.Find("Host");
                    System.Random rnd        = new System.Random();

                    if (ply != null)
                    {
                        gameObject = ply.GetGameObject() as GameObject;
                    }

                    //foreach (Camera079 item in Scp079PlayerScript.allCameras)
                    //{
                    //    if(item.cameraName.Contains("ICOM"))
                    //        plugin.Debug($"Name:{item.cameraName}");
                    //}

                    //foreach(Smod2.API.Player p in plugin.Server.GetPlayers())
                    //{
                    //    FootstepSync foots = (p.GetGameObject() as UnityEngine.GameObject).GetComponent<FootstepSync>();

                    //    foots.CallCmdSyncFoot(true);
                    //}

                    //if(args.Length > 1)
                    //{
                    //    SanyaPlugin.CallAmbientSound(int.Parse(args[1]));
                    //}

                    //RandomItemSpawner rnde = UnityEngine.GameObject.FindObjectOfType<RandomItemSpawner>();

                    //foreach(var i in rnde.pickups)
                    //{
                    //    plugin.Info($"{i.itemID} {i.posID}");
                    //}

                    //foreach(var i in rnde.posIds)
                    //{
                    //    plugin.Info($"{i.index} {i.posID} {i.position.position}");
                    //}

                    //(ply.GetGameObject() as UnityEngine.GameObject).GetComponent<FlashEffect>().CallCmdBlind(true);

                    //Scp049PlayerScript s049 = gameObject.GetComponent<Scp049PlayerScript>();
                    //Vector3 position = s049.plyCam.transform.position;
                    //Vector3 forward = s049.plyCam.transform.forward;

                    //plugin.Debug($"Raycast...");
                    //RaycastHit raycastHit;
                    //if (Physics.Raycast(position, forward, out raycastHit, 500f, 262144))
                    //{
                    //    plugin.Error($"name:{raycastHit.transform.name} parent:{raycastHit.transform.parent.name} root:{raycastHit.transform.root.name}");
                    //}
                    //else
                    //{
                    //    plugin.Warn($"not hit(raycast)");
                    //}

                    //plugin.Debug($"CheckGround...");
                    //Vector3 pos = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y - 0.8f, gameObject.transform.position.z);
                    //Collider[] hits = Physics.OverlapBox(pos, FallDamage.GroundCheckSize, new Quaternion(0f, 0f, 0f, 0f), FallDamage.staticGroundMask);
                    //if (hits.Length != 0)
                    //{
                    //    foreach (var i in hits)
                    //    {
                    //        plugin.Error($"name:{i.transform.name} parent:{i.transform.parent.name} root:{i.transform.root.name}");
                    //    }
                    //}
                    //else
                    //{
                    //    plugin.Warn($"not hit(ground)");
                    //}

                    //foreach (var i in GameObject.FindObjectsOfType<TeslaGate>())
                    //{
                    //    plugin.Debug($"{i.killerMask.ToString()}");
                    //}

                    //for (int i = 0; i < 32; i++)
                    //{
                    //    plugin.Debug($"Layer[{i}]{LayerMask.LayerToName(i)}");
                    //    if (((1 << i) & 1208246273) != 0)
                    //    {
                    //        plugin.Warn($"1208246273 in [{i}]");
                    //    }
                    //    if (((1 << i) & 1207976449) != 0)
                    //    {
                    //        plugin.Warn($"1207976449 in [{i}]");
                    //    }
                    //}

                    //plugin.Debug($"{LayerMask.GetMask(new string[] { "CCTV" })}");

                    //CharacterClassManager ccm = gameObject.GetComponent<CharacterClassManager>();
                    //PlayerStats.HitInfo info = new PlayerStats.HitInfo(1f, ply.Name, DamageTypes.None, ply.PlayerId);
                    //gameObject.GetComponent<RagdollManager>().SpawnRagdoll(gameObject.transform.position, gameObject.transform.rotation, ccm.curClass, info, false,
                    //    gameObject.GetComponent<Dissonance.Integrations.UNet_HLAPI.HlapiPlayer>().PlayerId, gameObject.GetComponent<NicknameSync>().myNick,
                    //    gameObject.GetComponent<RemoteAdmin.QueryProcessor>().PlayerId, gameObject);

                    //plugin.Debug($"{GameObject.FindObjectOfType<TeslaGate>().killerMask.value}");

                    //RandomItemSpawner rnde = UnityEngine.GameObject.FindObjectOfType<RandomItemSpawner>();
                    //foreach (var pos in rnde.posIds)
                    //{
                    //    plugin.Warn($"[{pos.index}] {pos.posID} -> [{pos.position.position}]");
                    //}

                    //plugin.Debug($"{(ply.GetCurrentItem().GetComponent() as Inventory).items[(ply.GetCurrentItem().GetComponent() as Inventory).curItem].}");

                    //var outside = GameObject.FindObjectOfType<AlphaWarheadOutsitePanel>();

                    //if(outside != null)
                    //{
                    //    outside.SetKeycardState(false);
                    //}

                    //GrenadeManager gre = GameObject.FindObjectOfType<GrenadeManager>();
                    //foreach (var i in GrenadeManager.grenadesOnScene)
                    //{
                    //    plugin.Error($"{i.id}");
                    //    gre.CallRpcExplode(i.id, ply.PlayerId);
                    //}

                    //GrenadeManager gre = GameObject.FindObjectOfType<GrenadeManager>();
                    //foreach(var i in gre.availableGrenades)
                    //{
                    //    plugin.Error($"{i.apiName}[{i.inventoryID}]:{i.timeUnitilDetonation}");
                    //}

                    //GrenadeManager gre = GameObject.FindObjectOfType<GrenadeManager>();
                    //foreach (var i in GrenadeManager.grenadesOnScene)
                    //{
                    //    plugin.Error($"{i.id}:{i.transform.position}");
                    //}

                    //plugin.Error($"return:{MEC.Timing.KillCoroutines("FollowingGrenade")}");

                    //gameObject.GetComponent<PlyMovementSync>().SetAllowInput(SanyaPlugin.test);

                    //for(var i = 0; i < Scp079PlayerScript.allCameras.Length; i++)
                    //{
                    //    plugin.Warn($"[{i}]{Scp079PlayerScript.allCameras[i].cameraName}");
                    //}

                    //plugin.Error($"{plugin.Server.GetAppFolder(false,true)}");
                    //plugin.Error($"{plugin.Server.GetAppFolder(true,true)}");
                    //plugin.Warn($"{gameObject.GetComponent<ServerRoles>().GetUncoloredRoleString()}:{gameObject.GetComponent<ServerRoles>().MyColor}");

                    //plugin.Error($"Count:{plugin.playersData.Count}");
                    //foreach(PlayerData player in plugin.playersData)
                    //{
                    //    plugin.Error($"{player.steamid}:{player.level}:{player.exp}");
                    //}

                    //foreach(PlayerData data in plugin.playersData)
                    //{
                    //    plugin.Warn($"{data.steamid}:Level{data.level}({data.exp}EXP/Next:{Mathf.Clamp(data.level*3-data.exp,0,data.level*3-data.exp)})");
                    //}

                    //MEC.Timing.RunCoroutine(plugin._CheckIsLimitedSteam(ply), MEC.Segment.FixedUpdate);

                    //ServerConsole.Disconnect(gameObject, plugin.steam_kick_limited_message);

                    //plugin.Error($"{host.GetComponent<MTFRespawn>().timeToNextRespawn}");

                    //foreach(var i in gameObject.GetComponent<Medkit>().Medkits)
                    //{
                    //    plugin.Error($"{i.InventoryID}:{i.Label}:{i.MaximumHealthRegeneration}:{i.MinimumHealthRegeneration}");
                    //}

                    //gameObject.GetComponent<Inventory>().NetworkcurItem = -1;

                    //plugin.Error($"{LayerMask.GetMask(new string[] { "Ragdoll" })}");

                    //foreach(var i in plugin.playersData)
                    //{
                    //    plugin.Error($"{i.steamid}:{i.limited}");
                    //    i.limited = true;
                    //}

                    //plugin.SavePlayersData();

                    //RandomItemSpawner rnde = UnityEngine.GameObject.FindObjectOfType<RandomItemSpawner>();
                    //foreach(var i in rnde.posIds)
                    //{
                    //    plugin.Error($"{i.index}:{i.posID}:{i.position.position}");
                    //}
                    //plugin.Error($"-----");
                    //foreach(var i in rnde.pickups)
                    //{
                    //    plugin.Error($"{i.itemID}:{i.posID}:{(ItemType)i.itemID}");
                    //}

                    //var lcz = host.GetComponent<DecontaminationLCZ>();
                    //foreach(var i in lcz.announcements)
                    //{
                    //    plugin.Error($"{i.startTime}:{i.options}");
                    //}

                    //GameObject[] array = GameObject.FindGameObjectsWithTag("RoomID");
                    //foreach(GameObject gameObject2 in array)
                    //{
                    //    if(gameObject2.GetComponent<Rid>() != null)
                    //    {
                    //        plugin.Error($"{gameObject2.GetComponent<Rid>().id}:{gameObject2.transform.position}");
                    //    }
                    //}

                    //foreach(var pos in SanyaPlugin.Call106PDRandomExit(false))
                    //{
                    //    plugin.Error($"{pos}");
                    //}

                    //GameObject tunnel = GameObject.Find("Root_CollapsedTunnel");
                    //GameObject entrance = GameObject.Find("EntranceRooms");

                    //if(tunnel != null)
                    //{
                    //    plugin.Error($"{tunnel.name}/{tunnel.transform.position}");
                    //}

                    //if(entrance != null)
                    //{
                    //    plugin.Error($"{entrance.name}/{entrance.transform.position}");
                    //    foreach(Transform i in entrance.GetComponentInChildren<Transform>())
                    //    {
                    //        plugin.Error($"{i.name}/{i.position}/{i.localPosition}");
                    //        plugin.Error($"--->{i.}");
                    //    }
                    //}

                    //ImageGenerator ig_ent = null;
                    //ImageGenerator ig_hcz = null;
                    //ImageGenerator ig_lcz = null;

                    //foreach(ImageGenerator ig in GameObject.FindObjectsOfType<ImageGenerator>())
                    //{
                    //    if(ig.height == 0)
                    //    {
                    //        plugin.Error("lcz found");
                    //        ig_lcz = ig;
                    //    }else if(ig.height == -1000)
                    //    {
                    //        plugin.Error("hcz found");
                    //        ig_hcz = ig;
                    //    }
                    //    else
                    //    {
                    //        plugin.Error("ent found");
                    //        ig_ent = ig;
                    //    }
                    //}

                    //foreach(var i in ig_ent.roomsOfType)
                    //{
                    //    foreach(var x in i.roomsOfType)
                    //    {
                    //        foreach(var y in x.room)
                    //        {
                    //            plugin.Error($"{y.name}/{x.type}");
                    //        }
                    //    }
                    //}

                    //int testmask = 1208246273;
                    //testmask |= 1 << 4;
                    //plugin.Debug($"{testmask}");

                    //for(int i = 0; i < 32; i++)
                    //{
                    //    plugin.Debug($"Layer[{i}]{LayerMask.LayerToName(i)}");
                    //    if(((1 << i) & 1208246273) != 0)
                    //    {
                    //        plugin.Warn($"1208246273 in [{i}]");
                    //    }
                    //    if(((1 << i) & testmask) != 0)
                    //    {
                    //        plugin.Warn($"testmask in [{i}]");
                    //    }
                    //}

                    //foreach(var i in UnityEngine.Object.FindObjectsOfType<BreakableWindow>())
                    //{
                    //    plugin.Error($"{i.health}");
                    //}

                    //foreach(var i in UnityEngine.Object.FindObjectsOfType<Radio>())
                    //{
                    //    System.Type radiotype = i.GetType();
                    //    var myRadio = radiotype.GetField("myRadio", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    //    var radioUniq = radiotype.GetField("radioUniq", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    //    plugin.Error($"name:{i.name}/isLocalPlayer:{i.isLocalPlayer}/myRadio:{(int)myRadio.GetValue(i)}/radioUniq:{(int)radioUniq.GetValue(i)}");
                    //}

                    return(new string[] { "test ok" });
                }
            }

            return(new string[] { GetUsage() });
        }
Exemplo n.º 5
0
    public void SetRandomRoles()
    {
        MTFRespawn component = base.GetComponent <MTFRespawn>();

        if (base.isLocalPlayer && base.isServer)
        {
            List <GameObject> list    = new List <GameObject>();
            List <GameObject> list2   = new List <GameObject>();
            GameObject[]      players = PlayerManager.singleton.players;
            foreach (GameObject item in players)
            {
                list.Add(item);
            }
            while (list.Count > 0)
            {
                int index = UnityEngine.Random.Range(0, list.Count);
                list2.Add(list[index]);
                list.RemoveAt(index);
            }
            GameObject[] array2     = list2.ToArray();
            RoundSummary component2 = base.GetComponent <RoundSummary>();
            bool         flag       = false;
            if ((float)UnityEngine.Random.Range(0, 100) < this.ciPercentage)
            {
                flag = true;
            }
            for (int j = 0; j < array2.Length; j++)
            {
                int num = (this.forceClass != -1) ? this.forceClass : this.Find_Random_ID_Using_Defined_Team(this.classTeamQueue[j]);
                if (this.klasy[num].team == Team.CDP)
                {
                    component2.summary.classD_start++;
                }
                if (this.klasy[num].team == Team.RSC)
                {
                    component2.summary.scientists_start++;
                }
                if (this.klasy[num].team == Team.SCP)
                {
                    component2.summary.scp_start++;
                }
                if (num == 4)
                {
                    if (flag)
                    {
                        num = 8;
                    }
                    else
                    {
                        component.playersToNTF.Add(array2[j]);
                    }
                }
                if (TutorialManager.status)
                {
                    this.SetPlayersClass(14, base.gameObject);
                }
                else if (num != 4)
                {
                    this.SetPlayersClass(num, array2[j]);
                }
            }
            component.SummonNTF();
        }
    }
Exemplo n.º 6
0
        public static bool Prefix(MTFRespawn __instance)
        {
            if (EventPlugin.RespawnPatchDisable)
            {
                return(true);
            }

            try
            {
                int num = 0;
                __instance.playersToNTF.Clear();

                Log.Debug($"Respawn: Got players: {EventPlugin.DeadPlayers.Count}");

                foreach (ReferenceHub player in EventPlugin.DeadPlayers.ToArray())
                {
                    if (player.GetOverwatch() || player.GetRole() != RoleType.Spectator)
                    {
                        Log.Debug($"Removing {player.GetNickname()} -- Overwatch true or not spectator");
                        EventPlugin.DeadPlayers.Remove(player);
                    }
                }

                if (Plugin.Config.GetBool("exiled_random_respawns"))
                {
                    EventPlugin.DeadPlayers.ShuffleList();
                }

                bool isChaos    = __instance.nextWaveIsCI;
                int  maxRespawn = isChaos ? __instance.maxCIRespawnAmount : __instance.maxMTFRespawnAmount;

                List <ReferenceHub> playersToRespawn = EventPlugin.DeadPlayers.Take(maxRespawn).ToList();
                Log.Debug($"Respawn: pre-vent list: {playersToRespawn.Count}");
                Events.InvokeTeamRespawn(ref isChaos, ref maxRespawn, ref playersToRespawn);

                if (maxRespawn <= 0 || playersToRespawn == null || playersToRespawn.Count == 0)
                {
                    return(false);
                }

                foreach (ReferenceHub player in playersToRespawn)
                {
                    if (num >= maxRespawn)
                    {
                        break;
                    }

                    if (player != null)
                    {
                        ++num;
                        if (isChaos)
                        {
                            __instance.GetComponent <CharacterClassManager>().SetPlayersClass(RoleType.ChaosInsurgency, player.gameObject);
                            ServerLogs.AddLog(ServerLogs.Modules.ClassChange, player.GetNickname() + " (" + player.GetUserId() +
                                              ") respawned as Chaos Insurgency agent.", ServerLogs.ServerLogType.GameEvent);
                        }
                        else
                        {
                            __instance.playersToNTF.Add(player.gameObject);
                        }

                        EventPlugin.DeadPlayers.Remove(player);
                    }
                }

                if (num > 0)
                {
                    ServerLogs.AddLog(ServerLogs.Modules.ClassChange,
                                      (__instance.nextWaveIsCI ? "Chaos Insurgency" : "MTF") + " respawned!", ServerLogs.ServerLogType.GameEvent);
                    if (__instance.nextWaveIsCI)
                    {
                        __instance.Invoke("CmdDelayCIAnnounc", 1f);
                    }
                }

                __instance.SummonNTF();
                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"RespawnEvent error: {exception}");
                return(true);
            }
        }
Exemplo n.º 7
0
        public static bool Prefix(MTFRespawn __instance)
        {
            if (EventPlugin.RespawnPatchDisable)
            {
                return(true);
            }

            try
            {
                int num = 0;
                __instance.playersToNTF.Clear();
                List <GameObject> players = EventPlugin.DeadPlayers;
                Log.Debug($"Respawn: Got players: {players.Count}");
                foreach (GameObject player in players.ToArray())
                {
                    if (player.GetComponent <ServerRoles>().OverwatchEnabled || player.GetComponent <CharacterClassManager>().CurClass != RoleType.Spectator)
                    {
                        Log.Debug($"Removing {Player.GetPlayer(player)} -- Overwatch true");
                        players.Remove(player);
                    }
                }

                if (Plugin.Config.GetBool("exiled_random_respawns"))
                {
                    players.ShuffleList();
                }
                bool isChaos                = __instance.nextWaveIsCI;
                int  maxRespawn             = isChaos ? __instance.maxCIRespawnAmount : __instance.maxMTFRespawnAmount;
                List <GameObject> toRespawn = players.Take(maxRespawn).ToList();
                Log.Debug($"Respawn: pre-vent list: {toRespawn.Count}");
                Events.InvokeTeamRespawn(ref isChaos, ref maxRespawn, ref toRespawn);

                foreach (GameObject ply in toRespawn)
                {
                    if (!(ply == null))
                    {
                        ++num;
                        if (isChaos)
                        {
                            __instance.GetComponent <CharacterClassManager>()
                            .SetPlayersClass(RoleType.ChaosInsurgency, ply);
                            ServerLogs.AddLog(ServerLogs.Modules.ClassChange,
                                              ply.GetComponent <NicknameSync>().MyNick + " (" + ply.GetComponent <CharacterClassManager>().UserId +
                                              ") respawned as Chaos Insurgency agent.", ServerLogs.ServerLogType.GameEvent);
                        }
                        else
                        {
                            __instance.playersToNTF.Add(ply);
                        }

                        EventPlugin.DeadPlayers.Remove(ply);
                    }
                }

                if (num > 0)
                {
                    ServerLogs.AddLog(ServerLogs.Modules.ClassChange,
                                      (__instance.nextWaveIsCI ? "Chaos Insurgency" : "MTF") + " respawned!", ServerLogs.ServerLogType.GameEvent);
                    if (__instance.nextWaveIsCI)
                    {
                        __instance.Invoke("CmdDelayCIAnnounc", 1f);
                    }
                }

                __instance.SummonNTF();
                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"Respawn Event error: {e}");
                return(true);
            }
        }
Exemplo n.º 8
0
        public string CallvoteHandler(ReferenceHub player, string[] args)         // lowercase to match command
        {
            Log.Info(player.nicknameSync.MyNick + " called vote with arguments: ");
            for (int i = 0; i < args.Length; i++)
            {
                Log.Info("\t" + i + ": " + args[i]);
            }
            if (args.Length == 0)
            {
                //return new string[] { "callvote RestartRound", "callvote Kick <player>", "callvote <custom> [options]" };
                return("callvote Kick/Kill/<custom> <player>/[options]");
            }
            else
            {
                if (CurrentVote != null)
                {
                    //return new string[] { "A vote is currently in progress." };
                    return("A vote is currently in progress.");
                }
                else
                {
                    Dictionary <int, string> options = new Dictionary <int, string>();
                    switch (args[0].ToLower())
                    {
                    case "kick":
                        if (this.EnableKick)
                        {
                            if (!player.CheckPermission("playervote.kick"))
                            {
                                return("You don't have the required permission to call kick votes.");
                            }

                            if (args.Length == 1)
                            {
                                return("callvote Kick <player>");
                            }
                            else
                            {
                                Log.Info("Vote called by " + player.nicknameSync.MyNick + " to " + args[0] + " player " + args[1]);

                                ReferenceHub locatedPlayer = Player.GetPlayer(args[1]);
                                if (locatedPlayer != null)
                                {
                                    options[1] = "Yes";
                                    options[2] = "No";

                                    StartVote(new Vote(player.nicknameSync.MyNick + " asks: Kick " + locatedPlayer.nicknameSync.MyNick + "?", options), delegate(Vote vote)
                                    {
                                        int votePercent = (int)((float)vote.Counter[1] / (float)(ServerConsole.PlayersAmount - 1) * 100f);
                                        if (votePercent >= this.ThresholdKick)
                                        {
                                            Extensions.BC(5, votePercent + "% voted yes. Kicking player " + locatedPlayer.nicknameSync.MyNick + ".");
                                            GameCore.Console.singleton.TypeCommand($"/ban " + locatedPlayer.queryProcessor.PlayerId + " 0", new PVoteSender());
                                        }
                                        else
                                        {
                                            Extensions.BC(5, "Only " + votePercent + "% voted yes. " + this.ThresholdKick + "% was required to kick " + locatedPlayer.nicknameSync.MyNick + ".");
                                        }
                                    });

                                    break;
                                }
                                else
                                {
                                    return("Did not find any players with the name or partial name of " + args[1]);
                                }
                            }
                        }
                        else
                        {
                            return("callvote Kick is not enabled.");
                        }

                    case "kill":
                        if (this.EnableKill)
                        {
                            if (!player.CheckPermission("playervote.kill"))
                            {
                                return("You don't have the required permission to call kill votes.");
                            }

                            if (args.Length == 1)
                            {
                                return("callvote Kill <player>");
                            }
                            else
                            {
                                Log.Info("Vote called by " + player.nicknameSync.MyNick + " to " + args[0] + " player " + args[1]);

                                ReferenceHub locatedPlayer = Player.GetPlayer(args[1]);
                                if (locatedPlayer != null)
                                {
                                    options[1] = "Yes";
                                    options[2] = "No";

                                    StartVote(new Vote(player.nicknameSync.MyNick + " asks: Kill " + locatedPlayer.nicknameSync.MyNick + "?", options), delegate(Vote vote)
                                    {
                                        int votePercent = (int)((float)vote.Counter[1] / (float)(ServerConsole.PlayersAmount - 1) * 100f);
                                        if (votePercent >= this.ThresholdKill)
                                        {
                                            Extensions.BC(5, votePercent + "% voted yes. Killing player " + locatedPlayer.nicknameSync.MyNick + ".");
                                            locatedPlayer.playerStats.SetHPAmount(0);
                                            locatedPlayer.playerStats._hpDirty = true;
                                        }
                                        else
                                        {
                                            Extensions.BC(5, "Only " + votePercent + "% voted yes. " + this.ThresholdKill + "% was required to kill " + locatedPlayer.nicknameSync.MyNick + ".");
                                        }
                                    });

                                    break;
                                }
                                else
                                {
                                    return("Did not find any players with the name or partial name of " + args[1]);
                                }
                            }
                        }
                        else
                        {
                            return("callvote Kill is not enabled.");
                        }


                    case "nuke":
                        if (EnableNuke)
                        {
                            if (!player.CheckPermission("playervote.nuke"))
                            {
                                return("You don't have the required permission to call nuke votes.");
                            }

                            Log.Info("Vote called by " + player.nicknameSync.MyNick + " to " + args[0]);
                            //return new string[] { "To be implemented." };

                            options[1] = "Yes";
                            options[2] = "No";

                            StartVote(new Vote(player.nicknameSync.MyNick + " asks: NUKE THE FACILITY?!?", options), delegate(Vote vote)
                            {
                                int votePercent = (int)((float)vote.Counter[1] / (float)(ServerConsole.PlayersAmount - 1) * 100f);
                                if (votePercent >= this.ThresholdNuke)
                                {
                                    Extensions.BC(5, votePercent + "% voted yes. Nuking the facility...");
                                    EnableNuke = true;
                                }
                                else
                                {
                                    Extensions.BC(5, "Only " + votePercent + "% voted yes. " + this.ThresholdNuke + "% was required to nuke the facility.");
                                }
                            });
                            break;
                        }
                        else
                        {
                            return("callvote Nuke is not enabled.");
                        }

                    case "respawnwave":
                        if (EnableRespawnWave)
                        {
                            if (!player.CheckPermission("playervote.respawnwave"))
                            {
                                return("You don't have the required permission to call respawnwave votes.");
                            }

                            Log.Info("Vote called by " + player.nicknameSync.MyNick + " to " + args[0]);
                            //return new string[] { "To be implemented." };

                            options[1] = "No";
                            options[2] = "MTF";
                            options[3] = "CI";

                            StartVote(new Vote(player.nicknameSync.MyNick + " asks: Respawn the next wave?", options), delegate(Vote vote)
                            {
                                int votePercent    = (int)((float)vote.Counter[1] / (float)(ServerConsole.PlayersAmount - 1) * 100f);
                                int mtfVotePercent = (int)((float)vote.Counter[2] / (float)(ServerConsole.PlayersAmount - 1) * 100f);
                                int ciVotePercent  = (int)((float)vote.Counter[3] / (float)(ServerConsole.PlayersAmount - 1) * 100f);
                                if (mtfVotePercent >= this.ThresholdRespawnWave)
                                {
                                    Extensions.BC(5, mtfVotePercent + "% voted yes. Respawning a wave of Nine-Tailed Fox...");

                                    MTFRespawn _MTFRespawn = PlayerManager.localPlayer.GetComponent <MTFRespawn>();

                                    bool oldNextRespawn      = _MTFRespawn.nextWaveIsCI;
                                    _MTFRespawn.nextWaveIsCI = false;
                                    _MTFRespawn.RespawnDeadPlayers();
                                    _MTFRespawn.nextWaveIsCI = oldNextRespawn;
                                }
                                else if (ciVotePercent >= this.ThresholdRespawnWave)
                                {
                                    Extensions.BC(5, ciVotePercent + "% voted yes. Respawning a wave of Chaos Insurgency...");

                                    MTFRespawn _MTFRespawn = PlayerManager.localPlayer.GetComponent <MTFRespawn>();

                                    bool oldNextRespawn      = _MTFRespawn.nextWaveIsCI;
                                    _MTFRespawn.nextWaveIsCI = true;
                                    _MTFRespawn.RespawnDeadPlayers();
                                    _MTFRespawn.nextWaveIsCI = oldNextRespawn;
                                }
                                else
                                {
                                    Extensions.BC(5, votePercent + "% voted no. " + this.ThresholdRespawnWave + "% was required to respawn the next wave.");
                                }
                            });
                            break;
                        }
                        else
                        {
                            return("callvote RespawnWave is not enabled.");
                        }

                    case "restartround":
                        if (EnableRestartRound)
                        {
                            if (!player.CheckPermission("playervote.restartround"))
                            {
                                return("You don't have the required permission to call restartround votes.");
                            }

                            Log.Info("Vote called by " + player.nicknameSync.MyNick + " to " + args[0]);
                            //return new string[] { "To be implemented." };

                            options[1] = "Yes";
                            options[2] = "No";

                            StartVote(new Vote(player.nicknameSync.MyNick + " asks: Restart the round?", options), delegate(Vote vote)
                            {
                                int votePercent = (int)((float)vote.Counter[1] / (float)(ServerConsole.PlayersAmount - 1) * 100f);
                                if (votePercent >= this.ThresholdRestartRound)
                                {
                                    Extensions.BC(5, votePercent + "% voted yes. Restarting the round...");
                                    PlayerManager.localPlayer.GetComponent <PlayerStats>().Roundrestart();
                                }
                                else
                                {
                                    Extensions.BC(5, "Only " + votePercent + "% voted yes. " + this.ThresholdRestartRound + "% was required to restart the round.");
                                }
                            });
                            break;
                        }
                        else
                        {
                            return("callvote RestartRound is not enabled.");
                        }

                    default:
                        if (!player.CheckPermission("playervote.custom"))
                        {
                            return("You don't have the required permission to call custom votes.");
                        }

                        if (args.Length == 1)
                        {
                            Log.Info("Binary vote called by " + player.nicknameSync.MyNick + ": " + string.Join(" ", args));
                            options[1] = "Yes";
                            options[2] = "No";
                        }
                        else
                        {
                            Log.Info("Multiple-choice vote called by " + player.nicknameSync.MyNick + ": " + string.Join(" ", args));
                            for (int i = 1; i < args.Length; i++)
                            {
                                options[i] = args[i];
                            }
                        }
                        StartVote(new Vote(player.nicknameSync.MyNick + " asks: " + args[0], options), null);
                        break;
                    }
                    return("Vote has been started!");
                }
            }
        }