Пример #1
0
        private MapIcon GetMapIconForMonster(EntityWrapper entity, MonsterConfigLine monsterConfigLine)
        {
            // If ignored entity found, skip
            foreach (string _entity in IgnoreEntitiesList)
            {
                if (entity.Path.Contains(_entity))
                {
                    return(null);
                }
            }

            if (!entity.IsHostile)
            {
                return(new CreatureMapIcon(entity, "ms-cyan.png", () => Settings.Minions, Settings.MinionsIcon));
            }

            MonsterRarity monsterRarity = entity.GetComponent <ObjectMagicProperties>().Rarity;
            Func <EntityWrapper, Func <string, string>, CreatureMapIcon> iconCreator;

            string overrideIcon = null;
            var    life         = entity.GetComponent <Life>();

            if (life.HasBuff("hidden_monster"))
            {
                overrideIcon = HiddenIcons[(int)monsterRarity];
            }


            return(iconCreators.TryGetValue(monsterRarity, out iconCreator)
                ? iconCreator(entity, text => monsterConfigLine?.MinimapIcon ?? overrideIcon ?? text) : null);
        }
Пример #2
0
    private void ActivateRarityPlates(MonsterRarity rarity)
    {
        switch (rarity)
        {
        case MonsterRarity.COMMON: common = true; uncommon = rare = mythic = false; break;

        case MonsterRarity.UNCOMMON: uncommon = true; common = rare = mythic = false; break;

        case MonsterRarity.RARE: rare = true; common = uncommon = mythic = false; break;

        case MonsterRarity.MYTHIC: mythic = true; common = uncommon = rare = false; break;
        }
        if (attackOnOff)
        {
            attackPlates.ForEach(plate => plate.SetActive(plate.GetComponent <BestiaryPlateManager>().GetMonsterRarity() == rarity));
        }
        if (defenseOnOff)
        {
            defensePlates.ForEach(plate => plate.SetActive(plate.GetComponent <BestiaryPlateManager>().GetMonsterRarity() == rarity));
        }
        if (sabotageOnOff)
        {
            sabotagePlates.ForEach(plate => plate.SetActive(plate.GetComponent <BestiaryPlateManager>().GetMonsterRarity() == rarity));
        }
    }
Пример #3
0
 public Monster(string name_, int level_, MonsterRarity rarity_ = MonsterRarity.Common,
                string race_ = "", string family_ = "", string baseMonster_ = "")
     : base(name_, baseMonster_)
 {
     rarity      = rarity_;
     Race        = race_;
     family      = family_;
     Stats.Level = level_;
     random      = new Random();
 }
Пример #4
0
        private MapIcon GetMapIconForMonster(EntityWrapper entity)
        {
            if (!entity.IsHostile)
            {
                return(new CreatureMapIcon(entity, "monster_ally.png", () => Settings.Minions, 6));
            }

            MonsterRarity monsterRarity = entity.GetComponent <ObjectMagicProperties>().Rarity;
            Func <EntityWrapper, CreatureMapIcon> iconCreator;

            return(iconCreators.TryGetValue(monsterRarity, out iconCreator) ? iconCreator(entity) : null);
        }
Пример #5
0
        private MapIcon GetMapIconForMonster(EntityWrapper entity, MonsterConfigLine monsterConfigLine)
        {
            if (!entity.IsHostile)
            {
                return(new CreatureMapIcon(entity, "ms-cyan.png", () => Settings.Minions, 4));
            }

            MonsterRarity monsterRarity = entity.GetComponent <ObjectMagicProperties>().Rarity;
            Func <EntityWrapper, Func <string, string>, CreatureMapIcon> iconCreator;

            return(iconCreators.TryGetValue(monsterRarity, out iconCreator) ? iconCreator(entity, text => monsterConfigLine?.MinimapIcon ?? text) : null);
        }
Пример #6
0
        private string GenerateName(MonsterRarity rarity)
        {
            int    index       = random.Next(0, Monsters[rarity].Count);
            string monsterName = null;

            if (Monsters[rarity].Count != 0)
            {
                monsterName = Monsters[rarity][index];
            }

            return(monsterName);
        }
Пример #7
0
 public void LinkPrefabToScript(Monster monster, GameObject panelController)
 {
     rarity = monster.GetRarity;
     ImagesFillers.AddMonsterPlate(monsterFace, monsterTypeIcon, monsterPlateBG, monster);
     monsterName.text  = !monster.Stats.Catched ? NOT_CATCHED : monster.MonsterName;
     monsterName.color = !monster.Stats.Catched ? Color.white : (monster.Stats.Catched ? Color.green : Color.yellow);
     if (monster.Stats.Catched)
     {
         PanelController controller = panelController.GetComponent <PanelController>();
         monsterButton.onClick.AddListener(() => controller.GoToMonsterPanel(controller.monsterMenu, monster));
     }
 }
Пример #8
0
 private void Calc(EntityWrapper entityWrapper)
 {
     if (!countedIds.Contains(entityWrapper.LongId))
     {
         countedIds.Add(entityWrapper.LongId);
         MonsterRarity rarity = entityWrapper.GetComponent <ObjectMagicProperties>().Rarity;
         if (entityWrapper.IsHostile && counters.ContainsKey(rarity))
         {
             counters[rarity]++;
             summaryCounter++;
         }
     }
 }
Пример #9
0
        private Color GetTextColorByRarity(MonsterRarity rarity)
        {
            switch (rarity)
            {
            case MonsterRarity.Unique:
                return(Settings.UniqueTextColor.Value);

            case MonsterRarity.Rare:
                return(Settings.RareTextColor.Value);

            default:
                return(Color.Gray);
            }
        }
Пример #10
0
 public HudTexture(string fileName, MonsterRarity rarity)
     : this(fileName, Color.White)
 {
     switch (rarity)
     {
         case MonsterRarity.Magic:
             color = HudSkin.MagicColor;
             break;
         case MonsterRarity.Rare:
             color = HudSkin.RareColor;
             break;
         case MonsterRarity.Unique:
             color = HudSkin.UniqueColor;
             break;
     }
 }
Пример #11
0
        public MonsterTable()
        {
            random = new Random();

            Weights = new Dictionary <MonsterRarity, double>();
            Weights[MonsterRarity.Common]    = 0.67;
            Weights[MonsterRarity.Uncommon]  = 0.20;
            Weights[MonsterRarity.Elite]     = 0.11;
            Weights[MonsterRarity.Legendary] = 0.02;

            Monsters = new Dictionary <MonsterRarity, List <string> >();
            for (MonsterRarity rarity = MonsterRarity.Common; rarity <= MonsterRarity.Legendary; ++rarity)
            {
                Monsters[rarity] = new List <string>();
            }
        }
Пример #12
0
        public HudTexture(string fileName, MonsterRarity rarity)
            : this(fileName, Color.White)
        {
            switch (rarity)
            {
            case MonsterRarity.Magic:
                color = HudSkin.MagicColor;
                break;

            case MonsterRarity.Rare:
                color = HudSkin.RareColor;
                break;

            case MonsterRarity.Unique:
                color = HudSkin.UniqueColor;
                break;
            }
        }
Пример #13
0
        private void Calc(EntityWrapper entityWrapper)
        {
            HashSet <long> monstersHashSet;
            var            areaHash = gameController.Area.CurrentArea.Hash;

            if (!countedIds.TryGetValue(areaHash, out monstersHashSet))
            {
                monstersHashSet      = new HashSet <long>();
                countedIds[areaHash] = monstersHashSet;
            }
            if (!monstersHashSet.Contains(entityWrapper.LongId))
            {
                monstersHashSet.Add(entityWrapper.LongId);
                MonsterRarity rarity = entityWrapper.GetComponent <ObjectMagicProperties>().Rarity;
                if (entityWrapper.IsHostile && counters.ContainsKey(rarity))
                {
                    counters[rarity]++;
                    summaryCounter++;
                }
            }
        }
Пример #14
0
        public override void Render()
        {
            /*if (RenderDebugInformation.Tick >= 500)
             * {
             *  Error += RenderDebugInformation.Tick;
             *  if (Error >= 5000)
             *  {
             *      LogError("Reloaded because works more than 5 sec", 5);
             *      InitObjects();
             *      Error = 0;
             *  }
             * }*/

            if (Settings.ToggleWindow)
            {
                if (Settings.ToggleWindowKey.PressedOnce())
                {
                    Settings.ToggleWindowState = !Settings.ToggleWindowState;
                }

                if (!Settings.ToggleWindowState)
                {
                    return;
                }
            }

            windowState = Settings.Enable;
            ImGui.Begin($"{Name}", ref windowState);

            if (Settings.Enable != windowState)
            {
                if (!Settings.ToggleWindow)
                {
                    Settings.Enable.Value = windowState;
                }
                else
                {
                    Settings.ToggleWindowState = windowState;
                }
            }

            if (ImGui.Button("Reload"))
            {
                InitObjects();
            }

            ImGui.SameLine();
            ImGui.PushItemWidth(200);

            if (ImGui.InputText("Filter", ref inputFilter, 128))
            {
            }

            ImGui.PopItemWidth();
            ImGui.SameLine();
            ImGui.PushItemWidth(128);

            if (ImGui.BeginCombo("Rarity", selectedRarityString))
            {
                for (var index = 0; index < Rarities.Count; index++)
                {
                    var rarity     = Rarities[index];
                    var isSelected = selectedRarityString == rarity;

                    if (ImGui.Selectable(rarity, isSelected))
                    {
                        selectedRarityString = rarity;
                        selectedRarity       = (MonsterRarity)index;
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }

                ImGui.EndCombo();
            }

            ImGui.PopItemWidth();
            ImGui.SameLine();

            if (ImGui.Button("Debug around entities"))
            {
                var entites       = GameController.Entities;
                var player        = GameController.Player;
                var playerGridPos = player.GridPos;

                if (!selectedRarityString.Equals("All", StringComparison.Ordinal))
                {
                    if (inputFilter.Length == 0)
                    {
                        DebugEntities = entites.Where(x => x.Rarity == selectedRarity &&
                                                      x.GridPos.Distance(playerGridPos) < Settings.NearestEntsRange)
                                        .OrderBy(x => x.GridPos.Distance(playerGridPos)).ToList();
                    }
                    else
                    {
                        DebugEntities = entites
                                        .Where(x => x.Path.Contains(inputFilter) &&
                                               x.GetComponent <ObjectMagicProperties>()?.Rarity == selectedRarity &&
                                               x.GridPos.Distance(playerGridPos) < Settings.NearestEntsRange)
                                        .OrderBy(x => x.GridPos.Distance(playerGridPos)).ToList();
                    }
                }
                else
                {
                    if (inputFilter.Length == 0)
                    {
                        DebugEntities = entites.Where(x => x.GridPos.Distance(playerGridPos) < Settings.NearestEntsRange)
                                        .OrderBy(x => x.GridPos.Distance(playerGridPos)).ToList();
                    }
                    else
                    {
                        DebugEntities = entites
                                        .Where(x => x.Path.Contains(inputFilter) &&
                                               x.GridPos.Distance(playerGridPos) < Settings.NearestEntsRange)
                                        .OrderBy(x => x.GridPos.Distance(playerGridPos)).ToList();
                    }
                }
            }

            foreach (var o in objects)
            {
                if (ImGui.TreeNode($"{o.Key}##{_version}"))
                {
                    ImGui.Indent();

                    try
                    {
                        Debug(o.Value);
                    }
                    catch (Exception e)
                    {
                        DebugWindow.LogError($"{Name} -> {e}");
                    }

                    ImGui.Unindent();
                    ImGui.TreePop();
                }
            }

            if (ImGui.TreeNode("UIHover"))
            {
                ImGui.Indent();

                try
                {
                    Debug(GameController.IngameState.UIHover);
                }
                catch (Exception e)
                {
                    DebugWindow.LogError($"UIHover -> {e}");
                }

                ImGui.Unindent();
                ImGui.TreePop();
            }

            if (ImGui.TreeNode("UIHover as Item"))
            {
                ImGui.Indent();

                try
                {
                    Debug(GameController.IngameState.UIHover.AsObject <HoverItemIcon>());
                }
                catch (Exception e)
                {
                    DebugWindow.LogError($"UIHover -> {e}");
                }

                ImGui.Unindent();
                ImGui.TreePop();
            }

            if (ImGui.TreeNode("Only visible InGameUi"))
            {
                ImGui.Indent();
                var os    = GameController.IngameState.IngameUi.Children.Where(x => x.IsVisibleLocal);
                var index = 0;

                foreach (var el in os)
                {
                    try
                    {
                        if (ImGui.TreeNode($"{el.Address:X} - {el.X}:{el.Y},{el.Width}:{el.Height}##{el.GetHashCode()}"))
                        {
                            var keyForOffset = $"{el.Address}{el.GetHashCode()}";

                            if (OffsetFinder.TryGetValue(keyForOffset, out var offset))
                            {
                                ImGui.Text($"Offset: {offset:X}");
                            }
                            else
                            {
                                var IngameUi = GameController.IngameState.IngameUi;
                                var pointers = IngameUi.M.ReadPointersArray(IngameUi.Address, IngameUi.Address + 10000);

                                for (var i = 0; i < pointers.Count; i++)
                                {
                                    var p = pointers[i];
                                    if (p == el.Address)
                                    {
                                        OffsetFinder[keyForOffset] = i * 0x8;
                                    }
                                }
                            }

                            Debug(el);
                            ImGui.TreePop();
                        }

                        if (ImGui.IsItemHovered())
                        {
                            var clientRectCache = el.GetClientRectCache;
                            Graphics.DrawFrame(clientRectCache, ColorSwaper.Value, 1);

                            foreach (var element in el.Children)
                            {
                                clientRectCache = element.GetClientRectCache;
                                Graphics.DrawFrame(clientRectCache, ColorSwaper.Value, 1);
                            }
                        }

                        index++;
                    }
                    catch (Exception e)
                    {
                        DebugWindow.LogError($"UIHover -> {e}");
                    }
                }

                ImGui.Unindent();
                ImGui.TreePop();
            }

            if (DebugEntities.Count > 0 && ImGui.TreeNode($"Entities {DebugEntities.Count}"))
            {
                var camera = GameController.IngameState.Camera;

                for (var index = 0; index < DebugEntities.Count; index++)
                {
                    var debugEntity   = DebugEntities[index];
                    var worldtoscreen = camera.WorldToScreen(debugEntity.Pos);
                    Graphics.DrawBox(worldtoscreen.TranslateToNum(-9, -9), worldtoscreen.TranslateToNum(18, 18), Color.Black);
                    Graphics.DrawText($"{index}", worldtoscreen);

                    if (ImGui.TreeNode($"[{index}] {debugEntity}"))
                    {
                        Debug(debugEntity);
                        ImGui.TreePop();
                    }
                }
            }

            ImGui.End();
        }
Пример #15
0
        public override void Render()
        {
            /*if (RenderDebugInformation.Tick >= 500)
             * {
             *  Error += RenderDebugInformation.Tick;
             *  if (Error >= 5000)
             *  {
             *      LogError("Reloaded because works more than 5 sec", 5);
             *      InitObjects();
             *      Error = 0;
             *  }
             * }*/

            if (Settings.ToggleWindow)
            {
                if (Settings.ToggleWindowKey.PressedOnce())
                {
                    Settings.ToggleWindowState = !Settings.ToggleWindowState;
                }

                if (!Settings.ToggleWindowState)
                {
                    return;
                }
            }

            if (Settings.DebugHoverItem.PressedOnce())
            {
                var ingameStateUiHover = GameController.IngameState.UIHover;
                var hoverItemIcon      = GameController.IngameState.UIHover.AsObject <HoverItemIcon>();
                if (ingameStateUiHover.Address != 0)
                {
                    AddObjects(new{ Hover = ingameStateUiHover, HoverLikeItem = hoverItemIcon }, "Stored UIHover");
                }
            }
            windowState = Settings.Enable;
            ImGui.Begin($"{Name}", ref windowState);

            if (Settings.Enable != windowState)
            {
                if (!Settings.ToggleWindow)
                {
                    Settings.Enable.Value = windowState;
                }
                else
                {
                    Settings.ToggleWindowState = windowState;
                }
            }

            if (ImGui.Button("Reload"))
            {
                InitObjects();
            }

            ImGui.SameLine();
            ImGui.PushItemWidth(200);
            var mem          = GameController.Memory;
            var FileRootAddr = mem.AddressOfProcess + mem.BaseOffsets[OffsetsName.FileRoot];

            ImGui.Text($"FileRoot: {FileRootAddr:X}");

            if (ImGui.InputText("Filter", ref inputFilter, 128))
            {
            }

            ImGui.PopItemWidth();
            ImGui.SameLine();
            ImGui.PushItemWidth(128);

            if (ImGui.BeginCombo("Rarity", selectedRarityString))
            {
                for (var index = 0; index < Rarities.Count; index++)
                {
                    var rarity     = Rarities[index];
                    var isSelected = selectedRarityString == rarity;

                    if (ImGui.Selectable(rarity, isSelected))
                    {
                        selectedRarityString = rarity;
                        selectedRarity       = (MonsterRarity)index;
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }

                ImGui.EndCombo();
            }

            ImGui.PopItemWidth();
            ImGui.SameLine();

            if (ImGui.Button("Debug around entities"))
            {
                var entites       = GameController.Entities;
                var player        = GameController.Player;
                var playerGridPos = player.GridPos;

                if (!selectedRarityString.Equals("All", StringComparison.Ordinal))
                {
                    if (inputFilter.Length == 0)
                    {
                        DebugEntities = entites.Where(x => x.Rarity == selectedRarity &&
                                                      x.GridPos.Distance(playerGridPos) < Settings.NearestEntsRange)
                                        .OrderBy(x => x.GridPos.Distance(playerGridPos)).ToList();
                    }
                    else
                    {
                        DebugEntities = entites
                                        .Where(x => (x.Path.Contains(inputFilter) || x.Address.ToString("x").ToLower().Contains(inputFilter.ToLower())) &&
                                               x.GetComponent <ObjectMagicProperties>()?.Rarity == selectedRarity &&
                                               x.GridPos.Distance(playerGridPos) < Settings.NearestEntsRange)
                                        .OrderBy(x => x.GridPos.Distance(playerGridPos)).ToList();
                    }
                }
                else
                {
                    if (inputFilter.Length == 0)
                    {
                        DebugEntities = entites.Where(x => x.GridPos.Distance(playerGridPos) < Settings.NearestEntsRange)
                                        .OrderBy(x => x.GridPos.Distance(playerGridPos)).ToList();
                    }
                    else
                    {
                        DebugEntities = entites
                                        .Where(x => (x.Path.Contains(inputFilter) || x.Address.ToString("x").ToLower().Contains(inputFilter.ToLower())) &&
                                               x.GridPos.Distance(playerGridPos) < Settings.NearestEntsRange)
                                        .OrderBy(x => x.GridPos.Distance(playerGridPos)).ToList();
                    }
                }
            }

            ImGui.SameLine();
            ImGui.PushItemWidth(128);
            if (ImGui.InputText("CheckAddressIsGuiObject", ref guiObjAddr, 128))
            {
                if (long.TryParse(guiObjAddr, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out var objAddr))
                {
                    var queue = new Queue <Element>();
                    queue.Enqueue(GameController.Game.IngameState.UIRoot);
                    var found = false;
                    while (queue.Count > 0)
                    {
                        var element = queue.Dequeue();

                        if (element.Address == objAddr)
                        {
                            var indexPath = new List <int>();
                            var iterator  = element;

                            while (iterator != null && iterator.Address != 0)
                            {
                                if (iterator.Parent != null && iterator.Parent.Address != 0)
                                {
                                    indexPath.Add(iterator.Parent.Children.ToList().FindIndex(x => x.Address == iterator.Address));
                                }

                                iterator = iterator.Parent;
                            }

                            indexPath.Reverse();

                            LogMessage("IS gui element!" + $"Path from root: [{string.Join(", ", indexPath)}]", 3);
                            found = true;
                            break;
                        }

                        foreach (var elementChild in element.Children)
                        {
                            queue.Enqueue(elementChild);
                        }
                    }
                    if (!found)
                    {
                        LogMessage("NOT a gui element!", 3);
                    }
                }
            }

            foreach (var o in objects)
            {
                if (ImGui.TreeNode($"{o.Key}##{_version}"))
                {
                    ImGui.Indent();

                    try
                    {
                        Debug(o.Value);
                    }
                    catch (Exception e)
                    {
                        DebugWindow.LogError($"{Name} -> {e}");
                    }

                    finally
                    {
                        ImGui.Unindent();
                        ImGui.TreePop();
                    }
                }
            }

            if (ImGui.TreeNode("UIHover"))
            {
                ImGui.Indent();

                try
                {
                    Debug(GameController.IngameState.UIHover);
                }
                catch (Exception e)
                {
                    DebugWindow.LogError($"UIHover -> {e}");
                }
                finally
                {
                    ImGui.Unindent();
                    ImGui.TreePop();
                }
            }

            if (ImGui.TreeNode("UIHover as Item"))
            {
                ImGui.Indent();

                try
                {
                    Debug(GameController.IngameState.UIHover.AsObject <HoverItemIcon>());
                }
                catch (Exception e)
                {
                    DebugWindow.LogError($"UIHover -> {e}");
                }
                finally
                {
                    ImGui.Unindent();
                    ImGui.TreePop();
                }
            }

            if (ImGui.TreeNode("Only visible InGameUi"))
            {
                ImGui.Indent();
                var os    = GameController.IngameState.IngameUi.Children.Where(x => x.IsVisibleLocal);
                var index = 0;

                foreach (var el in os)
                {
                    try
                    {
                        if (ImGui.TreeNode($"{el.Address:X} - {el.X}:{el.Y},{el.Width}:{el.Height}##{el.GetHashCode()}"))
                        {
                            var keyForOffset = $"{el.Address}{el.GetHashCode()}";

                            if (OffsetFinder.TryGetValue(keyForOffset, out var offset))
                            {
                                ImGui.Text($"Offset: {offset:X}");
                            }
                            else
                            {
                                var IngameUi = GameController.IngameState.IngameUi;
                                var pointers = IngameUi.M.ReadPointersArray(IngameUi.Address, IngameUi.Address + 10000);

                                for (var i = 0; i < pointers.Count; i++)
                                {
                                    var p = pointers[i];
                                    if (p == el.Address)
                                    {
                                        OffsetFinder[keyForOffset] = i * 0x8;
                                    }
                                }
                            }

                            Debug(el);
                            ImGui.TreePop();
                        }

                        if (ImGui.IsItemHovered())
                        {
                            var clientRectCache = el.GetClientRectCache;
                            Graphics.DrawFrame(clientRectCache, ColorSwaper.Value, 1);

                            foreach (var element in el.Children)
                            {
                                clientRectCache = element.GetClientRectCache;
                                Graphics.DrawFrame(clientRectCache, ColorSwaper.Value, 1);
                            }
                        }

                        index++;
                    }
                    catch (Exception e)
                    {
                        DebugWindow.LogError($"UIHover -> {e}");
                    }
                }

                ImGui.Unindent();
                ImGui.TreePop();
            }

            if (DebugEntities.Count > 0 && ImGui.TreeNode($"Entities {DebugEntities.Count}"))
            {
                var camera = GameController.IngameState.Camera;

                for (var index = 0; index < DebugEntities.Count; index++)
                {
                    var debugEntity   = DebugEntities[index];
                    var worldtoscreen = camera.WorldToScreen(debugEntity.Pos);

                    Graphics.DrawText($"{index}", worldtoscreen);

                    if (ImGui.TreeNode($"[{index}] {debugEntity}"))
                    {
                        Debug(debugEntity);
                        ImGui.TreePop();
                    }

                    var borderColor = Color.Black;
                    if (ImGui.IsItemHovered())
                    {
                        borderColor = Color.DarkSlateGray;
                    }
                    Graphics.DrawBox(worldtoscreen.TranslateToNum(-9, -9), worldtoscreen.TranslateToNum(18, 18), borderColor);
                }
            }

            ImGui.End();
        }