Exemple #1
0
        private void AddAmmo()
        {
            List <MyInventoryItem> items = new List <MyInventoryItem>();

            m_inventory.GetItems(items);
            if (items.Capacity <= 1)
            {
                var ammo = new MyObjectBuilder_AmmoMagazine()
                {
                    SubtypeName = "SpotlightTurretAmmoMagazine"
                };

                m_inventory.AddItems(2, ammo);
            }
        }
Exemple #2
0
        // Closing Event Callbacks
        private void OnMarkForClose(IMyEntity obj)
        {
            var ammo = new MyObjectBuilder_AmmoMagazine()
            {
                SubtypeName = "SpotlightTurretAmmoMagazine"
            };
            IMyInventory           inv   = obj.GameLogic.GetAs <TurretSpotlight>().m_inventory;
            List <MyInventoryItem> items = new List <MyInventoryItem>();

            inv.GetItems(items);
            MyFixedPoint amount = 0;

            foreach (var item in items)
            {
                amount += item.Amount;
            }

            obj.GameLogic.GetAs <TurretSpotlight>().m_inventory.RemoveItemsOfType(amount, ammo);
        }
Exemple #3
0
        public static int CalculatePlayerThreat(IMyCharacter character, Vector3D requesterPosition)
        {
            if (character.IsDead)
            {
                return(0);
            }
            float threat   = 0;
            float distance = (float)Vector3D.Distance(requesterPosition, character.GetPosition());

            threat += distance < 175 ? distance < 125 ? distance < 75 ? 5000 : 2500 : 1500 : 500;
            if (character.EquippedTool is IMyAngleGrinder)
            {
                threat *= 5;
            }
            IMyInventory           myInventory = character.GetInventory();
            List <MyInventoryItem> items       = new List <MyInventoryItem>();

            myInventory.GetItems(items);
            foreach (MyInventoryItem item in items)
            {
                if (item.Type == MyItemType.MakeTool("AngleGrinder4Item"))
                {
                    threat += 1000;
                    continue;
                }
                if (item.Type == MyItemType.MakeTool("AngleGrinder3Item"))
                {
                    threat += 750;
                    continue;
                }
                if (item.Type == MyItemType.MakeTool("AngleGrinder2Item"))
                {
                    threat += 500;
                    continue;
                }
                if (item.Type == MyItemType.MakeTool("AngleGrinderItem"))
                {
                    threat += 250;
                    continue;
                }
                if (item.Type == MyItemType.MakeTool("UltimateAutomaticRifleItem"))
                {
                    threat += 100;
                    continue;
                }
                if (item.Type == MyItemType.MakeTool("RapidFireAutomaticRifleItem"))
                {
                    threat += 80;
                    continue;
                }
                if (item.Type == MyItemType.MakeTool("PreciseAutomaticRifleItem"))
                {
                    threat += 60;
                    continue;
                }
                if (item.Type == MyItemType.MakeTool("AutomaticRifleItem"))
                {
                    threat += 40;
                    continue;
                }
                if (item.Type == MyItemType.MakeAmmo("NATO_5p56x45mm"))
                {
                    threat += 20;
                    continue;
                }
            }

            return((int)threat);
        }