Ejemplo n.º 1
0
        public void UpdateQuestData(ushort[] questBuffer, int difficulty)
        {
            QuestDebugRow[,] questRows;
            ushort questBits;

            switch (difficulty)
            {
            case 2: questRows = QuestRowsHell; break;

            case 1: questRows = QuestRowsNightmare; break;

            case 0:
            default: questRows = QuestRowsNormal; break;
            }

            for (int i = 0; i < questBuffer.Length; i++)
            {
                questBits = questBuffer[i];

                D2QuestHelper.D2Quest q = D2QuestHelper.GetByQuestBufferIndex(i);
                if (q != null)
                {
                    try
                    {
                        questRows[q.Act - 1, q.Quest - 1].Update(questBits);
                    }
                    catch (System.NullReferenceException ex)
                    {
                        // System.NullReferenceException
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void ProcessGameData()
        {
            // Make sure the game is loaded.
            var gameInfo = GetGameInfo();

            if (gameInfo == null)
            {
                wasInTitleScreen = true;
                return;
            }

            UpdateDebugWindow(gameInfo);

            // Get associated character data.
            Character             character    = GetCurrentCharacter(gameInfo);
            UnitReader            unitReader   = new UnitReader(reader, memory);
            var                   statsMap     = unitReader.GetStatsMap(gameInfo.Player);
            var                   itemStatsMap = unitReader.GetItemStatsMap(gameInfo.Player);
            Dictionary <int, int> itemClassMap = unitReader.GetItemClassMap(gameInfo.Player);

            // Update character data.
            character.UpdateMode((D2Data.Mode)gameInfo.Player.eMode);
            character.ParseStats(statsMap, itemStatsMap, gameInfo.Game.Difficulty);
            int count0 = D2QuestHelper.GetReallyCompletedQuestCount(GetQuestBuffer(gameInfo.PlayerData, 0));
            int count1 = D2QuestHelper.GetReallyCompletedQuestCount(GetQuestBuffer(gameInfo.PlayerData, 1));
            int count2 = D2QuestHelper.GetReallyCompletedQuestCount(GetQuestBuffer(gameInfo.PlayerData, 2));

            character.CompletedQuestCounts[0] = count0;
            character.CompletedQuestCounts[1] = count1;
            character.CompletedQuestCounts[2] = count2;

            // Update UI.
            main.UpdateLabels(character, itemClassMap);
            main.writeFiles(character);
            main.TcpStream(character);

#if DEBUG
            // Console.WriteLine("Normal:    " + character.CompletedQuestCounts[0] + "/" + D2QuestHelper.Quests.Count + " (" + (character.CompletedQuestCounts[0] * 100.0f / D2QuestHelper.Quests.Count) + "%)" );
            // Console.WriteLine("Nightmare: " + character.CompletedQuestCounts[1] + "/" + D2QuestHelper.Quests.Count + " (" + (character.CompletedQuestCounts[1] * 100.0f / D2QuestHelper.Quests.Count) + "%)");
            // Console.WriteLine("Hell:      " + character.CompletedQuestCounts[2] + "/" + D2QuestHelper.Quests.Count + " (" + (character.CompletedQuestCounts[2] * 100.0f / D2QuestHelper.Quests.Count) + "%)");
#endif

            // Update autosplits only if enabled and the character was a freshly started character.
            if (IsAutosplitCharacter(character) && main.Settings.DoAutosplit)
            {
                UpdateAutoSplits(gameInfo, character);
            }
        }
Ejemplo n.º 3
0
        private void LoadQuests(Label[] actLabels, QuestDebugRow[,] questRows, TabPage tabPage)
        {
            int y;

            for (int i = 0; i < 5; i++)
            {
                y                     = i * 100 - (i > 3 ? 3 * 16 : 0);
                actLabels[i]          = new Label();
                actLabels[i].Text     = "Act " + (i + 1);
                actLabels[i].Width    = 80;
                actLabels[i].Location = new Point(20, y);
                tabPage.Controls.Add(actLabels[i]);
                for (int j = 0; j < (i == 3 ? 3 : 6); j++)
                {
                    questRows[i, j]          = new QuestDebugRow(D2QuestHelper.GetByActAndQuest(i + 1, j + 1));
                    questRows[i, j].Location = new Point(100, y + (j * 16));
                    tabPage.Controls.Add(questRows[i, j]);
                }
            }
        }
Ejemplo n.º 4
0
        private void UpdateAutoSplits(GameInfo gameInfo, Character character)
        {
            foreach (AutoSplit autosplit in main.Settings.Autosplits)
            {
                if (autosplit.IsReached)
                {
                    continue;
                }
                if (autosplit.Type != AutoSplit.SplitType.Special)
                {
                    continue;
                }
                if (autosplit.Value == (int)AutoSplit.Special.GameStart)
                {
                    CompleteAutoSplit(autosplit, character);
                }
                if (autosplit.Value == (int)AutoSplit.Special.Clear100Percent &&
                    character.CompletedQuestCounts[gameInfo.Game.Difficulty] == D2QuestHelper.Quests.Count &&
                    autosplit.MatchesDifficulty(gameInfo.Game.Difficulty))
                {
                    CompleteAutoSplit(autosplit, character);
                }
                if (autosplit.Value == (int)AutoSplit.Special.Clear100PercentAllDifficulties &&
                    character.CompletedQuestCounts[0] == D2QuestHelper.Quests.Count &&
                    character.CompletedQuestCounts[1] == D2QuestHelper.Quests.Count &&
                    character.CompletedQuestCounts[2] == D2QuestHelper.Quests.Count)
                {
                    CompleteAutoSplit(autosplit, character);
                }
            }

            bool haveUnreachedCharLevelSplits = false;
            bool haveUnreachedAreaSplits      = false;
            bool haveUnreachedItemSplits      = false;
            bool haveUnreachedQuestSplits     = false;

            foreach (AutoSplit autosplit in main.Settings.Autosplits)
            {
                if (autosplit.IsReached || !autosplit.MatchesDifficulty(gameInfo.Game.Difficulty))
                {
                    continue;
                }
                switch (autosplit.Type)
                {
                case AutoSplit.SplitType.CharLevel:
                    haveUnreachedCharLevelSplits = true;
                    break;

                case AutoSplit.SplitType.Area:
                    haveUnreachedAreaSplits = true;
                    break;

                case AutoSplit.SplitType.Item:
                    haveUnreachedItemSplits = true;
                    break;

                case AutoSplit.SplitType.Quest:
                    haveUnreachedQuestSplits = true;
                    break;
                }
            }

            // if no unreached splits, return
            if (!(haveUnreachedCharLevelSplits || haveUnreachedAreaSplits || haveUnreachedItemSplits || haveUnreachedQuestSplits))
            {
                return;
            }

            List <int> itemsIds = new List <int>();
            int        area     = -1;

            if (haveUnreachedItemSplits)
            {
                // Get all item IDs.
                var inventoryReader = new InventoryReader(reader, memory);
                itemsIds = (from item in inventoryReader.EnumerateInventory()
                            select item.eClass).ToList();
            }

            if (haveUnreachedAreaSplits)
            {
                area = reader.ReadByte(memory.Address.Area, AddressingMode.Relative);
            }

            ushort[] questBuffer = null;

            if (haveUnreachedQuestSplits)
            {
                questBuffer = GetQuestBuffer(gameInfo.PlayerData, gameInfo.Game.Difficulty);
            }

            foreach (AutoSplit autosplit in main.Settings.Autosplits)
            {
                if (autosplit.IsReached || !autosplit.MatchesDifficulty(gameInfo.Game.Difficulty))
                {
                    continue;
                }

                switch (autosplit.Type)
                {
                case AutoSplit.SplitType.CharLevel:
                    if (autosplit.Value <= character.Level)
                    {
                        CompleteAutoSplit(autosplit, character);
                    }
                    break;

                case AutoSplit.SplitType.Area:
                    if (autosplit.Value == area)
                    {
                        CompleteAutoSplit(autosplit, character);
                    }
                    break;

                case AutoSplit.SplitType.Item:
                    if (itemsIds.Contains(autosplit.Value))
                    {
                        CompleteAutoSplit(autosplit, character);
                    }
                    break;

                case AutoSplit.SplitType.Quest:
                    if (D2QuestHelper.IsQuestComplete((D2QuestHelper.Quest)autosplit.Value, questBuffer))
                    {
                        CompleteAutoSplit(autosplit, character);
                    }
                    break;
                }
            }
        }