예제 #1
0
        internal void Parse(
            UnitReader unitReader,
            GameInfo gameInfo
            )
        {
            var data = unitReader.GetStatsMap(gameInfo.Player);

            CharClass = (CharacterClass)gameInfo.Player.eClass;

            int penalty = ResistancePenalty.GetPenaltyByGame(gameInfo.Game);

            int ValueByStatID(Dictionary <StatIdentifier, D2Stat> d, StatIdentifier statID)
            {
                // Get the value if if the key exists, else assume zero.
                return(d.TryGetValue(statID, out D2Stat stat) ? stat.Value : 0);
            }

            int getStat(StatIdentifier statID) => ValueByStatID(data, statID);

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

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

            Gold      = getStat(StatIdentifier.Gold);
            GoldStash = getStat(StatIdentifier.GoldStash);

            VelocityPercent = getStat(StatIdentifier.VelocityPercent);
            AttackRate      = getStat(StatIdentifier.AttackRate);
            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    = getStat(StatIdentifier.FasterHitRecovery);
            FasterRunWalk        = getStat(StatIdentifier.FasterRunWalk);
            FasterCastRate       = getStat(StatIdentifier.FasterCastRate);
            IncreasedAttackSpeed = getStat(StatIdentifier.IncreasedAttackSpeed);

            AttackerSelfDamage = getStat(StatIdentifier.AttackerSelfDamage);

            MagicFind   = getStat(StatIdentifier.MagicFind);
            MonsterGold = getStat(StatIdentifier.MonsterGold);

            Mana    = getStat(StatIdentifier.Mana) >> 8;
            ManaMax = getStat(StatIdentifier.ManaMax) >> 8;

            Life    = getStat(StatIdentifier.Hitpoints) >> 8;
            LifeMax = getStat(StatIdentifier.HitpointsMax) >> 8;
        }
예제 #2
0
        internal void Parse(
            D2Unit unit,
            UnitReader unitReader,
            ISkillReader skillReader,
            IProcessMemoryReader reader,
            GameInfo gameInfo
            )
        {
            var monsterData = unitReader.GetMonsterData(unit);

            Name = reader.ReadNullTerminatedString(monsterData.szMonName, 300, System.Text.Encoding.Unicode);

            Class = unit.eClass;

            var skillIds = new List <uint>();

            foreach (var skill in skillReader.EnumerateSkills(unit))
            {
                var d = skillReader.ReadSkillData(skill);
                skillIds.Add(d.SkillId);
            }
            SkillIds = skillIds;

            var data = unitReader.GetStatsMap(unit);

            int penalty = ResistancePenalty.GetPenaltyByGame(gameInfo.Game);

            int ValueByStatID(Dictionary <StatIdentifier, D2Stat> d, StatIdentifier statID)
            {
                // Get the value if if the key exists, else assume zero.
                return(d.TryGetValue(statID, out D2Stat stat) ? stat.Value : 0);
            }

            int getStat(StatIdentifier statID) => ValueByStatID(data, statID);

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

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

            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);
        }