Beispiel #1
0
        private void SpawnEnemiesOnSurface()
        {
            var spawnRegion = PlayerPed.Position.Around(25f);
            var random      = new Random();
            var totalAliens = random.Next(8, 13);

            for (int i = 0; i < totalAliens; i++)
            {
                var randDist   = Function.Call <float>(Hash.GET_RANDOM_FLOAT_IN_RANGE, 20f, 100f);
                var spawnPoint = spawnRegion.Around(randDist);
                var ground     = World.GetGroundHeight(spawnPoint + Vector3.WorldUp);
                if (ground == 0)
                {
                    continue;
                }

                var ped = GtsLibNet.CreateAlien(null, spawnPoint, random.Next(20, 180));
                ped.Position = new Vector3(ped.Position.X, ped.Position.Y, ground);
                ped.Weapons.Give((WeaponHash)Game.GenerateHash("weapon_pulserifle"), 15, true, true);
                ped.AddBlip();
                ped.IsOnlyDamagedByPlayer = true;
                _alienPeds.Add(ped);
                Script.Yield();
            }
        }
Beispiel #2
0
        public void Start()
        {
            var spawnRegion = new Vector3(-9946.63f, -10148.71f, 1000.36f);
            var random      = new Random();

            for (var i = 0; i < 15; i++)
            {
                var randDist   = Function.Call <float>(Hash.GET_RANDOM_FLOAT_IN_RANGE, 20f, 100f);
                var spawnPoint = spawnRegion.Around(randDist);
                var ground     = World.GetGroundHeight(spawnPoint + Vector3.WorldUp);
                if (ground == 0)
                {
                    continue;
                }
                var ped = GtsLibNet.CreateAlien(null, spawnPoint, random.Next(135, 220));
                ped.Position = new Vector3(ped.Position.X, ped.Position.Y, ground);
                ped.Weapons.Give((WeaponHash)Game.GenerateHash("weapon_pulserifle"), 15, true, true);
                ped.AddBlip();
                ped.IsOnlyDamagedByPlayer = true;
                _hostiles.Add(ped);
                Script.Yield();
            }

            var ufoModel = new Model("zanufo");

            ufoModel.Request();
            while (!ufoModel.IsLoaded)
            {
                Script.Yield();
            }
            for (var i = 0; i < 4; i++)
            {
                var randDist   = Function.Call <float>(Hash.GET_RANDOM_FLOAT_IN_RANGE, 40f, 145f);
                var spawnPoint = spawnRegion.Around(randDist);
                var vehicle    = World.CreateVehicle(ufoModel, spawnPoint);
                vehicle.PlaceOnGround();
                vehicle.IsOnlyDamagedByPlayer = true;
                var pedModel = (Model)GtsLibNet.GetAlienModel();
                pedModel.Request();
                while (!pedModel.IsLoaded)
                {
                    Script.Yield();
                }
                var ped = vehicle.CreatePedOnSeat(VehicleSeat.Driver, pedModel);
                var b   = ped.AddBlip();
                b.Sprite = (BlipSprite)422;
                b.Name   = "UFO";
                ped.IsOnlyDamagedByPlayer = true;
                Function.Call(Hash.SET_CURRENT_PED_VEHICLE_WEAPON, ped,
                              Game.GenerateHash("VEHICLE_WEAPON_PLAYER_LAZER"));
                GtsLibNet.GivePedAlienAttributes(ped);
                pedModel.MarkAsNoLongerNeeded();
                _hostiles.Add(ped);
                _ufos.Add(vehicle);
                Script.Yield();
            }
            ufoModel.MarkAsNoLongerNeeded();
        }