Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private static List <SkillInfo> ReadSkillInfos(D2Unit p, ISkillReader skillReader)
        {
            var skills = new List <SkillInfo>();

            foreach (var skill in skillReader.EnumerateSkills(p))
            {
                var skillData = skillReader.ReadSkillData(skill);
                var skillInfo = new SkillInfo
                {
                    Id     = skillData.SkillId,
                    Points = skillReader.GetTotalNumberOfSkillPoints(skill),
                };
                skills.Add(skillInfo);
            }
            return(skills);
        }
Exemplo n.º 3
0
        private static bool MatchesStartingSkills(D2Unit p, ISkillReader skillReader)
        {
            int skillCount = 0;

            foreach (D2Skill skill in skillReader.EnumerateSkills(p))
            {
                var   skillData = skillReader.ReadSkillData(skill);
                Skill skillId   = (Skill)skillData.SkillId;
                if (!StartingSkills[(CharacterClass)p.eClass].ContainsKey(skillId))
                {
                    return(false);
                }

                if (StartingSkills[(CharacterClass)p.eClass][skillId] != skillReader.GetTotalNumberOfSkillPoints(skill))
                {
                    return(false);
                }
                skillCount++;
            }

            return(skillCount == StartingSkills[(CharacterClass)p.eClass].Count);
        }