Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
 public static MyInventoryItem MockAmmo(String subType, float amount = 1)
 {
     return(new MyInventoryItem(MyItemType.MakeAmmo(subType), 0, (MyFixedPoint)amount));
 }
Ejemplo n.º 3
0
            void DrawInfoUI()
            {
                if (HostProgram.CombatLoaderSubsystem.UpdateNum > LastInventoryUpdate)
                {
                    LastInventoryUpdate = HostProgram.CombatLoaderSubsystem.UpdateNum;

                    var Builder = Host.Context.SharedStringBuilder;
                    Builder.Clear();

                    if (HostProgram.TorpedoSubsystem != null)
                    {
                        Builder.AppendLine("== TORPEDO TUBES ==");
                        Builder.AppendLine();

                        foreach (var kvp in HostProgram.TorpedoSubsystem.TorpedoTubeGroups)
                        {
                            int ready = kvp.Value.NumReady;
                            int total = kvp.Value.Children.Count();
                            if (total > 0)
                            {
                                // LG [||--    ] AUTO
                                Builder.Append(kvp.Value.Name).Append(" [").Append('|', ready).Append('-', total - ready).Append(' ', Math.Max(0, 8 - total)).Append(kvp.Value.AutoFire ? "] AUTO \n" : "] MANL \n");
                            }
                        }

                        Builder.AppendLine();
                    }


                    Builder.AppendLine("  ==== AMMO ====  ");

                    Builder.AppendLine();

                    int numGats = HostProgram.CombatLoaderSubsystem.TotalInventory.GetValueOrDefault(MyItemType.MakeAmmo("NATO_25x184mm"));

                    int percentGats = Math.Min(numGats / 10, 10);

                    Builder.Append('|', percentGats).Append(' ', 10 - percentGats).Append(' ').Append(string.Format("{0:000}", numGats)).AppendLine("  ");

                    Builder.AppendLine();

                    Builder.AppendLine("  ==== ==== ====  ");

                    Builder.AppendLine();

                    Builder.AppendLine(HostProgram.CombatLoaderSubsystem.LoadingInventory ? "  LOADING...    " : "");


                    foreach (var screen in Host.ActiveLookingGlass.LeftHUDs)
                    {
                        screen.FontColor = Host.ActiveLookingGlass.kFocusedColor;
                        screen.WriteText(Builder.ToString());
                    }
                }
            }
Ejemplo n.º 4
0
            void DrawActionsUI(TimeSpan timestamp)
            {
                if (!HUDPromptOK)
                {
                    HUDPromptOK = true;
                    Builder.Clear();

                    Builder.AppendLine(" ===== BAR 2 ===== ");
                    Builder.AppendLine();
                    Builder.AppendLine("1 - FIRE WEAPON");
                    Builder.AppendLine("2 - CAMERA");
                    Builder.AppendLine("3 - COMBAT AUTOP.");
                    Builder.AppendLine("4 - RAYCAST");
                    Builder.AppendLine("5 - FIRE MISSILE");
                    Builder.AppendLine("6 - CONFIRM KILL");
                    Builder.AppendLine("7 - JUMP");
                    Builder.AppendLine("8 - RELOAD AMMO/");
                    Builder.AppendLine("    TORPEDOES");
                    Builder.AppendLine();
                    Builder.AppendLine(" ===== BAR 3 ===== ");
                    Builder.AppendLine();
                    Builder.AppendLine("1 - WELDERS ON/OFF");
                    Builder.AppendLine("2 - TURRETS ON/OFF");
                    Builder.AppendLine("3 - PROJECTORS");
                    Builder.AppendLine("    ON/OFF");

                    foreach (var screen in Host.ActiveLookingGlass.RightHUDs)
                    {
                        screen.FontColor = Host.ActiveLookingGlass.kFocusedColor;
                        screen.WriteText(Builder.ToString());
                    }
                }

                if (HostProgram.CombatLoaderSubsystem.UpdateNum > LastInventoryUpdate)
                {
                    Builder.Clear();
                    Builder.AppendLine("  ==== TORP ====  ");

                    LastInventoryUpdate = HostProgram.CombatLoaderSubsystem.UpdateNum;

                    int numTorpsReserve = 10000;

                    foreach (var kvp in HostProgram.TorpComponents)
                    {
                        if (!HostProgram.CombatLoaderSubsystem.TotalInventory.ContainsKey(kvp.Key))
                        {
                            numTorpsReserve = 0;
                            break;
                        }
                        numTorpsReserve = Math.Min(numTorpsReserve, HostProgram.CombatLoaderSubsystem.TotalInventory[kvp.Key] / kvp.Value);
                    }

                    int numTorpsLoaded = HostProgram.TorpedoSubsystem.TorpedoTubeGroups["SM"].NumReady;

                    Builder.AppendLine();
                    Builder.Append("[");
                    for (int i = 1; i < 5; i++)
                    {
                        Builder.Append(i <= numTorpsLoaded ? "^" : " ").Append(i < 4 ? '|' : ']');
                    }
                    Builder.Append($"  {numTorpsLoaded}/4  ");
                    Builder.AppendLine();
                    Builder.AppendLine();
                    for (int i = 0; i < 24; i++)
                    {
                        if (i % 4 == 0)
                        {
                            Builder.Append(' ');
                        }
                        if (i == 12)
                        {
                            Builder.AppendLine(" ");
                        }
                        Builder.Append(i < numTorpsReserve ? '^' : ' ');
                    }

                    Builder.Append(numTorpsReserve > 24 ? "+ " : "  ");
                    Builder.AppendLine();

                    Builder.AppendLine("  ==== GATS ====  ");

                    Builder.AppendLine();

                    int numGats = HostProgram.CombatLoaderSubsystem.TotalInventory.GetValueOrDefault(MyItemType.MakeAmmo("NATO_25x184mm"));

                    int percentGats = Math.Min(numGats / 10, 10);

                    Builder.Append('|', percentGats).Append(' ', 10 - percentGats).Append(' ').Append(string.Format("{0:000}", numGats)).AppendLine("  ");

                    Builder.AppendLine();

                    Builder.AppendLine("  ==== ==== ====  ");

                    Builder.AppendLine();

                    Builder.AppendLine(HostProgram.CombatLoaderSubsystem.LoadingInventory ? "  LOADING...    " : "");

                    foreach (var screen in Host.ActiveLookingGlass.LeftHUDs)
                    {
                        screen.FontColor = Host.ActiveLookingGlass.kFocusedColor;
                        screen.WriteText(Builder.ToString());
                    }
                }
            }
Ejemplo n.º 5
0
            void DrawInfoUI()
            {
                if (HostProgram.CombatLoaderSubsystem.UpdateNum > LastInventoryUpdate)
                {
                    LastInventoryUpdate = HostProgram.CombatLoaderSubsystem.UpdateNum;

                    Builder.Clear();
                    Builder.AppendLine("  ==== TORP ====  \n");

                    if (HostProgram.TorpedoSubsystem == null)
                    {
                        Builder.AppendLine("- NO TORPEDOS -    ");
                    }
                    else
                    {
                        foreach (var kvp in HostProgram.TorpedoSubsystem.TorpedoTubeGroups)
                        {
                            int ready = kvp.Value.NumReady;
                            int total = kvp.Value.Children.Count();
                            // LG [||--    ] AUTO
                            Builder.Append(kvp.Value.Name).Append(" [").Append('|', ready).Append('-', total - ready).Append(' ', Math.Max(0, 8 - total)).Append(kvp.Value.AutoFire ? "] AUTO \n" : "] MANL \n");
                        }
                    }
//
//                     int numTorpsReserve = 10000;
//
//                     foreach (var kvp in HostProgram.TorpComponents)
//                     {
//                         if (!HostProgram.CombatLoaderSubsystem.TotalInventory.ContainsKey(kvp.Key))
//                         {
//                             numTorpsReserve = 0;
//                             break;
//                         }
//                         numTorpsReserve = Math.Min(numTorpsReserve, HostProgram.CombatLoaderSubsystem.TotalInventory[kvp.Key] / kvp.Value);
//                     }
//
//                     if (HostProgram.TorpedoSubsystem.TorpedoTubeGroups.ContainsKey("SM"))
//                     {
//                         int numTorpsLoaded = HostProgram.TorpedoSubsystem.TorpedoTubeGroups["SM"].NumReady;
//
//                         Builder.AppendLine();
//                         Builder.Append("[");
//                         for (int i = 1; i < 5; i++)
//                         {
//                             Builder.Append(i <= numTorpsLoaded ? "^" : " ").Append(i < 4 ? '|' : ']');
//                         }
//                         Builder.Append($"  {numTorpsLoaded}/4  ");
//                         Builder.AppendLine();
//                         Builder.AppendLine();
//                         for (int i = 0; i < 24; i++)
//                         {
//                             if (i % 4 == 0) Builder.Append(' ');
//                             if (i == 12) Builder.AppendLine(" ");
//                             Builder.Append(i < numTorpsReserve ? '^' : ' ');
//                         }
//
//                         Builder.Append(numTorpsReserve > 24 ? "+ " : "  ");
//                         Builder.AppendLine();
//                     }
//                     else
//                     {
//                         Builder.AppendLine("NO TORPEDOES");
//                     }

                    Builder.AppendLine("\n  == 25x184MM ==  \n");

                    var ammoType    = MyItemType.MakeAmmo("NATO_25x184mm");
                    int ammo        = HostProgram.CombatLoaderSubsystem.TotalInventory.GetValueOrDefault(ammoType);
                    int target      = HostProgram.CombatLoaderSubsystem.TotalInventoryRequests.GetValueOrDefault(ammoType, 500);
                    int percentAmmo = Math.Min(ammo * 10 / target, 10);

                    Builder.Append('|', percentAmmo).Append(' ', 10 - percentAmmo).Append(' ').Append(string.Format("{0:000}", ammo)).AppendLine("  ");

                    Builder.AppendLine("\n  == ROCKETS ==  \n");

                    ammoType    = MyItemType.MakeAmmo("Missile200mm");
                    ammo        = HostProgram.CombatLoaderSubsystem.TotalInventory.GetValueOrDefault(ammoType);
                    target      = HostProgram.CombatLoaderSubsystem.TotalInventoryRequests.GetValueOrDefault(ammoType, 200);
                    percentAmmo = Math.Min(ammo * 10 / target, 10);

                    Builder.Append('|', percentAmmo).Append(' ', 10 - percentAmmo).Append(' ').Append(string.Format("{0:000}", ammo)).AppendLine("  ");

                    Builder.AppendLine("\n  ==== ==== ====  \n");

                    Builder.AppendLine(HostProgram.CombatLoaderSubsystem.LoadingInventory ? "  LOADING...    " : "");

                    foreach (var screen in Host.ActiveLookingGlass.LeftHUDs)
                    {
                        screen.FontColor = Host.ActiveLookingGlass.kFocusedColor;
                        screen.WriteText(Builder.ToString());
                    }
                }
            }