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 void Sleep(Vector3 position) { Ped[] peds = World.GetNearbyPeds(position, 50f).Where(IsEnemy).ToArray(); if (!peds.Any()) { TimeSpan time = World.CurrentDayTime + new TimeSpan(0, 8, 0, 0); Game.Player.Character.IsVisible = false; Game.Player.CanControlCharacter = false; Game.Player.Character.FreezePosition = true; Game.FadeScreenOut(2000); Script.Wait(2000); World.CurrentDayTime = time; Game.Player.Character.IsVisible = true; Game.Player.CanControlCharacter = true; Game.Player.Character.FreezePosition = false; Game.Player.Character.ClearBloodDamage(); Weather randWeather = RandoMath.GetRandomElementFromArray(Map.weathers); World.Weather = randWeather; Character.currentEnergyLevel = 1f; Character.currentHungerLevel -= 0.15f; Character.currentThirstLevel -= 0.25f; Script.Wait(2000); Game.FadeScreenIn(2000); } else { UI.Notify("You cannot sleep here as there are ~r~hostiles~w~ nearby!"); } }
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 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 Setup() { Function.Call(Hash.ADD_SCENARIO_BLOCKING_AREA, -10000.0f, -10000.0f, -1000.0f, 10000.0f, 10000.0f, 1000.0f, 0, 1, 1, 1); Function.Call(Hash.CLEAR_AREA, Game.Player.Character.Position.X, Game.Player.Character.Position.Y, Game.Player.Character.Position.Z, 1000F, false, false, false, false); Function.Call(Hash.SET_CREATE_RANDOM_COPS, false); Function.Call(Hash.SET_RANDOM_BOATS, false); Function.Call(Hash.SET_RANDOM_TRAINS, false); Function.Call(Hash.SET_GARBAGE_TRUCKS, false); Function.Call(Hash.DELETE_ALL_TRAINS); Function.Call(Hash.SET_PED_POPULATION_BUDGET, 0); Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 0); Function.Call(Hash.SET_ALL_LOW_PRIORITY_VEHICLE_GENERATORS_ACTIVE, false); Function.Call(Hash.SET_NUMBER_OF_PARKED_VEHICLES, 0); Function.Call((Hash)0xF796359A959DF65D, false); Function.Call(Hash.DISABLE_VEHICLE_DISTANTLIGHTS, true); Ped[] all_ped = World.GetAllPeds(); if (all_ped.Length > 0) { foreach (Ped ped in all_ped) { ped.Delete(); } } Vehicle[] all_vecs = World.GetAllVehicles(); if (all_vecs.Length > 0) { foreach (Vehicle vehicle in all_vecs) { vehicle.Delete(); } } World.SetBlackout(true); Weather rndWeather = RandoMath.GetRandomElementFromArray(weathers); World.TransitionToWeather(rndWeather, 0f); Function.Call(Hash.SET_CLOCK_TIME, 07, 00, 00); Function.Call(Hash.SET_CLOCK_DATE, 01, 01, 20); }
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 void Setup() { playerOldMaxWantedLevel = Game.MaxWantedLevel; playerOldMoney = Game.Player.Money; playerOldPosition = Game.Player.Character.Position; playerOldHeading = Game.Player.Character.Heading; playerOldModel = Game.Player.Character.Model; playerOldWeapons = Game.Player.Character.Weapons; Game.MaxWantedLevel = 0; Game.Player.WantedLevel = 0; Game.Player.Money = 0; Model characterModel; PedHash[] characterMaleModels = { PedHash.FreemodeMale01 }; PedHash[] characterFemaleModels = { PedHash.FreemodeFemale01 }; PedHash[] characterModels; if (playerGender == Gender.Male) { characterModels = characterMaleModels; } else { characterModels = characterFemaleModels; } characterModel = new Model(RandoMath.GetRandomElementFromArray(characterModels)); characterModel.Request(500); if (characterModel.IsInCdImage && characterModel.IsValid) { while (!characterModel.IsLoaded) { Script.Wait(100); } Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash); if (playerGender == Gender.Male) { Function.Call(Hash.SET_PED_HEAD_BLEND_DATA, Game.Player.Character.Handle, 44, 44, 0, 44, 44, 0, 1.0f, 1.0f, 0.0f, true); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 12, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 1, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 0, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 233, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 24, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 12, 0, 0); Function.Call(Hash._SET_PED_HAIR_COLOR, Game.Player.Character.Handle, 57, 58); Function.Call(Hash._SET_PED_EYE_COLOR, Game.Player.Character.Handle, 3); Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 1, 0, 1.0f); Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 2, 1, 1.0f); Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 1, 1, 57, 58); Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 2, 1, 57, 58); } else { Function.Call(Hash.SET_PED_HEAD_BLEND_DATA, Game.Player.Character.Handle, 33, 33, 0, 33, 33, 0, 1.0f, 1.0f, 0.0f, true); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 4, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 243, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 7, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 0, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 24, 0, 0); Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 84, 0, 0); Function.Call(Hash._SET_PED_HAIR_COLOR, Game.Player.Character.Handle, 11, 11); Function.Call(Hash._SET_PED_EYE_COLOR, Game.Player.Character.Handle, 3); Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 2, 1, 1.0f); Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 2, 1, 11, 11); } } characterModel.MarkAsNoLongerNeeded(); Game.Player.Money = 0; Game.Player.Character.Position = new Vector3(478.8616f, -921.53f, 38.77953f); Game.Player.Character.Heading = 266; var model = new Model("prop_beach_fire"); model.Request(250); if (model.IsInCdImage && model.IsValid) { while (!model.IsLoaded) { Script.Wait(50); } var CFpos = new Vector3(482.3683f, -921.3369f, 37.2f); campFire = World.CreateProp(model, CFpos, true, false); } model.MarkAsNoLongerNeeded(); campFire.AddBlip(); campFire.CurrentBlip.Sprite = (BlipSprite)436; campFire.CurrentBlip.Color = BlipColor.Yellow; campFire.CurrentBlip.Name = "Campfire"; var model2 = new Model("prop_skid_tent_01"); model2.Request(250); if (model2.IsInCdImage && model2.IsValid) { while (!model2.IsLoaded) { Script.Wait(50); } var Tpos = new Vector3(478.2682f, -925.3043f, 36.8f); tent = World.CreateProp(model2, Tpos, true, false); tent.Heading = 135; } model2.MarkAsNoLongerNeeded(); tent.AddBlip(); tent.CurrentBlip.Sprite = BlipSprite.CaptureHouse; tent.CurrentBlip.Color = BlipColor.Blue; tent.CurrentBlip.Name = "Tent"; var model3 = new Model("prop_const_fence02a"); model3.Request(250); if (model3.IsInCdImage && model3.IsValid) { while (!model3.IsLoaded) { Script.Wait(50); } var Bpos = new Vector3(418.9457f, -890.5727f, 28.4f); barrier = World.CreateProp(model3, Bpos, true, false); barrier.Heading = 270; } model3.MarkAsNoLongerNeeded(); var model4 = new Model("prop_dumpster_02a"); model4.Request(250); if (model4.IsInCdImage && model4.IsValid) { while (!model4.IsLoaded) { Script.Wait(50); } var Dpos = new Vector3(459.4905f, -933.745f, 31.2f); dumpster = World.CreateProp(model4, Dpos, true, false); dumpster.Heading = 270; } model4.MarkAsNoLongerNeeded(); ResetCharacter(); }
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()); } } } } }