コード例 #1
0
        Character ProcessCharacterData(D2GameInfo gameInfo)
        {
            string    playerName = gameInfo.PlayerData.PlayerName;
            Character character  = CharacterByNameCached(playerName);

            if (wasInTitleScreen)
            {
                // A brand new character has been started.
                // The extra wasInTitleScreen check prevents DI from splitting
                // when it was started AFTER Diablo 2, but the char is still a new char
                if (IsNewChar())
                {
                    ActiveCharacterTimestamp = DateTime.Now;
                    ActiveCharacter          = character;
                    OnCharacterCreated(new CharacterCreatedEventArgs(character));
                }

                // Not in title screen anymore.
                wasInTitleScreen = false;
            }

            character.UpdateMode((D2Data.Mode)gameInfo.Player.eMode);

            // Don't update stats while dead.
            if (!character.IsDead)
            {
                character.ParseStats(unitReader, gameInfo);
            }
            return(character);
        }
コード例 #2
0
 void ProcessQuests(D2GameInfo gameInfo)
 {
     gameQuests = new List <QuestCollection>();
     if (ReadFlags.HasFlag(DataReaderEnableFlags.QuestBuffers))
     {
         gameQuests = ReadQuests(gameInfo);
     }
 }
コード例 #3
0
 internal void ParseStats(UnitReader unitReader, D2GameInfo gameInfo)
 {
     ParseStats(
         unitReader.GetStatsMap(gameInfo.Player),
         unitReader.GetItemStatsMap(gameInfo.Player),
         gameInfo
         );
 }
コード例 #4
0
        void ProcessCharacterData(D2GameInfo gameInfo)
        {
            character = GetCurrentCharacter(gameInfo);
            character.UpdateMode((D2Data.Mode)gameInfo.Player.eMode);

            Dictionary <StatIdentifier, D2Stat> playerStats = unitReader.GetStatsMap(gameInfo.Player);
            Dictionary <StatIdentifier, D2Stat> itemStats   = unitReader.GetItemStatsMap(gameInfo.Player);

            character.ParseStats(playerStats, itemStats, gameInfo);
        }
コード例 #5
0
        Game ReadGameData(D2GameInfo gameInfo)
        {
            var g = new Game();

            g.Area       = reader.ReadByte(memory.Area, AddressingMode.Relative);
            g.PlayersX   = Math.Max(reader.ReadByte(memory.PlayersX, AddressingMode.Relative), (byte)1);
            g.Difficulty = (GameDifficulty)gameInfo.Game.Difficulty;
            g.GameCount  = gameCount;
            g.CharCount  = charCount;
            return(g);
        }
コード例 #6
0
        Character GetCurrentCharacter(D2GameInfo gameInfo)
        {
            string playerName = gameInfo.PlayerData.PlayerName;

            // Read character stats.
            int level      = unitReader.GetStatValue(gameInfo.Player, StatIdentifier.Level) ?? 0;
            int experience = unitReader.GetStatValue(gameInfo.Player, StatIdentifier.Experience) ?? 0;

            // We encountered this character name before.
            if (characters.TryGetValue(playerName, out Character character))
            {
                // We were just in the title screen and came back to a new character.
                bool resetOnBeginning = wasInTitleScreen && experience == 0;

                // If we lost experience on level 1 we have a reset. Level 1 check is important or
                // this might think we reset when losing experience in nightmare or hell after dying.
                bool resetOnLevelOne = character.Level == 1 && experience < character.Experience;

                // Check for reset with same character name.
                if (resetOnBeginning || resetOnLevelOne || level < character.Level)
                {
                    // Recreate character.
                    characters.Remove(playerName);
                    character = null;
                }
            }

            // If this character has not been read before, or if the character was reset
            // with the same name as a previous character.
            if (character == null)
            {
                character = new Character {
                    Name = playerName
                };
                characters[playerName] = character;

                // A brand new character has been started.
                if (experience == 0 && level == 1)
                {
                    activeCharacterTimestamp = DateTime.Now;
                    activeCharacter          = character;
                    OnCharacterCreated(new CharacterCreatedEventArgs(character));
                }
            }

            // Not in title screen anymore.
            wasInTitleScreen = false;

            return(character);
        }
コード例 #7
0
        /// <summary>
        /// fill the player data by dictionary
        /// </summary>
        /// <param name="dict"></param>
        /// <param name="resistancPenalty"></param>
        internal void ParseStats(Dictionary <StatIdentifier, D2Stat> data, Dictionary <StatIdentifier, D2Stat> itemData, D2GameInfo gameInfo)
        {
            // Don't update stats while dead.
            if (IsDead)
            {
                return;
            }

            CharClass = (CharacterClass)gameInfo.Player.eClass;

            int penalty = (int)ResistancePenalty.GetPenaltyByGameDifficulty((GameDifficulty)gameInfo.Game.Difficulty);
            Func <StatIdentifier, int> getStat = statID =>
            {
                D2Stat stat;
                // Get the value if if the key exists, else assume zero.
                return(data.TryGetValue(statID, out stat) ? stat.Value : 0);
            };
            Func <StatIdentifier, int> getItemStat = statID =>
            {
                D2Stat stat;
                // Get the value if if the key exists, else assume zero.
                return(itemData.TryGetValue(statID, out stat) ? stat.Value : 0);
            };

            Level      = getStat(StatIdentifier.Level);
            Experience = getStat(StatIdentifier.Experience);

            VelocityPercent = getStat(StatIdentifier.VelocityPercent);
            AttackRate      = getStat(StatIdentifier.AttackRate);

            Strength  = getStat(StatIdentifier.Strength);
            Dexterity = getStat(StatIdentifier.Dexterity);
            Vitality  = getStat(StatIdentifier.Vitality);
            Energy    = getStat(StatIdentifier.Energy);

            Defense = getStat(StatIdentifier.Defense);

            int maxFire      = BASE_MAX_RESIST + getStat(StatIdentifier.ResistFireMax);
            int maxCold      = BASE_MAX_RESIST + getStat(StatIdentifier.ResistColdMax);
            int maxLightning = BASE_MAX_RESIST + getStat(StatIdentifier.ResistLightningMax);
            int maxPoison    = BASE_MAX_RESIST + getStat(StatIdentifier.ResistPoisonMax);

            FireResist      = Utility.Clamp(getStat(StatIdentifier.ResistFire) + penalty, MIN_RESIST, maxFire);
            ColdResist      = Utility.Clamp(getStat(StatIdentifier.ResistCold) + penalty, MIN_RESIST, maxCold);
            LightningResist = Utility.Clamp(getStat(StatIdentifier.ResistLightning) + penalty, MIN_RESIST, maxLightning);
            PoisonResist    = Utility.Clamp(getStat(StatIdentifier.ResistPoison) + penalty, MIN_RESIST, maxPoison);

            FasterHitRecovery    = getItemStat(StatIdentifier.FasterHitRecovery);
            FasterRunWalk        = getItemStat(StatIdentifier.FasterRunWalk);
            FasterCastRate       = getItemStat(StatIdentifier.FasterCastRate);
            IncreasedAttackSpeed = getItemStat(StatIdentifier.IncreasedAttackSpeed);

            Gold      = getStat(StatIdentifier.Gold);
            GoldStash = getStat(StatIdentifier.GoldStash);
        }
コード例 #8
0
 GameDifficulty ProcessCurrentDifficulty(D2GameInfo gameInfo)
 {
     return(ReadFlags.HasFlag(DataReaderEnableFlags.CurrentDifficulty)
         ? (GameDifficulty)gameInfo.Game.Difficulty
         : GameDifficulty.Normal);
 }
コード例 #9
0
 List <QuestCollection> ReadQuests(D2GameInfo gameInfo) => (
     from address in gameInfo.PlayerData.Quests
         where !address.IsNull
     select ReadQuestBuffer(address) into questBuffer
     select TransformToQuestList(questBuffer) into quests
     select new QuestCollection(quests)).ToList();
コード例 #10
0
 List <QuestCollection> ProcessQuests(D2GameInfo gameInfo)
 {
     return(ReadFlags.HasFlag(DataReaderEnableFlags.QuestBuffers)
         ? ReadQuests(gameInfo)
         : new List <QuestCollection>());
 }
コード例 #11
0
 Quests ReadQuests(D2GameInfo gameInfo) => new Quests((
                                                          from address in gameInfo.PlayerData.Quests
                                                              where !address.IsNull
                                                          select ReadQuestBuffer(address) into questBuffer
                                                          select TransformToQuestList(questBuffer) into quests
                                                          select quests).ToList());
コード例 #12
0
 void ProcessCurrentDifficulty(D2GameInfo gameInfo)
 {
     currentDifficulty = ReadFlags.HasFlag(DataReaderEnableFlags.CurrentDifficulty)
         ? (GameDifficulty)gameInfo.Game.Difficulty : GameDifficulty.Normal;
 }