Example #1
0
 private void UseWeaponsCrate(MapProp prop)
 {
     if (prop?.Weapons != null)
     {
         _weaponsMenu.OnMenuChange += delegate(UIMenu oldMenu, UIMenu newMenu, bool forward)
         {
             if (newMenu == _storageMenu)
             {
                 TradeOffWeapons(prop, prop.Weapons, _storageMenu, true);
             }
             else if (newMenu == _myWeaponsMenu)
             {
                 List <Weapon>     playerWeapons    = new List <Weapon>();
                 WeaponHash[]      source           = (WeaponHash[])Enum.GetValues(typeof(WeaponHash));
                 WeaponComponent[] weaponComponents = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent));
                 source.ToList().ForEach(delegate(WeaponHash hash)
                 {
                     if ((int)hash != -1569615261 && PlayerPed.Weapons.HasWeapon(hash))
                     {
                         GTA.Weapon val = PlayerPed.Weapons[hash];
                         WeaponComponent[] components = (from c in weaponComponents
                                                         where PlayerPed.Weapons[hash].IsComponentActive(c)
                                                         select c).ToArray();
                         Weapon item = new Weapon(val.Ammo, hash, components);
                         playerWeapons.Add(item);
                     }
                 });
                 TradeOffWeapons(prop, playerWeapons, _myWeaponsMenu, false);
             }
         };
         _weaponsMenu.Visible = !_weaponsMenu.Visible;
     }
 }
Example #2
0
        private void CraftAmmo()
        {
            _craftWeaponsMenu.Clear();
            WeaponGroup[] weaponGroups3 = (WeaponGroup[])Enum.GetValues(typeof(WeaponGroup));
            weaponGroups3 = (from w in weaponGroups3
                             where (int)w != 1595662460 && (int)w != -1609580060 && (int)w != -728555052 && (int)w != -942583726
                             select w).ToArray();
            List <WeaponGroup> list = weaponGroups3.ToList();

            list.Add(GTA.WeaponGroup.AssaultRifle);
            weaponGroups3 = list.ToArray();
            WeaponGroup[] array = weaponGroups3;
            for (int i = 0; i < array.Length; i++)
            {
                WeaponGroup weaponGroup = array[i];
                UIMenuItem  menuItem    = new UIMenuItem(string.Format("{0}", ((int)weaponGroup == 970310034) ? "Assult Rifle" : ((object)weaponGroup).ToString()), $"Craft ammo for {weaponGroup}");
                menuItem.SetLeftBadge(UIMenuItem.BadgeStyle.Ammo);
                int required = GetRequiredPartsForWeaponGroup(weaponGroup);
                menuItem.Description = $"Required Weapon Parts: ~y~{required}~s~";
                _craftWeaponsMenu.AddItem(menuItem);
                menuItem.Activated += delegate
                {
                    InventoryItemBase inventoryItemBase = PlayerInventory.Instance.ItemFromName("Weapon Parts");
                    if (inventoryItemBase != null)
                    {
                        if (inventoryItemBase.Amount >= required)
                        {
                            WeaponHash[] array2 = (WeaponHash[])Enum.GetValues(typeof(WeaponHash));
                            WeaponHash   val    = Array.Find(array2, (WeaponHash h) => PlayerPed.Weapons.HasWeapon(h) && PlayerPed.Weapons[h].Group == weaponGroup);
                            GTA.Weapon   val2   = PlayerPed.Weapons[val];
                            if (val2 != null)
                            {
                                int num = 10 * required;
                                if (val2.Ammo + num <= val2.MaxAmmo)
                                {
                                    PlayerPed.Weapons.Select(val2);
                                    if (val2.Ammo + num > val2.MaxAmmo)
                                    {
                                        val2.Ammo = val2.MaxAmmo;
                                    }
                                    else
                                    {
                                        GTA.Weapon obj = val2;
                                        obj.Ammo = obj.Ammo + num;
                                    }
                                    PlayerInventory.Instance.AddItem(inventoryItemBase, -required, ItemType.Resource);
                                }
                            }
                        }
                        else
                        {
                            UI.Notify("Not enough weapon parts.");
                        }
                    }
                };
            }
            _craftWeaponsMenu.Visible = !_craftWeaponsMenu.Visible;
        }
        public static void SavePlayerWeapons()
        {
            IEnumerable <WeaponHash> hashes = from hash in (WeaponHash[])Enum.GetValues(typeof(WeaponHash))
                                              where Game.Player.Character.Weapons.HasWeapon(hash)
                                              select hash;

            WeaponComponent[] componentHashes = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent));
            List <Weapon>     weapons         = hashes.ToList().ConvertAll(delegate(WeaponHash hash)
            {
                GTA.Weapon weapon            = Game.Player.Character.Weapons[hash];
                WeaponComponent[] components = (from h in componentHashes
                                                where weapon.IsComponentActive(h)
                                                select h).ToArray();
                return(new Weapon(weapon.Ammo, weapon.Hash, components));
            }).ToList();

            PlayerWeapons = weapons;
        }
        public static void AddPedData(Ped ped)
        {
            SurvivorPed survivorPed         = Population.survivorList.Find(match: a => a.pedEntity == ped);
            PedTasks    pedTasks            = survivorPed.tasks;
            IEnumerable <WeaponHash> hashes = from hash in (WeaponHash[])Enum.GetValues(typeof(WeaponHash))
                                              where ped.Weapons.HasWeapon(hash)
                                              select hash;

            WeaponComponent[] componentHashes = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent));
            List <Weapon>     weapons         = hashes.ToList().ConvertAll(delegate(WeaponHash hash)
            {
                GTA.Weapon weapon            = ped.Weapons[hash];
                WeaponComponent[] components = (from h in componentHashes
                                                where weapon.IsComponentActive(h)
                                                select h).ToArray();
                return(new Weapon(weapon.Ammo, weapon.Hash, components));
            }).ToList();
            PedData pedData = new PedData(ped.Handle, ped.Model.Hash, ped.Rotation, ped.Position, pedTasks, weapons);

            PlayerPedCollection.Add(pedData);
        }
Example #5
0
		public Inventory(MenuType menuType, bool ignoreContainers = false)
		{
			MenuType = menuType;
			InventoryItemBase alcohol = new InventoryItemBase(0, 20, "Alcohol", "A colorless volatile flammable liquid.");
			InventoryItemBase battery = new InventoryItemBase(0, 25, "Battery", "A resource that can provide an electrical charge.");
			InventoryItemBase binding = new InventoryItemBase(0, 25, "Binding", "A strong adhesive.");
			InventoryItemBase bottle = new InventoryItemBase(0, 10, "Bottle", "A container used for storing drinks or other liquids..");
			InventoryItemBase cloth = new InventoryItemBase(0, 25, "Cloth", "Woven or felted fabric.");
			InventoryItemBase dirtyWater = new InventoryItemBase(0, 25, "Dirty Water", "Liquid obtained from an undrinkable source of water.");
			InventoryItemBase metal = new InventoryItemBase(0, 25, "Metal", "It's freaking metal.");
			InventoryItemBase wood = new InventoryItemBase(0, 25, "Wood", "It's freaking wood.");
			InventoryItemBase plastic = new InventoryItemBase(0, 25, "Plastic", "A synthetic material made from a wide range of organic polymers.");
			InventoryItemBase rawMeat = new InventoryItemBase(0, 15, "Raw Meat", "Can be cooked to create ~g~Cooked Meat~s~.");
			InventoryItemBase matches = new InventoryItemBase(0, 10, "Matches", "Can be used to create fire.");
			InventoryItemBase weaponParts = new InventoryItemBase(25, 25, "Weapon Parts", "Used to create weapon components, and weapons. (Weapons crafting coming soon)");
			InventoryItemBase vehicleParts = new InventoryItemBase(0, 25, "Vehicle Parts", "USed to repair vehicles.");
			UsableInventoryItem bandage = new UsableInventoryItem(0, 10, "Bandage", "A strip of material used to bind a wound or to protect an injured part of the body.", new UsableItemEvent[2]
			{
				new UsableItemEvent(ItemEvent.GiveHealth, 25),
				new UsableItemEvent(ItemEvent.GiveArmor, 15)
			})
			{
				RequiredComponents = new CraftableItemComponent[3]
				{
					new CraftableItemComponent(binding, 1),
					new CraftableItemComponent(alcohol, 2),
					new CraftableItemComponent(cloth, 2)
				}
			};
			CraftableInventoryItem supp = new CraftableInventoryItem(0, 5, "Suppressor", "Can be used to suppress a rifle, pistol, shotgun, or SMG.", delegate
			{
				GTA.Weapon val = PlayerPed.Weapons.Current;
				if ((int)val.Hash != -1569615261)
				{
					WeaponComponent[] obj = new WeaponComponent[6];
                    obj[0] = WeaponComponent.AtArSupp;
                    obj[1] = WeaponComponent.AtArSupp02;
                    obj[2] = WeaponComponent.AtPiSupp;
                    obj[3] = WeaponComponent.AtPiSupp02;
                    obj[4] = WeaponComponent.AtSrSupp;
                    obj[5] = WeaponComponent.AtSrSupp03;
					WeaponComponent[] array = (WeaponComponent[])obj;
					WeaponComponent[] array2 = array;
					foreach (WeaponComponent val2 in array2)
					{
						if (Function.Call<bool>(GTA.Native.Hash._CAN_WEAPON_HAVE_COMPONENT, (InputArgument[])new InputArgument[2]
						{
							(uint)(int)val.Hash,
							(uint)(int)val2
						}) && !val.IsComponentActive(val2))
						{
							val.SetComponent(val2, true);
							return true;
						}
					}
					UI.Notify("You can't equip this right now.");
					return false;
				}
				UI.Notify("No weapon selected!");
				return false;
			})
			{
				RequiredComponents = new CraftableItemComponent[2]
				{
					new CraftableItemComponent(weaponParts, 2),
					new CraftableItemComponent(binding, 1)
				}
			};
			BuildableInventoryItem sandbag = new BuildableInventoryItem(0, 5, "Sand Block", "Used to provide cover in combat situations", "prop_mb_sandblock_02", GTA.BlipSprite.Standard, GTA.BlipColor.White, Vector3.Zero, false, false, true)
			{
				RequiredComponents = new CraftableItemComponent[4]
				{
					new CraftableItemComponent(metal, 3),
					new CraftableItemComponent(binding, 2),
					new CraftableItemComponent(cloth, 1),
					new CraftableItemComponent(wood, 2)
				}
			};
			BuildableInventoryItem workbench = new BuildableInventoryItem(0, 2, "Work Bench", "Can be used to craft ammunition.", "prop_tool_bench02", GTA.BlipSprite.AmmuNation, GTA.BlipColor.Yellow, Vector3.Zero, true, false, true)
			{
				RequiredComponents = new CraftableItemComponent[4]
				{
					new CraftableItemComponent(metal, 15),
					new CraftableItemComponent(wood, 5),
					new CraftableItemComponent(plastic, 5),
					new CraftableItemComponent(binding, 5)
				}
			};
			BuildableInventoryItem gate = new BuildableInventoryItem(0, 3, "Gate", "A metal gate that can be opened by vehicles or peds.", "prop_gate_prison_01", GTA.BlipSprite.Standard, GTA.BlipColor.White, Vector3.Zero, true, true, true)
			{
				RequiredComponents = new CraftableItemComponent[3]
				{
					new CraftableItemComponent(metal, 5),
					new CraftableItemComponent(binding, 3),
					new CraftableItemComponent(battery, 1)
				}
			};
			WeaponInventoryItem molotov = new WeaponInventoryItem(0, 25, "Molotov", "A bottle-based improvised incendiary weapon.", 1, GTA.Native.WeaponHash.Molotov, null)
			{
				RequiredComponents = new CraftableItemComponent[3]
				{
					new CraftableItemComponent(alcohol, 1),
					new CraftableItemComponent(cloth, 1),
					new CraftableItemComponent(bottle, 1)
				}
			};
			WeaponInventoryItem knife = new WeaponInventoryItem(0, 1, "Knife", "An improvised knife.", 1, GTA.Native.WeaponHash.Knife, null)
			{
				RequiredComponents = new CraftableItemComponent[2]
				{
					new CraftableItemComponent(metal, 3),
					new CraftableItemComponent(binding, 1)
				}
			};
			WeaponInventoryItem flashlight = new WeaponInventoryItem(0, 5, "Flashlight", "A battery-operated portable light.", 1, GTA.Native.WeaponHash.Flashlight, null)
			{
				RequiredComponents = new CraftableItemComponent[3]
				{
					new CraftableItemComponent(battery, 4),
					new CraftableItemComponent(plastic, 4),
					new CraftableItemComponent(binding, 4)
				}
			};
			FoodInventoryItem cookedMeat = new FoodInventoryItem(0, 15, "Cooked Meat", "Can be creating from cooking raw meat.", "mp_player_inteat@burger", "mp_player_int_eat_burger", GTA.AnimationFlags.UpperBodyOnly, -1, FoodType.Food, 0.25f)
			{
				RequiredComponents = new CraftableItemComponent[2]
				{
					new CraftableItemComponent(rawMeat, 1),
					new CraftableItemComponent(alcohol, 2)
				},
				NearbyResource = NearbyResource.CampFire
			};
			FoodInventoryItem packagedFood = new FoodInventoryItem(0, 15, "Packaged Food", "Usually obtained from stores around Los Santos.", "mp_player_inteat@pnq", "loop", GTA.AnimationFlags.UpperBodyOnly, -1, FoodType.SpecialFood, 0.3f);
			FoodInventoryItem water = new FoodInventoryItem(0, 15, "Clean Water", "Can be made from dirty water or obtained from stores around Los Santos.", "mp_player_intdrink", "loop_bottle", GTA.AnimationFlags.UpperBodyOnly, -1, FoodType.Water, 0.35f)
			{
				RequiredComponents = new CraftableItemComponent[1]
				{
					new CraftableItemComponent(dirtyWater, 1)
				},
				NearbyResource = NearbyResource.CampFire
			};
			BuildableInventoryItem tent = new BuildableInventoryItem(1, 5, "Tent", "A portable shelter made of cloth, supported by one or more poles and stretched tight by cords or loops attached to pegs driven into the ground.", "prop_skid_tent_01", GTA.BlipSprite.CaptureHouse, 0, Vector3.Zero, true, false, true)
			{
				RequiredComponents = new CraftableItemComponent[3]
				{
					new CraftableItemComponent(wood, 3),
					new CraftableItemComponent(cloth, 4),
					new CraftableItemComponent(binding, 3)
				}
			};
			BuildableInventoryItem campFire = new BuildableInventoryItem(1, 5, "Camp Fire", "An open-air fire in a camp, used for cooking and as a focal point for social activity.", "prop_beach_fire", GTA.BlipSprite.Standard, 0, Vector3.Zero, false, false, true)
			{
				RequiredComponents = new CraftableItemComponent[3]
				{
					new CraftableItemComponent(wood, 3),
					new CraftableItemComponent(alcohol, 1),
					new CraftableItemComponent(matches, 1)
				}
			};
			BuildableInventoryItem wall = new BuildableInventoryItem(0, 15, "Wall", "A wooden wall that can be used for creating shelters.", "prop_fncconstruc_01d", GTA.BlipSprite.Standard, 0, Vector3.Zero, false, false, true)
			{
				RequiredComponents = new CraftableItemComponent[2]
				{
					new CraftableItemComponent(wood, 4),
					new CraftableItemComponent(binding, 3)
				}
			};
			BuildableInventoryItem barrier = new BuildableInventoryItem(0, 10, "Barrier", "A wooden barrier that can be used to barricade gaps in your safe zone.", "prop_fncwood_16b", GTA.BlipSprite.Standard, 0, Vector3.Zero, false, false, true)
			{
				RequiredComponents = new CraftableItemComponent[2]
				{
					new CraftableItemComponent(wood, 5),
					new CraftableItemComponent(binding, 2)
				}
			};
			BuildableInventoryItem door = new BuildableInventoryItem(0, 5, "Door", "A  hinged, sliding, or revolving barrier at the entrance to a building, room, or vehicle, or in the framework of a cupboard.", "ex_p_mp_door_office_door01", GTA.BlipSprite.Standard, 0, Vector3.Zero, true, true, true)
			{
				RequiredComponents = new CraftableItemComponent[3]
				{
					new CraftableItemComponent(wood, 3),
					new CraftableItemComponent(binding, 1),
					new CraftableItemComponent(metal, 1)
				}
			};
			CraftableInventoryItem repairKit = new CraftableInventoryItem(0, 10, "Vehicle Repair Kit", "Used to repair vehicle engines.", delegate
			{
				UI.Notify("You can only use this when repairing a vehicle.");
				return false;
			})
			{
				RequiredComponents = new CraftableItemComponent[3]
				{
					new CraftableItemComponent(vehicleParts, 5),
					new CraftableItemComponent(metal, 5),
					new CraftableItemComponent(binding, 2)
				}
			};
			Items.AddRange(new InventoryItemBase[17]
			{
				bandage,
				molotov,
				knife,
				flashlight,
				cookedMeat,
				packagedFood,
				water,
				tent,
				campFire,
				wall,
				barrier,
				door,
				supp,
				gate,
				sandbag,
				workbench,
				repairKit
			});
			Resources.AddRange(new InventoryItemBase[13]
			{
				binding,
				alcohol,
				cloth,
				bottle,
				metal,
				wood,
				battery,
				plastic,
				rawMeat,
				dirtyWater,
				matches,
				weaponParts,
				vehicleParts
			});
			Items.Sort((InventoryItemBase c1, InventoryItemBase c2) => string.Compare(c1.Id, c2.Id, StringComparison.Ordinal));
			Resources.Sort((InventoryItemBase c1, InventoryItemBase c2) => string.Compare(c1.Id, c2.Id, StringComparison.Ordinal));
			LoadMenus();
			if (!ignoreContainers)
			{
				WeaponStorageInventoryItem weaponCrate = new WeaponStorageInventoryItem(0, 1, "Weapons Crate", "A crate specifically used to store weapons.", "hei_prop_carrier_crate_01a", GTA.BlipSprite.AssaultRifle, 0, Vector3.Zero, true, false, true, new List<Weapon>())
				{
					RequiredComponents = new CraftableItemComponent[4]
					{
						new CraftableItemComponent(metal, 15),
						new CraftableItemComponent(wood, 15),
						new CraftableItemComponent(plastic, 15),
						new CraftableItemComponent(binding, 10)
					}
				};
				Items.Add(weaponCrate);
			}
		}