public void VehicleSpawn(Vector3 position, float heading) { int tempMaxVehicles = maxVehicles; if (IsCityZone(Game.Player.Character.Position)) { tempMaxVehicles = maxVehicles * 2; } if (vehicleCount >= tempMaxVehicles || position == Vector3.Zero || Extensions.DistanceBetweenV3(position, startingLoc) < minSpawnDistance || Extensions.DistanceBetweenV3(position, Game.Player.Character.Position) < minSpawnDistance) { return; } else { var model = GetRandomVehicleModel(); var vehicle = Extensions.SpawnVehicle(model, position, heading); int rnd = RandoMath.CachedRandom.Next(0, 100); if (rnd <= 10) { vehicle.EngineHealth = 1000.0f; } else { vehicle.EngineHealth = 0.0f; } vehicle.DirtLevel = 14.0f; var vehicleDoors = vehicle.GetDoors(); for (int i = 0; i < 5; i++) { var door = RandoMath.GetRandomElementFromArray(vehicleDoors); vehicle.OpenDoor(door, false, true); } for (int i = 0; i < 3; i++) { List <int> windows = new List <int>(); if (Function.Call <bool>(Hash.IS_VEHICLE_WINDOW_INTACT, vehicle.Handle, i)) { windows.Add(i); } if (windows.Count > 0) { int window = RandoMath.GetRandomElementFromList(windows); Function.Call(Hash.SMASH_VEHICLE_WINDOW, vehicle.Handle, window); } } } }
public ZombiePed ZombieSpawn(Vector3 pos) { int tempMaxZombies = maxZombies; if (IsCityZone(Game.Player.Character.Position)) { tempMaxZombies = maxZombies * 2; } if (zombieCount >= tempMaxZombies || pos == Vector3.Zero || Extensions.DistanceBetweenV3(pos, startingLoc) < minSpawnDistance || Extensions.DistanceBetweenV3(pos, Game.Player.Character.Position) < minSpawnDistance) { return(null); } else { Ped ped; if (customZombies == true) { Model model = new Model(RandoMath.GetRandomElementFromList(ZombieModels)); ped = World.CreatePed(model, pos); } else { ped = World.CreateRandomPed(pos); } Infect(ped); ZombiePed newZombie = zombieList.Find(match: a => a.pedEntity == ped); if (newZombie == null) { return(null); } return(newZombie); } }
public void PopulateAnimals() { Vector3 spawnPosition = new Vector3(0f, 0f, 0f); animalCount = animalList.Count; aniPopRanThisFrame = false; aniPopTicksSinceLastUpdate++; if (!aniPopRanThisFrame) { if (aniPopTicksSinceLastUpdate >= aniPopTicksBetweenUpdates) { int tempMaxAnimals = maxAnimals; if (IsCityZone(Game.Player.Character.Position)) { tempMaxAnimals = maxAnimals * 2; } for (int i = 0; i < tempMaxAnimals; i++) { int rndNum = RandoMath.CachedRandom.Next(1, 101); if (rndNum <= 40) { spawnPosition = World.GetNextPositionOnStreet(Game.Player.Character.Position.Around(maxSpawnDistance), true); } else { spawnPosition = World.GetNextPositionOnSidewalk(Game.Player.Character.Position.Around(maxSpawnDistance)); } Vector3 checkPosition = spawnPosition.Around(5); if (checkPosition.IsOnScreen() || Extensions.DistanceTo(Game.Player.Character, spawnPosition) < minSpawnDistance || IsSafeZone(checkPosition)) { continue; } try { if (animalCount < tempMaxAnimals) { Model model; if (IsCityZone(spawnPosition)) { model = new Model(RandoMath.GetRandomElementFromList(CityAnimalModels)); } else { model = new Model(RandoMath.GetRandomElementFromList(CountryAnimalModels)); } Ped ped = World.CreatePed(model, spawnPosition); ped.RelationshipGroup = Relationships.AnimalGroup; ped.Task.WanderAround(); animalList.Add(ped); aniPopTicksSinceLastUpdate = 0 - RandoMath.CachedRandom.Next(aniPopTicksBetweenUpdates / 3); aniPopRanThisFrame = true; } } catch (Exception e) { Debug.Log(e.ToString()); } } } } }