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 static Model GetRandomVehicleModel() { Model model = default(Model); if (IsCityZone(Game.Player.Character.Position)) { model = new Model(RandoMath.GetRandomElementFromList(CityVehicleModels)); } else { model = new Model(RandoMath.GetRandomElementFromList(CountryVehicleModels)); } return(model.Request(1500) ? model : null); }
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 void OnTick(object sender, EventArgs e) { if (Game.Player.Character.IsDead) { inventoryMenu.Visible = false; craftCampfireMenu.Visible = false; } if (Main.ModActive) { Game.DisableControlThisFrame(2, GTA.Control.Phone); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Phone) && !Main.MasterMenuPool.IsAnyMenuOpen()) { inventoryMenu.Visible = !inventoryMenu.Visible; } } if (Main.ModActive && !Game.Player.Character.IsInVehicle()) { try { Prop prop = World.GetClosest(Game.Player.Character.Position, World.GetNearbyProps(Game.Player.Character.Position, 2.5f)); if (prop == Character.tent) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to sleep in Tent"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { Population.Sleep(Game.Player.Character.Position); } } else if (prop == Character.campFire) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to craft using Campfire"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { craftCampfireMenu.Visible = !craftCampfireMenu.Visible; } } if (craftCampfireMenu.Visible) { Game.Player.CanControlCharacter = false; } else { Game.Player.CanControlCharacter = true; } Ped ped = World.GetClosest(Game.Player.Character.Position, World.GetNearbyPeds(Game.Player.Character, 1.5f)); if (!(ped == null) && ped.IsDead && ped.IsHuman && !lootedPeds.Contains(ped)) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to search corpse"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { Game.Player.Character.Task.PlayAnimation("pickup_object", "pickup_low"); int itemRnd = RandoMath.CachedRandom.Next(0, 10); if (itemRnd < 3) { List <InventoryItem> itemsToFind = playerItemInventory; for (int i = 0; i < itemsToFind.Count; i++) { if (itemsToFind[i].GetType() == typeof(InventoryCraftableFoodItem)) { itemsToFind.Remove(itemsToFind[i]); } } InventoryItem itemFound = RandoMath.GetRandomElementFromList(itemsToFind); int invCheckAmount = playerItemInventory.Find(item => item.Name == itemFound.Name).Amount; int invCheckMaxAmount = playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount; if (invCheckAmount == invCheckMaxAmount) { UI.Notify("Found ~b~" + itemFound.Name + "~w~ but inventory is full!", true); } else { playerItemInventory.Find(item => item.Name == itemFound.Name).Amount++; UI.Notify("Found ~b~" + itemFound.Name + "~g~ (" + playerItemInventory.Find(item => item.Name == itemFound.Name).Amount + "/" + playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount + ")", true); lootedPeds.Add(ped); itemsSubMenu.MenuItems.Find(item => item.Text == itemFound.Name).SetRightLabel("(" + playerItemInventory.Find(item => item.Name == itemFound.Name).Amount + "/" + playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount + ")"); } } else if (itemRnd > 5) { List <InventoryMaterial> materialsToFind = playerMaterialInventory; for (int i = 0; i < materialsToFind.Count; i++) { if (materialsToFind[i].GetType() == typeof(InventoryCraftableMaterial) || materialsToFind[i].Name == "Raw Meat") { materialsToFind.Remove(materialsToFind[i]); } } InventoryItem materialFound = RandoMath.GetRandomElementFromList(materialsToFind); int invCheckAmount = playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount; int invCheckMaxAmount = playerMaterialInventory.Find(material => material.Name == materialFound.Name).MaxAmount; if (invCheckAmount == invCheckMaxAmount) { UI.Notify("Found ~b~" + materialFound.Name + "~w~ but inventory is full!", true); } else { playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount++; UI.Notify("Found ~b~" + materialFound.Name + "~g~ (" + playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount + "/" + playerMaterialInventory.Find(material => material.Name == materialFound.Name).MaxAmount + ")", true); lootedPeds.Add(ped); materialsSubMenu.MenuItems.Find(item => item.Text == materialFound.Name).SetRightLabel("(" + playerMaterialInventory.Find(item => item.Name == materialFound.Name).Amount + "/" + playerMaterialInventory.Find(item => item.Name == materialFound.Name).MaxAmount + ")"); craftCampfireMenu.MenuItems.Find(item => item.Text == materialFound.Name).SetRightLabel("(" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")"); } } else { UI.Notify("Found nothing", true); lootedPeds.Add(ped); } } } else if (!(ped == null) && ped.IsDead && !ped.IsHuman && !lootedPeds.Contains(ped)) { Extensions.DisplayHelpTextThisFrame("Press ~INPUT_CONTEXT~ to harvest meat from animal corpse"); Game.DisableControlThisFrame(2, GTA.Control.Context); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context)) { if (Game.Player.Character.Weapons.HasWeapon(WeaponHash.Knife)) { int invCheckAmount = playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount; int invCheckMaxAmount = playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount; if (invCheckAmount == invCheckMaxAmount) { UI.Notify("You cannot carry any more ~b~Raw Meat~w~!", true); } else { Game.Player.Character.Weapons.Select(WeaponHash.Knife, true); Game.Player.Character.Task.PlayAnimation("pickup_object", "pickup_low", 8f, 3000, AnimationFlags.None); playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount++; materialsSubMenu.MenuItems.Find(item => item.Text == "Raw Meat").SetRightLabel("(" + playerMaterialInventory.Find(item => item.Name == "Raw Meat").Amount + "/" + playerMaterialInventory.Find(item => item.Name == "Raw Meat").MaxAmount + ")"); craftCampfireMenu.MenuItems[0].SetRightLabel("(" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")"); UI.Notify("You have harvested ~b~Raw Meat ~g~(" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + "/" + playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount + ")", true); lootedPeds.Add(ped); } } else { UI.Notify("You need a knife to harvest ~b~Raw Meat~w~ from dead animals!", true); } } } } catch (Exception x) { Debug.Log(x.ToString()); } } }
public static SurvivorPed SurvivorSpawn(Vector3 pos) { Ped ped; if (customSurvivors == true) { Model model = new Model(RandoMath.GetRandomElementFromList(SurvivorModels)); ped = World.CreatePed(model, pos.Around(5f)); } else { ped = World.CreateRandomPed(pos.Around(5f)); } Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, ped.Handle, 0, 0); Function.Call(Hash.SET_PED_PATH_CAN_USE_CLIMBOVERS, ped.Handle, true); Function.Call(Hash.SET_PED_PATH_CAN_USE_LADDERS, ped.Handle, true); Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, ped.Handle, true); Function.Call(Hash.SET_PED_PATH_PREFER_TO_AVOID_WATER, ped.Handle, true); Function.Call(Hash.SET_PED_PATH_CAN_DROP_FROM_HEIGHT, ped.Handle, true); ped.Accuracy = 75; ped.DiesInstantlyInWater = false; Function.Call(Hash.SET_PED_COMBAT_MOVEMENT, ped.Handle, 1, true); int rndWeapon = RandoMath.CachedRandom.Next(0, 11); ped.MaxHealth = 100; ped.Health = ped.MaxHealth; ped.Armor = 70; if (rndWeapon < 5) { ped.Weapons.Give(WeaponHash.SMG, 300, true, true); ped.Weapons.Give(WeaponHash.Pistol, 120, true, true); ped.Weapons.Give(WeaponHash.Knife, 0, false, true); } if (rndWeapon >= 5) { ped.Weapons.Give(WeaponHash.AssaultRifle, 300, true, true); ped.Weapons.Give(WeaponHash.CombatPistol, 120, true, true); ped.Weapons.Give(WeaponHash.BattleAxe, 0, false, true); } ped.Money = 0; ped.NeverLeavesGroup = true; SurvivorPed newSurvivor = new SurvivorPed(ped); bool couldEnlistWithoutAdding = false; for (int i = 0; i < survivorList.Count; i++) { if (survivorList[i].pedEntity == null) { survivorList[i].AttachData(ped); newSurvivor = survivorList[i]; couldEnlistWithoutAdding = true; break; } } if (!couldEnlistWithoutAdding) { survivorList.Add(newSurvivor); } else { UI.Notify("Survivor not added to list"); } return(newSurvivor); }
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()); } } } } }