void OnAddCommand(BasePlayer player, string[] args)
        {
            if (args.Length != 2)
            {
                SendReply(player, "Usage: <color=#ffd479>/za add NAME RADIUS</color>");
                return;
            }

            Vector3 position;

            if (!TryFindPointOnNavMesh(player.transform.position, out position))
            {
                SendReply(player, $"Couldn't find a position on the navmesh near your location. Please try again.");
                return;
            }

            string name = args[0].ToLowerInvariant();
            float  radius;

            try
            {
                radius = Convert.ToSingle(args[1]);
            }
            catch
            {
                SendReply(player, $"Radius must be a valid number between 0 and {MAX_SPAWN_RADIUS}");
                return;
            }

            var location = new ZombieAttackLocation(name, position, radius);

            Settings.Locations[name] = location;

            SendReply(player, $"Added <color=#ffd479>{location}</color> as an attack location with a spawn radius of <color=#ffd479>{location.Radius}</color>.");
        }
Beispiel #2
0
        void BeginAttack(ZombieAttackLocation location)
        {
            int attackers = UnityEngine.Random.Range(Settings.MinAttackers, Settings.MaxAttackers);

            Puts($"Sending {attackers} attackers to {location}");

            for (int idx = 0; idx < attackers; idx++)
            {
                Vector3 spawnPosition = GetRandomPositionNear(location.Position, 50f);

                BaseCombatEntity entity = SpawnAttacker(ZOMBIE_PREFAB, spawnPosition);
                entity.enableSaving = false;
                entity.Spawn();
                entity.InitializeHealth(entity.StartHealth(), entity.StartMaxHealth());

                ItemDefinition item = ItemManager.FindItemDefinition(WeaponItems.GetRandom());

                var npc = entity.gameObject.GetComponent <NPCPlayer>();
                npc.inventory.containerBelt.Clear();
                npc.inventory.containerBelt.AddItem(item, 1);
                npc.EquipTest();
                npc.SetDestination(location.Position);

                Puts($"Spawned attacker at {spawnPosition} equipped with {item.name}");
            }

            PrintToChat("<color=#ff0000>THE ATTACK HAS BEGUN!</color>");
        }