public void PopulateZombies() { Vector3 spawnPosition = new Vector3(0f, 0f, 0f); zombieCount = zombieList.Count; zomPopRanThisFrame = false; zomPopTicksSinceLastUpdate++; if (!zomPopRanThisFrame) { if (zomPopTicksSinceLastUpdate >= zomPopTicksBetweenUpdates) { int tempMaxZombies = maxZombies; if (IsCityZone(Game.Player.Character.Position)) { tempMaxZombies = maxZombies * 2; } for (int i = 0; i < tempMaxZombies; 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 { ZombieSpawn(spawnPosition); zomPopTicksSinceLastUpdate = 0 - RandoMath.CachedRandom.Next(zomPopTicksBetweenUpdates / 3); zomPopRanThisFrame = true; } catch (Exception e) { Debug.Log(e.ToString()); } } } } }
public void PopulateVehicles() { Vector3 spawnPosition = new Vector3(0f, 0f, 0f); Vehicle[] all_vecs = World.GetAllVehicles(); vehicleCount = all_vecs.Length; vehPopRanThisFrame = false; vehPopTicksSinceLastUpdate++; if (!vehPopRanThisFrame) { if (vehPopTicksSinceLastUpdate >= vehPopTicksBetweenUpdates) { int tempMaxVehicles = maxVehicles; if (IsCityZone(Game.Player.Character.Position)) { tempMaxVehicles = maxVehicles * 2; } for (int i = 0; i < tempMaxVehicles; i++) { spawnPosition = World.GetNextPositionOnStreet(Game.Player.Character.Position.Around(maxSpawnDistance), true); Vector3 checkPosition = spawnPosition.Around(5); if (checkPosition.IsOnScreen() || Extensions.DistanceTo(Game.Player.Character, spawnPosition) < minSpawnDistance || IsSafeZone(checkPosition)) { continue; } try { VehicleSpawn(spawnPosition, RandoMath.RandomHeading()); vehPopTicksSinceLastUpdate = 0 - RandoMath.CachedRandom.Next(vehPopTicksBetweenUpdates / 3); vehPopRanThisFrame = true; } catch (Exception e) { Debug.Log(e.ToString()); } } } } }
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()); } } } } }