// Destroys a door with a set delay.
        private IEnumerator <float> _destroyDoorDelay(Smod2.API.Door door, float delay)
        {
            yield return(Timing.WaitForSeconds(delay));

            Action <Smod2.API.Door> destroyDoor = (d) => d.Destroyed = true;

            destroyDoor(door);
        }
        // This method checks if the door is allowed to be destroyed.
        private bool canBeBrokenDown(Smod2.API.Door door)
        {
            bool breakIfOpen = plugin.GetConfigBool("zbd_breakopendoors");

            if ((door.Open && breakIfOpen) || !door.Open)
            {
                if (!isDisallowed(door))
                {
                    return(true);
                }
            }

            return(false);
        }
        // Counts the amount of zombies within range of the door.
        private List <Player> getZombiesNearby(Smod2.API.Door door, List <Player> zombies)
        {
            List <Player> nearbyZombies = new List <Player>();
            Vector        doorPos       = door.Position;

            foreach (Player zombie in zombies)
            {
                Vector zombiePos = zombie.GetPosition();

                if (Vector.Distance(zombiePos, doorPos) <= plugin.GetConfigFloat("zbd_zombies_range"))
                {
                    nearbyZombies.Add(zombie);
                }
            }

            return(nearbyZombies);
        }
示例#4
0
 public override void EventStart(RoundStartEvent ev)
 {
     if (!isQueue)
     {
         return;
     }
     PluginHandler.Shared.Server.Map.Broadcast(5, Translation["start"], false);
     Smod2.API.Door gate_a = PluginHandler.Shared.Server.Map.GetDoors().Find(x => x.Name == "GATE_A");
     gate_a.Open   = true;
     gate_a.Locked = true;
     Player[] scps = ev.Server.GetPlayers().Where(x => x.TeamRole.Team == Smod2.API.TeamType.SCP).ToArray();
     foreach (Player scp in scps)
     {
         scp.ChangeRole(Smod2.API.RoleType.SCP_049);
         scp.PersonalBroadcast(30, Translation["scp049_start"], false);
     }
 }
示例#5
0
        private async Task HuntersWait()
        {
            foreach (int index in actualHunters)
            {
                Player player = PluginHandler.Shared.Server.GetPlayer(index);
                player.ChangeRole(Smod2.API.RoleType.FACILITY_GUARD);
                player.PersonalBroadcast(30, "Zaraz wkroczysz jako Hunter!", false);
            }
            await Task.Delay(TimeSpan.FromSeconds(30));

            Smod2.API.Door door = PluginHandler.Shared.Server.Map.GetDoors().Find(x => x.Name == "914");
            door.Open = true;
            foreach (int index in actualHunters)
            {
                Player player = PluginHandler.Shared.Server.GetPlayer(index);
                player.Teleport(door.Position);
            }
        }
示例#6
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            if (args.Length > 0)
            {
                Player targetPlayer = args.Length > 1 ? Server.GetPlayers(args[0]).FirstOrDefault() : sender as Player;

                if (targetPlayer == null)
                {
                    return new string[] { "Could not find player" }
                }
                ;

                Managers.ATFile.AddMissingPlayerVariables(targetPlayer);

                SMDoor closestDoor = null;
                float  dist        = float.MaxValue;

                foreach (SMDoor d in Server.Map.GetDoors())
                {
                    float newDist = Vector.Distance(d.Position, targetPlayer.GetPosition());

                    if (newDist < dist)
                    {
                        closestDoor = d;
                        dist        = newDist;
                    }
                }

                switch ((args.Length > 1 ? args[1] : args[0]).ToUpper())
                {
                case "BREAK":
                case "DESTROY":
                case "DESTR":
                case "BRK":
                case "BR":
                    closestDoor.TriggerAction(DoorActions.DESTROYED);
                    return(new string[] { "Closest door broken." });

                case "LOCK":
                case "L":
                    closestDoor.IsLocked = true;
                    return(new string[] { "Closest door locked." });

                case "UNLOCK":
                case "UL":
                case "!L":
                    closestDoor.IsLocked = false;
                    return(new string[] { "Closest door unlocked." });

                case "OPEN":
                case "OP":
                case "O":
                    closestDoor.IsOpen = true;
                    return(new string[] { "Closest door opened." });

                case "CLOSE":
                case "CL":
                case "C":
                    closestDoor.IsOpen = false;
                    return(new string[] { "Closest door closed." });

                default:
                    return(new string[] { "Arguements: \"" + string.Join(" ", args) + "\" is not recognized" });
                }
            }
            else
            {
                return new string[] { GetUsage() }
            };
        }
    }
}
        // When a door is accessed by a zombie, we check if there are enough zombies near the door. If yes, we break it.
        public void OnDoorAccess(PlayerDoorAccessEvent ev)
        {
            int threshold = plugin.GetConfigInt("zbd_zombies_threshold");

            List <Player> zombies = plugin.Server.GetPlayers(Role.SCP_049_2);
            List <Player> nearbyZombies;
            int           nearbyZombiesCount;

            if (ev.Player.TeamRole.Role.Equals(Role.SCP_049_2))
            {
                Smod2.API.Door door = ev.Door;

                // Don't check gates, because you can't open those anyways.
                if (GATE_NAMES.Contains(door.Name))
                {
                    return;
                }

                // Only allow to destroy doors which normally can't be opened.
                if (isDisallowed(door) && plugin.GetConfigBool("zbd_broadcast_cannotopen"))
                {
                    if (!gettingCannotOpenBC.Contains(ev.Player.SteamId))
                    {
                        Timing.RunCoroutine(_displayCantBreak(ev.Player));
                    }
                }
                else if (!ev.Allow && !isMarked(door) && canBeBrokenDown(door))
                {
                    nearbyZombies      = getZombiesNearby(door, zombies);
                    nearbyZombiesCount = nearbyZombies.Count;

                    if (nearbyZombiesCount >= threshold)
                    {
                        float delay = plugin.GetConfigFloat("zbd_delay");

                        // Marking the door for destruction
                        markedDoorsPos.Add(door.Position.GetHashCode());

                        if (plugin.GetConfigBool("zbd_broadcast_countdown"))
                        {
                            // Display the countdown for each player
                            foreach (Player zombie in nearbyZombies)
                            {
                                Timing.RunCoroutine(_displayCountdown(zombie, delay));
                            }
                        }

                        Timing.RunCoroutine(_destroyDoorDelay(door, delay));
                    }
                    else if (plugin.GetConfigBool("zbd_broadcast_zombiesneeded"))
                    {
                        int amountNeeded = threshold - nearbyZombiesCount;

                        // Display zombies needed broadcast, don't do it for players already receiving this broadcast.
                        foreach (Player zombie in nearbyZombies)
                        {
                            if (!gettingZombiesNeededBC.Contains(zombie.SteamId))
                            {
                                Timing.RunCoroutine(_displayZombiesNeeded(zombie, amountNeeded));
                            }
                        }
                    }
                }
            }
        }
        // Checks if a door is in the disallowed list.
        private bool isDisallowed(Smod2.API.Door door)
        {
            string[] disallowedDoors = plugin.GetConfigList("zbd_doors_disallow");

            return(disallowedDoors.Contains(door.Name));
        }
 // Checks if a door will be destroyed
 private bool isMarked(Smod2.API.Door door)
 {
     return(markedDoorsPos.Contains(door.Position.GetHashCode()));
 }