Example #1
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>");
        }
Example #2
0
        private void SpawnNpcEntity(string prefabPath, Vector3 pos)
        {
            Vector3 point;

            if (FindPointOnNavmesh(pos, 50, out point))
            {
                BaseCombatEntity entity = InstantiateEntity(prefabPath, point);
                entity.enableSaving = false;
                entity.Spawn();

                entity.InitializeHealth(entity.StartHealth(), entity.StartMaxHealth());

                var npc = entity.gameObject.AddComponent <HumanController>();
                npc.SetInfo(prefabPath, point);
                animalList.Add(entity);
            }
        }
Example #3
0
        private void SpawnAnimalEntity(string type, Vector3 pos)
        {
            Vector3 point;

            if (FindPointOnNavmesh(pos, 50, out point))
            {
                BaseCombatEntity entity = InstantiateEntity($"assets/rust.ai/agents/{type}/{type}.prefab", point);
                entity.enableSaving = false;
                entity.Spawn();

                entity.InitializeHealth(entity.StartHealth(), entity.StartMaxHealth());
                entity.lifestate = BaseCombatEntity.LifeState.Alive;

                var npc = entity.gameObject.AddComponent <AnimalController>();
                npc.SetInfo(type, point);
                animalList.Add(entity);
            }
        }