Beispiel #1
0
        public ZombiePed ZombieSpawn(Vector3 pos)
        {
            ZombiePed ped;
            int       maxZombies = Population.maxZombies;

            if (IsCityZone(Game.Player.Character.Position))
            {
                maxZombies = Population.maxZombies * 2;
            }
            if (((this.zombieCount >= maxZombies) || ((pos == Vector3.Zero) || (Extensions.DistanceBetweenV3(pos, this.startingLoc) < minSpawnDistance))) || (Extensions.DistanceBetweenV3(pos, Game.Player.Character.Position) < minSpawnDistance))
            {
                ped = null;
            }
            else
            {
                Ped ped;
                if (!customZombies)
                {
                    ped = World.CreateRandomPed(pos);
                }
                else
                {
                    Model model = new Model(RandoMath.GetRandomElementFromList <string>(ZombieModels));
                    ped = World.CreatePed(model, pos);
                }
                Infect(ped);
                ZombiePed objA = zombieList.Find(a => a.pedEntity == ped);
                ped = !ReferenceEquals(objA, null) ? objA : null;
            }
            return(ped);
        }
Beispiel #2
0
        public static Model GetRandomVehicleModel()
        {
            Model model = new Model();

            if (IsCityZone(Game.Player.Character.Position))
            {
                model = new Model(RandoMath.GetRandomElementFromList <string>(CityVehicleModels));
            }
            else
            {
                model = new Model(RandoMath.GetRandomElementFromList <string>(CountryVehicleModels));
            }
            return(model.Request(0x5dc) ? model : 0);
        }
Beispiel #3
0
        public void VehicleSpawn(Vector3 position, float heading)
        {
            int maxVehicles = Population.maxVehicles;

            if (IsCityZone(Game.Player.Character.Position))
            {
                maxVehicles = Population.maxVehicles * 2;
            }
            if (((this.vehicleCount < maxVehicles) && ((position != Vector3.Zero) && (Extensions.DistanceBetweenV3(position, this.startingLoc) >= minSpawnDistance))) && (Extensions.DistanceBetweenV3(position, Game.Player.Character.Position) >= minSpawnDistance))
            {
                Vehicle vehicle = Extensions.SpawnVehicle(GetRandomVehicleModel(), position, heading);
                vehicle.EngineHealth = (RandoMath.CachedRandom.Next(0, 100) > 10) ? 0f : 1000f;
                vehicle.DirtLevel    = 14f;
                VehicleDoor[] doors = vehicle.GetDoors();
                int           num3  = 0;
                while (true)
                {
                    if (num3 >= 5)
                    {
                        int item = 0;
                        while (true)
                        {
                            if (item >= 3)
                            {
                                break;
                            }
                            List <int>      theList   = new List <int>();
                            InputArgument[] arguments = new InputArgument[] { vehicle.Handle, item };
                            if (Function.Call <bool>(Hash._0x46E571A0E20D01F1, arguments))
                            {
                                theList.Add(item);
                            }
                            if (theList.Count > 0)
                            {
                                int             randomElementFromList = RandoMath.GetRandomElementFromList <int>(theList);
                                InputArgument[] argumentArray2        = new InputArgument[] { vehicle.Handle, randomElementFromList };
                                Function.Call(Hash._0x9E5B5E4D2CCD2259, argumentArray2);
                            }
                            item++;
                        }
                        break;
                    }
                    VehicleDoor randomElementFromArray = RandoMath.GetRandomElementFromArray <VehicleDoor>(doors);
                    vehicle.OpenDoor(randomElementFromArray, false, true);
                    num3++;
                }
            }
        }
Beispiel #4
0
 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 closest = World.GetClosest <Prop>(Game.Player.Character.Position, World.GetNearbyProps(Game.Player.Character.Position, 2.5f));
             if (closest == 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 (closest == 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;
                 }
             }
             Game.Player.CanControlCharacter = !craftCampfireMenu.Visible;
             Ped ped = World.GetClosest <Ped>(Game.Player.Character.Position, World.GetNearbyPeds(Game.Player.Character, 1.5f));
             if (((ped == null) || (!ped.IsDead || !ped.IsHuman)) || this.lootedPeds.Contains(ped))
             {
                 if (((ped != null) && (ped.IsDead && !ped.IsHuman)) && !this.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)(-1716189206)))
                         {
                             UI.Notify("You need a knife to harvest ~b~Raw Meat~w~ from dead animals!", true);
                         }
                         else if (Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount == Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount)
                         {
                             UI.Notify("You cannot carry any more ~b~Raw Meat~w~!", true);
                         }
                         else
                         {
                             Game.Player.Character.Weapons.Select((WeaponHash)(-1716189206), true);
                             Game.Player.Character.Task.PlayAnimation("pickup_object", "pickup_low", 8f, 0xbb8, AnimationFlags.None);
                             InventoryMaterial local7 = Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat");
                             local7.Amount++;
                             object[] objArray5 = new object[5];
                             objArray5[0] = "(";
                             objArray5[1] = Inventory.playerMaterialInventory.Find(item => item.Name == "Raw Meat").Amount;
                             object[] local10 = objArray5;
                             local10[2] = "/";
                             local10[3] = Inventory.playerMaterialInventory.Find(item => item.Name == "Raw Meat").MaxAmount;
                             object[] local12 = local10;
                             local12[4] = ")";
                             materialsSubMenu.MenuItems.Find(item => item.Text == "Raw Meat").SetRightLabel(string.Concat(local12));
                             craftCampfireMenu.MenuItems[0].SetRightLabel("(" + Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")");
                             object[] objArray6 = new object[5];
                             objArray6[0] = "You have harvested ~b~Raw Meat ~g~(";
                             objArray6[1] = Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount;
                             object[] local15 = objArray6;
                             local15[2] = "/";
                             local15[3] = Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").MaxAmount;
                             object[] local17 = local15;
                             local17[4] = ")";
                             UI.Notify(string.Concat(local17), true);
                             this.lootedPeds.Add(ped);
                         }
                     }
                 }
             }
             else
             {
                 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 num = RandoMath.CachedRandom.Next(0, 10);
                     if (num < 3)
                     {
                         List <InventoryItem> playerItemInventory = Inventory.playerItemInventory;
                         int num4 = 0;
                         while (true)
                         {
                             if (num4 >= playerItemInventory.Count)
                             {
                                 InventoryItem itemFound = RandoMath.GetRandomElementFromList <InventoryItem>(playerItemInventory);
                                 if (Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).Amount == Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount)
                                 {
                                     UI.Notify("Found ~b~" + itemFound.Name + "~w~ but inventory is full!", true);
                                 }
                                 else
                                 {
                                     InventoryItem local1 = Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name);
                                     local1.Amount++;
                                     object[] objArray1 = new object[] { "Found ~b~", itemFound.Name, "~g~ (", Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).Amount, "/", Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount, ")" };
                                     UI.Notify(string.Concat(objArray1), true);
                                     this.lootedPeds.Add(ped);
                                     object[] objArray2 = new object[] { "(", Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).Amount, "/", Inventory.playerItemInventory.Find(item => item.Name == itemFound.Name).MaxAmount, ")" };
                                     itemsSubMenu.MenuItems.Find(item => item.Text == itemFound.Name).SetRightLabel(string.Concat(objArray2));
                                 }
                                 break;
                             }
                             if (playerItemInventory[num4].GetType() == typeof(InventoryCraftableFoodItem))
                             {
                                 playerItemInventory.Remove(playerItemInventory[num4]);
                             }
                             num4++;
                         }
                     }
                     else if (num <= 5)
                     {
                         UI.Notify("Found nothing", true);
                         this.lootedPeds.Add(ped);
                     }
                     else
                     {
                         List <InventoryMaterial> playerMaterialInventory = Inventory.playerMaterialInventory;
                         int num8 = 0;
                         while (true)
                         {
                             if (num8 >= playerMaterialInventory.Count)
                             {
                                 InventoryItem materialFound = RandoMath.GetRandomElementFromList <InventoryMaterial>(playerMaterialInventory);
                                 if (Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount == Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name).MaxAmount)
                                 {
                                     UI.Notify("Found ~b~" + materialFound.Name + "~w~ but inventory is full!", true);
                                 }
                                 else
                                 {
                                     InventoryMaterial local2 = Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name);
                                     local2.Amount++;
                                     object[] objArray3 = new object[] { "Found ~b~", materialFound.Name, "~g~ (", Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name).Amount, "/", Inventory.playerMaterialInventory.Find(material => material.Name == materialFound.Name).MaxAmount, ")" };
                                     UI.Notify(string.Concat(objArray3), true);
                                     this.lootedPeds.Add(ped);
                                     object[] objArray4 = new object[] { "(", Inventory.playerMaterialInventory.Find(item => item.Name == materialFound.Name).Amount, "/", Inventory.playerMaterialInventory.Find(item => item.Name == materialFound.Name).MaxAmount, ")" };
                                     materialsSubMenu.MenuItems.Find(item => item.Text == materialFound.Name).SetRightLabel(string.Concat(objArray4));
                                     craftCampfireMenu.MenuItems.Find(item => item.Text == materialFound.Name).SetRightLabel("(" + Inventory.playerMaterialInventory.Find(material => material.Name == "Raw Meat").Amount + ")");
                                 }
                                 break;
                             }
                             if ((playerMaterialInventory[num8].GetType() == typeof(InventoryCraftableMaterial)) || (playerMaterialInventory[num8].Name == "Raw Meat"))
                             {
                                 playerMaterialInventory.Remove(playerMaterialInventory[num8]);
                             }
                             num8++;
                         }
                     }
                 }
             }
         }
         catch (Exception exception1)
         {
             Debug.Log(exception1.ToString());
         }
     }
 }
Beispiel #5
0
        public static SurvivorPed SurvivorSpawn(Vector3 pos)
        {
            Ped ped;

            if (!customSurvivors)
            {
                ped = World.CreateRandomPed(pos.Around(5f));
            }
            else
            {
                Model model = new Model(RandoMath.GetRandomElementFromList <string>(SurvivorModels));
                ped = World.CreatePed(model, pos.Around(5f));
            }
            InputArgument[] arguments = new InputArgument[] { ped.Handle, 0, 0 };
            Function.Call(Hash._0x70A2D1137C8ED7C9, arguments);
            InputArgument[] argumentArray2 = new InputArgument[] { ped.Handle, true };
            Function.Call(Hash._0x8E06A6FE76C9EFF4, argumentArray2);
            InputArgument[] argumentArray3 = new InputArgument[] { ped.Handle, true };
            Function.Call(Hash._0x77A5B103C87F476E, argumentArray3);
            InputArgument[] argumentArray4 = new InputArgument[] { ped.Handle, true };
            Function.Call(Hash._0x6B7A646C242A7059, argumentArray4);
            ped.DiesInstantlyInWater = false;
            InputArgument[] argumentArray5 = new InputArgument[] { ped.Handle, 1, true };
            Function.Call(Hash._0x4D9CA1009AFBD057, argumentArray5);
            int num = RandoMath.CachedRandom.Next(0, 11);

            ped.MaxHealth = 100;
            ped.Health    = ped.MaxHealth;
            ped.Armor     = 70;
            if (num < 5)
            {
                ped.Weapons.Give(WeaponHash.SMG, 300, true, true);
                ped.Weapons.Give(WeaponHash.Pistol, 120, true, true);
                ped.Weapons.Give((WeaponHash)(-1716189206), 0, false, true);
            }
            if (num >= 5)
            {
                ped.Weapons.Give((WeaponHash)(-1074790547), 300, true, true);
                ped.Weapons.Give(WeaponHash.CombatPistol, 120, true, true);
                ped.Weapons.Give((WeaponHash)(-853065399), 0, false, true);
            }
            ped.Money            = 0;
            ped.NeverLeavesGroup = true;
            SurvivorPed item = new SurvivorPed(ped);
            bool        flag = false;
            int         num2 = 0;

            while (true)
            {
                if (num2 < survivorList.Count)
                {
                    if (survivorList[num2].pedEntity != null)
                    {
                        num2++;
                        continue;
                    }
                    survivorList[num2].AttachData(ped);
                    item = survivorList[num2];
                    flag = true;
                }
                if (!flag)
                {
                    survivorList.Add(item);
                }
                else
                {
                    UI.Notify("Survivor not added to list");
                }
                return(item);
            }
        }
Beispiel #6
0
        public void PopulateAnimals()
        {
            int     maxAnimals;
            int     num2;
            Vector3 vector = new Vector3(0f, 0f, 0f);

            this.animalCount        = animalList.Count;
            this.aniPopRanThisFrame = false;
            this.aniPopTicksSinceLastUpdate++;
            if (this.aniPopRanThisFrame || (this.aniPopTicksSinceLastUpdate < this.aniPopTicksBetweenUpdates))
            {
                return;
            }
            else
            {
                maxAnimals = Population.maxAnimals;
                if (IsCityZone(Game.Player.Character.Position))
                {
                    maxAnimals = Population.maxAnimals * 2;
                }
                num2 = 0;
            }
            while (true)
            {
                while (true)
                {
                    if (num2 < maxAnimals)
                    {
                        int  num3  = RandoMath.CachedRandom.Next(1, 0x65);
                        bool flag4 = num3 <= 40;
                        vector = !flag4?World.GetNextPositionOnSidewalk(Game.Player.Character.Position.Around((float)maxSpawnDistance)) : World.GetNextPositionOnStreet(Game.Player.Character.Position.Around((float)maxSpawnDistance), true);

                        Vector3 vector2 = vector.Around(5f);
                        if (!((vector2.IsOnScreen() || (Extensions.DistanceTo(Game.Player.Character, vector) < minSpawnDistance)) || IsSafeZone(vector2)))
                        {
                            try
                            {
                                if (this.animalCount < maxAnimals)
                                {
                                    Model model;
                                    if (IsCityZone(vector))
                                    {
                                        model = new Model(RandoMath.GetRandomElementFromList <string>(CityAnimalModels));
                                    }
                                    else
                                    {
                                        model = new Model(RandoMath.GetRandomElementFromList <string>(CountryAnimalModels));
                                    }
                                    Ped item = World.CreatePed(model, vector);
                                    item.RelationshipGroup = Relationships.AnimalGroup;
                                    item.Task.WanderAround();
                                    animalList.Add(item);
                                    this.aniPopTicksSinceLastUpdate = 0 - RandoMath.CachedRandom.Next(this.aniPopTicksBetweenUpdates / 3);
                                    this.aniPopRanThisFrame         = true;
                                }
                            }
                            catch (Exception exception1)
                            {
                                Debug.Log(exception1.ToString());
                            }
                        }
                    }
                    else
                    {
                        return;
                    }
                    break;
                }
                num2++;
            }
        }